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

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: 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 bool IsContained(const InputMethodDescriptors& descriptors,
satorux1 2013/04/19 03:54:17 function comment is missing. Besides, IsContained(
Seigo Nonaka 2013/04/20 04:50:31 Done.
35 const InputMethodDescriptor& target) {
36 for (size_t i = 0; i < descriptors.size(); ++i) {
37 if (descriptors[i].id() == target.id())
38 return true;
39 }
40 return false;
41 }
42
34 class InputMethodManagerImplTest : public testing::Test { 43 class InputMethodManagerImplTest : public testing::Test {
35 public: 44 public:
36 InputMethodManagerImplTest() 45 InputMethodManagerImplTest()
37 : delegate_(NULL), 46 : delegate_(NULL),
38 controller_(NULL), 47 controller_(NULL),
39 candidate_window_controller_(NULL), 48 candidate_window_controller_(NULL),
40 xkeyboard_(NULL) { 49 xkeyboard_(NULL) {
41 } 50 }
42 virtual ~InputMethodManagerImplTest() {} 51 virtual ~InputMethodManagerImplTest() {}
43 52
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 246 }
238 247
239 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { 248 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
240 scoped_ptr<InputMethodDescriptors> methods( 249 scoped_ptr<InputMethodDescriptors> methods(
241 manager_->GetSupportedInputMethods()); 250 manager_->GetSupportedInputMethods());
242 ASSERT_TRUE(methods.get()); 251 ASSERT_TRUE(methods.get());
243 // Try to find random 4-5 layuts and IMEs to make sure the returned list is 252 // Try to find random 4-5 layuts and IMEs to make sure the returned list is
244 // correct. 253 // correct.
245 const InputMethodDescriptor* id_to_find = 254 const InputMethodDescriptor* id_to_find =
246 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc"); 255 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( 256 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
250 "mozc-chewing"); 257 "mozc-chewing");
258 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
251 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 259 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
252 "xkb:us::eng"); 260 "xkb:us::eng");
253 EXPECT_NE(methods->end(), 261 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
254 std::find(methods->begin(), methods->end(), *id_to_find));
255 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 262 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
256 "xkb:us:dvorak:eng"); 263 "xkb:us:dvorak:eng");
257 EXPECT_NE(methods->end(), 264 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
258 std::find(methods->begin(), methods->end(), *id_to_find));
259 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 265 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
260 "xkb:fr::fra"); 266 "xkb:fr::fra");
261 EXPECT_NE(methods->end(), 267 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
262 std::find(methods->begin(), methods->end(), *id_to_find));
263 } 268 }
264 269
265 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { 270 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
266 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See 271 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See
267 // ibus_input_method.txt. 272 // ibus_input_method.txt.
268 ComponentExtensionInitialize(); 273 ComponentExtensionInitialize();
269 manager_->EnableLayouts("en-US", ""); 274 manager_->EnableLayouts("en-US", "");
270 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 275 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
271 { 276 {
272 // For http://crbug.com/19655#c11 - (1) 277 // For http://crbug.com/19655#c11 - (1)
273 scoped_ptr<InputMethodDescriptors> methods( 278 scoped_ptr<InputMethodDescriptors> methods(
274 manager_->GetActiveInputMethods()); 279 manager_->GetActiveInputMethods());
275 const InputMethodDescriptor* id_to_find = 280 const InputMethodDescriptor* id_to_find =
276 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 281 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
277 "english-m"); // The "English Mystery" IME. 282 "english-m"); // The "English Mystery" IME.
278 EXPECT_EQ(methods->end(), 283 EXPECT_FALSE(IsContained(*methods.get(), *id_to_find));
279 std::find(methods->begin(), methods->end(), *id_to_find));
280 } 284 }
281 // For http://crbug.com/19655#c11 - (2) 285 // For http://crbug.com/19655#c11 - (2)
282 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); 286 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count());
283 287
284 // For http://crbug.com/19655#c11 - (5) 288 // For http://crbug.com/19655#c11 - (5)
285 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. 289 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U.
286 manager_->EnableLayouts("ja", ""); // Japanese 290 manager_->EnableLayouts("ja", ""); // Japanese
287 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 291 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
288 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); 292 EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count());
289 } 293 }
(...skipping 13 matching lines...) Expand all
303 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { 307 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
304 manager_->EnableLayouts("ko", ""); // Korean 308 manager_->EnableLayouts("ko", ""); // Korean
305 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 309 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
306 scoped_ptr<InputMethodDescriptors> methods( 310 scoped_ptr<InputMethodDescriptors> methods(
307 manager_->GetActiveInputMethods()); 311 manager_->GetActiveInputMethods());
308 ASSERT_TRUE(methods.get()); 312 ASSERT_TRUE(methods.get());
309 EXPECT_EQ(2U, methods->size()); 313 EXPECT_EQ(2U, methods->size());
310 const InputMethodDescriptor* id_to_find = 314 const InputMethodDescriptor* id_to_find =
311 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 315 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
312 "xkb:us::eng"); 316 "xkb:us::eng");
313 EXPECT_NE(methods->end(), 317 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
314 std::find(methods->begin(), methods->end(), *id_to_find));
315 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 318 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
316 "xkb:kr:kr104:kor"); 319 "xkb:kr:kr104:kor");
317 EXPECT_NE(methods->end(), 320 EXPECT_TRUE(IsContained(*methods.get(), *id_to_find));
318 std::find(methods->begin(), methods->end(), *id_to_find));
319 } 321 }
320 322
321 TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) { 323 TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) {
322 InputMethodConfigValue config; 324 InputMethodConfigValue config;
323 config.type = InputMethodConfigValue::kValueTypeString; 325 config.type = InputMethodConfigValue::kValueTypeString;
324 config.string_value = "string"; 326 config.string_value = "string";
325 EXPECT_EQ(0, controller_->set_input_method_config_internal_count_); 327 EXPECT_EQ(0, controller_->set_input_method_config_internal_count_);
326 EXPECT_TRUE(manager_->SetInputMethodConfig("section", "name", config)); 328 EXPECT_TRUE(manager_->SetInputMethodConfig("section", "name", config));
327 EXPECT_EQ(1, controller_->set_input_method_config_internal_count_); 329 EXPECT_EQ(1, controller_->set_input_method_config_internal_count_);
328 EXPECT_EQ("section", 330 EXPECT_EQ("section",
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1196 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1195 EXPECT_EQ(1, controller_->change_input_method_count_); 1197 EXPECT_EQ(1, controller_->change_input_method_count_);
1196 EXPECT_EQ(ext_id1, controller_->change_input_method_id_); 1198 EXPECT_EQ(ext_id1, controller_->change_input_method_id_);
1197 manager_->ChangeInputMethod(ext_id2); 1199 manager_->ChangeInputMethod(ext_id2);
1198 EXPECT_EQ(2, controller_->change_input_method_count_); 1200 EXPECT_EQ(2, controller_->change_input_method_count_);
1199 EXPECT_EQ(ext_id2, controller_->change_input_method_id_); 1201 EXPECT_EQ(ext_id2, controller_->change_input_method_id_);
1200 } 1202 }
1201 1203
1202 } // namespace input_method 1204 } // namespace input_method
1203 } // namespace chromeos 1205 } // 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