1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.chrome.browser.vr.rules; 6 7 import android.content.Intent; 8 9 import org.junit.runner.Description; 10 import org.junit.runners.model.Statement; 11 12 import org.chromium.base.CommandLine; 13 import org.chromium.chrome.browser.vr.TestVrShellDelegate; 14 import org.chromium.chrome.browser.vr.rules.XrActivityRestriction.SupportedActivity; 15 import org.chromium.chrome.browser.vr.util.VrTestRuleUtils; 16 import org.chromium.chrome.browser.webapps.WebappActivityTestRule; 17 18 /** 19 * VR extension of WebappActivityTestRule. Applies WebappActivityTestRule then opens 20 * up a WebappActivity to a blank page while performing some additional VR-only setup. 21 */ 22 public class WebappActivityVrTestRule extends WebappActivityTestRule implements VrTestRule { 23 private boolean mDonEnabled; 24 25 @Override apply(final Statement base, final Description desc)26 public Statement apply(final Statement base, final Description desc) { 27 return super.apply(new Statement() { 28 @Override 29 public void evaluate() throws Throwable { 30 VrTestRuleUtils.evaluateVrTestRuleImpl( 31 base, desc, WebappActivityVrTestRule.this, () -> { 32 startWebappActivity(); 33 TestVrShellDelegate.createTestVrShellDelegate(getActivity()); 34 }); 35 } 36 }, desc); 37 } 38 39 @Override 40 public @SupportedActivity int getRestriction() { 41 return SupportedActivity.WAA; 42 } 43 44 @Override 45 public boolean isDonEnabled() { 46 return CommandLine.getInstance().hasSwitch("vr-don-enabled"); 47 } 48 49 @Override 50 public Intent createIntent() { 51 return VrTestRuleUtils.maybeAddStandaloneIntentData(super.createIntent()); 52 } 53 } 54