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

Unified Diff: content/browser/renderer_host/render_widget_host_view_win_browsertest.cc

Issue 10912171: Introduce RenderWidgetHostViewWinTest for Tsf handling (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove call count expectations. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | ui/base/win/tsf_bridge.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..300865fb085d8b0ca3e6b033f72879f0005f02a8
--- /dev/null
+++ b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
@@ -0,0 +1,137 @@
+// 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 "base/command_line.h"
+#include "base/win/metro.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/test_utils.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/shell/shell.h"
+#include "content/test/content_browser_test_utils.h"
+#include "content/test/content_browser_test.h"
+#include "ui/base/win/mock_tsf_bridge.h"
+#include "ui/base/win/tsf_bridge.h"
+
+namespace {
+class RenderWidgetHostViewWinTest : public content::ContentBrowserTest {
+ public:
+ RenderWidgetHostViewWinTest() {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) {
+ command_line->AppendSwitch("--enable-text-service-framework");
sky 2012/09/10 16:44:09 Can't you use the constant here?
Seigo Nonaka 2012/09/10 19:04:10 Sorry, I forget using constant. Fixed. On 2012/09
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwichToPasswordField) {
+ ui::MockTsfBridge mock_bridge;
+ ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
+ GURL test_url = content::GetTestUrl("textinput",
+ "ime_enable_disable_test.html");
+
+ content::NavigateToURL(shell(), test_url);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ // Focus to the text field, the IME should be enabled.
+ bool success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(text01_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_TRUE(mock_bridge.is_ime_enabled());
+
+ // Focus to the password field, the IME should be disabled.
+ success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(password02_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ ui::TsfBridge::ReplaceForTesting(old_bridge);
+}
+
+IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSameField) {
+ ui::MockTsfBridge mock_bridge;
+ ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
+ GURL test_url = content::GetTestUrl("textinput",
+ "ime_enable_disable_test.html");
+
+ content::NavigateToURL(shell(), test_url);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ // Focus to the text field, the IME should be enabled.
+ bool success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(text01_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_TRUE(mock_bridge.is_ime_enabled());
+
+ // Focus to another text field, the IME should be enabled.
+ success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(text02_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_TRUE(mock_bridge.is_ime_enabled());
+
+ ui::TsfBridge::ReplaceForTesting(old_bridge);
+}
+
+IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSamePasswordField) {
+ ui::MockTsfBridge mock_bridge;
+ ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
+ GURL test_url = content::GetTestUrl("textinput",
+ "ime_enable_disable_test.html");
+
+ content::NavigateToURL(shell(), test_url);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ // Focus to the password field, the IME should be disabled.
+ bool success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(password01_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ // Focus to the another password field, the IME should be disabled.
+ success = false;
+ EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
+ shell()->web_contents()->GetRenderViewHost(), L"",
+ L"window.domAutomationController.send(password02_focus());",
+ &success));
+ EXPECT_TRUE(success);
+ content::WaitForLoadStop(shell()->web_contents());
+ content::RunAllPendingInMessageLoop();
+ EXPECT_FALSE(mock_bridge.is_ime_enabled());
+
+ ui::TsfBridge::ReplaceForTesting(old_bridge);
+}
+} // namespace
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | ui/base/win/tsf_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698