OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 std::vector<std::string> input_method_ids; | 263 std::vector<std::string> input_method_ids; |
264 input_method_ids.push_back("xkb:fr::fra"); // France - French | 264 input_method_ids.push_back("xkb:fr::fra"); // France - French |
265 input_method_ids.push_back("xkb:be::fra"); // Belgium - French | 265 input_method_ids.push_back("xkb:be::fra"); // Belgium - French |
266 // If the list is already sorted, nothing should happen. | 266 // If the list is already sorted, nothing should happen. |
267 ReorderInputMethodIdsForLanguageCode("fr", &input_method_ids); | 267 ReorderInputMethodIdsForLanguageCode("fr", &input_method_ids); |
268 ASSERT_EQ(2U, input_method_ids.size()); | 268 ASSERT_EQ(2U, input_method_ids.size()); |
269 EXPECT_EQ("xkb:fr::fra", input_method_ids[0]); | 269 EXPECT_EQ("xkb:fr::fra", input_method_ids[0]); |
270 EXPECT_EQ("xkb:be::fra", input_method_ids[1]); | 270 EXPECT_EQ("xkb:be::fra", input_method_ids[1]); |
271 } | 271 } |
272 | 272 |
| 273 TEST(LanguageConfigModelTest, GetInputMethodIdsForLanguageCode) { |
| 274 std::multimap<std::string, std::string> language_code_to_ids_map; |
| 275 language_code_to_ids_map.insert(std::make_pair("ja", "mozc")); |
| 276 language_code_to_ids_map.insert(std::make_pair("ja", "mozc-jp")); |
| 277 language_code_to_ids_map.insert(std::make_pair("ja", "xkb:jp:jpn")); |
| 278 language_code_to_ids_map.insert(std::make_pair("fr", "xkb:fr:fra")); |
| 279 |
| 280 std::vector<std::string> result; |
| 281 EXPECT_TRUE(GetInputMethodIdsFromLanguageCodeInternal( |
| 282 language_code_to_ids_map, "ja", kAllInputMethods, &result)); |
| 283 EXPECT_EQ(3U, result.size()); |
| 284 EXPECT_TRUE(GetInputMethodIdsFromLanguageCodeInternal( |
| 285 language_code_to_ids_map, "ja", kKeyboardLayoutsOnly, &result)); |
| 286 ASSERT_EQ(1U, result.size()); |
| 287 EXPECT_EQ("xkb:jp:jpn", result[0]); |
| 288 |
| 289 EXPECT_TRUE(GetInputMethodIdsFromLanguageCodeInternal( |
| 290 language_code_to_ids_map, "fr", kAllInputMethods, &result)); |
| 291 ASSERT_EQ(1U, result.size()); |
| 292 EXPECT_EQ("xkb:fr:fra", result[0]); |
| 293 EXPECT_TRUE(GetInputMethodIdsFromLanguageCodeInternal( |
| 294 language_code_to_ids_map, "fr", kKeyboardLayoutsOnly, &result)); |
| 295 ASSERT_EQ(1U, result.size()); |
| 296 EXPECT_EQ("xkb:fr:fra", result[0]); |
| 297 |
| 298 EXPECT_FALSE(GetInputMethodIdsFromLanguageCodeInternal( |
| 299 language_code_to_ids_map, "invalid_lang", kAllInputMethods, &result)); |
| 300 EXPECT_FALSE(GetInputMethodIdsFromLanguageCodeInternal( |
| 301 language_code_to_ids_map, "invalid_lang", kKeyboardLayoutsOnly, &result)); |
| 302 } |
| 303 |
273 } // namespace input_method | 304 } // namespace input_method |
274 } // namespace chromeos | 305 } // namespace chromeos |
OLD | NEW |