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.VrTestRule.PAGE_LOAD_TIMEOUT_
S; | 7 import static org.chromium.chrome.browser.vr_shell.VrTestRule.PAGE_LOAD_TIMEOUT_
S; |
8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS
; | 8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_SHORT_MS
; |
9 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_DAYDREAM; |
10 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_V
IEWER_NON_DAYDREAM; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 mVrTestRule.executeStepAndWait( | 173 mVrTestRule.executeStepAndWait( |
174 "stepCheckFrameDataWhileNonFocusedTab()", mVrTestRule.getFirstTa
bWebContents()); | 174 "stepCheckFrameDataWhileNonFocusedTab()", mVrTestRule.getFirstTa
bWebContents()); |
175 mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents()); | 175 mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents()); |
176 } | 176 } |
177 | 177 |
178 /** | 178 /** |
179 * Helper function to run the tests checking for the upgrade/install InfoBar
being present since | 179 * Helper function to run the tests checking for the upgrade/install InfoBar
being present since |
180 * all that differs is the value returned by VrCoreVersionChecker and a coup
le asserts. | 180 * all that differs is the value returned by VrCoreVersionChecker and a coup
le asserts. |
181 * | 181 * |
182 * @param checkerReturnValue The value to have the VrCoreVersionChecker retu
rn | 182 * @param checkerReturnCompatibility The compatibility to have the VrCoreVer
sionChecker return |
183 */ | 183 */ |
184 private void infoBarTestHelper(int checkerReturnValue) throws InterruptedExc
eption { | 184 private void infoBarTestHelper(int checkerReturnCompatibility) throws Interr
uptedException { |
185 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI
mpl(); | 185 MockVrCoreVersionCheckerImpl mockChecker = new MockVrCoreVersionCheckerI
mpl(); |
186 mockChecker.setMockReturnValue(checkerReturnValue); | 186 mockChecker.setMockReturnValue(new VrCoreInfo(null, checkerReturnCompati
bility)); |
187 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest
ing(mockChecker); | 187 VrUtils.getVrShellDelegateInstance().overrideVrCoreVersionCheckerForTest
ing(mockChecker); |
188 mVrTestRule.loadUrlAndAwaitInitialization( | 188 mVrTestRule.loadUrlAndAwaitInitialization( |
189 VrTestRule.getHtmlTestFile("generic_webvr_page"), PAGE_LOAD_TIME
OUT_S); | 189 VrTestRule.getHtmlTestFile("generic_webvr_page"), PAGE_LOAD_TIME
OUT_S); |
190 String displayFound = "VRDisplay Found"; | 190 String displayFound = "VRDisplay Found"; |
191 String barPresent = "InfoBar present"; | 191 String barPresent = "InfoBar present"; |
192 if (checkerReturnValue == VrCoreVersionChecker.VR_READY) { | 192 if (checkerReturnCompatibility == VrCoreCompatibility.VR_READY) { |
193 Assert.assertTrue( | 193 Assert.assertTrue( |
194 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); | 194 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); |
195 Assert.assertFalse(barPresent, | 195 Assert.assertFalse(barPresent, |
196 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); | 196 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); |
197 } else if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE | 197 } else if (checkerReturnCompatibility == VrCoreCompatibility.VR_OUT_OF_D
ATE |
198 || checkerReturnValue == VrCoreVersionChecker.VR_NOT_AVAILABLE)
{ | 198 || checkerReturnCompatibility == VrCoreCompatibility.VR_NOT_AVAI
LABLE) { |
199 // Out of date and missing cases are the same, but with different te
xt | 199 // Out of date and missing cases are the same, but with different te
xt |
200 String expectedMessage, expectedButton; | 200 String expectedMessage, expectedButton; |
201 if (checkerReturnValue == VrCoreVersionChecker.VR_OUT_OF_DATE) { | 201 if (checkerReturnCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE
) { |
202 expectedMessage = mVrTestRule.getActivity().getString( | 202 expectedMessage = mVrTestRule.getActivity().getString( |
203 R.string.vr_services_check_infobar_update_text); | 203 R.string.vr_services_check_infobar_update_text); |
204 expectedButton = mVrTestRule.getActivity().getString( | 204 expectedButton = mVrTestRule.getActivity().getString( |
205 R.string.vr_services_check_infobar_update_button); | 205 R.string.vr_services_check_infobar_update_button); |
206 } else { | 206 } else { |
207 expectedMessage = mVrTestRule.getActivity().getString( | 207 expectedMessage = mVrTestRule.getActivity().getString( |
208 R.string.vr_services_check_infobar_install_text); | 208 R.string.vr_services_check_infobar_install_text); |
209 expectedButton = mVrTestRule.getActivity().getString( | 209 expectedButton = mVrTestRule.getActivity().getString( |
210 R.string.vr_services_check_infobar_install_button); | 210 R.string.vr_services_check_infobar_install_button); |
211 } | 211 } |
212 Assert.assertFalse( | 212 Assert.assertFalse( |
213 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); | 213 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); |
214 Assert.assertTrue(barPresent, | 214 Assert.assertTrue(barPresent, |
215 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); | 215 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); |
216 TextView tempView = | 216 TextView tempView = |
217 (TextView) mVrTestRule.getActivity().getWindow().getDecorVie
w().findViewById( | 217 (TextView) mVrTestRule.getActivity().getWindow().getDecorVie
w().findViewById( |
218 R.id.infobar_message); | 218 R.id.infobar_message); |
219 Assert.assertEquals(expectedMessage, tempView.getText().toString()); | 219 Assert.assertEquals(expectedMessage, tempView.getText().toString()); |
220 tempView = (TextView) mVrTestRule.getActivity().getWindow().getDecor
View().findViewById( | 220 tempView = (TextView) mVrTestRule.getActivity().getWindow().getDecor
View().findViewById( |
221 R.id.button_primary); | 221 R.id.button_primary); |
222 Assert.assertEquals(expectedButton, tempView.getText().toString()); | 222 Assert.assertEquals(expectedButton, tempView.getText().toString()); |
223 } else if (checkerReturnValue == VrCoreVersionChecker.VR_NOT_SUPPORTED)
{ | 223 } else if (checkerReturnCompatibility == VrCoreCompatibility.VR_NOT_SUPP
ORTED) { |
224 Assert.assertFalse( | 224 Assert.assertFalse( |
225 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); | 225 displayFound, mVrTestRule.vrDisplayFound(mVrTestRule.getFirs
tTabWebContents())); |
226 Assert.assertFalse(barPresent, | 226 Assert.assertFalse(barPresent, |
227 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); | 227 VrUtils.isInfoBarPresent(mVrTestRule.getActivity().getWindow
().getDecorView())); |
228 } else { | 228 } else { |
229 Assert.fail( | 229 Assert.fail("Invalid VrCoreVersionChecker compatibility: " |
230 "Invalid VrCoreVersionChecker value: " + String.valueOf(chec
kerReturnValue)); | 230 + String.valueOf(checkerReturnCompatibility)); |
231 } | 231 } |
232 Assert.assertEquals(checkerReturnValue, mockChecker.getLastReturnValue()
); | 232 Assert.assertEquals( |
| 233 checkerReturnCompatibility, mockChecker.getLastReturnValue().com
patibility); |
233 } | 234 } |
234 | 235 |
235 /** | 236 /** |
236 * Tests that the upgrade/install VR Services InfoBar is not present when VR
Services is | 237 * Tests that the upgrade/install VR Services InfoBar is not present when VR
Services is |
237 * installed and up to date. | 238 * installed and up to date. |
238 */ | 239 */ |
239 @Test | 240 @Test |
240 @MediumTest | 241 @MediumTest |
241 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE
xception { | 242 public void testInfoBarNotPresentWhenVrServicesCurrent() throws InterruptedE
xception { |
242 infoBarTestHelper(VrCoreVersionChecker.VR_READY); | 243 infoBarTestHelper(VrCoreCompatibility.VR_READY); |
243 } | 244 } |
244 | 245 |
245 /** | 246 /** |
246 * Tests that the upgrade VR Services InfoBar is present when VR Services is
outdated. | 247 * Tests that the upgrade VR Services InfoBar is present when VR Services is
outdated. |
247 */ | 248 */ |
248 @Test | 249 @Test |
249 @MediumTest | 250 @MediumTest |
250 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc
eption { | 251 public void testInfoBarPresentWhenVrServicesOutdated() throws InterruptedExc
eption { |
251 infoBarTestHelper(VrCoreVersionChecker.VR_OUT_OF_DATE); | 252 infoBarTestHelper(VrCoreCompatibility.VR_OUT_OF_DATE); |
252 } | 253 } |
253 | 254 |
254 /** | 255 /** |
255 * Tests that the install VR Services InfoBar is present when VR Services is
missing. | 256 * Tests that the install VR Services InfoBar is present when VR Services is
missing. |
256 */ | 257 */ |
257 @Test | 258 @Test |
258 @MediumTest | 259 @MediumTest |
259 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce
ption { | 260 public void testInfoBarPresentWhenVrServicesMissing() throws InterruptedExce
ption { |
260 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_AVAILABLE); | 261 infoBarTestHelper(VrCoreCompatibility.VR_NOT_AVAILABLE); |
261 } | 262 } |
262 | 263 |
263 /** | 264 /** |
264 * Tests that the install VR Services InfoBar is not present when VR is not
supported on the | 265 * Tests that the install VR Services InfoBar is not present when VR is not
supported on the |
265 * device. | 266 * device. |
266 */ | 267 */ |
267 @Test | 268 @Test |
268 @MediumTest | 269 @MediumTest |
269 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru
ptedException { | 270 public void testInfoBarNotPresentWhenVrServicesNotSupported() throws Interru
ptedException { |
270 infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED); | 271 infoBarTestHelper(VrCoreCompatibility.VR_NOT_SUPPORTED); |
271 } | 272 } |
272 | 273 |
273 /** | 274 /** |
274 * Tests that the reported WebVR capabilities match expectations on the devi
ces the WebVR tests | 275 * Tests that the reported WebVR capabilities match expectations on the devi
ces the WebVR tests |
275 * are run on continuously. | 276 * are run on continuously. |
276 */ | 277 */ |
277 @Test | 278 @Test |
278 @MediumTest | 279 @MediumTest |
279 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce
ption { | 280 public void testDeviceCapabilitiesMatchExpectations() throws InterruptedExce
ption { |
280 mVrTestRule.loadUrlAndAwaitInitialization( | 281 mVrTestRule.loadUrlAndAwaitInitialization( |
(...skipping 11 matching lines...) Expand all Loading... |
292 @MediumTest | 293 @MediumTest |
293 @RetryOnFailure(message = "Flaky on L crbug.com/713781") | 294 @RetryOnFailure(message = "Flaky on L crbug.com/713781") |
294 public void testPresentationLocksFocus() throws InterruptedException { | 295 public void testPresentationLocksFocus() throws InterruptedException { |
295 mVrTestRule.loadUrlAndAwaitInitialization( | 296 mVrTestRule.loadUrlAndAwaitInitialization( |
296 VrTestRule.getHtmlTestFile("test_presentation_locks_focus"), PAG
E_LOAD_TIMEOUT_S); | 297 VrTestRule.getHtmlTestFile("test_presentation_locks_focus"), PAG
E_LOAD_TIMEOUT_S); |
297 mVrTestRule.enterPresentationAndWait( | 298 mVrTestRule.enterPresentationAndWait( |
298 mVrTestRule.getFirstTabCvc(), mVrTestRule.getFirstTabWebContents
()); | 299 mVrTestRule.getFirstTabCvc(), mVrTestRule.getFirstTabWebContents
()); |
299 mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents()); | 300 mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents()); |
300 } | 301 } |
301 } | 302 } |
OLD | NEW |