Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / renderer_host / render_widget_host_view_win_browsertest.cc
blob77763ab97ceeca3d622776f5878becdfb736a77f
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.
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/ime/win/mock_tsf_bridge.h"
16 #include "ui/base/ime/win/tsf_bridge.h"
18 namespace content {
19 class RenderWidgetHostViewWinTest : public ContentBrowserTest {
20 public:
21 RenderWidgetHostViewWinTest() {}
23 virtual void SetUpCommandLine(CommandLine* command_line) {
24 command_line->AppendSwitch(switches::kEnableTextServicesFramework);
28 // crbug.com/151798
29 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest,
30 DISABLED_SwichToPasswordField) {
31 ui::MockTSFBridge mock_bridge;
32 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
33 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
35 NavigateToURL(shell(), test_url);
36 WaitForLoadStop(shell()->web_contents());
37 RunAllPendingInMessageLoop();
39 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
41 // Focus to the text field, the IME should be enabled.
42 bool success = false;
43 EXPECT_TRUE(ExecuteScriptAndExtractBool(
44 shell()->web_contents(),
45 "window.domAutomationController.send(text01_focus());",
46 &success));
47 EXPECT_TRUE(success);
48 WaitForLoadStop(shell()->web_contents());
49 RunAllPendingInMessageLoop();
50 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
52 // Focus to the password field, the IME should be disabled.
53 success = false;
54 EXPECT_TRUE(ExecuteScriptAndExtractBool(
55 shell()->web_contents(),
56 "window.domAutomationController.send(password02_focus());",
57 &success));
58 EXPECT_TRUE(success);
59 WaitForLoadStop(shell()->web_contents());
60 RunAllPendingInMessageLoop();
61 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
63 ui::TSFBridge::ReplaceForTesting(old_bridge);
66 // crbug.com/151798
67 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest,
68 DISABLED_SwitchToSameField) {
69 ui::MockTSFBridge mock_bridge;
70 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
71 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
73 NavigateToURL(shell(), test_url);
74 WaitForLoadStop(shell()->web_contents());
75 RunAllPendingInMessageLoop();
77 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
79 // Focus to the text field, the IME should be enabled.
80 bool success = false;
81 EXPECT_TRUE(ExecuteScriptAndExtractBool(
82 shell()->web_contents(),
83 "window.domAutomationController.send(text01_focus());",
84 &success));
85 EXPECT_TRUE(success);
86 WaitForLoadStop(shell()->web_contents());
87 RunAllPendingInMessageLoop();
88 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
90 // Focus to another text field, the IME should be enabled.
91 success = false;
92 EXPECT_TRUE(ExecuteScriptAndExtractBool(
93 shell()->web_contents(),
94 "window.domAutomationController.send(text02_focus());",
95 &success));
96 EXPECT_TRUE(success);
97 WaitForLoadStop(shell()->web_contents());
98 RunAllPendingInMessageLoop();
99 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
101 ui::TSFBridge::ReplaceForTesting(old_bridge);
104 // crbug.com/151798
105 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest,
106 DISABLED_SwitchToSamePasswordField) {
107 ui::MockTSFBridge mock_bridge;
108 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
109 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
111 NavigateToURL(shell(), test_url);
112 WaitForLoadStop(shell()->web_contents());
113 RunAllPendingInMessageLoop();
115 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
117 // Focus to the password field, the IME should be disabled.
118 bool success = false;
119 EXPECT_TRUE(ExecuteScriptAndExtractBool(
120 shell()->web_contents(),
121 "window.domAutomationController.send(password01_focus());",
122 &success));
123 EXPECT_TRUE(success);
124 WaitForLoadStop(shell()->web_contents());
125 RunAllPendingInMessageLoop();
126 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
128 // Focus to the another password field, the IME should be disabled.
129 success = false;
130 EXPECT_TRUE(ExecuteScriptAndExtractBool(
131 shell()->web_contents(),
132 "window.domAutomationController.send(password02_focus());",
133 &success));
134 EXPECT_TRUE(success);
135 WaitForLoadStop(shell()->web_contents());
136 RunAllPendingInMessageLoop();
137 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
139 ui::TSFBridge::ReplaceForTesting(old_bridge);
142 } // namespace content