| Index: chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrShellTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrShellTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrShellTest.java
|
| index 360769f04e78109b2321e3eb5f527b8954929fb1..03e2a6fdf7da5ed11b838c59158acaa48382f5f5 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrShellTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrShellTest.java
|
| @@ -7,18 +7,25 @@ package org.chromium.chrome.browser.vr_shell;
|
| import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_DAYDREAM;
|
| import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_NON_DAYDREAM;
|
|
|
| -import android.os.SystemClock;
|
| +import android.content.pm.ActivityInfo;
|
| import android.test.suitebuilder.annotation.MediumTest;
|
|
|
| import org.chromium.base.ThreadUtils;
|
| +import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.Restriction;
|
| import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
|
| +import org.chromium.chrome.test.util.RenderUtils.ViewRenderer;
|
| +
|
| +import java.io.IOException;
|
|
|
| /**
|
| * Instrumentation tests for VR Shell (Chrome VR)
|
| */
|
| public class VrShellTest extends ChromeTabbedActivityTestBase {
|
| + private static final String GOLDEN_DIR =
|
| + "chrome/test/data/android/render_tests";
|
| private VrShellDelegate mDelegate;
|
| + private ViewRenderer mViewRenderer;
|
|
|
| @Override
|
| protected void setUp() throws Exception {
|
| @@ -29,6 +36,8 @@ public class VrShellTest extends ChromeTabbedActivityTestBase {
|
| @Override
|
| public void startMainActivity() throws InterruptedException {
|
| startMainActivityOnBlankPage();
|
| + mViewRenderer = new ViewRenderer(getActivity(),
|
| + GOLDEN_DIR, this.getClass().getSimpleName());
|
| }
|
|
|
| private void forceEnterVr() {
|
| @@ -51,8 +60,7 @@ public class VrShellTest extends ChromeTabbedActivityTestBase {
|
|
|
| private void testEnterExitVrMode(boolean supported) {
|
| forceEnterVr();
|
| - // TODO(bsheedy): Remove sleep once crbug.com/644533 is fixed
|
| - SystemClock.sleep(1500);
|
| + getInstrumentation().waitForIdleSync();
|
| if (supported) {
|
| assertTrue(mDelegate.isInVR());
|
| } else {
|
| @@ -62,6 +70,42 @@ public class VrShellTest extends ChromeTabbedActivityTestBase {
|
| assertFalse(mDelegate.isInVR());
|
| }
|
|
|
| + private void testEnterExitVrModeImage(boolean supported) throws IOException {
|
| + int prevOrientation = getActivity().getRequestedOrientation();
|
| + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
| + getInstrumentation().waitForIdleSync();
|
| + mViewRenderer.renderAndCompare(
|
| + getActivity().getWindow().getDecorView().getRootView(),
|
| + "blank_page");
|
| +
|
| + forceEnterVr();
|
| + getInstrumentation().waitForIdleSync();
|
| + // Currently, screenshots only show the static UI overlay, not the
|
| + // actual content. Thus, 1:1 pixel checking is reliable until a
|
| + // way to take screenshots of VR content is added, in which case
|
| + // % similarity or some other method will need to be used. We're
|
| + // assuming that if the UI overlay is visible, then the device has
|
| + // successfully entered VR mode.
|
| + if (supported) {
|
| + mViewRenderer.renderAndCompare(
|
| + getActivity().getWindow().getDecorView().getRootView(),
|
| + "vr_entered");
|
| + } else {
|
| + mViewRenderer.renderAndCompare(
|
| + getActivity().getWindow().getDecorView().getRootView(),
|
| + "blank_page");
|
| + }
|
| +
|
| + forceExitVr();
|
| + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
| + getInstrumentation().waitForIdleSync();
|
| + mViewRenderer.renderAndCompare(
|
| + getActivity().getWindow().getDecorView().getRootView(),
|
| + "blank_page");
|
| +
|
| + getActivity().setRequestedOrientation(prevOrientation);
|
| + }
|
| +
|
| /**
|
| * Verifies that browser successfully enters and exits VR mode when told to
|
| * on Daydream-ready devices. Requires that the phone is unlocked.
|
| @@ -80,4 +124,27 @@ public class VrShellTest extends ChromeTabbedActivityTestBase {
|
| public void testEnterExitVrModeUnsupported() {
|
| testEnterExitVrMode(false);
|
| }
|
| +
|
| + /**
|
| + * Verifies that browser successfully enters and exits VR mode when told to
|
| + * on Daydream-ready devices via a screendiffing check.
|
| + * Requires that the phone is unlocked.
|
| + */
|
| + @Restriction(RESTRICTION_TYPE_DAYDREAM)
|
| + @Feature("RenderTest")
|
| + @MediumTest
|
| + public void testEnterExitVrModeSupportedImage() throws IOException {
|
| + testEnterExitVrModeImage(true);
|
| + }
|
| +
|
| + /**
|
| + * Verifies that browser does not enter VR mode on Non-Daydream-ready devices
|
| + * via a screendiffing check. Requires that the phone is unlocked.
|
| + */
|
| + @Restriction(RESTRICTION_TYPE_NON_DAYDREAM)
|
| + @Feature("RenderTest")
|
| + @MediumTest
|
| + public void testEnterExitVrModeUnsupportedImage() throws IOException {
|
| + testEnterExitVrModeImage(false);
|
| + }
|
| }
|
|
|