| 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 | |
| 428 // US keyboard + Thai = US keyboard + kesmanee. | 416 // US keyboard + Thai = US keyboard + kesmanee. |
| 429 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Th) { | 417 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Th) { |
| 430 const InputMethodDescriptor* descriptor = | 418 const InputMethodDescriptor* descriptor = |
| 431 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. | 419 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
| 432 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 420 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
| 433 std::vector<std::string> input_method_ids; | 421 std::vector<std::string> input_method_ids; |
| 434 util_.GetFirstLoginInputMethodIds("th", *descriptor, &input_method_ids); | 422 util_.GetFirstLoginInputMethodIds("th", *descriptor, &input_method_ids); |
| 435 ASSERT_EQ(2U, input_method_ids.size()); | 423 ASSERT_EQ(2U, input_method_ids.size()); |
| 436 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 424 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
| 437 EXPECT_EQ("_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_th", | 425 EXPECT_EQ("_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_th", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 EXPECT_FALSE(display_name.empty()) | 470 EXPECT_FALSE(display_name.empty()) |
| 483 << "Invalid language code " << language_code; | 471 << "Invalid language code " << language_code; |
| 484 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. | 472 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. |
| 485 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) | 473 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) |
| 486 << "Invalid language code " << language_code; | 474 << "Invalid language code " << language_code; |
| 487 } | 475 } |
| 488 } | 476 } |
| 489 | 477 |
| 490 } // namespace input_method | 478 } // namespace input_method |
| 491 } // namespace chromeos | 479 } // namespace chromeos |
| OLD | NEW |