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

Side by Side 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: rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/win/metro.h"
7 #include "content/public/browser/web_contents.h"
8 #include "content/public/common/content_switches.h"
9 #include "content/public/test/test_utils.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "content/shell/shell.h"
12 #include "content/test/content_browser_test_utils.h"
13 #include "content/test/content_browser_test.h"
14 #include "ui/base/ime/text_input_type.h"
15 #include "ui/base/win/mock_tsf_bridge.h"
16 #include "ui/base/win/tsf_bridge.h"
17
18 namespace {
19 class RenderWidgetHostViewWinTest : public content::ContentBrowserTest {
20 public:
21 RenderWidgetHostViewWinTest() {}
22
23 virtual void SetUpCommandLine(CommandLine* command_line) {
24 command_line->AppendSwitch(switches::kEnableTextServicesFramework);
25 }
26 };
27
28 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwichToPasswordField) {
29 ui::MockTsfBridge mock_bridge;
30 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
31 GURL test_url = content::GetTestUrl("textinput",
32 "ime_enable_disable_test.html");
33
34 content::NavigateToURL(shell(), test_url);
35 content::WaitForLoadStop(shell()->web_contents());
36 content::RunAllPendingInMessageLoop();
37
38 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
39
40 // Focus to the text field, the IME should be enabled.
41 bool success = false;
42 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
43 shell()->web_contents()->GetRenderViewHost(), L"",
44 L"window.domAutomationController.send(text01_focus());",
45 &success));
46 EXPECT_TRUE(success);
47 content::WaitForLoadStop(shell()->web_contents());
48 content::RunAllPendingInMessageLoop();
49 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
50
51 // Focus to the password field, the IME should be disabled.
52 success = false;
53 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
54 shell()->web_contents()->GetRenderViewHost(), L"",
55 L"window.domAutomationController.send(password02_focus());",
56 &success));
57 EXPECT_TRUE(success);
58 content::WaitForLoadStop(shell()->web_contents());
59 content::RunAllPendingInMessageLoop();
60 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
61
62 ui::TsfBridge::ReplaceForTesting(old_bridge);
63 }
64
65 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSameField) {
66 ui::MockTsfBridge mock_bridge;
67 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
68 GURL test_url = content::GetTestUrl("textinput",
69 "ime_enable_disable_test.html");
70
71 content::NavigateToURL(shell(), test_url);
72 content::WaitForLoadStop(shell()->web_contents());
73 content::RunAllPendingInMessageLoop();
74
75 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
76
77 // Focus to the text field, the IME should be enabled.
78 bool success = false;
79 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
80 shell()->web_contents()->GetRenderViewHost(), L"",
81 L"window.domAutomationController.send(text01_focus());",
82 &success));
83 EXPECT_TRUE(success);
84 content::WaitForLoadStop(shell()->web_contents());
85 content::RunAllPendingInMessageLoop();
86 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
87
88 // Focus to another text field, the IME should be enabled.
89 success = false;
90 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
91 shell()->web_contents()->GetRenderViewHost(), L"",
92 L"window.domAutomationController.send(text02_focus());",
93 &success));
94 EXPECT_TRUE(success);
95 content::WaitForLoadStop(shell()->web_contents());
96 content::RunAllPendingInMessageLoop();
97 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
98
99 ui::TsfBridge::ReplaceForTesting(old_bridge);
100 }
101
102 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSamePasswordField) {
103 ui::MockTsfBridge mock_bridge;
104 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
105 GURL test_url = content::GetTestUrl("textinput",
106 "ime_enable_disable_test.html");
107
108 content::NavigateToURL(shell(), test_url);
109 content::WaitForLoadStop(shell()->web_contents());
110 content::RunAllPendingInMessageLoop();
111
112 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
113
114 // Focus to the password field, the IME should be disabled.
115 bool success = false;
116 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
117 shell()->web_contents()->GetRenderViewHost(), L"",
118 L"window.domAutomationController.send(password01_focus());",
119 &success));
120 EXPECT_TRUE(success);
121 content::WaitForLoadStop(shell()->web_contents());
122 content::RunAllPendingInMessageLoop();
123 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
124
125 // Focus to the another password field, the IME should be disabled.
126 success = false;
127 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
128 shell()->web_contents()->GetRenderViewHost(), L"",
129 L"window.domAutomationController.send(password02_focus());",
130 &success));
131 EXPECT_TRUE(success);
132 content::WaitForLoadStop(shell()->web_contents());
133 content::RunAllPendingInMessageLoop();
134 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
135
136 ui::TsfBridge::ReplaceForTesting(old_bridge);
137 }
138 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698