Chromium Code Reviews| 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_CHECK_INTERVAL_L ONG_MS; | 7 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_CHECK_INTERVAL_L ONG_MS; |
| 8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_CHECK_INTERVAL_S HORT_MS; | 8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_CHECK_INTERVAL_S HORT_MS; |
| 9 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_LONG_MS; | 9 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_LONG_MS; |
| 10 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS ; | 10 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS ; |
| 11 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V IEWER_DAYDREAM; | 11 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V IEWER_DAYDREAM; |
| 12 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V IEWER_NON_DAYDREAM; | 12 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V IEWER_NON_DAYDREAM; |
| 13 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_W EBVR_SUPPORTED; | 13 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_W EBVR_SUPPORTED; |
| 14 | 14 |
| 15 import android.support.test.filters.LargeTest; | |
| 16 import android.support.test.filters.MediumTest; | |
| 15 import android.support.test.filters.SmallTest; | 17 import android.support.test.filters.SmallTest; |
| 16 | 18 |
| 17 import org.chromium.base.Log; | 19 import org.chromium.base.Log; |
| 18 import org.chromium.base.test.util.CommandLineFlags; | 20 import org.chromium.base.test.util.CommandLineFlags; |
| 19 import org.chromium.base.test.util.Restriction; | 21 import org.chromium.base.test.util.Restriction; |
| 20 import org.chromium.base.test.util.UrlUtils; | 22 import org.chromium.base.test.util.UrlUtils; |
| 21 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; | 23 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; |
| 22 import org.chromium.content.browser.test.util.ClickUtils; | 24 import org.chromium.content.browser.test.util.ClickUtils; |
| 23 import org.chromium.content.browser.test.util.Criteria; | 25 import org.chromium.content.browser.test.util.Criteria; |
| 24 import org.chromium.content.browser.test.util.CriteriaHelper; | 26 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 25 import org.chromium.content.browser.test.util.JavaScriptUtils; | 27 import org.chromium.content.browser.test.util.JavaScriptUtils; |
| 26 import org.chromium.content_public.browser.WebContents; | 28 import org.chromium.content_public.browser.WebContents; |
| 27 | 29 |
| 28 import java.util.concurrent.Callable; | 30 import java.util.concurrent.Callable; |
| 31 import java.util.concurrent.CountDownLatch; | |
| 29 import java.util.concurrent.TimeUnit; | 32 import java.util.concurrent.TimeUnit; |
| 30 import java.util.concurrent.TimeoutException; | 33 import java.util.concurrent.TimeoutException; |
| 31 | 34 |
| 32 /** | 35 /** |
| 33 * This is a workaround for testing aspects of WebVR that aren't testable with | 36 * This is a workaround for testing aspects of WebVR that aren't testable with |
| 34 * WebVR's mocked layout tests, such as E2E tests. | 37 * WebVR's mocked layout tests, such as E2E tests. |
| 35 * | 38 * |
| 36 * The general test flow is: | 39 * The general test flow is: |
| 37 * - Load the HTML file containing the test, which: | 40 * - Load the HTML file containing the test, which: |
| 38 * - Loads the WebVR boilerplate code and some test functions | 41 * - Loads the WebVR boilerplate code and some test functions |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 String testName = "test_nfc_fires_vrdisplayactivate"; | 248 String testName = "test_nfc_fires_vrdisplayactivate"; |
| 246 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 249 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 247 simNfcScanAndWait(mWebContents); | 250 simNfcScanAndWait(mWebContents); |
| 248 endTest(mWebContents); | 251 endTest(mWebContents); |
| 249 } | 252 } |
| 250 | 253 |
| 251 /** | 254 /** |
| 252 * Tests that screen touches are not registered when the viewer is a | 255 * Tests that screen touches are not registered when the viewer is a |
| 253 * Daydream View. | 256 * Daydream View. |
| 254 */ | 257 */ |
| 255 @SmallTest | 258 @LargeTest |
| 256 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) | 259 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) |
| 257 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept ion { | 260 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept ion { |
| 258 String testName = "test_screen_taps_not_registered_on_daydream"; | 261 String testName = "test_screen_taps_not_registered_on_daydream"; |
| 259 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 262 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 260 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 263 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
| 261 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 264 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); |
| 262 enterVrTapAndWait(mWebContents); | 265 enterVrTapAndWait(mWebContents); |
| 266 // Wait on VrShellImpl to say that its parent consumed the touch event | |
| 267 // Set to 2 because there's an ACTION_DOWN followed by ACTION_UP | |
| 268 final CountDownLatch touchRegisteredLatch = new CountDownLatch(2); | |
| 269 ((VrShellImpl) VrShellDelegate.getVrShellForTesting()) | |
| 270 .setOnDispatchTouchEventForTesting(new Runnable() { | |
| 271 @Override | |
| 272 public void run() { | |
| 273 touchRegisteredLatch.countDown(); | |
| 274 } | |
| 275 }); | |
| 263 enterVrTap(); | 276 enterVrTap(); |
| 277 touchRegisteredLatch.await(); | |
|
mthiesse
2017/03/28 18:08:01
What's the timeout on this? Will it wait forever i
bsheedy
2017/03/28 20:50:35
Done, and made the await() have a one second timeo
| |
| 264 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); | 278 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); |
| 265 endTest(mWebContents); | 279 endTest(mWebContents); |
| 266 } | 280 } |
| 267 | 281 |
| 268 /** | 282 /** |
| 269 * Tests that screen touches are still registered when the viewer is | 283 * Tests that screen touches are still registered when the viewer is |
| 270 * Cardboard. | 284 * Cardboard. |
| 271 */ | 285 */ |
| 272 @SmallTest | 286 @MediumTest |
| 273 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) | 287 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) |
| 274 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio n { | 288 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio n { |
| 275 String testName = "test_screen_taps_registered_on_cardboard"; | 289 String testName = "test_screen_taps_registered_on_cardboard"; |
| 276 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 290 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 277 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 291 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
| 278 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 292 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); |
| 293 // Tap and wait to enter VR | |
| 279 enterVrTapAndWait(mWebContents); | 294 enterVrTapAndWait(mWebContents); |
| 280 enterVrTap(); | 295 // Tap and wait for Javascript to receive it |
| 281 executeStepAndWait("stepVerifyAdditionalTap()", mWebContents); | 296 enterVrTapAndWait(mWebContents); |
| 282 endTest(mWebContents); | 297 endTest(mWebContents); |
| 283 } | 298 } |
| 284 | 299 |
| 285 /** | 300 /** |
| 286 * Tests that non-focused tabs cannot get pose information. | 301 * Tests that non-focused tabs cannot get pose information. |
| 287 */ | 302 */ |
| 288 @SmallTest | 303 @SmallTest |
| 289 public void testPoseDataUnfocusedTab() throws InterruptedException { | 304 public void testPoseDataUnfocusedTab() throws InterruptedException { |
| 290 String testName = "test_pose_data_unfocused_tab"; | 305 String testName = "test_pose_data_unfocused_tab"; |
| 291 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 306 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 292 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 307 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
| 293 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); | 308 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); |
| 294 | 309 |
| 295 loadUrlInNewTab("about:blank"); | 310 loadUrlInNewTab("about:blank"); |
| 296 | 311 |
| 297 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent s); | 312 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent s); |
| 298 endTest(mWebContents); | 313 endTest(mWebContents); |
| 299 } | 314 } |
| 300 } | 315 } |
| OLD | NEW |