| 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 OnDispatchTouchEventCallb
ack() { |
| 271 @Override |
| 272 public void onDispatchTouchEvent( |
| 273 boolean parentConsumed, boolean cardboardTriggered)
{ |
| 274 if (!parentConsumed) fail("Parent did not consume event"
); |
| 275 if (cardboardTriggered) fail("Cardboard event triggered"
); |
| 276 touchRegisteredLatch.countDown(); |
| 277 } |
| 278 }); |
| 263 enterVrTap(); | 279 enterVrTap(); |
| 280 assertTrue("VrShellImpl dispatched touches", |
| 281 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI
SECONDS)); |
| 264 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); | 282 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); |
| 265 endTest(mWebContents); | 283 endTest(mWebContents); |
| 266 } | 284 } |
| 267 | 285 |
| 268 /** | 286 /** |
| 269 * Tests that screen touches are still registered when the viewer is | 287 * Tests that screen touches are still registered when the viewer is |
| 270 * Cardboard. | 288 * Cardboard. |
| 271 */ | 289 */ |
| 272 @SmallTest | 290 @MediumTest |
| 273 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) | 291 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) |
| 274 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { | 292 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { |
| 275 String testName = "test_screen_taps_registered_on_cardboard"; | 293 String testName = "test_screen_taps_registered_on_cardboard"; |
| 276 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 294 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 277 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 295 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
| 278 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 296 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); |
| 297 // Tap and wait to enter VR |
| 279 enterVrTapAndWait(mWebContents); | 298 enterVrTapAndWait(mWebContents); |
| 280 enterVrTap(); | 299 // Tap and wait for Javascript to receive it |
| 281 executeStepAndWait("stepVerifyAdditionalTap()", mWebContents); | 300 enterVrTapAndWait(mWebContents); |
| 282 endTest(mWebContents); | 301 endTest(mWebContents); |
| 283 } | 302 } |
| 284 | 303 |
| 285 /** | 304 /** |
| 286 * Tests that non-focused tabs cannot get pose information. | 305 * Tests that non-focused tabs cannot get pose information. |
| 287 */ | 306 */ |
| 288 @SmallTest | 307 @SmallTest |
| 289 public void testPoseDataUnfocusedTab() throws InterruptedException { | 308 public void testPoseDataUnfocusedTab() throws InterruptedException { |
| 290 String testName = "test_pose_data_unfocused_tab"; | 309 String testName = "test_pose_data_unfocused_tab"; |
| 291 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 310 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
| 292 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 311 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
| 293 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); | 312 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); |
| 294 | 313 |
| 295 loadUrlInNewTab("about:blank"); | 314 loadUrlInNewTab("about:blank"); |
| 296 | 315 |
| 297 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent
s); | 316 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent
s); |
| 298 endTest(mWebContents); | 317 endTest(mWebContents); |
| 299 } | 318 } |
| 300 } | 319 } |
| OLD | NEW |