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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 const InputMethodDescriptor* descriptor = | 394 const InputMethodDescriptor* descriptor = |
395 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. | 395 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
396 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 396 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
397 std::vector<std::string> input_method_ids; | 397 std::vector<std::string> input_method_ids; |
398 util_.GetFirstLoginInputMethodIds("zh-CN", *descriptor, &input_method_ids); | 398 util_.GetFirstLoginInputMethodIds("zh-CN", *descriptor, &input_method_ids); |
399 ASSERT_EQ(2U, input_method_ids.size()); | 399 ASSERT_EQ(2U, input_method_ids.size()); |
400 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 400 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
401 EXPECT_EQ(pinyin_ime_id, input_method_ids[1]); // Pinyin for US keybaord. | 401 EXPECT_EQ(pinyin_ime_id, input_method_ids[1]); // Pinyin for US keybaord. |
402 } | 402 } |
403 | 403 |
404 // Korean keyboard + Korean UI = Korean keyboard + mozc-hangul. | |
405 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_KR_And_Ko) { | |
406 // Korean keyboard | |
407 const InputMethodDescriptor* descriptor = | |
408 util_.GetInputMethodDescriptorFromId("xkb:kr:kr104:kor"); | |
409 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | |
410 std::vector<std::string> input_method_ids; | |
411 util_.GetFirstLoginInputMethodIds("ko", *descriptor, &input_method_ids); | |
412 ASSERT_EQ(2U, input_method_ids.size()); | |
413 EXPECT_EQ("xkb:kr:kr104:kor", input_method_ids[0]); | |
414 EXPECT_EQ("mozc-hangul", input_method_ids[1]); // Mozc for JP keybaord. | |
415 } | |
416 | |
417 // US keyboard + Russian UI = US keyboard + Russsian keyboard | 404 // US keyboard + Russian UI = US keyboard + Russsian keyboard |
418 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Ru) { | 405 TEST_F(InputMethodUtilTest, TestGetFirstLoginInputMethodIds_Us_And_Ru) { |
419 const InputMethodDescriptor* descriptor = | 406 const InputMethodDescriptor* descriptor = |
420 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. | 407 util_.GetInputMethodDescriptorFromId("xkb:us::eng"); // US keyboard. |
421 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 408 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
422 std::vector<std::string> input_method_ids; | 409 std::vector<std::string> input_method_ids; |
423 util_.GetFirstLoginInputMethodIds("ru", *descriptor, &input_method_ids); | 410 util_.GetFirstLoginInputMethodIds("ru", *descriptor, &input_method_ids); |
424 ASSERT_EQ(2U, input_method_ids.size()); | 411 ASSERT_EQ(2U, input_method_ids.size()); |
425 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 412 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
426 EXPECT_EQ("xkb:ru::rus", input_method_ids[1]); // Russian keyboard. | 413 EXPECT_EQ("xkb:ru::rus", input_method_ids[1]); // Russian keyboard. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 EXPECT_FALSE(display_name.empty()) | 482 EXPECT_FALSE(display_name.empty()) |
496 << "Invalid language code " << language_code; | 483 << "Invalid language code " << language_code; |
497 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. | 484 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. |
498 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) | 485 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) |
499 << "Invalid language code " << language_code; | 486 << "Invalid language code " << language_code; |
500 } | 487 } |
501 } | 488 } |
502 | 489 |
503 } // namespace input_method | 490 } // namespace input_method |
504 } // namespace chromeos | 491 } // namespace chromeos |
OLD | NEW |