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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 #else | 49 #else |
50 typedef testing::Test LanguageOptionsHandlerTest; | 50 typedef testing::Test LanguageOptionsHandlerTest; |
51 #endif | 51 #endif |
52 | 52 |
53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
54 TEST_F(LanguageOptionsHandlerTest, GetInputMethodList) { | 54 TEST_F(LanguageOptionsHandlerTest, GetInputMethodList) { |
55 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); | 55 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); |
56 scoped_ptr<ListValue> list( | 56 scoped_ptr<ListValue> list( |
57 chromeos::CrosLanguageOptionsHandler::GetInputMethodList(descriptors)); | 57 chromeos::options2::CrosLanguageOptionsHandler::GetInputMethodList( |
| 58 descriptors)); |
58 ASSERT_EQ(4U, list->GetSize()); | 59 ASSERT_EQ(4U, list->GetSize()); |
59 | 60 |
60 DictionaryValue* entry = NULL; | 61 DictionaryValue* entry = NULL; |
61 DictionaryValue *language_code_set = NULL; | 62 DictionaryValue *language_code_set = NULL; |
62 std::string input_method_id; | 63 std::string input_method_id; |
63 std::string display_name; | 64 std::string display_name; |
64 std::string language_code; | 65 std::string language_code; |
65 | 66 |
66 // As shown below, the list should be input method ids should appear in | 67 // As shown below, the list should be input method ids should appear in |
67 // the same order of the descriptors. | 68 // the same order of the descriptors. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); | 102 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); |
102 EXPECT_EQ("mozc", input_method_id); | 103 EXPECT_EQ("mozc", input_method_id); |
103 // Commented out. See above. | 104 // Commented out. See above. |
104 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); | 105 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); |
105 ASSERT_TRUE(language_code_set->HasKey("ja")); | 106 ASSERT_TRUE(language_code_set->HasKey("ja")); |
106 } | 107 } |
107 | 108 |
108 TEST_F(LanguageOptionsHandlerTest, GetLanguageList) { | 109 TEST_F(LanguageOptionsHandlerTest, GetLanguageList) { |
109 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); | 110 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); |
110 scoped_ptr<ListValue> list( | 111 scoped_ptr<ListValue> list( |
111 chromeos::CrosLanguageOptionsHandler::GetLanguageList(descriptors)); | 112 chromeos::options2::CrosLanguageOptionsHandler::GetLanguageList( |
| 113 descriptors)); |
112 ASSERT_EQ(8U, list->GetSize()); | 114 ASSERT_EQ(8U, list->GetSize()); |
113 | 115 |
114 DictionaryValue* entry = NULL; | 116 DictionaryValue* entry = NULL; |
115 std::string language_code; | 117 std::string language_code; |
116 std::string display_name; | 118 std::string display_name; |
117 std::string native_display_name; | 119 std::string native_display_name; |
118 | 120 |
119 // As shown below, the list should be sorted by the display names, | 121 // As shown below, the list should be sorted by the display names, |
120 // and these names should not have duplicates. | 122 // and these names should not have duplicates. |
121 | 123 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); | 188 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); |
187 EXPECT_EQ("es-419", language_code); | 189 EXPECT_EQ("es-419", language_code); |
188 EXPECT_EQ("Spanish (Latin America)", display_name); | 190 EXPECT_EQ("Spanish (Latin America)", display_name); |
189 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica)", native_display_name); | 191 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica)", native_display_name); |
190 } | 192 } |
191 #endif // defined(OS_CHROMEOS) | 193 #endif // defined(OS_CHROMEOS) |
192 | 194 |
193 #if !defined(OS_MACOSX) | 195 #if !defined(OS_MACOSX) |
194 TEST_F(LanguageOptionsHandlerTest, GetUILanguageCodeSet) { | 196 TEST_F(LanguageOptionsHandlerTest, GetUILanguageCodeSet) { |
195 scoped_ptr<DictionaryValue> dictionary( | 197 scoped_ptr<DictionaryValue> dictionary( |
196 LanguageOptionsHandler::GetUILanguageCodeSet()); | 198 options2::LanguageOptionsHandler::GetUILanguageCodeSet()); |
197 EXPECT_TRUE(dictionary->HasKey("en-US")); | 199 EXPECT_TRUE(dictionary->HasKey("en-US")); |
198 // Note that we don't test a false case, as such an expectation will | 200 // Note that we don't test a false case, as such an expectation will |
199 // fail when we add support for the language. | 201 // fail when we add support for the language. |
200 // EXPECT_FALSE(dictionary->HasKey("no")); | 202 // EXPECT_FALSE(dictionary->HasKey("no")); |
201 } | 203 } |
202 #endif // !defined(OS_MACOSX) | 204 #endif // !defined(OS_MACOSX) |
203 | 205 |
204 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { | 206 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { |
205 scoped_ptr<DictionaryValue> dictionary( | 207 scoped_ptr<DictionaryValue> dictionary( |
206 LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); | 208 options2::LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); |
207 EXPECT_TRUE(dictionary->HasKey("en-US")); | 209 EXPECT_TRUE(dictionary->HasKey("en-US")); |
208 } | 210 } |
OLD | NEW |