Commit 841efbea authored by bsheedy's avatar bsheedy Committed by Commit Bot

Automate VR omnibox text entry/navigation tests

Automates all the manual tests from https://crbug.com/887523, which all
relate to omnibox text entry and navigation while in the VR browser.

Bug: 887523
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:linux_vr;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I0db4cc10def31779b8a59f63e2a1f227cf0a6e29
Reviewed-on: https://chromium-review.googlesource.com/c/1263433Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597168}
parent 75fb442a
...@@ -390,4 +390,26 @@ public class VrBrowserControllerInputTest { ...@@ -390,4 +390,26 @@ public class VrBrowserControllerInputTest {
> navigationTimestamp; > navigationTimestamp;
}); });
} }
/**
* Tests that pressing the app button on the Daydream controller exits omnibox text input mode.
*/
@Test
@MediumTest
public void testAppButtonExitsOmniboxTextInput() throws InterruptedException {
// We should always have the keyboard installed and up to date during automated testing, so
// this isn't strictly required. However, it may prevent weird issues when running locally
// if you don't have the keyboard installed for some reason.
NativeUiUtils.enableMockedKeyboard();
NativeUiUtils.clickElementAndWaitForUiQuiescence(UserFriendlyElementName.URL, new PointF());
// This acts as an assert that we're actually in omnibox text input mode. If the omnibox
// is not actually visible, we'll hit a DCHECK in the native code.
NativeUiUtils.clickElementAndWaitForUiQuiescence(
UserFriendlyElementName.OMNIBOX_TEXT_FIELD, new PointF());
NativeUiUtils.revertToRealInput();
// Wait for the URL bar to re-appear, which we take as a signal that we've exited omnibox
// text input mode.
NativeUiUtils.performActionAndWaitForVisibilityChange(
UserFriendlyElementName.URL, () -> { mController.pressReleaseAppButton(); });
}
} }
...@@ -664,6 +664,25 @@ public class VrBrowserNavigationTest { ...@@ -664,6 +664,25 @@ public class VrBrowserNavigationTest {
@Test @Test
@MediumTest @MediumTest
public void testUrlEntryTriggersNavigation() throws InterruptedException { public void testUrlEntryTriggersNavigation() throws InterruptedException {
testUrlEntryTriggersNavigationImpl();
}
/**
* Tests that inputting a URL into the URL bar in Incognito Mode results in a successful
* navigation.
*/
@Test
@MediumTest
public void testUrlEntryTriggersNavigationIncognito() throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(() -> {
mTestRule.getActivity()
.getTabCreator(true /* incognito */)
.launchUrl("about:blank", TabLaunchType.FROM_LINK);
});
testUrlEntryTriggersNavigationImpl();
}
private void testUrlEntryTriggersNavigationImpl() throws InterruptedException {
NativeUiUtils.enableMockedKeyboard(); NativeUiUtils.enableMockedKeyboard();
NativeUiUtils.clickElementAndWaitForUiQuiescence(UserFriendlyElementName.URL, new PointF()); NativeUiUtils.clickElementAndWaitForUiQuiescence(UserFriendlyElementName.URL, new PointF());
// This is a roundabout solution for ensuring that the committing/pressing of enter actually // This is a roundabout solution for ensuring that the committing/pressing of enter actually
...@@ -680,4 +699,47 @@ public class VrBrowserNavigationTest { ...@@ -680,4 +699,47 @@ public class VrBrowserNavigationTest {
ChromeTabUtils.waitForTabPageLoaded( ChromeTabUtils.waitForTabPageLoaded(
mTestRule.getActivity().getActivityTab(), "chrome://version/"); mTestRule.getActivity().getActivityTab(), "chrome://version/");
} }
/**
* Tests that clicking on a suggestion results in a successful navigation.
*/
@Test
@MediumTest
public void testSuggestionClickTriggersNavigation() throws InterruptedException {
testSuggestionClickTriggersNavigationImpl();
}
/**
* Tests that clicking on a suggestion while in Incognito Mode results in a successful
* navigation.
*/
@Test
@MediumTest
public void testSuggestionClickTriggersNavigationIncognito() throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(() -> {
mTestRule.getActivity()
.getTabCreator(true /* incognito */)
.launchUrl("about:blank", TabLaunchType.FROM_LINK);
});
testSuggestionClickTriggersNavigationImpl();
}
private void testSuggestionClickTriggersNavigationImpl() throws InterruptedException {
NativeUiUtils.enableMockedKeyboard();
NativeUiUtils.clickElementAndWaitForUiQuiescence(UserFriendlyElementName.URL, new PointF());
NativeUiUtils.performActionAndWaitForVisibilityChange(
UserFriendlyElementName.SUGGESTION_BOX,
() -> { NativeUiUtils.inputString("chrome://"); });
// Blindly clicking in the center of the suggestion box should end up clicking the middle
// suggestion, which for "chrome://" should be a valid chrome:// URL.
NativeUiUtils.clickElement(UserFriendlyElementName.SUGGESTION_BOX, new PointF());
ChromeTabUtils.waitForTabPageLoaded(
mTestRule.getActivity().getActivityTab(), (String) null);
// We can't just wait for navigation to finish and then check because waitForTabPageLoaded
// only supports either exact URL matching or no URL matching, and no URL matching results
// in the URL still being about:blank when we check.
CriteriaHelper.pollInstrumentationThread(() -> {
return mTestRule.getActivity().getActivityTab().getUrl().startsWith("chrome://");
});
}
} }
...@@ -33,9 +33,14 @@ import java.util.concurrent.CountDownLatch; ...@@ -33,9 +33,14 @@ import java.util.concurrent.CountDownLatch;
* omnibox or back button. * omnibox or back button.
*/ */
public class NativeUiUtils { public class NativeUiUtils {
// How many frames to wait after entering text in the omnibox before we can assume that
// suggestions are updated. This should only be used if the workaround of inputting text and
// waiting for the suggestion box to appear doesn't work, e.g. if you need to input text, wait
// for autocomplete, then input more text before committing. 20 is arbitrary, but stable.
public static final int NUM_FRAMES_FOR_SUGGESTION_UPDATE = 20;
// Arbitrary but reasonable amount of time to expect the UI to stop updating after interacting // Arbitrary but reasonable amount of time to expect the UI to stop updating after interacting
// with an element. // with an element.
private static final int DEFAULT_UI_QUIESCENCE_TIMEOUT_MS = 1000; private static final int DEFAULT_UI_QUIESCENCE_TIMEOUT_MS = 2000;
/** /**
* Enables the use of both the mock head pose (locked forward) and Chrome-side mocked controller * Enables the use of both the mock head pose (locked forward) and Chrome-side mocked controller
......
...@@ -73,6 +73,10 @@ UiElementName UserFriendlyElementNameToUiElementName( ...@@ -73,6 +73,10 @@ UiElementName UserFriendlyElementNameToUiElementName(
return kExitPrompt; return kExitPrompt;
case UserFriendlyElementName::kSuggestionBox: case UserFriendlyElementName::kSuggestionBox:
return kOmniboxSuggestions; return kOmniboxSuggestions;
case UserFriendlyElementName::kOmniboxTextField:
return kOmniboxTextField;
case UserFriendlyElementName::kOmniboxCloseButton:
return kOmniboxCloseButton;
default: default:
NOTREACHED(); NOTREACHED();
return kNone; return kNone;
......
...@@ -27,6 +27,9 @@ enum class UserFriendlyElementName : int { ...@@ -27,6 +27,9 @@ enum class UserFriendlyElementName : int {
// menu // menu
kExitPrompt, // DOFF prompt/request to exit VR kExitPrompt, // DOFF prompt/request to exit VR
kSuggestionBox, // Box containing the omnibox suggestions kSuggestionBox, // Box containing the omnibox suggestions
kOmniboxTextField, // The Omnibox's text input field that shows up when the
// URL bar is clicked.
kOmniboxCloseButton, // The button the exits the omnibox's text input mode.
}; };
// These are the types of actions that Java can request callbacks for once // These are the types of actions that Java can request callbacks for once
......
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