OLD | NEW |
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_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 const InputMethodDescriptor* descriptor = | 406 const InputMethodDescriptor* descriptor = |
407 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. | 407 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
408 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 408 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
409 std::vector<std::string> input_method_ids; | 409 std::vector<std::string> input_method_ids; |
410 util_.GetFirstLoginInputMethodIds("ru", *descriptor, &input_method_ids); | 410 util_.GetFirstLoginInputMethodIds("ru", *descriptor, &input_method_ids); |
411 ASSERT_EQ(2U, input_method_ids.size()); | 411 ASSERT_EQ(2U, input_method_ids.size()); |
412 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 412 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
413 EXPECT_EQ("xkb:ru::rus", input_method_ids[1]); // Russian keyboard. | 413 EXPECT_EQ("xkb:ru::rus", input_method_ids[1]); // Russian keyboard. |
414 } | 414 } |
415 | 415 |
| 416 // US keyboard + Traditional Chinese = US keyboard + chewing. |
| 417 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_ZhTw) { |
| 418 const InputMethodDescriptor* descriptor = |
| 419 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
| 420 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
| 421 std::vector<std::string> input_method_ids; |
| 422 util_.GetFirstLoginInputMethodIds("zh-TW", *descriptor, &input_method_ids); |
| 423 ASSERT_EQ(2U, input_method_ids.size()); |
| 424 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
| 425 EXPECT_EQ(zhuyin_ime_id, input_method_ids[1]); // Chewing. |
| 426 } |
| 427 |
416 // US keyboard + Thai = US keyboard + kesmanee. | 428 // US keyboard + Thai = US keyboard + kesmanee. |
417 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Th) { | 429 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Th) { |
418 const InputMethodDescriptor* descriptor = | 430 const InputMethodDescriptor* descriptor = |
419 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. | 431 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
420 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 432 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
421 std::vector<std::string> input_method_ids; | 433 std::vector<std::string> input_method_ids; |
422 util_.GetFirstLoginInputMethodIds("th", *descriptor, &input_method_ids); | 434 util_.GetFirstLoginInputMethodIds("th", *descriptor, &input_method_ids); |
423 ASSERT_EQ(2U, input_method_ids.size()); | 435 ASSERT_EQ(2U, input_method_ids.size()); |
424 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 436 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
425 EXPECT_EQ("_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_th", | 437 EXPECT_EQ("_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_th", |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 EXPECT_FALSE(display_name.empty()) | 482 EXPECT_FALSE(display_name.empty()) |
471 << "Invalid language code " << language_code; | 483 << "Invalid language code " << language_code; |
472 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. | 484 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. |
473 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) | 485 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) |
474 << "Invalid language code " << language_code; | 486 << "Invalid language code " << language_code; |
475 } | 487 } |
476 } | 488 } |
477 | 489 |
478 } // namespace input_method | 490 } // namespace input_method |
479 } // namespace chromeos | 491 } // namespace chromeos |
OLD | NEW |