Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/ui/ash/keyboard_end_to_end_browsertest.cc

Issue 2771793002: End to end test: async focus shouldn't trigger virtual keyboard. (Closed)
Patch Set: Rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shell.h"
5 #include "base/command_line.h" 6 #include "base/command_line.h"
6 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "chrome/browser/chromeos/input_method/textinput_test_helper.h"
7 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
14 #include "ui/aura/window_tree_host.h"
12 #include "ui/keyboard/content/keyboard_constants.h" 15 #include "ui/keyboard/content/keyboard_constants.h"
13 #include "ui/keyboard/keyboard_controller.h" 16 #include "ui/keyboard/keyboard_controller.h"
14 #include "ui/keyboard/keyboard_switches.h" 17 #include "ui/keyboard/keyboard_switches.h"
15 #include "ui/keyboard/keyboard_test_util.h" 18 #include "ui/keyboard/keyboard_test_util.h"
16 19
17 namespace { 20 namespace {
18 21
19 bool IsKeyboardVisible() { 22 bool IsKeyboardVisible() {
20 return keyboard::KeyboardController::GetInstance()->keyboard_visible(); 23 return keyboard::KeyboardController::GetInstance()->keyboard_visible();
21 } 24 }
(...skipping 27 matching lines...) Expand all
49 52
50 class KeyboardEndToEndTest : public InProcessBrowserTest { 53 class KeyboardEndToEndTest : public InProcessBrowserTest {
51 public: 54 public:
52 KeyboardEndToEndTest() {} 55 KeyboardEndToEndTest() {}
53 ~KeyboardEndToEndTest() override {} 56 ~KeyboardEndToEndTest() override {}
54 57
55 // Ensure that the virtual keyboard is enabled. 58 // Ensure that the virtual keyboard is enabled.
56 void SetUpCommandLine(base::CommandLine* command_line) override { 59 void SetUpCommandLine(base::CommandLine* command_line) override {
57 command_line->AppendSwitch(keyboard::switches::kEnableVirtualKeyboard); 60 command_line->AppendSwitch(keyboard::switches::kEnableVirtualKeyboard);
58 } 61 }
62
63 void SetUpOnMainThread() override {
64 GURL test_url =
65 ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
66 base::FilePath("inputs.html"));
67 ui_test_utils::NavigateToURL(browser(), test_url);
68 web_contents = browser()->tab_strip_model()->GetActiveWebContents();
69 ASSERT_TRUE(web_contents);
70
71 EXPECT_FALSE(IsKeyboardVisible());
72 }
73
74 protected:
75 // Initialized in |SetUpOnMainThread|.
76 content::WebContents* web_contents;
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(KeyboardEndToEndTest);
59 }; 80 };
60 81
61 IN_PROC_BROWSER_TEST_F(KeyboardEndToEndTest, OpenIfFocusedOnClick) { 82 IN_PROC_BROWSER_TEST_F(KeyboardEndToEndTest, OpenIfFocusedOnClick) {
62 GURL test_url =
63 ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"),
64 base::FilePath("inputs.html"));
65 ui_test_utils::NavigateToURL(browser(), test_url);
66 content::WebContents* web_contents =
67 browser()->tab_strip_model()->GetActiveWebContents();
68 ASSERT_TRUE(web_contents);
69
70 EXPECT_FALSE(IsKeyboardVisible());
71
72 ClickElementWithId(web_contents, "text"); 83 ClickElementWithId(web_contents, "text");
73 84
74 ASSERT_TRUE(keyboard::WaitUntilShown()); 85 ASSERT_TRUE(keyboard::WaitUntilShown());
75 EXPECT_TRUE(IsKeyboardVisible()); 86 EXPECT_TRUE(IsKeyboardVisible());
76 87
77 ClickElementWithId(web_contents, "blur"); 88 ClickElementWithId(web_contents, "blur");
78 ASSERT_TRUE(keyboard::WaitUntilHidden()); 89 ASSERT_TRUE(keyboard::WaitUntilHidden());
79 EXPECT_FALSE(IsKeyboardVisible()); 90 EXPECT_FALSE(IsKeyboardVisible());
80 } 91 }
81 92
93 IN_PROC_BROWSER_TEST_F(KeyboardEndToEndTest, OpenOnlyOnSyncFocus) {
94 auto* controller = keyboard::KeyboardController::GetInstance();
95 EXPECT_FALSE(IsKeyboardVisible());
96
97 chromeos::TextInputTestHelper helper;
98
99 ClickElementWithId(web_contents, "sync");
100
101 helper.WaitForTextInputStateChanged(ui::TEXT_INPUT_TYPE_TEXT);
102
103 EXPECT_EQ(controller->GetStateForTest(),
104 keyboard::KeyboardControllerState::LOADING_EXTENSION);
105
106 EXPECT_TRUE(keyboard::WaitUntilShown());
107
108 ClickElementWithId(web_contents, "blur");
109 ASSERT_TRUE(keyboard::WaitUntilHidden());
110
111 ClickElementWithId(web_contents, "async");
112 helper.WaitForTextInputStateChanged(ui::TEXT_INPUT_TYPE_TEXT);
113 EXPECT_EQ(controller->GetStateForTest(),
114 keyboard::KeyboardControllerState::HIDDEN);
115 }
116
82 } // namespace keyboard 117 } // namespace keyboard
OLDNEW
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698