Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/WebVrTest.java

Issue 2859533003: WebVR: lock focus while presenting to presenting window (Closed)
Patch Set: Update comment + fix comment line lengths Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_W EBVR_SUPPORTED; 9 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_W EBVR_SUPPORTED;
10 10
11 import android.os.Build; 11 import android.os.Build;
12 import android.support.test.filters.LargeTest; 12 import android.support.test.filters.LargeTest;
13 import android.support.test.filters.MediumTest; 13 import android.support.test.filters.MediumTest;
14 import android.support.test.filters.SmallTest; 14 import android.support.test.filters.SmallTest;
15 import android.widget.TextView; 15 import android.widget.TextView;
16 16
17 import org.chromium.base.test.util.CommandLineFlags; 17 import org.chromium.base.test.util.CommandLineFlags;
18 import org.chromium.base.test.util.DisabledTest; 18 import org.chromium.base.test.util.DisabledTest;
19 import org.chromium.base.test.util.Restriction; 19 import org.chromium.base.test.util.Restriction;
20 import org.chromium.chrome.R; 20 import org.chromium.chrome.R;
21 21
22 import java.util.concurrent.CountDownLatch; 22 import java.util.concurrent.CountDownLatch;
23 import java.util.concurrent.TimeUnit; 23 import java.util.concurrent.TimeUnit;
24 24
25 /** 25 /**
26 * End-to-end tests for WebVR using the WebVR test framework from 26 * End-to-end tests for WebVR using the WebVR test framework from VrTestBase.
27 * VrTestBase.
28 */ 27 */
29 @CommandLineFlags.Add("enable-webvr") 28 @CommandLineFlags.Add("enable-webvr")
30 @Restriction(RESTRICTION_TYPE_WEBVR_SUPPORTED) 29 @Restriction(RESTRICTION_TYPE_WEBVR_SUPPORTED)
31 public class WebVrTest extends VrTestBase { 30 public class WebVrTest extends VrTestBase {
32 private static final String TAG = "WebVrTest"; 31 private static final String TAG = "WebVrTest";
33 32
34 /** 33 /**
35 * Tests that a successful requestPresent call actually enters VR 34 * Tests that a successful requestPresent call actually enters VR
36 */ 35 */
37 @SmallTest 36 @SmallTest
38 public void testRequestPresentEntersVr() throws InterruptedException { 37 public void testRequestPresentEntersVr() throws InterruptedException {
39 String testName = "test_requestPresent_enters_vr"; 38 String testName = "test_requestPresent_enters_vr";
40 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 39 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
41 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); 40 assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
42 enterVrTapAndWait(mWebContents); 41 enterVrTapAndWait(mWebContents);
43 assertTrue("VrShellDelegate is in VR", VrShellDelegate.isInVr()); 42 assertTrue("VrShellDelegate is in VR", VrShellDelegate.isInVr());
44 endTest(mWebContents); 43 endTest(mWebContents);
45 } 44 }
46 45
47 /** 46 /**
48 * Tests that scanning the Daydream View NFC tag on supported devices 47 * Tests that scanning the Daydream View NFC tag on supported devices fires the
49 * fires the vrdisplayactivate event. 48 * vrdisplayactivate event.
50 */ 49 */
51 @SmallTest 50 @SmallTest
52 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) 51 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
53 public void testNfcFiresVrdisplayactivate() throws InterruptedException { 52 public void testNfcFiresVrdisplayactivate() throws InterruptedException {
54 String testName = "test_nfc_fires_vrdisplayactivate"; 53 String testName = "test_nfc_fires_vrdisplayactivate";
55 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 54 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
56 simNfcScanAndWait(mWebContents); 55 simNfcScanAndWait(mWebContents);
57 endTest(mWebContents); 56 endTest(mWebContents);
58 } 57 }
59 58
60 /** 59 /**
61 * Tests that screen touches are not registered when the viewer is a 60 * Tests that screen touches are not registered when the viewer is a Daydrea m View.
62 * Daydream View.
63 */ 61 */
64 @LargeTest 62 @LargeTest
65 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) 63 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
66 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept ion { 64 public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedExcept ion {
67 String testName = "test_screen_taps_not_registered_on_daydream"; 65 String testName = "test_screen_taps_not_registered_on_daydream";
68 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 66 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
69 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); 67 assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
70 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); 68 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents);
71 enterVrTapAndWait(mWebContents); 69 enterVrTapAndWait(mWebContents);
72 // Wait on VrShellImpl to say that its parent consumed the touch event 70 // Wait on VrShellImpl to say that its parent consumed the touch event
(...skipping 10 matching lines...) Expand all
83 } 81 }
84 }); 82 });
85 enterVrTap(); 83 enterVrTap();
86 assertTrue("VrShellImpl dispatched touches", 84 assertTrue("VrShellImpl dispatched touches",
87 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI SECONDS)); 85 touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLI SECONDS));
88 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents); 86 executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents);
89 endTest(mWebContents); 87 endTest(mWebContents);
90 } 88 }
91 89
92 /** 90 /**
93 * Tests that Daydream controller clicks are registered as screen taps when 91 * Tests that Daydream controller clicks are registered as screen taps when the viewer is a
94 * the viewer is a Daydream View. 92 * Daydream View.
95 */ 93 */
96 @LargeTest 94 @LargeTest
97 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) 95 @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
98 public void testControllerClicksRegisteredAsTapsOnDaydream() throws Interrup tedException { 96 public void testControllerClicksRegisteredAsTapsOnDaydream() throws Interrup tedException {
99 EmulatedVrController controller = new EmulatedVrController(getActivity() ); 97 EmulatedVrController controller = new EmulatedVrController(getActivity() );
100 String testName = "test_screen_taps_registered"; 98 String testName = "test_screen_taps_registered";
101 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 99 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
102 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); 100 assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
103 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents); 101 executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents);
104 // Tap and wait to enter VR 102 // Tap and wait to enter VR
105 enterVrTapAndWait(mWebContents); 103 enterVrTapAndWait(mWebContents);
106 // Send a controller click and wait for JavaScript to receive it 104 // Send a controller click and wait for JavaScript to receive it
107 controller.pressReleaseTouchpadButton(); 105 controller.pressReleaseTouchpadButton();
108 waitOnJavaScriptStep(mWebContents); 106 waitOnJavaScriptStep(mWebContents);
109 endTest(mWebContents); 107 endTest(mWebContents);
110 } 108 }
111 109
112 /** 110 /**
113 * Tests that screen touches are still registered when the viewer is 111 * Tests that screen touches are still registered when the viewer is Cardboa rd.
114 * Cardboard.
115 */ 112 */
116 /* 113 /*
117 @MediumTest 114 @MediumTest
118 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM) 115 @Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM)
119 */ 116 */
120 @DisabledTest(message = "crbug.com/713781") 117 @DisabledTest(message = "crbug.com/713781")
121 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio n { 118 public void testScreenTapsRegisteredOnCardboard() throws InterruptedExceptio n {
122 String testName = "test_screen_taps_registered"; 119 String testName = "test_screen_taps_registered";
123 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 120 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
124 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); 121 assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
(...skipping 15 matching lines...) Expand all
140 assertTrue("VRDisplay found", vrDisplayFound(mWebContents)); 137 assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
141 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents); 138 executeStepAndWait("stepCheckFrameDataWhileFocusedTab()", mWebContents);
142 139
143 loadUrlInNewTab("about:blank"); 140 loadUrlInNewTab("about:blank");
144 141
145 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent s); 142 executeStepAndWait("stepCheckFrameDataWhileNonFocusedTab()", mWebContent s);
146 endTest(mWebContents); 143 endTest(mWebContents);
147 } 144 }
148 145
149 /** 146 /**
150 * Helper function to run the tests checking for the upgrade/install InfoBar 147 * Helper function to run the tests checking for the upgrade/install InfoBar being present since
151 * being present since all that differs is the value returned by VrCoreVersi onChecker 148 * all that differs is the value returned by VrCoreVersionChecker and a coup le asserts.
152 * and a couple asserts. 149 *
153 * @param checkerReturnValue The value to have the VrCoreVersionChecker retu rn 150 * @param checkerReturnValue The value to have the VrCoreVersionChecker retu rn
154 */ 151 */
155 private void infoBarTestHelper(int checkerReturnValue) throws InterruptedExc eption { 152 private void infoBarTestHelper(int checkerReturnValue) throws InterruptedExc eption {
156 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI mpl(); 153 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI mpl();
157 mockChecker.setMockReturnValue(checkerReturnValue); 154 mockChecker.setMockReturnValue(checkerReturnValue);
158 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest ing(mockChecker); 155 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest ing(mockChecker);
159 String testName = "generic_webvr_page"; 156 String testName = "generic_webvr_page";
160 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 157 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
161 String displayFound = "VRDisplay Found"; 158 String displayFound = "VRDisplay Found";
162 String barPresent = "InfoBar present"; 159 String barPresent = "InfoBar present";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 assertFalse(barPresent, 192 assertFalse(barPresent,
196 VrUtils.isUpdateInstallInfoBarPresent( 193 VrUtils.isUpdateInstallInfoBarPresent(
197 getActivity().getWindow().getDecorView())); 194 getActivity().getWindow().getDecorView()));
198 } else { 195 } else {
199 fail("Invalid VrCoreVersionChecker value: " + String.valueOf(checker ReturnValue)); 196 fail("Invalid VrCoreVersionChecker value: " + String.valueOf(checker ReturnValue));
200 } 197 }
201 assertEquals(checkerReturnValue, mockChecker.getLastReturnValue()); 198 assertEquals(checkerReturnValue, mockChecker.getLastReturnValue());
202 } 199 }
203 200
204 /** 201 /**
205 * Tests that the upgrade/install VR Services InfoBar is not present when 202 * Tests that the upgrade/install VR Services InfoBar is not present when VR Services is
206 * VR Services is installed and up to date. 203 * installed and up to date.
207 */ 204 */
208 @MediumTest 205 @MediumTest
209 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE xception { 206 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE xception {
210 infoBarTestHelper(VrCoreVersionChecker.VR_READY); 207 infoBarTestHelper(VrCoreVersionChecker.VR_READY);
211 } 208 }
212 209
213 /** 210 /**
214 * Tests that the upgrade VR Services InfoBar is present when 211 * Tests that the upgrade VR Services InfoBar is present when VR Services is outdated.
215 * VR Services is outdated.
216 */ 212 */
217 @MediumTest 213 @MediumTest
218 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc eption { 214 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc eption {
219 infoBarTestHelper(VrCoreVersionChecker.VR_OUT_OF_DATE); 215 infoBarTestHelper(VrCoreVersionChecker.VR_OUT_OF_DATE);
220 } 216 }
221 217
222 /** 218 /**
223 * Tests that the install VR Services InfoBar is present when VR 219 * Tests that the install VR Services InfoBar is present when VR Services is missing.
224 * Services is missing.
225 */ 220 */
226 @MediumTest 221 @MediumTest
227 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce ption { 222 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce ption {
228 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_AVAILABLE); 223 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_AVAILABLE);
229 } 224 }
230 225
231 /** 226 /**
232 * Tests that the install VR Services InfoBar is not present when VR 227 * Tests that the install VR Services InfoBar is not present when VR is not supported on the
233 * is not supported on the device. 228 * device.
234 */ 229 */
235 @MediumTest 230 @MediumTest
236 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru ptedException { 231 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru ptedException {
237 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED); 232 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED);
238 } 233 }
239 234
240 /** 235 /**
241 * Tests that the reported WebVR capabilities match expectations on the 236 * Tests that the reported WebVR capabilities match expectations on the devi ces the WebVR tests
242 * devices the WebVR tests are run on continuously. 237 * are run on continuously.
243 */ 238 */
244 @MediumTest 239 @MediumTest
245 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce ption { 240 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce ption {
246 String testName = "test_device_capabilities_match_expectations"; 241 String testName = "test_device_capabilities_match_expectations";
247 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S); 242 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
248 assertTrue("VRDisplayFound", vrDisplayFound(mWebContents)); 243 assertTrue("VRDisplayFound", vrDisplayFound(mWebContents));
249 executeStepAndWait("stepCheckDeviceCapabilities('" + Build.DEVICE + "')" , mWebContents); 244 executeStepAndWait("stepCheckDeviceCapabilities('" + Build.DEVICE + "')" , mWebContents);
250 endTest(mWebContents); 245 endTest(mWebContents);
251 } 246 }
247
248 /**
249 * Tests that focus is locked to the presenting display for purposes of VR i nput.
250 */
251 @MediumTest
252 public void testPresentationLocksFocus() throws InterruptedException {
253 String testName = "test_presentation_locks_focus";
254 loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
255 enterVrTapAndWait(mWebContents);
256 waitOnJavaScriptStep(mWebContents);
257 endTest(mWebContents);
258 }
252 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698