Chromium Code Reviews| Index: chrome/browser/ui/ash/keyboard_end_to_end_browsertest.cc |
| diff --git a/chrome/browser/ui/ash/keyboard_end_to_end_browsertest.cc b/chrome/browser/ui/ash/keyboard_end_to_end_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2a256689c4e9cde795dfe250c5342cb4afbccc26 |
| --- /dev/null |
| +++ b/chrome/browser/ui/ash/keyboard_end_to_end_browsertest.cc |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "ui/keyboard/content/keyboard_constants.h" |
| +#include "ui/keyboard/keyboard_controller.h" |
| +#include "ui/keyboard/keyboard_switches.h" |
| +#include "ui/keyboard/keyboard_test_util.h" |
| + |
| +namespace { |
|
oshima
2017/03/22 21:03:44
nit: new line before after function
oka
2017/03/22 21:14:21
Done.
|
| +bool IsKeyboardVisible() { |
| + return keyboard::KeyboardController::GetInstance()->keyboard_visible(); |
| +} |
| +} // namespace |
| + |
| +namespace keyboard { |
| + |
| +class KeyboardEndToEndTest : public InProcessBrowserTest { |
| + public: |
| + KeyboardEndToEndTest() {} |
| + ~KeyboardEndToEndTest() override {} |
| + |
| + // Ensure that the virtual keyboard is enabled. |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + command_line->AppendSwitch(keyboard::switches::kEnableVirtualKeyboard); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(KeyboardEndToEndTest, OpenAndCloseOnFocusAndBlur) { |
| + GURL test_url = |
| + ui_test_utils::GetTestUrl(base::FilePath("chromeos/virtual_keyboard"), |
| + base::FilePath("inputs.html")); |
| + ui_test_utils::NavigateToURL(browser(), test_url); |
| + content::WebContents* web_contents = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + ASSERT_TRUE(web_contents); |
| + |
| + EXPECT_FALSE(IsKeyboardVisible()); |
| + |
| + ASSERT_TRUE(content::ExecuteScript( |
| + web_contents, "document.getElementById('text').focus();")); |
| + |
| + ASSERT_TRUE(keyboard::WaitUntilShown()); |
| + EXPECT_TRUE(IsKeyboardVisible()); |
| + |
| + ASSERT_TRUE(content::ExecuteScript( |
| + web_contents, "document.getElementById('text').blur();")); |
| + |
| + ASSERT_TRUE(keyboard::WaitUntilHidden()); |
| + EXPECT_FALSE(IsKeyboardVisible()); |
| +} |
| + |
| +} // namespace keyboard |