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/ui/webui/options2/language_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/language_options_handler2.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Commented out. See above. | 115 // Commented out. See above. |
116 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); | 116 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); |
117 ASSERT_TRUE(language_code_set->HasKey("ja")); | 117 ASSERT_TRUE(language_code_set->HasKey("ja")); |
118 } | 118 } |
119 | 119 |
120 TEST_F(LanguageOptionsHandlerTest, GetLanguageList) { | 120 TEST_F(LanguageOptionsHandlerTest, GetLanguageList) { |
121 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); | 121 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); |
122 scoped_ptr<ListValue> list( | 122 scoped_ptr<ListValue> list( |
123 chromeos::options2::CrosLanguageOptionsHandler::GetLanguageList( | 123 chromeos::options2::CrosLanguageOptionsHandler::GetLanguageList( |
124 descriptors)); | 124 descriptors)); |
125 ASSERT_EQ(8U, list->GetSize()); | 125 ASSERT_EQ(9U, list->GetSize()); |
126 | 126 |
127 DictionaryValue* entry = NULL; | 127 DictionaryValue* entry = NULL; |
128 std::string language_code; | 128 std::string language_code; |
129 std::string display_name; | 129 std::string display_name; |
130 std::string native_display_name; | 130 std::string native_display_name; |
131 | 131 |
132 // As shown below, the list should be sorted by the display names, | 132 // As shown below, the list should be sorted by the display names, |
133 // and these names should not have duplicates. | 133 // and these names should not have duplicates. |
134 | 134 |
135 // This comes from kExtraLanguages. | 135 // This comes from kExtraLanguages. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); | 190 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); |
191 EXPECT_EQ("ja", language_code); | 191 EXPECT_EQ("ja", language_code); |
192 EXPECT_EQ("Japanese", display_name); | 192 EXPECT_EQ("Japanese", display_name); |
193 EXPECT_EQ("\u65E5\u672C\u8A9E", native_display_name); | 193 EXPECT_EQ("\u65E5\u672C\u8A9E", native_display_name); |
194 | 194 |
195 // This comes from kExtraLanguages. | 195 // This comes from kExtraLanguages. |
196 ASSERT_TRUE(list->GetDictionary(7, &entry)); | 196 ASSERT_TRUE(list->GetDictionary(7, &entry)); |
197 ASSERT_TRUE(entry->GetString("code", &language_code)); | 197 ASSERT_TRUE(entry->GetString("code", &language_code)); |
198 ASSERT_TRUE(entry->GetString("displayName", &display_name)); | 198 ASSERT_TRUE(entry->GetString("displayName", &display_name)); |
199 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); | 199 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); |
| 200 EXPECT_EQ("ms", language_code); |
| 201 EXPECT_EQ("Malay", display_name); |
| 202 EXPECT_EQ("Bahasa Melayu", native_display_name); |
| 203 |
| 204 // This comes from kExtraLanguages. |
| 205 ASSERT_TRUE(list->GetDictionary(8, &entry)); |
| 206 ASSERT_TRUE(entry->GetString("code", &language_code)); |
| 207 ASSERT_TRUE(entry->GetString("displayName", &display_name)); |
| 208 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); |
200 EXPECT_EQ("es-419", language_code); | 209 EXPECT_EQ("es-419", language_code); |
201 EXPECT_EQ("Spanish (Latin America)", display_name); | 210 EXPECT_EQ("Spanish (Latin America)", display_name); |
202 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica)", native_display_name); | 211 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica)", native_display_name); |
203 } | 212 } |
204 #endif // defined(OS_CHROMEOS) | 213 #endif // defined(OS_CHROMEOS) |
205 | 214 |
206 #if !defined(OS_MACOSX) | 215 #if !defined(OS_MACOSX) |
207 TEST_F(LanguageOptionsHandlerTest, GetUILanguageCodeSet) { | 216 TEST_F(LanguageOptionsHandlerTest, GetUILanguageCodeSet) { |
208 scoped_ptr<DictionaryValue> dictionary( | 217 scoped_ptr<DictionaryValue> dictionary( |
209 options2::LanguageOptionsHandler::GetUILanguageCodeSet()); | 218 options2::LanguageOptionsHandler::GetUILanguageCodeSet()); |
210 EXPECT_TRUE(dictionary->HasKey("en-US")); | 219 EXPECT_TRUE(dictionary->HasKey("en-US")); |
211 // Note that we don't test a false case, as such an expectation will | 220 // Note that we don't test a false case, as such an expectation will |
212 // fail when we add support for the language. | 221 // fail when we add support for the language. |
213 // EXPECT_FALSE(dictionary->HasKey("no")); | 222 // EXPECT_FALSE(dictionary->HasKey("no")); |
214 } | 223 } |
215 #endif // !defined(OS_MACOSX) | 224 #endif // !defined(OS_MACOSX) |
216 | 225 |
217 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { | 226 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { |
218 scoped_ptr<DictionaryValue> dictionary( | 227 scoped_ptr<DictionaryValue> dictionary( |
219 options2::LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); | 228 options2::LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); |
220 EXPECT_TRUE(dictionary->HasKey("en-US")); | 229 EXPECT_TRUE(dictionary->HasKey("en-US")); |
221 } | 230 } |
OLD | NEW |