Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/command_line.h" | |
| 6 #include "base/files/file.h" | |
| 7 #include "chrome/browser/ui/browser.h" | |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 9 #include "chrome/test/base/in_process_browser_test.h" | |
| 10 #include "chrome/test/base/ui_test_utils.h" | |
| 11 #include "content/public/test/browser_test_utils.h" | |
| 12 #include "ui/keyboard/content/keyboard_constants.h" | |
| 13 #include "ui/keyboard/keyboard_controller.h" | |
| 14 #include "ui/keyboard/keyboard_switches.h" | |
| 15 #include "ui/keyboard/keyboard_test_util.h" | |
| 16 | |
| 17 namespace { | |
|
oshima
2017/03/22 21:03:44
nit: new line before after function
oka
2017/03/22 21:14:21
Done.
| |
| 18 bool IsKeyboardVisible() { | |
| 19 return keyboard::KeyboardController::GetInstance()->keyboard_visible(); | |
| 20 } | |
| 21 } // namespace | |
| 22 | |
| 23 namespace keyboard { | |
| 24 | |
| 25 class KeyboardEndToEndTest : public InProcessBrowserTest { | |
| 26 public: | |
| 27 KeyboardEndToEndTest() {} | |
| 28 ~KeyboardEndToEndTest() override {} | |
| 29 | |
| 30 // Ensure that the virtual keyboard is enabled. | |
| 31 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 32 command_line->AppendSwitch(keyboard::switches::kEnableVirtualKeyboard); | |
| 33 } | |
| 34 }; | |
| 35 | |
| 36 IN_PROC_BROWSER_TEST_F(KeyboardEndToEndTest, OpenAndCloseOnFocusAndBlur) { | |
| 37 GURL test_url = | |
| 38 ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"), | |
| 39 base::FilePath("inputs.html")); | |
| 40 ui_test_utils::NavigateToURL(browser(), test_url); | |
| 41 content::WebContents* web_contents = | |
| 42 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 43 ASSERT_TRUE(web_contents); | |
| 44 | |
| 45 EXPECT_FALSE(IsKeyboardVisible()); | |
| 46 | |
| 47 ASSERT_TRUE(content::ExecuteScript( | |
| 48 web_contents, "document.getElementById('text').focus();")); | |
| 49 | |
| 50 ASSERT_TRUE(keyboard::WaitUntilShown()); | |
| 51 EXPECT_TRUE(IsKeyboardVisible()); | |
| 52 | |
| 53 ASSERT_TRUE(content::ExecuteScript( | |
| 54 web_contents, "document.getElementById('text').blur();")); | |
| 55 | |
| 56 ASSERT_TRUE(keyboard::WaitUntilHidden()); | |
| 57 EXPECT_FALSE(IsKeyboardVisible()); | |
| 58 } | |
| 59 | |
| 60 } // namespace keyboard | |
| OLD | NEW |