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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win_browsertest.cc

Issue 21189003: Change IME conversion status by focusing input element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [WIP] Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector>
6
5 #include "base/command_line.h" 7 #include "base/command_line.h"
6 #include "base/win/metro.h" 8 #include "base/win/metro.h"
9 #include "content/browser/renderer_host/render_widget_host_view_win.h"
10 #include "content/public/browser/render_view_host.h"
7 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
8 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
9 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
10 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
11 #include "content/shell/shell.h" 15 #include "content/shell/shell.h"
12 #include "content/test/content_browser_test_utils.h" 16 #include "content/test/content_browser_test_utils.h"
13 #include "content/test/content_browser_test.h" 17 #include "content/test/content_browser_test.h"
18 #include "ui/base/ime/composition_text.h"
14 #include "ui/base/ime/text_input_type.h" 19 #include "ui/base/ime/text_input_type.h"
20 #include "ui/base/ime/win/imm32_manager.h"
15 #include "ui/base/ime/win/mock_tsf_bridge.h" 21 #include "ui/base/ime/win/mock_tsf_bridge.h"
16 #include "ui/base/ime/win/tsf_bridge.h" 22 #include "ui/base/ime/win/tsf_bridge.h"
17 23
18 namespace content { 24 namespace content {
19 class RenderWidgetHostViewWinTest : public ContentBrowserTest { 25 namespace {
26
27 class MockIMM32Manager : public ui::IMM32Manager {
20 public: 28 public:
21 RenderWidgetHostViewWinTest() {} 29 virtual void SetTextInputMode(HWND window_handle,
30 ui::TextInputMode input_mode) OVERRIDE {
31 ++call_count_;
32 window_handle_ = window_handle;
33 input_mode_ = input_mode;
34 }
35
36 void Reset() {
37 call_count_ = 0;
38 }
39
40 HWND window_handle_;
Yohei Yukawa 2013/08/07 02:42:14 please initialize these fields in the constructor.
Yohei Yukawa 2013/08/07 02:42:14 please put private:
yoichio 2013/08/07 03:33:55 Done.
41 ui::TextInputMode input_mode_;
42 size_t call_count_;
43 };
Yohei Yukawa 2013/08/07 02:42:14 Can we put this? DISALLOW_COPY_AND_ASSIGN(MockIM
yoichio 2013/08/07 03:33:55 Done.
44
45 // Testing class serving initialized RenderWidgetHostViewWin instance;
46 class RenderWidgetHostViewWinBrowserTest : public ContentBrowserTest {
47 public:
48 RenderWidgetHostViewWinBrowserTest() {}
49
50 virtual void SetUpOnMainThread() OVERRIDE {
51 ContentBrowserTest::SetUpOnMainThread();
52
53 NavigateToURL(shell(), GURL("about:blank"));
54
55 view_ = static_cast<RenderWidgetHostViewWin*>(
56 RenderWidgetHostViewPort::FromRWHV(
57 shell()->web_contents()->GetRenderViewHost()->GetView()));
Yohei Yukawa 2013/08/07 02:42:14 Please make sure this indent is correct in the sty
yoichio 2013/08/07 03:33:55 Done.
58 CHECK(view_);
59 }
60
61 protected:
62 RenderWidgetHostViewWin* view_;
63 };
64
65 } // namespace
66
67 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinBrowserTest, TextInputTypeChanged) {
68 ASSERT_TRUE(view_->m_hWnd);
69
70 MockIMM32Manager* mock = new MockIMM32Manager();
71 mock->Reset();
72 view_->imm32_manager_.reset(mock);
73 view_->TextInputTypeChanged(ui::TEXT_INPUT_TYPE_NONE, false,
74 ui::TEXT_INPUT_MODE_EMAIL);
75
76 EXPECT_EQ(1, mock->call_count_);
77 EXPECT_EQ(view_->m_hWnd, mock->window_handle_);
78 EXPECT_EQ(ui::TEXT_INPUT_MODE_EMAIL, mock->input_mode_);
79
80 mock->Reset();
81 view_->TextInputTypeChanged(ui::TEXT_INPUT_TYPE_NONE, false,
82 ui::TEXT_INPUT_MODE_EMAIL);
83 EXPECT_EQ(0, mock->call_count_);
84 }
85
86 class RenderWidgetHostViewWinTSFTest : public ContentBrowserTest {
87 public:
88 RenderWidgetHostViewWinTSFTest() {}
22 89
23 virtual void SetUpCommandLine(CommandLine* command_line) { 90 virtual void SetUpCommandLine(CommandLine* command_line) {
24 command_line->AppendSwitch(switches::kEnableTextServicesFramework); 91 command_line->AppendSwitch(switches::kEnableTextServicesFramework);
25 } 92 }
26 }; 93 };
27 94
28 // crbug.com/151798 95 // crbug.com/151798
29 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, 96 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTSFTest,
30 DISABLED_SwichToPasswordField) { 97 DISABLED_SwichToPasswordField) {
31 ui::MockTSFBridge mock_bridge; 98 ui::MockTSFBridge mock_bridge;
32 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); 99 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
33 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 100 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
34 101
35 NavigateToURL(shell(), test_url); 102 NavigateToURL(shell(), test_url);
36 WaitForLoadStop(shell()->web_contents()); 103 WaitForLoadStop(shell()->web_contents());
37 RunAllPendingInMessageLoop(); 104 RunAllPendingInMessageLoop();
38 105
39 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 106 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
(...skipping 17 matching lines...) Expand all
57 &success)); 124 &success));
58 EXPECT_TRUE(success); 125 EXPECT_TRUE(success);
59 WaitForLoadStop(shell()->web_contents()); 126 WaitForLoadStop(shell()->web_contents());
60 RunAllPendingInMessageLoop(); 127 RunAllPendingInMessageLoop();
61 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); 128 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
62 129
63 ui::TSFBridge::ReplaceForTesting(old_bridge); 130 ui::TSFBridge::ReplaceForTesting(old_bridge);
64 } 131 }
65 132
66 // crbug.com/151798 133 // crbug.com/151798
67 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, 134 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTSFTest,
68 DISABLED_SwitchToSameField) { 135 DISABLED_SwitchToSameField) {
69 ui::MockTSFBridge mock_bridge; 136 ui::MockTSFBridge mock_bridge;
70 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); 137 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
71 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 138 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
72 139
73 NavigateToURL(shell(), test_url); 140 NavigateToURL(shell(), test_url);
74 WaitForLoadStop(shell()->web_contents()); 141 WaitForLoadStop(shell()->web_contents());
75 RunAllPendingInMessageLoop(); 142 RunAllPendingInMessageLoop();
76 143
77 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 144 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
(...skipping 17 matching lines...) Expand all
95 &success)); 162 &success));
96 EXPECT_TRUE(success); 163 EXPECT_TRUE(success);
97 WaitForLoadStop(shell()->web_contents()); 164 WaitForLoadStop(shell()->web_contents());
98 RunAllPendingInMessageLoop(); 165 RunAllPendingInMessageLoop();
99 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); 166 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type());
100 167
101 ui::TSFBridge::ReplaceForTesting(old_bridge); 168 ui::TSFBridge::ReplaceForTesting(old_bridge);
102 } 169 }
103 170
104 // crbug.com/151798 171 // crbug.com/151798
105 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, 172 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTSFTest,
106 DISABLED_SwitchToSamePasswordField) { 173 DISABLED_SwitchToSamePasswordField) {
107 ui::MockTSFBridge mock_bridge; 174 ui::MockTSFBridge mock_bridge;
108 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); 175 ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge);
109 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); 176 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html");
110 177
111 NavigateToURL(shell(), test_url); 178 NavigateToURL(shell(), test_url);
112 WaitForLoadStop(shell()->web_contents()); 179 WaitForLoadStop(shell()->web_contents());
113 RunAllPendingInMessageLoop(); 180 RunAllPendingInMessageLoop();
114 181
115 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); 182 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type());
(...skipping 17 matching lines...) Expand all
133 &success)); 200 &success));
134 EXPECT_TRUE(success); 201 EXPECT_TRUE(success);
135 WaitForLoadStop(shell()->web_contents()); 202 WaitForLoadStop(shell()->web_contents());
136 RunAllPendingInMessageLoop(); 203 RunAllPendingInMessageLoop();
137 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); 204 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type());
138 205
139 ui::TSFBridge::ReplaceForTesting(old_bridge); 206 ui::TSFBridge::ReplaceForTesting(old_bridge);
140 } 207 }
141 208
142 } // namespace content 209 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698