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

Side by Side Diff: chrome/browser/chromeos/input_method/mode_indicator_browsertest.cc

Issue 190033005: [IME] Removes the duplicated IMEs in chrome://settings/languages, and support async component IMEs … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try to make test green. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "chrome/browser/chromeos/input_method/input_method_util.h"
8 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" 9 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chromeos/ime/component_extension_ime_manager.h" 11 #include "chromeos/ime/component_extension_ime_manager.h"
12 #include "chromeos/ime/extension_ime_util.h"
11 #include "chromeos/ime/input_method_manager.h" 13 #include "chromeos/ime/input_method_manager.h"
14 #include "chromeos/ime/input_method_whitelist.h"
12 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/ime/chromeos/ime_bridge.h" 18 #include "ui/base/ime/chromeos/ime_bridge.h"
16 #include "ui/base/ime/input_method_factory.h" 19 #include "ui/base/ime/input_method_factory.h"
17 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
18 #include "ui/views/widget/widget_observer.h" 21 #include "ui/views/widget/widget_observer.h"
19 22
20 namespace chromeos { 23 namespace chromeos {
21 namespace input_method { 24 namespace input_method {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 public: 92 public:
90 ModeIndicatorBrowserTest() 93 ModeIndicatorBrowserTest()
91 : InProcessBrowserTest() {} 94 : InProcessBrowserTest() {}
92 virtual ~ModeIndicatorBrowserTest() {} 95 virtual ~ModeIndicatorBrowserTest() {}
93 96
94 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 97 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
95 ui::SetUpInputMethodFactoryForTesting(); 98 ui::SetUpInputMethodFactoryForTesting();
96 } 99 }
97 100
98 void InitializeIMF() { 101 void InitializeIMF() {
102 InputMethodManager::Get()
103 ->GetInputMethodUtil()
104 ->InitXkbInputMethodsForTesting();
99 // Make sure ComponentExtensionIMEManager is initialized. 105 // Make sure ComponentExtensionIMEManager is initialized.
100 // ComponentExtensionIMEManagerImpl::InitializeAsync posts 106 // ComponentExtensionIMEManagerImpl::InitializeAsync posts
101 // ReadComponentExtensionsInfo to the FILE thread for the 107 // ReadComponentExtensionsInfo to the FILE thread for the
102 // initialization. If it is never initialized for some reasons, 108 // initialization. If it is never initialized for some reasons,
103 // the test is timed out and failed. 109 // the test is timed out and failed.
104 ComponentExtensionIMEManager* ceimm = 110 ComponentExtensionIMEManager* ceimm =
105 InputMethodManager::Get()->GetComponentExtensionIMEManager(); 111 InputMethodManager::Get()->GetComponentExtensionIMEManager();
106 while (!ceimm->IsInitialized()) { 112 while (!ceimm->IsInitialized()) {
107 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 113 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
108 } 114 }
(...skipping 10 matching lines...) Expand all
119 const int kInnerSize = 43; 125 const int kInnerSize = 43;
120 } // namespace 126 } // namespace
121 127
122 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) { 128 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) {
123 InitializeIMF(); 129 InitializeIMF();
124 130
125 InputMethodManager* imm = InputMethodManager::Get(); 131 InputMethodManager* imm = InputMethodManager::Get();
126 ASSERT_TRUE(imm); 132 ASSERT_TRUE(imm);
127 133
128 std::vector<std::string> keyboard_layouts; 134 std::vector<std::string> keyboard_layouts;
129 keyboard_layouts.push_back("xkb:fr::fra"); 135 keyboard_layouts.push_back(
136 extension_ime_util::GetInputMethodIDByKeyboardLayout("xkb:fr::fra"));
130 137
131 // Add keyboard layouts to enable the mode indicator. 138 // Add keyboard layouts to enable the mode indicator.
132 imm->EnableLoginLayouts("fr", keyboard_layouts); 139 imm->EnableLoginLayouts("fr", keyboard_layouts);
133 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); 140 ASSERT_LT(1UL, imm->GetNumActiveInputMethods());
134 141
135 chromeos::IMECandidateWindowHandlerInterface* candidate_window = 142 chromeos::IMECandidateWindowHandlerInterface* candidate_window =
136 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); 143 chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
137 candidate_window->FocusStateChanged(true); 144 candidate_window->FocusStateChanged(true);
138 145
139 // Check if the size of the mode indicator is expected. 146 // Check if the size of the mode indicator is expected.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 193 }
187 } 194 }
188 195
189 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) { 196 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) {
190 InitializeIMF(); 197 InitializeIMF();
191 198
192 InputMethodManager* imm = InputMethodManager::Get(); 199 InputMethodManager* imm = InputMethodManager::Get();
193 ASSERT_TRUE(imm); 200 ASSERT_TRUE(imm);
194 201
195 std::vector<std::string> keyboard_layouts; 202 std::vector<std::string> keyboard_layouts;
196 keyboard_layouts.push_back("xkb:fr::fra"); 203 keyboard_layouts.push_back(
204 extension_ime_util::GetInputMethodIDByKeyboardLayout("xkb:fr::fra"));
197 205
198 // Add keyboard layouts to enable the mode indicator. 206 // Add keyboard layouts to enable the mode indicator.
199 imm->EnableLoginLayouts("fr", keyboard_layouts); 207 imm->EnableLoginLayouts("fr", keyboard_layouts);
200 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); 208 ASSERT_LT(1UL, imm->GetNumActiveInputMethods());
201 209
202 chromeos::IMECandidateWindowHandlerInterface* candidate_window = 210 chromeos::IMECandidateWindowHandlerInterface* candidate_window =
203 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); 211 chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
204 candidate_window->FocusStateChanged(true); 212 candidate_window->FocusStateChanged(true);
205 213
206 { 214 {
207 ScopedModeIndicatorObserverForTesting observer; 215 ScopedModeIndicatorObserverForTesting observer;
208 216
209 EXPECT_TRUE(imm->SwitchToNextInputMethod()); 217 EXPECT_TRUE(imm->SwitchToNextInputMethod());
210 EXPECT_EQ(1UL, observer.max_widget_list_size()); 218 EXPECT_EQ(1UL, observer.max_widget_list_size());
211 const views::Widget* widget1 = observer.widget_list()[0]; 219 const views::Widget* widget1 = observer.widget_list()[0];
212 220
213 EXPECT_TRUE(imm->SwitchToNextInputMethod()); 221 EXPECT_TRUE(imm->SwitchToNextInputMethod());
214 EXPECT_EQ(2UL, observer.max_widget_list_size()); 222 EXPECT_EQ(2UL, observer.max_widget_list_size());
215 223
216 // When a new mode indicator is displayed, the previous one should be 224 // When a new mode indicator is displayed, the previous one should be
217 // closed. 225 // closed.
218 content::RunAllPendingInMessageLoop(); 226 content::RunAllPendingInMessageLoop();
219 EXPECT_EQ(1UL, observer.widget_list_size()); 227 EXPECT_EQ(1UL, observer.widget_list_size());
220 const views::Widget* widget2 = observer.widget_list()[0]; 228 const views::Widget* widget2 = observer.widget_list()[0];
221 EXPECT_NE(widget1, widget2); 229 EXPECT_NE(widget1, widget2);
222 } 230 }
223 } 231 }
224 } // namespace input_method 232 } // namespace input_method
225 } // namespace chromeos 233 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698