summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-31 17:13:11 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-31 17:13:11 +0000
commitcd33fc1003fbe0de043eef5bd1b42f3c0e0994e5 (patch)
tree48ce56ece826413ddb4059933c2dbc438ca546c7
parent2114fef2a9fca042d847717183bb98161820c0e0 (diff)
downloadchromium_src-cd33fc1003fbe0de043eef5bd1b42f3c0e0994e5.zip
chromium_src-cd33fc1003fbe0de043eef5bd1b42f3c0e0994e5.tar.gz
chromium_src-cd33fc1003fbe0de043eef5bd1b42f3c0e0994e5.tar.bz2
Add browser tests for password field behavior
BUG=352360 Review URL: https://codereview.chromium.org/211933002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260578 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/ash/ash_keyboard_controller_proxy.h2
-rw-r--r--chrome/browser/ui/ash/keyboard_controller_browsertest.cc79
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--ui/keyboard/keyboard_controller_proxy.h16
4 files changed, 97 insertions, 2 deletions
diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h
index bd33a37..11b56ab 100644
--- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h
+++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h
@@ -37,8 +37,6 @@ class AshKeyboardControllerProxy
virtual ~AshKeyboardControllerProxy();
private:
- friend class AshKeyboardControllerProxyTest;
-
void OnRequest(const ExtensionHostMsg_Request_Params& params);
// keyboard::KeyboardControllerProxy overrides
diff --git a/chrome/browser/ui/ash/keyboard_controller_browsertest.cc b/chrome/browser/ui/ash/keyboard_controller_browsertest.cc
new file mode 100644
index 0000000..0be099a
--- /dev/null
+++ b/chrome/browser/ui/ash/keyboard_controller_browsertest.cc
@@ -0,0 +1,79 @@
+// Copyright 2014 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 "base/command_line.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/common/url_constants.h"
+#include "ui/base/ime/dummy_text_input_client.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/input_method_factory.h"
+#include "ui/keyboard/keyboard_constants.h"
+#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_controller_proxy.h"
+#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_util.h"
+
+class VirtualKeyboardWebContentTest : public InProcessBrowserTest {
+ public:
+ VirtualKeyboardWebContentTest() {};
+ virtual ~VirtualKeyboardWebContentTest() {};
+
+ virtual void SetUp() OVERRIDE {
+ ui::SetUpInputMethodFactoryForTesting();
+ InProcessBrowserTest::SetUp();
+ }
+
+ // Ensure that the virtual keyboard is enabled.
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ command_line->AppendSwitch(
+ keyboard::switches::kEnableVirtualKeyboard);
+ command_line->AppendSwitch(
+ keyboard::switches::kEnableInputView);
+ }
+
+ keyboard::KeyboardControllerProxy* proxy() {
+ return ash::Shell::GetInstance()->keyboard_controller()->proxy();
+ }
+
+ protected:
+ void SetFocus(ui::TextInputClient* client) {
+ ui::InputMethod* input_method = proxy()->GetInputMethod();
+ input_method->SetFocusedTextInputClient(client);
+ if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE)
+ input_method->ShowImeIfNeeded();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWebContentTest);
+};
+
+// When focused on a password field, system virtual keyboard should be used
+// instead of IME provided virtual keyboard. At non password field, IME provided
+// virtual keyboard should show up if any.
+IN_PROC_BROWSER_TEST_F(VirtualKeyboardWebContentTest,
+ ShowSystemKeyboardAtPasswordField) {
+ ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT);
+ ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_PASSWORD);
+ ui::DummyTextInputClient input_client_2(ui::TEXT_INPUT_TYPE_TEXT);
+
+ scoped_ptr<keyboard::KeyboardControllerProxy::TestApi> test_api;
+ test_api.reset(new keyboard::KeyboardControllerProxy::TestApi(proxy()));
+
+ // Mock IME sets input_view.
+ keyboard::SetOverrideContentUrl(GURL(content::kAboutBlankURL));
+
+ SetFocus(&input_client_0);
+ EXPECT_EQ(test_api->keyboard_contents()->GetURL(),
+ GURL(content::kAboutBlankURL));
+
+ SetFocus(&input_client_1);
+ EXPECT_EQ(test_api->keyboard_contents()->GetURL(),
+ GURL(keyboard::kKeyboardURL));
+
+ SetFocus(&input_client_2);
+ EXPECT_EQ(test_api->keyboard_contents()->GetURL(),
+ GURL(content::kAboutBlankURL));
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d0f287b..84439c8 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1404,6 +1404,7 @@
'browser/ui/ash/accelerator_commands_browsertest.cc',
'browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc',
'browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc',
+ 'browser/ui/ash/keyboard_controller_browsertest.cc',
'browser/ui/ash/shelf_browsertest.cc',
'browser/ui/ash/volume_controller_browsertest_chromeos.cc',
'browser/ui/autofill/autofill_dialog_controller_browsertest.cc',
@@ -1782,6 +1783,7 @@
'browser/extensions/api/terminal/terminal_private_apitest.cc',
'browser/net/nss_context_chromeos_browsertest.cc',
'browser/notifications/login_state_notification_blocker_chromeos_browsertest.cc',
+ 'browser/ui/ash/keyboard_controller_browsertest.cc',
'browser/ui/views/select_file_dialog_extension_browsertest.cc',
'test/data/webui/certificate_viewer_dialog_test.js',
'test/data/webui/certificate_viewer_ui_test-inl.h',
diff --git a/ui/keyboard/keyboard_controller_proxy.h b/ui/keyboard/keyboard_controller_proxy.h
index 8f48c0c..f05f6f2 100644
--- a/ui/keyboard/keyboard_controller_proxy.h
+++ b/ui/keyboard/keyboard_controller_proxy.h
@@ -31,6 +31,20 @@ namespace keyboard {
// keyboard window.
class KEYBOARD_EXPORT KeyboardControllerProxy {
public:
+ class TestApi {
+ public:
+ explicit TestApi(KeyboardControllerProxy* proxy) : proxy_(proxy) {}
+
+ const content::WebContents* keyboard_contents() {
+ return proxy_->keyboard_contents_.get();
+ }
+
+ private:
+ KeyboardControllerProxy* proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestApi);
+ };
+
KeyboardControllerProxy();
virtual ~KeyboardControllerProxy();
@@ -104,6 +118,8 @@ class KEYBOARD_EXPORT KeyboardControllerProxy {
virtual void SetupWebContents(content::WebContents* contents);
private:
+ friend class TestApi;
+
// Loads the web contents for the given |url|.
void LoadContents(const GURL& url);