| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.vr_shell; | 5 package org.chromium.chrome.browser.vr_shell; |
| 6 | 6 |
| 7 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS
; | 7 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS
; |
| 8 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_DAYDREAM; | 8 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_DAYDREAM; |
| 9 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_NON_DAYDREAM; | 9 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_NON_DAYDREAM; |
| 10 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_W
EBVR_SUPPORTED; | 10 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_W
EBVR_SUPPORTED; |
| 11 | 11 |
| 12 import android.os.Build; | 12 import android.os.Build; |
| 13 import android.support.test.filters.LargeTest; | 13 import android.support.test.filters.LargeTest; |
| 14 import android.support.test.filters.MediumTest; | 14 import android.support.test.filters.MediumTest; |
| 15 import android.support.test.filters.SmallTest; | 15 import android.support.test.filters.SmallTest; |
| 16 import android.widget.TextView; | 16 import android.widget.TextView; |
| 17 | 17 |
| 18 import org.junit.Assert; |
| 19 import org.junit.Rule; |
| 20 import org.junit.Test; |
| 21 import org.junit.runner.RunWith; |
| 22 |
| 18 import org.chromium.base.test.util.CommandLineFlags; | 23 import org.chromium.base.test.util.CommandLineFlags; |
| 19 import org.chromium.base.test.util.DisableIf; | 24 import org.chromium.base.test.util.DisableIf; |
| 20 import org.chromium.base.test.util.Restriction; | 25 import org.chromium.base.test.util.Restriction; |
| 21 import org.chromium.chrome.R; | 26 import org.chromium.chrome.R; |
| 27 import org.chromium.chrome.browser.ChromeSwitches; |
| 28 import org.chromium.chrome.test.ChromeActivityTestRule; |
| 29 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 30 import org.chromium.chrome.test.ChromeTabbedActivityTestRule; |
| 22 | 31 |
| 23 import java.util.concurrent.CountDownLatch; | 32 import java.util.concurrent.CountDownLatch; |
| 24 import java.util.concurrent.TimeUnit; | 33 import java.util.concurrent.TimeUnit; |
| 25 | 34 |
| 26 /** | 35 /** |
| 27 * End-to-end tests for WebVR using the WebVR test framework from VrTestBase. | 36 * End-to-end tests for WebVR using the WebVR test framework from VrTestBase. |
| 28 */ | 37 */ |
| 29 @CommandLineFlags.Add("enable-webvr") | 38 @RunWith(ChromeJUnit4ClassRunner.class) |
| 39 @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
| 40 ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, "enable-webvr"}) |
| 30 @Restriction(RESTRICTION_TYPE_WEBVR_SUPPORTED) | 41 @Restriction(RESTRICTION_TYPE_WEBVR_SUPPORTED) |
| 31 public class WebVrTest extends VrTestBase { | 42 public class WebVrTest { |
| 32 private static final String TAG = "WebVrTest"; | 43 @Rule |
| 44 public VrTestRule mVrTestRule = new VrTestRule(); |
| 45 |
| 46 @Rule |
| 47 public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActi
vityTestRule(); |
| 33 | 48 |
| 34 /** | 49 /** |
| 35 * Tests that a successful requestPresent call actually enters VR | 50 * Tests that a successful requestPresent call actually enters VR |
| 36 */ | 51 */ |
| 52 @Test |
| 37 @SmallTest | 53 @SmallTest |
| 38 public void testRequestPresentEntersVr() throws InterruptedException { | 54 public void testRequestPresentEntersVr() throws InterruptedException { |
| 39 String testName = "test_requestPresent_enters_vr"; | 55 String testName = "test_requestPresent_enters_vr"; |
| 40 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 56 mActivityTestRule.loadUrl( |
| 41 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 57 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 42 enterVrTapAndWait(mWebContents); | 58 Assert.assertTrue( |
| 43 assertTrue("VrShellDelegate is in VR", VrShellDelegate.isInVr()); | 59 "VRDisplay found", mVrTestRule.vrDisplayFound(mActivityTestRule.
getActivity())); |
| 44 endTest(mWebContents); | 60 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 61 Assert.assertTrue("VrShellDelegate is in VR", VrShellDelegate.isInVr()); |
| 62 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 45 } | 63 } |
| 46 | 64 |
| 47 /** | 65 /** |
| 48 * Tests that scanning the Daydream View NFC tag on supported devices fires
the | 66 * Tests that scanning the Daydream View NFC tag on supported devices fires
the |
| 49 * vrdisplayactivate event. | 67 * vrdisplayactivate event. |
| 50 */ | 68 */ |
| 69 @Test |
| 51 @SmallTest | 70 @SmallTest |
| 52 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) | 71 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) |
| 53 public void testNfcFiresVrdisplayactivate() throws InterruptedException { | 72 public void testNfcFiresVrdisplayactivate() throws InterruptedException { |
| 54 String testName = "test_nfc_fires_vrdisplayactivate"; | 73 String testName = "test_nfc_fires_vrdisplayactivate"; |
| 55 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 74 mActivityTestRule.loadUrl( |
| 56 simNfcScanAndWait(mWebContents); | 75 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 57 endTest(mWebContents); | 76 mVrTestRule.simNfcScanAndWait(mActivityTestRule.getActivity()); |
| 77 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 58 } | 78 } |
| 59 | 79 |
| 60 /** | 80 /** |
| 61 * Tests that screen touches are not registered when the viewer is a Daydrea
m View. | 81 * Tests that screen touches are not registered when the viewer is a Daydrea
m View. |
| 62 */ | 82 */ |
| 83 @Test |
| 63 @LargeTest | 84 @LargeTest |
| 64 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) | 85 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) |
| 65 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept
ion { | 86 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept
ion { |
| 66 String testName = "test_screen_taps_not_registered_on_daydream"; | 87 String testName = "test_screen_taps_not_registered_on_daydream"; |
| 67 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 88 mActivityTestRule.loadUrl( |
| 68 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 89 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 69 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 90 Assert.assertTrue( |
| 70 enterVrTapAndWait(mWebContents); | 91 "VRDisplay found", mVrTestRule.vrDisplayFound(mActivityTestRule.
getActivity())); |
| 92 mVrTestRule.executeStepAndWait( |
| 93 "stepVerifyNoInitialTaps()", mActivityTestRule.getActivity()); |
| 94 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 71 // Wait on VrShellImpl to say that its parent consumed the touch event | 95 // Wait on VrShellImpl to say that its parent consumed the touch event |
| 72 // Set to 2 because there's an ACTION_DOWN followed by ACTION_UP | 96 // Set to 2 because there's an ACTION_DOWN followed by ACTION_UP |
| 73 final CountDownLatch touchRegisteredLatch = new CountDownLatch(2); | 97 final CountDownLatch touchRegisteredLatch = new CountDownLatch(2); |
| 74 ((VrShellImpl) VrShellDelegate.getVrShellForTesting()) | 98 ((VrShellImpl) VrShellDelegate.getVrShellForTesting()) |
| 75 .setOnDispatchTouchEventForTesting(new OnDispatchTouchEventCallb
ack() { | 99 .setOnDispatchTouchEventForTesting(new OnDispatchTouchEventCallb
ack() { |
| 76 @Override | 100 @Override |
| 77 public void onDispatchTouchEvent( | 101 public void onDispatchTouchEvent( |
| 78 boolean parentConsumed, boolean cardboardTriggered)
{ | 102 boolean parentConsumed, boolean cardboardTriggered)
{ |
| 79 if (!parentConsumed) fail("Parent did not consume event"
); | 103 if (!parentConsumed) Assert.fail("Parent did not consume
event"); |
| 80 if (cardboardTriggered) fail("Cardboard event triggered"
); | 104 if (cardboardTriggered) Assert.fail("Cardboard event tri
ggered"); |
| 81 touchRegisteredLatch.countDown(); | 105 touchRegisteredLatch.countDown(); |
| 82 } | 106 } |
| 83 }); | 107 }); |
| 84 enterVrTap(); | 108 mVrTestRule.enterVrTap(mActivityTestRule.getActivity()); |
| 85 assertTrue("VrShellImpl dispatched touches", | 109 Assert.assertTrue("VrShellImpl dispatched touches", |
| 86 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI
SECONDS)); | 110 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI
SECONDS)); |
| 87 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); | 111 mVrTestRule.executeStepAndWait( |
| 88 endTest(mWebContents); | 112 "stepVerifyNoAdditionalTaps()", mActivityTestRule.getActivity())
; |
| 113 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 89 } | 114 } |
| 90 | 115 |
| 91 /** | 116 /** |
| 92 * Tests that Daydream controller clicks are registered as screen taps when
the viewer is a | 117 * Tests that Daydream controller clicks are registered as screen taps when
the viewer is a |
| 93 * Daydream View. | 118 * Daydream View. |
| 94 */ | 119 */ |
| 120 @Test |
| 95 @LargeTest | 121 @LargeTest |
| 96 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) | 122 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) |
| 97 public void testControllerClicksRegisteredAsTapsOnDaydream() throws Interrup
tedException { | 123 public void testControllerClicksRegisteredAsTapsOnDaydream() throws Interrup
tedException { |
| 98 EmulatedVrController controller = new EmulatedVrController(getActivity()
); | 124 EmulatedVrController controller = new EmulatedVrController(mActivityTest
Rule.getActivity()); |
| 99 String testName = "test_screen_taps_registered"; | 125 String testName = "test_screen_taps_registered"; |
| 100 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 126 mActivityTestRule.loadUrl( |
| 101 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 127 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 102 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 128 Assert.assertTrue( |
| 129 "VRDisplay found", mVrTestRule.vrDisplayFound(mActivityTestRule.
getActivity())); |
| 130 mVrTestRule.executeStepAndWait( |
| 131 "stepVerifyNoInitialTaps()", mActivityTestRule.getActivity()); |
| 103 // Tap and wait to enter VR | 132 // Tap and wait to enter VR |
| 104 enterVrTapAndWait(mWebContents); | 133 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 105 // Send a controller click and wait for JavaScript to receive it | 134 // Send a controller click and wait for JavaScript to receive it |
| 106 controller.pressReleaseTouchpadButton(); | 135 controller.pressReleaseTouchpadButton(); |
| 107 waitOnJavaScriptStep(mWebContents); | 136 mVrTestRule.waitOnJavaScriptStep(mActivityTestRule.getActivity()); |
| 108 endTest(mWebContents); | 137 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 109 } | 138 } |
| 110 | 139 |
| 111 /** | 140 /** |
| 112 * Tests that screen touches are still registered when the viewer is Cardboa
rd. | 141 * Tests that screen touches are still registered when the viewer is Cardboa
rd. |
| 113 */ | 142 */ |
| 143 @Test |
| 114 @MediumTest | 144 @MediumTest |
| 115 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) | 145 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) |
| 116 @DisableIf.Build(message = "Flaky on L crbug.com/713781", | 146 @DisableIf.Build(message = "Flaky on L crbug.com/713781", |
| 117 sdk_is_greater_than = Build.VERSION_CODES.KITKAT, | 147 sdk_is_greater_than = Build.VERSION_CODES.KITKAT, |
| 118 sdk_is_less_than = Build.VERSION_CODES.M) | 148 sdk_is_less_than = Build.VERSION_CODES.M) |
| 119 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { | 149 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { |
| 120 String testName = "test_screen_taps_registered"; | 150 String testName = "test_screen_taps_registered"; |
| 121 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 151 mActivityTestRule.loadUrl( |
| 122 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 152 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 123 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 153 Assert.assertTrue( |
| 154 "VRDisplay found", mVrTestRule.vrDisplayFound(mActivityTestRule.
getActivity())); |
| 155 mVrTestRule.executeStepAndWait( |
| 156 "stepVerifyNoInitialTaps()", mActivityTestRule.getActivity()); |
| 124 // Tap and wait to enter VR | 157 // Tap and wait to enter VR |
| 125 enterVrTapAndWait(mWebContents); | 158 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 126 // Tap and wait for JavaScript to receive it | 159 // Tap and wait for JavaScript to receive it |
| 127 enterVrTapAndWait(mWebContents); | 160 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 128 endTest(mWebContents); | 161 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 129 } | 162 } |
| 130 | 163 |
| 131 /** | 164 /** |
| 132 * Tests that non-focused tabs cannot get pose information. | 165 * Tests that non-focused tabs cannot get pose information. |
| 133 */ | 166 */ |
| 167 @Test |
| 134 @SmallTest | 168 @SmallTest |
| 135 public void testPoseDataUnfocusedTab() throws InterruptedException { | 169 public void testPoseDataUnfocusedTab() throws InterruptedException { |
| 136 String testName = "test_pose_data_unfocused_tab"; | 170 String testName = "test_pose_data_unfocused_tab"; |
| 137 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 171 mActivityTestRule.loadUrl( |
| 138 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 172 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 139 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); | 173 Assert.assertTrue( |
| 174 "VRDisplay found", mVrTestRule.vrDisplayFound(mActivityTestRule.
getActivity())); |
| 175 mVrTestRule.executeStepAndWait( |
| 176 "stepCheckFrameDataWhileFocusedTab()", mActivityTestRule.getActi
vity()); |
| 140 | 177 |
| 141 loadUrlInNewTab("about:blank"); | 178 mActivityTestRule.loadUrlInNewTab("about:blank"); |
| 142 | 179 |
| 143 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent
s); | 180 mVrTestRule.executeStepAndWait( |
| 144 endTest(mWebContents); | 181 "stepCheckFrameDataWhileNonFocusedTab()", mActivityTestRule.getA
ctivity()); |
| 182 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 145 } | 183 } |
| 146 | 184 |
| 147 /** | 185 /** |
| 148 * Helper function to run the tests checking for the upgrade/install InfoBar
being present since | 186 * Helper function to run the tests checking for the upgrade/install InfoBar
being present since |
| 149 * all that differs is the value returned by VrCoreVersionChecker and a coup
le asserts. | 187 * all that differs is the value returned by VrCoreVersionChecker and a coup
le asserts. |
| 150 * | 188 * |
| 151 * @param checkerReturnValue The value to have the VrCoreVersionChecker retu
rn | 189 * @param checkerReturnValue The value to have the VrCoreVersionChecker retu
rn |
| 152 */ | 190 */ |
| 153 private void infoBarTestHelper(int checkerReturnValue) throws InterruptedExc
eption { | 191 private void infoBarTestHelper(int checkerReturnValue) throws InterruptedExc
eption { |
| 154 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI
mpl(); | 192 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI
mpl(); |
| 155 mockChecker.setMockReturnValue(checkerReturnValue); | 193 mockChecker.setMockReturnValue(checkerReturnValue); |
| 156 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest
ing(mockChecker); | 194 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest
ing(mockChecker); |
| 157 String testName = "generic_webvr_page"; | 195 String testName = "generic_webvr_page"; |
| 158 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 196 mActivityTestRule.loadUrl( |
| 197 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 159 String displayFound = "VRDisplay Found"; | 198 String displayFound = "VRDisplay Found"; |
| 160 String barPresent = "InfoBar present"; | 199 String barPresent = "InfoBar present"; |
| 161 if (checkerReturnValue == VrCoreVersionChecker.VR_READY) { | 200 if (checkerReturnValue == VrCoreVersionChecker.VR_READY) { |
| 162 assertTrue(displayFound, vrDisplayFound(mWebContents)); | 201 Assert.assertTrue( |
| 163 assertFalse(barPresent, | 202 displayFound, mVrTestRule.vrDisplayFound(mActivityTestRule.g
etActivity())); |
| 203 Assert.assertFalse(barPresent, |
| 164 VrUtils.isUpdateInstallInfoBarPresent( | 204 VrUtils.isUpdateInstallInfoBarPresent( |
| 165 getActivity().getWindow().getDecorView())); | 205 mActivityTestRule.getActivity().getWindow().getDecor
View())); |
| 166 } else if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE | 206 } else if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE |
| 167 || checkerReturnValue == VrCoreVersionChecker.VR_NOT_AVAILABLE)
{ | 207 || checkerReturnValue == VrCoreVersionChecker.VR_NOT_AVAILABLE)
{ |
| 168 // Out of date and missing cases are the same, but with different te
xt | 208 // Out of date and missing cases are the same, but with different te
xt |
| 169 String expectedMessage, expectedButton; | 209 String expectedMessage, expectedButton; |
| 170 if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 210 if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE) { |
| 171 expectedMessage = | 211 expectedMessage = mActivityTestRule.getActivity().getString( |
| 172 getActivity().getString(R.string.vr_services_check_infob
ar_update_text); | 212 R.string.vr_services_check_infobar_update_text); |
| 173 expectedButton = | 213 expectedButton = mActivityTestRule.getActivity().getString( |
| 174 getActivity().getString(R.string.vr_services_check_infob
ar_update_button); | 214 R.string.vr_services_check_infobar_update_button); |
| 175 } else { | 215 } else { |
| 176 expectedMessage = | 216 expectedMessage = mActivityTestRule.getActivity().getString( |
| 177 getActivity().getString(R.string.vr_services_check_infob
ar_install_text); | 217 R.string.vr_services_check_infobar_install_text); |
| 178 expectedButton = | 218 expectedButton = mActivityTestRule.getActivity().getString( |
| 179 getActivity().getString(R.string.vr_services_check_infob
ar_install_button); | 219 R.string.vr_services_check_infobar_install_button); |
| 180 } | 220 } |
| 181 assertFalse(displayFound, vrDisplayFound(mWebContents)); | 221 Assert.assertFalse( |
| 182 assertTrue(barPresent, | 222 displayFound, mVrTestRule.vrDisplayFound(mActivityTestRule.g
etActivity())); |
| 223 Assert.assertTrue(barPresent, |
| 183 VrUtils.isUpdateInstallInfoBarPresent( | 224 VrUtils.isUpdateInstallInfoBarPresent( |
| 184 getActivity().getWindow().getDecorView())); | 225 mActivityTestRule.getActivity().getWindow().getDecor
View())); |
| 185 TextView tempView = (TextView) getActivity().getWindow().getDecorVie
w().findViewById( | 226 TextView tempView = (TextView) mActivityTestRule.getActivity() |
| 186 R.id.infobar_message); | 227 .getWindow() |
| 187 assertEquals(expectedMessage, tempView.getText().toString()); | 228 .getDecorView() |
| 188 tempView = (TextView) getActivity().getWindow().getDecorView().findV
iewById( | 229 .findViewById(R.id.infobar_message); |
| 189 R.id.button_primary); | 230 Assert.assertEquals(expectedMessage, tempView.getText().toString()); |
| 190 assertEquals(expectedButton, tempView.getText().toString()); | 231 tempView = (TextView) mActivityTestRule.getActivity() |
| 232 .getWindow() |
| 233 .getDecorView() |
| 234 .findViewById(R.id.button_primary); |
| 235 Assert.assertEquals(expectedButton, tempView.getText().toString()); |
| 191 } else if (checkerReturnValue == VrCoreVersionChecker.VR_NOT_SUPPORTED)
{ | 236 } else if (checkerReturnValue == VrCoreVersionChecker.VR_NOT_SUPPORTED)
{ |
| 192 assertFalse(displayFound, vrDisplayFound(mWebContents)); | 237 Assert.assertFalse( |
| 193 assertFalse(barPresent, | 238 displayFound, mVrTestRule.vrDisplayFound(mActivityTestRule.g
etActivity())); |
| 239 Assert.assertFalse(barPresent, |
| 194 VrUtils.isUpdateInstallInfoBarPresent( | 240 VrUtils.isUpdateInstallInfoBarPresent( |
| 195 getActivity().getWindow().getDecorView())); | 241 mActivityTestRule.getActivity().getWindow().getDecor
View())); |
| 196 } else { | 242 } else { |
| 197 fail("Invalid VrCoreVersionChecker value: " + String.valueOf(checker
ReturnValue)); | 243 Assert.fail( |
| 244 "Invalid VrCoreVersionChecker value: " + String.valueOf(chec
kerReturnValue)); |
| 198 } | 245 } |
| 199 assertEquals(checkerReturnValue, mockChecker.getLastReturnValue()); | 246 Assert.assertEquals(checkerReturnValue, mockChecker.getLastReturnValue()
); |
| 200 } | 247 } |
| 201 | 248 |
| 202 /** | 249 /** |
| 203 * Tests that the upgrade/install VR Services InfoBar is not present when VR
Services is | 250 * Tests that the upgrade/install VR Services InfoBar is not present when VR
Services is |
| 204 * installed and up to date. | 251 * installed and up to date. |
| 205 */ | 252 */ |
| 253 @Test |
| 206 @MediumTest | 254 @MediumTest |
| 207 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE
xception { | 255 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE
xception { |
| 208 infoBarTestHelper(VrCoreVersionChecker.VR_READY); | 256 infoBarTestHelper(VrCoreVersionChecker.VR_READY); |
| 209 } | 257 } |
| 210 | 258 |
| 211 /** | 259 /** |
| 212 * Tests that the upgrade VR Services InfoBar is present when VR Services is
outdated. | 260 * Tests that the upgrade VR Services InfoBar is present when VR Services is
outdated. |
| 213 */ | 261 */ |
| 262 @Test |
| 214 @MediumTest | 263 @MediumTest |
| 215 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc
eption { | 264 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc
eption { |
| 216 infoBarTestHelper(VrCoreVersionChecker.VR_OUT_OF_DATE); | 265 infoBarTestHelper(VrCoreVersionChecker.VR_OUT_OF_DATE); |
| 217 } | 266 } |
| 218 | 267 |
| 219 /** | 268 /** |
| 220 * Tests that the install VR Services InfoBar is present when VR Services is
missing. | 269 * Tests that the install VR Services InfoBar is present when VR Services is
missing. |
| 221 */ | 270 */ |
| 271 @Test |
| 222 @MediumTest | 272 @MediumTest |
| 223 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce
ption { | 273 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce
ption { |
| 224 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_AVAILABLE); | 274 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_AVAILABLE); |
| 225 } | 275 } |
| 226 | 276 |
| 227 /** | 277 /** |
| 228 * Tests that the install VR Services InfoBar is not present when VR is not
supported on the | 278 * Tests that the install VR Services InfoBar is not present when VR is not
supported on the |
| 229 * device. | 279 * device. |
| 230 */ | 280 */ |
| 281 @Test |
| 231 @MediumTest | 282 @MediumTest |
| 232 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru
ptedException { | 283 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru
ptedException { |
| 233 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED); | 284 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED); |
| 234 } | 285 } |
| 235 | 286 |
| 236 /** | 287 /** |
| 237 * Tests that the reported WebVR capabilities match expectations on the devi
ces the WebVR tests | 288 * Tests that the reported WebVR capabilities match expectations on the devi
ces the WebVR tests |
| 238 * are run on continuously. | 289 * are run on continuously. |
| 239 */ | 290 */ |
| 291 @Test |
| 240 @MediumTest | 292 @MediumTest |
| 241 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce
ption { | 293 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce
ption { |
| 242 String testName = "test_device_capabilities_match_expectations"; | 294 String testName = "test_device_capabilities_match_expectations"; |
| 243 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 295 mActivityTestRule.loadUrl( |
| 244 assertTrue("VRDisplayFound", vrDisplayFound(mWebContents)); | 296 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 245 executeStepAndWait("stepCheckDeviceCapabilities('" + Build.DEVICE + "')"
, mWebContents); | 297 Assert.assertTrue( |
| 246 endTest(mWebContents); | 298 "VRDisplayFound", mVrTestRule.vrDisplayFound(mActivityTestRule.g
etActivity())); |
| 299 mVrTestRule.executeStepAndWait("stepCheckDeviceCapabilities('" + Build.D
EVICE + "')", |
| 300 mActivityTestRule.getActivity()); |
| 301 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 247 } | 302 } |
| 248 | 303 |
| 249 /** | 304 /** |
| 250 * Tests that focus is locked to the presenting display for purposes of VR i
nput. | 305 * Tests that focus is locked to the presenting display for purposes of VR i
nput. |
| 251 */ | 306 */ |
| 307 @Test |
| 252 @MediumTest | 308 @MediumTest |
| 253 @DisableIf.Build(message = "Flaky on L crbug.com/713781", | 309 @DisableIf.Build(message = "Flaky on L crbug.com/713781", |
| 254 sdk_is_greater_than = Build.VERSION_CODES.KITKAT, | 310 sdk_is_greater_than = Build.VERSION_CODES.KITKAT, |
| 255 sdk_is_less_than = Build.VERSION_CODES.M) | 311 sdk_is_less_than = Build.VERSION_CODES.M) |
| 256 public void testPresentationLocksFocus() throws InterruptedException { | 312 public void testPresentationLocksFocus() throws InterruptedException { |
| 257 String testName = "test_presentation_locks_focus"; | 313 String testName = "test_presentation_locks_focus"; |
| 258 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 314 mActivityTestRule.loadUrl( |
| 259 enterVrTapAndWait(mWebContents); | 315 VrTestRule.getHtmlTestFile(testName), VrTestRule.PAGE_LOAD_TIMEO
UT_S); |
| 260 waitOnJavaScriptStep(mWebContents); | 316 mVrTestRule.enterVrTapAndWait(mActivityTestRule.getActivity()); |
| 261 endTest(mWebContents); | 317 mVrTestRule.waitOnJavaScriptStep(mActivityTestRule.getActivity()); |
| 318 mVrTestRule.endTest(mActivityTestRule.getActivity()); |
| 262 } | 319 } |
| 263 } | 320 } |
| OLD | NEW |