| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const InputMethodDescriptor* descriptor = | 141 const InputMethodDescriptor* descriptor = |
| 142 GetInputMethodDescriptorFromId("pinyin"); | 142 GetInputMethodDescriptorFromId("pinyin"); |
| 143 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. | 143 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
| 144 EXPECT_EQ("pinyin", descriptor->id()); | 144 EXPECT_EQ("pinyin", descriptor->id()); |
| 145 EXPECT_EQ("us", descriptor->keyboard_layout()); | 145 EXPECT_EQ("us", descriptor->keyboard_layout()); |
| 146 // This used to be "zh" but now we have "zh-CN" in ibus_input_methods.h, | 146 // This used to be "zh" but now we have "zh-CN" in ibus_input_methods.h, |
| 147 // hence this should be zh-CN now. | 147 // hence this should be zh-CN now. |
| 148 EXPECT_EQ("zh-CN", descriptor->language_code()); | 148 EXPECT_EQ("zh-CN", descriptor->language_code()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(InputMethodUtilTest, GetInputMethodDescriptorFromXkbId) { |
| 152 EXPECT_EQ(NULL, GetInputMethodDescriptorFromXkbId("non_existent")); |
| 153 |
| 154 const InputMethodDescriptor* descriptor = |
| 155 GetInputMethodDescriptorFromXkbId("us(dvorak)"); |
| 156 ASSERT_TRUE(NULL != descriptor); // ASSERT_NE doesn't compile. |
| 157 EXPECT_EQ("xkb:us:dvorak:eng", descriptor->id()); |
| 158 EXPECT_EQ("us(dvorak)", descriptor->keyboard_layout()); |
| 159 EXPECT_EQ("eng", descriptor->language_code()); |
| 160 } |
| 161 |
| 151 TEST_F(InputMethodUtilTest, GetLanguageNativeDisplayNameFromCode) { | 162 TEST_F(InputMethodUtilTest, GetLanguageNativeDisplayNameFromCode) { |
| 152 EXPECT_EQ(UTF8ToUTF16("suomi"), GetLanguageNativeDisplayNameFromCode("fi")); | 163 EXPECT_EQ(UTF8ToUTF16("suomi"), GetLanguageNativeDisplayNameFromCode("fi")); |
| 153 } | 164 } |
| 154 | 165 |
| 155 TEST_F(InputMethodUtilTest, SortLanguageCodesByNames) { | 166 TEST_F(InputMethodUtilTest, SortLanguageCodesByNames) { |
| 156 std::vector<std::string> language_codes; | 167 std::vector<std::string> language_codes; |
| 157 // Check if this function can handle an empty list. | 168 // Check if this function can handle an empty list. |
| 158 SortLanguageCodesByNames(&language_codes); | 169 SortLanguageCodesByNames(&language_codes); |
| 159 | 170 |
| 160 language_codes.push_back("ja"); | 171 language_codes.push_back("ja"); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 std::vector<std::string> language_codes; | 323 std::vector<std::string> language_codes; |
| 313 GetLanguageCodesFromInputMethodIds(input_method_ids, &language_codes); | 324 GetLanguageCodesFromInputMethodIds(input_method_ids, &language_codes); |
| 314 ASSERT_EQ(3U, language_codes.size()); | 325 ASSERT_EQ(3U, language_codes.size()); |
| 315 EXPECT_EQ("en-US", language_codes[0]); | 326 EXPECT_EQ("en-US", language_codes[0]); |
| 316 EXPECT_EQ("ja", language_codes[1]); | 327 EXPECT_EQ("ja", language_codes[1]); |
| 317 EXPECT_EQ("fr", language_codes[2]); | 328 EXPECT_EQ("fr", language_codes[2]); |
| 318 } | 329 } |
| 319 | 330 |
| 320 } // namespace input_method | 331 } // namespace input_method |
| 321 } // namespace chromeos | 332 } // namespace chromeos |
| OLD | NEW |