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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 EXPECT_TRUE(l10n_util::IsValidLocaleSyntax(language_code)) | 444 EXPECT_TRUE(l10n_util::IsValidLocaleSyntax(language_code)) |
445 << "Invalid language code " << language_code; | 445 << "Invalid language code " << language_code; |
446 EXPECT_FALSE(display_name.empty()) | 446 EXPECT_FALSE(display_name.empty()) |
447 << "Invalid language code " << language_code; | 447 << "Invalid language code " << language_code; |
448 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. | 448 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. |
449 EXPECT_NE(language_code, base::UTF16ToUTF8(display_name)) | 449 EXPECT_NE(language_code, base::UTF16ToUTF8(display_name)) |
450 << "Invalid language code " << language_code; | 450 << "Invalid language code " << language_code; |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
| 454 // Test the input method ID migration. |
| 455 TEST_F(InputMethodUtilTest, TestInputMethodIDMigration) { |
| 456 const char* const migration_cases[][2] = { |
| 457 {"ime:zh:pinyin", "zh-t-i0-pinyin"}, |
| 458 {"ime:zh-t:zhuyin", "zh-hant-t-i0-und"}, |
| 459 {"ime:zh-t:quick", "zh-hant-t-i0-cangjie-1987-x-m0-simplified"}, |
| 460 {"ime:jp:mozc_us", "nacl_mozc_us"}, |
| 461 {"ime:ko:hangul", "hangul_2set"}, |
| 462 {"m17n:deva_phone", "vkd_deva_phone"}, |
| 463 {"m17n:ar", "vkd_ar"}, |
| 464 {"t13n:hi", "hi-t-i0-und"}, |
| 465 {"unknown", "unknown"}, |
| 466 }; |
| 467 std::vector<std::string> input_method_ids; |
| 468 for (size_t i = 0; i < arraysize(migration_cases); ++i) |
| 469 input_method_ids.push_back(migration_cases[i][0]); |
| 470 // Duplicated hangul_2set. |
| 471 input_method_ids.push_back("ime:ko:hangul_2set"); |
| 472 |
| 473 util_.MigrateInputMethods(&input_method_ids); |
| 474 |
| 475 EXPECT_EQ(arraysize(migration_cases), input_method_ids.size()); |
| 476 for (size_t i = 0; i < arraysize(migration_cases); ++i) { |
| 477 EXPECT_EQ( |
| 478 extension_ime_util::GetInputMethodIDByEngineID(migration_cases[i][1]), |
| 479 input_method_ids[i]); |
| 480 } |
| 481 } |
| 482 |
454 } // namespace input_method | 483 } // namespace input_method |
455 } // namespace chromeos | 484 } // namespace chromeos |
OLD | NEW |