diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/input_method/DEPS | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/input_method/textinput_browsertest.cc | 74 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/data/textinput/ime_enable_disable_test.html | 31 |
4 files changed, 108 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/input_method/DEPS b/chrome/browser/chromeos/input_method/DEPS index 0294033..323c9b8 100644 --- a/chrome/browser/chromeos/input_method/DEPS +++ b/chrome/browser/chromeos/input_method/DEPS @@ -6,8 +6,8 @@ include_rules = [ specific_include_rules = { # The configuration layer. - '(input_method_delegate_impl|input_method_persistence|browser_state_monitor)' - '(_unittest)?\.(h|cc)': [ + '(input_method_delegate_impl|input_method_persistence|browser_state_monitor|' + 'textinput)((_unit|_browser)test)?\.(h|cc)': [ "+chrome/common", "+chrome/browser", "+chrome/test", diff --git a/chrome/browser/chromeos/input_method/textinput_browsertest.cc b/chrome/browser/chromeos/input_method/textinput_browsertest.cc new file mode 100644 index 0000000..6822ba5 --- /dev/null +++ b/chrome/browser/chromeos/input_method/textinput_browsertest.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2012 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 "ash/shell.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/interactive_test_utils.h" +#include "content/public/test/browser_test_utils.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/aura/client/aura_constants.h" +#include "ui/aura/root_window.h" +#include "ui/base/ime/input_method_factory.h" +#include "ui/base/ime/mock_input_method.h" + +namespace chromeos { + +class TextInputTest : public InProcessBrowserTest { + public: + TextInputTest() {} + virtual ~TextInputTest() {} + + protected: + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { + ui::SetUpInputMethodFacotryForTesting(); + } + + ui::MockInputMethod* GetInputMethod() { + ui::MockInputMethod* input_method = + static_cast<ui::MockInputMethod*>( + ash::Shell::GetPrimaryRootWindow()->GetProperty( + aura::client::kRootWindowInputMethodKey)); + CHECK(input_method); + return input_method; + } +}; + +IN_PROC_BROWSER_TEST_F(TextInputTest, SwitchToPasswordFieldTest) { + GURL url = ui_test_utils::GetTestUrl( + FilePath("textinput"), + FilePath("ime_enable_disable_test.html")); + ui_test_utils::NavigateToURL(browser(), url); + + content::WebContents* tab = + browser()->tab_strip_model()->GetActiveWebContents(); + + bool worker_finished = false; + ASSERT_TRUE(content::ExecuteScriptAndExtractBool( + tab, + "window.domAutomationController.send(text01_focus());", + &worker_finished)); + EXPECT_TRUE(worker_finished); + content::WaitForLoadStop(tab); + content::RunAllPendingInMessageLoop(); + + EXPECT_EQ(GetInputMethod()->latest_text_input_type(), + ui::TEXT_INPUT_TYPE_TEXT); + + worker_finished = false; + ASSERT_TRUE(content::ExecuteScriptAndExtractBool( + tab, + "window.domAutomationController.send(password01_focus());", + &worker_finished)); + EXPECT_TRUE(worker_finished); + content::WaitForLoadStop(tab); + content::RunAllPendingInMessageLoop(); + + EXPECT_EQ(GetInputMethod()->latest_text_input_type(), + ui::TEXT_INPUT_TYPE_PASSWORD); + +} + +} // namespace chromeos diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 3c77ec9..2be582e 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -343,6 +343,7 @@ 'browser/chromeos/cros/cros_in_process_browser_test.h', 'browser/chromeos/cros/cros_mock.cc', 'browser/chromeos/cros/cros_mock.h', + 'browser/chromeos/input_method/textinput_browsertest.cc', 'browser/chromeos/login/login_browsertest.cc', 'browser/chromeos/login/mock_authenticator.cc', 'browser/chromeos/login/mock_authenticator.h', diff --git a/chrome/test/data/textinput/ime_enable_disable_test.html b/chrome/test/data/textinput/ime_enable_disable_test.html new file mode 100644 index 0000000..336e289 --- /dev/null +++ b/chrome/test/data/textinput/ime_enable_disable_test.html @@ -0,0 +1,31 @@ +<html> + <head> + <script type="text/javascript"> + function text01_focus() { + document.getElementById('text01_id').focus(); + return true; + } + function text02_focus() { + document.getElementById('text02_id').focus(); + return true; + } + function password01_focus() { + document.getElementById('password01_id').focus(); + return true; + } + function password02_focus() { + document.getElementById('password02_id').focus(); + return true; + } + function onLoad() { + document.activeElement.blur(); + } + </script> + </head> + <body onload="onLoad()"> + <input type="text" id="text01_id"> + <input type="text" id="text02_id"> + <input type="password" id="password01_id"> + <input type="password" id="password02_id"> + </body> +</html> |