Commit 22a72b84 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[VK] Add browser tests for navigation.

There are some rules for showing/hiding the virtual keyboard when
navigating to a new page / tab. Added some tests to make sure we don't
regress these scenarios.

Bug: 849995
Change-Id: I2fee098943b6073a0d1c1f8b86cdf1a3b35455e5
Reviewed-on: https://chromium-review.googlesource.com/1233097Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593007}
parent 37015595
...@@ -192,6 +192,143 @@ IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest, DeleteInputHidesKeyboard) { ...@@ -192,6 +192,143 @@ IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest, DeleteInputHidesKeyboard) {
ASSERT_TRUE(WaitUntilHidden()); ASSERT_TRUE(WaitUntilHidden());
} }
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
NavigateToNewPageWithoutInputFieldHidesKeyboard) {
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ASSERT_TRUE(WaitUntilHidden());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
NavigateToNewPageWithAutoFocusShowsKeyboard) {
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
ui_test_utils::NavigateToURL(
browser(),
ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
base::FilePath("autofocus.html")));
ASSERT_TRUE(WaitUntilShown());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
NavigateToNewPageWithBlurredInputFieldHidesKeyboard) {
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
ui_test_utils::NavigateToURL(
browser(),
ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
base::FilePath("form.html")));
ASSERT_TRUE(WaitUntilHidden());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
OpenNewTabWhenKeyboardIsHiddenDoesNotShowKeyboard) {
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL("about:blank"), WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
EXPECT_FALSE(IsKeyboardShowing());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
OpenNewTabWhenKeyboardIsShownDoesNotHideKeyboard) {
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL("about:blank"), WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
// Opening a new tab will auto-focus onto the omnibox, so the keyboard does
// not hide.
EXPECT_FALSE(IsKeyboardHiding());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
CloseOneTabOfManyDoesNotHideKeyboard) {
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL("about:blank"), WindowOpenDisposition::NEW_BACKGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
// Closing the current tab will bring the background tab's omnibox to focus,
// so the keyboard does not hide.
web_contents->Close();
EXPECT_FALSE(IsKeyboardHiding());
}
IN_PROC_BROWSER_TEST_F(KeyboardEndToEndFormTest,
SwitchToTabWithBlurredInputHidesKeyboard) {
ui_test_utils::NavigateToURLWithDisposition(
browser(),
ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
base::FilePath("form.html")),
WindowOpenDisposition::NEW_BACKGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
browser()->tab_strip_model()->ActivateTabAt(1, true /* user_gesture */);
ASSERT_TRUE(WaitUntilHidden());
}
IN_PROC_BROWSER_TEST_F(
KeyboardEndToEndFormTest,
SwitchToTabWithFocusedInputWhenKeyboardIsHiddenShowsKeyboard) {
ui_test_utils::NavigateToURLWithDisposition(
browser(),
ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
base::FilePath("form.html")),
WindowOpenDisposition::NEW_BACKGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
browser()->tab_strip_model()->ActivateTabAt(1, true /* user_gesture */);
ASSERT_TRUE(WaitUntilHidden());
browser()->tab_strip_model()->ActivateTabAt(0, true /* user_gesture */);
ASSERT_TRUE(WaitUntilShown());
}
IN_PROC_BROWSER_TEST_F(
KeyboardEndToEndFormTest,
SwitchToTabWithFocusedInputWhenKeyboardIsShownDoesNotHideKeyboard) {
ui_test_utils::NavigateToURLWithDisposition(
browser(),
ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
base::FilePath("form.html")),
WindowOpenDisposition::NEW_BACKGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
browser()->tab_strip_model()->ActivateTabAt(1, true /* user_gesture */);
ClickElementWithId(web_contents, "username");
ASSERT_TRUE(WaitUntilShown());
browser()->tab_strip_model()->ActivateTabAt(0, true /* user_gesture */);
EXPECT_FALSE(IsKeyboardHiding());
}
class KeyboardEndToEndFocusTest : public KeyboardEndToEndTest { class KeyboardEndToEndFocusTest : public KeyboardEndToEndTest {
public: public:
KeyboardEndToEndFocusTest() KeyboardEndToEndFocusTest()
......
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