Commit 57bab706 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Make VR navigation test cover more

Makes VrBrowserNavigationTest#testNavigationButtons cover more of the
manual test requirements. Specifically, ensures that the buttons are
properly greyed out when they're disabled and that clicking on the back
button can't cause the browser to go to a different tab.

Bug: 887510
Change-Id: Ie4a09c2286d58f6a7a9d0539995bc226132213a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497471Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638666}
parent 25864ef8
......@@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.UrlConstants;
......@@ -34,17 +35,20 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabLaunchType;
import org.chromium.chrome.browser.vr.rules.ChromeTabbedActivityVrTestRule;
import org.chromium.chrome.browser.vr.util.NativeUiUtils;
import org.chromium.chrome.browser.vr.util.RenderTestUtils;
import org.chromium.chrome.browser.vr.util.VrBrowserTransitionUtils;
import org.chromium.chrome.browser.vr.util.VrInfoBarUtils;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.NewTabPageTestUtils;
import org.chromium.chrome.test.util.RenderTestRule;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.ClickUtils;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.DOMUtils;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
......@@ -63,6 +67,10 @@ public class VrBrowserNavigationTest {
@Rule
public ChromeTabbedActivityVrTestRule mTestRule = new ChromeTabbedActivityVrTestRule();
@Rule
public RenderTestRule mRenderTestRule =
new RenderTestRule("components/test/data/vr_browser_ui/render_tests");
private WebXrVrTestFramework mWebXrVrTestFramework;
private WebVrTestFramework mWebVrTestFramework;
private VrBrowserTestFramework mVrBrowserTestFramework;
......@@ -486,43 +494,83 @@ public class VrBrowserNavigationTest {
}
/**
* Tests navigation from a fullscreened WebVR to a WebVR page.
* Tests that the navigation buttons work only when they should, and are greyed out when not
* usable.
*/
@Test
@MediumTest
public void testNavigationButtons() throws IllegalArgumentException, InterruptedException {
@Feature({"Browser", "RenderTest"})
public void testNavigationButtons()
throws IllegalArgumentException, InterruptedException, IOException {
// TODO(https://crbug.com/930840): Remove this when the weird gradient behavior is fixed.
mRenderTestRule.setPixelDiffThreshold(2);
Assert.assertFalse(
"Back button is enabled.", VrBrowserTransitionUtils.isBackButtonEnabled());
Assert.assertFalse(
"Forward button is enabled.", VrBrowserTransitionUtils.isForwardButtonEnabled());
NativeUiUtils.clickElementAndWaitForUiQuiescence(
UserFriendlyElementName.OVERFLOW_MENU, new PointF());
RenderTestUtils.dumpAndCompare(NativeUiUtils.FRAME_BUFFER_SUFFIX_BROWSER_UI,
"navigation_buttons_both_disabled", mRenderTestRule);
// Opening a new tab shouldn't enable the back button
mTestRule.loadUrlInNewTab(getUrl(Page.PAGE_2D), false, TabLaunchType.FROM_CHROME_UI);
mTestRule.loadUrlInNewTab("about:blank", false, TabLaunchType.FROM_CHROME_UI);
final int tabId = mTestRule.getActivity().getActivityTab().getId();
Assert.assertFalse(
"Back button is enabled.", VrBrowserTransitionUtils.isBackButtonEnabled());
Assert.assertFalse(
"Forward button is enabled.", VrBrowserTransitionUtils.isForwardButtonEnabled());
// Actually click on the back button and ensure it doesn't go back to the first tab.
NativeUiUtils.clickElement(UserFriendlyElementName.BACK_BUTTON, new PointF());
NativeUiUtils.clickElementAndWaitForUiQuiescence(
UserFriendlyElementName.OVERFLOW_MENU, new PointF());
RenderTestUtils.dumpAndCompare(NativeUiUtils.FRAME_BUFFER_SUFFIX_BROWSER_UI,
"navigation_buttons_both_disabled", mRenderTestRule);
Assert.assertEquals("Back button navigated to previous tab", tabId,
mTestRule.getActivity().getActivityTab().getId());
// Navigating to a new page should enable the back button
mTestRule.loadUrl(getUrl(Page.PAGE_WEBVR));
mTestRule.loadUrl("chrome://version/");
Assert.assertTrue(
"Back button is disabled.", VrBrowserTransitionUtils.isBackButtonEnabled());
Assert.assertFalse(
"Forward button is enabled.", VrBrowserTransitionUtils.isForwardButtonEnabled());
// Navigating back should disable the back button and enable the forward button
VrBrowserTransitionUtils.navigateBack();
// Overflow menu should still be visible since navigation doesn't close it.
NativeUiUtils.waitForUiQuiescence();
RenderTestUtils.dumpAndCompare(NativeUiUtils.FRAME_BUFFER_SUFFIX_BROWSER_UI,
"navigation_buttons_back_enabled", mRenderTestRule);
// Navigating back should disable the back button and enable the forward button.
// We need to click twice - once to close the overflow menu, and once to actually click.
NativeUiUtils.clickElement(UserFriendlyElementName.BACK_BUTTON, new PointF());
NativeUiUtils.clickElement(UserFriendlyElementName.BACK_BUTTON, new PointF());
ChromeTabUtils.waitForTabPageLoaded(
mTestRule.getActivity().getActivityTab(), getUrl(Page.PAGE_2D));
mTestRule.getActivity().getActivityTab(), "about:blank");
Assert.assertFalse(
"Back button is enabled.", VrBrowserTransitionUtils.isBackButtonEnabled());
Assert.assertTrue(
"Forward button is disabled.", VrBrowserTransitionUtils.isForwardButtonEnabled());
// Once again, click on the back button and ensure it doesn't go back to the first tab.
NativeUiUtils.clickElement(UserFriendlyElementName.BACK_BUTTON, new PointF());
NativeUiUtils.clickElementAndWaitForUiQuiescence(
UserFriendlyElementName.OVERFLOW_MENU, new PointF());
RenderTestUtils.dumpAndCompare(NativeUiUtils.FRAME_BUFFER_SUFFIX_BROWSER_UI,
"navigation_buttons_forward_enabled", mRenderTestRule);
Assert.assertEquals("Back button navigated to previous tab", tabId,
mTestRule.getActivity().getActivityTab().getId());
// Navigating forward should disable the forward button and enable the back button
VrBrowserTransitionUtils.navigateForward();
NativeUiUtils.clickElement(UserFriendlyElementName.FORWARD_BUTTON, new PointF());
ChromeTabUtils.waitForTabPageLoaded(
mTestRule.getActivity().getActivityTab(), getUrl(Page.PAGE_WEBVR));
mTestRule.getActivity().getActivityTab(), "chrome://version/");
Assert.assertTrue(
"Back button is disabled.", VrBrowserTransitionUtils.isBackButtonEnabled());
Assert.assertFalse(
"Forward button is enabled.", VrBrowserTransitionUtils.isForwardButtonEnabled());
NativeUiUtils.clickElementAndWaitForUiQuiescence(
UserFriendlyElementName.OVERFLOW_MENU, new PointF());
RenderTestUtils.dumpAndCompare(NativeUiUtils.FRAME_BUFFER_SUFFIX_BROWSER_UI,
"navigation_buttons_back_enabled", mRenderTestRule);
}
/**
......
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