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

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

Issue 14123005: Remove operator function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 7 years, 8 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
« no previous file with comments | « no previous file | chromeos/chromeos.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/input_method/input_method_manager_impl.h" 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 13 matching lines...) Expand all
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/base/accelerators/accelerator.h" 25 #include "ui/base/accelerators/accelerator.h"
26 #include "ui/base/ime/text_input_test_support.h" 26 #include "ui/base/ime/text_input_test_support.h"
27 #include "ui/base/keycodes/keyboard_codes.h" 27 #include "ui/base/keycodes/keyboard_codes.h"
28 28
29 namespace chromeos { 29 namespace chromeos {
30 30
31 namespace input_method { 31 namespace input_method {
32 namespace { 32 namespace {
33 33
34 // Returns true if |descriptors| contain |target|.
35 bool Contain(const InputMethodDescriptors& descriptors,
36 const InputMethodDescriptor& target) {
37 for (size_t i = 0; i < descriptors.size(); ++i) {
38 if (descriptors[i].id() == target.id())
39 return true;
40 }
41 return false;
42 }
43
34 class InputMethodManagerImplTest : public testing::Test { 44 class InputMethodManagerImplTest : public testing::Test {
35 public: 45 public:
36 InputMethodManagerImplTest() 46 InputMethodManagerImplTest()
37 : delegate_(NULL), 47 : delegate_(NULL),
38 controller_(NULL), 48 controller_(NULL),
39 candidate_window_controller_(NULL), 49 candidate_window_controller_(NULL),
40 xkeyboard_(NULL) { 50 xkeyboard_(NULL) {
41 } 51 }
42 virtual ~InputMethodManagerImplTest() {} 52 virtual ~InputMethodManagerImplTest() {}
43 53
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 247 }
238 248
239 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { 249 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
240 scoped_ptr<InputMethodDescriptors> methods( 250 scoped_ptr<InputMethodDescriptors> methods(
241 manager_->GetSupportedInputMethods()); 251 manager_->GetSupportedInputMethods());
242 ASSERT_TRUE(methods.get()); 252 ASSERT_TRUE(methods.get());
243 // Try to find random 4-5 layuts and IMEs to make sure the returned list is 253 // Try to find random 4-5 layuts and IMEs to make sure the returned list is
244 // correct. 254 // correct.
245 const InputMethodDescriptor* id_to_find = 255 const InputMethodDescriptor* id_to_find =
246 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc"); 256 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc");
247 EXPECT_NE(methods->end(),
248 std::find(methods->begin(), methods->end(), *id_to_find));
249 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 257 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
250 "mozc-chewing"); 258 "mozc-chewing");
259 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
251 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 260 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
252 "xkb:us::eng"); 261 "xkb:us::eng");
253 EXPECT_NE(methods->end(), 262 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
254 std::find(methods->begin(), methods->end(), *id_to_find));
255 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 263 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
256 "xkb:us:dvorak:eng"); 264 "xkb:us:dvorak:eng");
257 EXPECT_NE(methods->end(), 265 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
258 std::find(methods->begin(), methods->end(), *id_to_find));
259 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 266 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
260 "xkb:fr::fra"); 267 "xkb:fr::fra");
261 EXPECT_NE(methods->end(), 268 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
262 std::find(methods->begin(), methods->end(), *id_to_find));
263 } 269 }
264 270
265 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { 271 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
266 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See 272 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See
267 // ibus_input_method.txt. 273 // ibus_input_method.txt.
268 ComponentExtensionInitialize(); 274 ComponentExtensionInitialize();
269 manager_->EnableLayouts("en-US", ""); 275 manager_->EnableLayouts("en-US", "");
270 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 276 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
271 { 277 {
272 // For http://crbug.com/19655#c11 - (1) 278 // For http://crbug.com/19655#c11 - (1)
273 scoped_ptr<InputMethodDescriptors> methods( 279 scoped_ptr<InputMethodDescriptors> methods(
274 manager_->GetActiveInputMethods()); 280 manager_->GetActiveInputMethods());
275 const InputMethodDescriptor* id_to_find = 281 const InputMethodDescriptor* id_to_find =
276 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 282 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
277 "english-m"); // The "English Mystery" IME. 283 "english-m"); // The "English Mystery" IME.
278 EXPECT_EQ(methods->end(), 284 EXPECT_FALSE(Contain(*methods.get(), *id_to_find));
279 std::find(methods->begin(), methods->end(), *id_to_find));
280 } 285 }
281 // For http://crbug.com/19655#c11 - (2) 286 // For http://crbug.com/19655#c11 - (2)
282 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); 287 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count());
283 288
284 // For http://crbug.com/19655#c11 - (5) 289 // For http://crbug.com/19655#c11 - (5)
285 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. 290 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U.
286 manager_->EnableLayouts("ja", ""); // Japanese 291 manager_->EnableLayouts("ja", ""); // Japanese
287 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 292 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
288 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); 293 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count());
289 } 294 }
(...skipping 13 matching lines...) Expand all
303 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { 308 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
304 manager_->EnableLayouts("ko", ""); // Korean 309 manager_->EnableLayouts("ko", ""); // Korean
305 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 310 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
306 scoped_ptr<InputMethodDescriptors> methods( 311 scoped_ptr<InputMethodDescriptors> methods(
307 manager_->GetActiveInputMethods()); 312 manager_->GetActiveInputMethods());
308 ASSERT_TRUE(methods.get()); 313 ASSERT_TRUE(methods.get());
309 EXPECT_EQ(2U, methods->size()); 314 EXPECT_EQ(2U, methods->size());
310 const InputMethodDescriptor* id_to_find = 315 const InputMethodDescriptor* id_to_find =
311 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 316 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
312 "xkb:us::eng"); 317 "xkb:us::eng");
313 EXPECT_NE(methods->end(), 318 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
314 std::find(methods->begin(), methods->end(), *id_to_find));
315 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 319 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
316 "xkb:kr:kr104:kor"); 320 "xkb:kr:kr104:kor");
317 EXPECT_NE(methods->end(), 321 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
318 std::find(methods->begin(), methods->end(), *id_to_find));
319 } 322 }
320 323
321 TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) { 324 TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) {
322 InputMethodConfigValue config; 325 InputMethodConfigValue config;
323 config.type = InputMethodConfigValue::kValueTypeString; 326 config.type = InputMethodConfigValue::kValueTypeString;
324 config.string_value = "string"; 327 config.string_value = "string";
325 EXPECT_EQ(0, controller_->set_input_method_config_internal_count_); 328 EXPECT_EQ(0, controller_->set_input_method_config_internal_count_);
326 EXPECT_TRUE(manager_->SetInputMethodConfig("section", "name", config)); 329 EXPECT_TRUE(manager_->SetInputMethodConfig("section", "name", config));
327 EXPECT_EQ(1, controller_->set_input_method_config_internal_count_); 330 EXPECT_EQ(1, controller_->set_input_method_config_internal_count_);
328 EXPECT_EQ("section", 331 EXPECT_EQ("section",
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1197 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1195 EXPECT_EQ(1, controller_->change_input_method_count_); 1198 EXPECT_EQ(1, controller_->change_input_method_count_);
1196 EXPECT_EQ(ext_id1, controller_->change_input_method_id_); 1199 EXPECT_EQ(ext_id1, controller_->change_input_method_id_);
1197 manager_->ChangeInputMethod(ext_id2); 1200 manager_->ChangeInputMethod(ext_id2);
1198 EXPECT_EQ(2, controller_->change_input_method_count_); 1201 EXPECT_EQ(2, controller_->change_input_method_count_);
1199 EXPECT_EQ(ext_id2, controller_->change_input_method_id_); 1202 EXPECT_EQ(ext_id2, controller_->change_input_method_id_);
1200 } 1203 }
1201 1204
1202 } // namespace input_method 1205 } // namespace input_method
1203 } // namespace chromeos 1206 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/chromeos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698