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; | |
17 import android.support.test.filters.SmallTest; | 15 import android.support.test.filters.SmallTest; |
18 | 16 |
19 import org.chromium.base.Log; | 17 import org.chromium.base.Log; |
20 import org.chromium.base.test.util.CommandLineFlags; | 18 import org.chromium.base.test.util.CommandLineFlags; |
21 import org.chromium.base.test.util.Restriction; | 19 import org.chromium.base.test.util.Restriction; |
22 import org.chromium.base.test.util.UrlUtils; | 20 import org.chromium.base.test.util.UrlUtils; |
23 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; | 21 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; |
24 import org.chromium.content.browser.test.util.ClickUtils; | 22 import org.chromium.content.browser.test.util.ClickUtils; |
25 import org.chromium.content.browser.test.util.Criteria; | 23 import org.chromium.content.browser.test.util.Criteria; |
26 import org.chromium.content.browser.test.util.CriteriaHelper; | 24 import org.chromium.content.browser.test.util.CriteriaHelper; |
27 import org.chromium.content.browser.test.util.JavaScriptUtils; | 25 import org.chromium.content.browser.test.util.JavaScriptUtils; |
28 import org.chromium.content_public.browser.WebContents; | 26 import org.chromium.content_public.browser.WebContents; |
29 | 27 |
30 import java.util.concurrent.Callable; | 28 import java.util.concurrent.Callable; |
31 import java.util.concurrent.CountDownLatch; | |
32 import java.util.concurrent.TimeUnit; | 29 import java.util.concurrent.TimeUnit; |
33 import java.util.concurrent.TimeoutException; | 30 import java.util.concurrent.TimeoutException; |
34 | 31 |
35 /** | 32 /** |
36 * This is a workaround for testing aspects of WebVR that aren't testable with | 33 * This is a workaround for testing aspects of WebVR that aren't testable with |
37 * WebVR's mocked layout tests, such as E2E tests. | 34 * WebVR's mocked layout tests, such as E2E tests. |
38 * | 35 * |
39 * The general test flow is: | 36 * The general test flow is: |
40 * - Load the HTML file containing the test, which: | 37 * - Load the HTML file containing the test, which: |
41 * - Loads the WebVR boilerplate code and some test functions | 38 * - Loads the WebVR boilerplate code and some test functions |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 String testName = "test_nfc_fires_vrdisplayactivate"; | 245 String testName = "test_nfc_fires_vrdisplayactivate"; |
249 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 246 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
250 simNfcScanAndWait(mWebContents); | 247 simNfcScanAndWait(mWebContents); |
251 endTest(mWebContents); | 248 endTest(mWebContents); |
252 } | 249 } |
253 | 250 |
254 /** | 251 /** |
255 * Tests that screen touches are not registered when the viewer is a | 252 * Tests that screen touches are not registered when the viewer is a |
256 * Daydream View. | 253 * Daydream View. |
257 */ | 254 */ |
258 @LargeTest | 255 @SmallTest |
259 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) | 256 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) |
260 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept
ion { | 257 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept
ion { |
261 String testName = "test_screen_taps_not_registered_on_daydream"; | 258 String testName = "test_screen_taps_not_registered_on_daydream"; |
262 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 259 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
263 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 260 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
264 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 261 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); |
265 enterVrTapAndWait(mWebContents); | 262 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 }); | |
279 enterVrTap(); | 263 enterVrTap(); |
280 assertTrue("VrShellImpl dispatched touches", | |
281 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI
SECONDS)); | |
282 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); | 264 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); |
283 endTest(mWebContents); | 265 endTest(mWebContents); |
284 } | 266 } |
285 | 267 |
286 /** | 268 /** |
287 * Tests that screen touches are still registered when the viewer is | 269 * Tests that screen touches are still registered when the viewer is |
288 * Cardboard. | 270 * Cardboard. |
289 */ | 271 */ |
290 @MediumTest | 272 @SmallTest |
291 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) | 273 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) |
292 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { | 274 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio
n { |
293 String testName = "test_screen_taps_registered_on_cardboard"; | 275 String testName = "test_screen_taps_registered_on_cardboard"; |
294 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 276 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
295 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 277 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
296 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); | 278 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); |
297 // Tap and wait to enter VR | |
298 enterVrTapAndWait(mWebContents); | 279 enterVrTapAndWait(mWebContents); |
299 // Tap and wait for Javascript to receive it | 280 enterVrTap(); |
300 enterVrTapAndWait(mWebContents); | 281 executeStepAndWait("stepVerifyAdditionalTap()", mWebContents); |
301 endTest(mWebContents); | 282 endTest(mWebContents); |
302 } | 283 } |
303 | 284 |
304 /** | 285 /** |
305 * Tests that non-focused tabs cannot get pose information. | 286 * Tests that non-focused tabs cannot get pose information. |
306 */ | 287 */ |
307 @SmallTest | 288 @SmallTest |
308 public void testPoseDataUnfocusedTab() throws InterruptedException { | 289 public void testPoseDataUnfocusedTab() throws InterruptedException { |
309 String testName = "test_pose_data_unfocused_tab"; | 290 String testName = "test_pose_data_unfocused_tab"; |
310 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); | 291 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); |
311 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); | 292 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); |
312 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); | 293 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); |
313 | 294 |
314 loadUrlInNewTab("about:blank"); | 295 loadUrlInNewTab("about:blank"); |
315 | 296 |
316 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent
s); | 297 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent
s); |
317 endTest(mWebContents); | 298 endTest(mWebContents); |
318 } | 299 } |
319 } | 300 } |
OLD | NEW |