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

Add VR test for clicking on a webpage

Adds a VR instrumentation test to ensure that clicks from the Daydream
controller are actually registered on the webpage.

Bug: 797299
Change-Id: I604918c57c403de81a8bd673420df912a7f0fa16
Reviewed-on: https://chromium-review.googlesource.com/843451Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526575}
parent d469db18
......@@ -10,6 +10,7 @@ import static org.chromium.chrome.browser.vr_shell.VrTestFramework.POLL_TIMEOUT_
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_DEVICE_DAYDREAM;
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_VIEWER_DAYDREAM;
import android.os.SystemClock;
import android.support.test.filters.MediumTest;
import org.junit.Assert;
......@@ -25,6 +26,7 @@ import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.vr_shell.rules.ChromeTabbedActivityVrTestRule;
import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.Coordinates;
import org.chromium.content.browser.test.util.Criteria;
......@@ -112,6 +114,31 @@ public class VrShellControllerInputTest {
Assert.assertTrue("Controller was able to scroll left", startScrollPoint > endScrollPoint);
}
/**
* Verifies that controller clicks in the VR browser are properly registered on the webpage.
* This is done by clicking on a link on the page and ensuring that it causes a navigation.
*/
@Test
@MediumTest
public void testControllerClicksRegisterOnWebpage() throws InterruptedException {
// Load page in VR and make sure the controller is pointed at the content quad
mVrTestRule.loadUrl(
VrTestFramework.getHtmlTestFile("test_controller_clicks_register_on_webpage"),
PAGE_LOAD_TIMEOUT_S);
VrTransitionUtils.forceEnterVr();
VrTransitionUtils.waitForVrEntry(POLL_TIMEOUT_LONG_MS);
EmulatedVrController controller = new EmulatedVrController(mVrTestRule.getActivity());
controller.recenterView();
// pressReleaseTouchpadButton() appears to be flaky for clicking on things, as sometimes
// it happens too fast for Chrome to register. So, manually press and release with a delay
controller.sendClickButtonToggleEvent();
SystemClock.sleep(50);
controller.sendClickButtonToggleEvent();
ChromeTabUtils.waitForTabPageLoaded(mVrTestRule.getActivity().getActivityTab(),
VrTestFramework.getHtmlTestFile("test_navigation_2d_page"));
}
/**
* Verifies that pressing the Daydream controller's 'app' button causes the user to exit
* fullscreen
......
<!DOCTYPE hmtl>
<!--
Used to test that a controller click is properly registered on the webpage as
if it were a mouseclick/touchscreen tap.
-->
<html>
<head>
<style>
html, body {
height: 100%;
margin: 0;
}
#linktoclick {
min-height: 100%;
}
</style>
</head>
<script>
function navigateOnClick() {
window.location.href = "./test_navigation_2d_page.html";
}
</script>
<body>
<div id="linktoclick" onclick="navigateOnClick()">This is a div</div>
</body>
</html>
\ No newline at end of file
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