Commit 60430141 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add VR e2e tests for controller app button

Adds two VR instrumentation tests to check that pressing the Daydream
controller's "app" button causes the browser to exit WebVR presentation
and fullscreen.

Bug: 742569, 728779
Change-Id: I11b92d876875e6224b30b0d5eab498786f698fbf
Reviewed-on: https://chromium-review.googlesource.com/571387Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487131}
parent d3c5dfad
...@@ -42,6 +42,14 @@ public class EmulatedVrController { ...@@ -42,6 +42,14 @@ public class EmulatedVrController {
mApi.buttonEvent.sendClickButtonEvent(); mApi.buttonEvent.sendClickButtonEvent();
} }
/**
* Presses and quickly releases the Daydream controller's app button.
* Or, if the button is already pressed, releases and quickly presses again.
*/
public void pressReleaseAppButton() {
mApi.buttonEvent.sendAppButtonEvent();
}
/** /**
* Holds the home button to recenter the view using an arbitrary, but valid * Holds the home button to recenter the view using an arbitrary, but valid
* orientation quaternion. * orientation quaternion.
......
...@@ -19,6 +19,7 @@ import org.junit.runner.RunWith; ...@@ -19,6 +19,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils; import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
...@@ -26,6 +27,9 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; ...@@ -26,6 +27,9 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils;
import java.util.concurrent.TimeoutException;
/** /**
* End-to-end tests for Daydream controller input while in the VR browser. * End-to-end tests for Daydream controller input while in the VR browser.
...@@ -33,6 +37,7 @@ import org.chromium.content.browser.test.util.CriteriaHelper; ...@@ -33,6 +37,7 @@ import org.chromium.content.browser.test.util.CriteriaHelper;
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, "enable-features=VrShell"}) ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, "enable-features=VrShell"})
@Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYDREAM})
public class VrShellControllerInputTest { public class VrShellControllerInputTest {
@Rule @Rule
public VrTestRule mVrTestRule = new VrTestRule(); public VrTestRule mVrTestRule = new VrTestRule();
...@@ -42,7 +47,6 @@ public class VrShellControllerInputTest { ...@@ -42,7 +47,6 @@ public class VrShellControllerInputTest {
* touchpad scrolls the webpage while in the VR browser. * touchpad scrolls the webpage while in the VR browser.
*/ */
@Test @Test
@Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYDREAM})
@MediumTest @MediumTest
public void testControllerScrolling() throws InterruptedException { public void testControllerScrolling() throws InterruptedException {
// Load page in VR and make sure the controller is pointed at the content quad // Load page in VR and make sure the controller is pointed at the content quad
...@@ -94,4 +98,35 @@ public class VrShellControllerInputTest { ...@@ -94,4 +98,35 @@ public class VrShellControllerInputTest {
endScrollPoint = cvc.getNativeScrollXForTest(); endScrollPoint = cvc.getNativeScrollXForTest();
Assert.assertTrue("Controller was able to scroll left", startScrollPoint > endScrollPoint); Assert.assertTrue("Controller was able to scroll left", startScrollPoint > endScrollPoint);
} }
/**
* Verifies that pressing the Daydream controller's 'app' button causes the user to exit
* fullscreen
*/
@Test
@MediumTest
@RetryOnFailure(message = "Very rarely, button press not registered (race condition?)")
public void testAppButtonExitsFullscreen() throws InterruptedException, TimeoutException {
mVrTestRule.loadUrlAndAwaitInitialization(
mVrTestRule.getHtmlTestFile("test_navigation_2d_page"), PAGE_LOAD_TIMEOUT_S);
VrTransitionUtils.forceEnterVr();
VrTransitionUtils.waitForVrEntry(POLL_TIMEOUT_LONG_MS);
// Enter fullscreen
DOMUtils.clickNode(mVrTestRule.getFirstTabCvc(), "fullscreen");
mVrTestRule.waitOnJavaScriptStep(mVrTestRule.getFirstTabWebContents());
Assert.assertTrue(DOMUtils.isFullscreen(mVrTestRule.getFirstTabWebContents()));
EmulatedVrController controller = new EmulatedVrController(mVrTestRule.getActivity());
controller.pressReleaseAppButton();
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
try {
return !DOMUtils.isFullscreen(mVrTestRule.getFirstTabWebContents());
} catch (InterruptedException | TimeoutException e) {
return false;
}
}
}, POLL_TIMEOUT_LONG_MS, POLL_CHECK_INTERVAL_LONG_MS);
}
} }
...@@ -21,6 +21,7 @@ import org.chromium.base.test.util.CommandLineFlags; ...@@ -21,6 +21,7 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisableIf; import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.MinAndroidSdkLevel; import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.vr_shell.util.CardboardUtils; import org.chromium.chrome.browser.vr_shell.util.CardboardUtils;
import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils; import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils;
...@@ -131,4 +132,23 @@ public class WebVrInputTest { ...@@ -131,4 +132,23 @@ public class WebVrInputTest {
mVrTestRule.getFirstTabCvc(), mVrTestRule.getFirstTabWebContents()); mVrTestRule.getFirstTabCvc(), mVrTestRule.getFirstTabWebContents());
mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents()); mVrTestRule.endTest(mVrTestRule.getFirstTabWebContents());
} }
/**
* Verifies that pressing the Daydream controller's 'app' button causes the user to exit
* WebVR presentation.
*/
@Test
@MediumTest
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
@RetryOnFailure(message = "Very rarely, button press not registered (race condition?)")
public void testAppButtonExitsPresentation() throws InterruptedException {
mVrTestRule.loadUrlAndAwaitInitialization(
mVrTestRule.getHtmlTestFile("generic_webvr_page"), PAGE_LOAD_TIMEOUT_S);
VrTransitionUtils.enterPresentationOrFail(mVrTestRule.getFirstTabCvc());
EmulatedVrController controller = new EmulatedVrController(mVrTestRule.getActivity());
controller.pressReleaseAppButton();
Assert.assertTrue("App button exited WebVR presentation",
mVrTestRule.pollJavaScriptBoolean("!vrDisplay.isPresenting", POLL_TIMEOUT_SHORT_MS,
mVrTestRule.getFirstTabWebContents()));
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment