Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: chrome/browser/dom_ui/options/language_options_handler_unittest.cc

Issue 6296017: dom-ui settings: enable languages & spell checker settings for all platforms.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: code review tweak Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // TODO(csilv): This is for the move CL. Changes to make this cross-platform
6 // will come in the followup CL.
7 #if defined(OS_CHROMEOS)
8
9 #include "chrome/browser/dom_ui/options/language_options_handler.h" 5 #include "chrome/browser/dom_ui/options/language_options_handler.h"
10 6
11 #include <string> 7 #include <string>
12 8
13 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
14 #include "base/values.h" 10 #include "base/values.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/chromeos/cros/cros_library.h" 14 #include "chrome/browser/chromeos/cros/cros_library.h"
16 #include "chrome/browser/chromeos/cros/input_method_library.h" 15 #include "chrome/browser/chromeos/cros/input_method_library.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #endif // defined(OS_CHROMEOS)
18 17
19 namespace chromeos { 18 #if defined(OS_CHROMEOS)
20 19 static chromeos::InputMethodDescriptors CreateInputMethodDescriptors() {
21 static InputMethodDescriptors CreateInputMethodDescriptors() { 20 chromeos::InputMethodDescriptors descriptors;
22 InputMethodDescriptors descriptors;
23 descriptors.push_back( 21 descriptors.push_back(
24 InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng")); 22 chromeos::InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng"));
25 descriptors.push_back( 23 descriptors.push_back(
26 InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra")); 24 chromeos::InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra"));
27 descriptors.push_back( 25 descriptors.push_back(
28 InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr")); 26 chromeos::InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr"));
29 descriptors.push_back( 27 descriptors.push_back(
30 InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us", "ja")); 28 chromeos::InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us",
29 "ja"));
31 return descriptors; 30 return descriptors;
32 } 31 }
33 32
34 TEST(LanguageOptionsHandlerTest, GetInputMethodList) { 33 TEST(LanguageOptionsHandlerTest, GetInputMethodList) {
35 // Use the stub libcros. The object will take care of the cleanup. 34 // Use the stub libcros. The object will take care of the cleanup.
36 ScopedStubCrosEnabler stub_cros_enabler; 35 chromeos::ScopedStubCrosEnabler stub_cros_enabler;
37 36
38 // Reset the library implementation so it will be initialized 37 // Reset the library implementation so it will be initialized
39 // again. Otherwise, non-stub implementation can be reused, if it's 38 // again. Otherwise, non-stub implementation can be reused, if it's
40 // already initialized elsewhere, which results in a crash. 39 // already initialized elsewhere, which results in a crash.
41 CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL, false); 40 chromeos::CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL,
41 false);
42 42
43 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); 43 chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
44 scoped_ptr<ListValue> list( 44 scoped_ptr<ListValue> list(
45 LanguageOptionsHandler::GetInputMethodList(descriptors)); 45 LanguageOptionsHandler::GetInputMethodList(descriptors));
46 ASSERT_EQ(4U, list->GetSize()); 46 ASSERT_EQ(4U, list->GetSize());
47 47
48 DictionaryValue* entry = NULL; 48 DictionaryValue* entry = NULL;
49 DictionaryValue *language_code_set = NULL; 49 DictionaryValue *language_code_set = NULL;
50 std::string input_method_id; 50 std::string input_method_id;
51 std::string display_name; 51 std::string display_name;
52 std::string language_code; 52 std::string language_code;
53 53
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ASSERT_TRUE(entry->GetString("id", &input_method_id)); 87 ASSERT_TRUE(entry->GetString("id", &input_method_id));
88 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 88 ASSERT_TRUE(entry->GetString("displayName", &display_name));
89 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); 89 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
90 EXPECT_EQ("mozc", input_method_id); 90 EXPECT_EQ("mozc", input_method_id);
91 // Commented out. See above. 91 // Commented out. See above.
92 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); 92 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name);
93 ASSERT_TRUE(language_code_set->HasKey("ja")); 93 ASSERT_TRUE(language_code_set->HasKey("ja"));
94 } 94 }
95 95
96 TEST(LanguageOptionsHandlerTest, GetLanguageList) { 96 TEST(LanguageOptionsHandlerTest, GetLanguageList) {
97 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); 97 chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
98 scoped_ptr<ListValue> list( 98 scoped_ptr<ListValue> list(
99 LanguageOptionsHandler::GetLanguageList(descriptors)); 99 LanguageOptionsHandler::GetLanguageList(descriptors));
100 ASSERT_EQ(6U, list->GetSize()); 100 ASSERT_EQ(6U, list->GetSize());
101 101
102 DictionaryValue* entry = NULL; 102 DictionaryValue* entry = NULL;
103 std::string language_code; 103 std::string language_code;
104 std::string display_name; 104 std::string display_name;
105 std::string native_display_name; 105 std::string native_display_name;
106 106
107 // As shown below, the list should be sorted by the display names, 107 // As shown below, the list should be sorted by the display names,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // This comes from kExtraLanguages. 151 // This comes from kExtraLanguages.
152 ASSERT_TRUE(list->GetDictionary(5, &entry)); 152 ASSERT_TRUE(list->GetDictionary(5, &entry));
153 ASSERT_TRUE(entry->GetString("code", &language_code)); 153 ASSERT_TRUE(entry->GetString("code", &language_code));
154 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 154 ASSERT_TRUE(entry->GetString("displayName", &display_name));
155 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name)); 155 ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
156 EXPECT_EQ("es-419", language_code); 156 EXPECT_EQ("es-419", language_code);
157 EXPECT_EQ("Spanish (Latin America and the Caribbean)", display_name); 157 EXPECT_EQ("Spanish (Latin America and the Caribbean)", display_name);
158 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica y el Caribe)", 158 EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica y el Caribe)",
159 native_display_name); 159 native_display_name);
160 } 160 }
161 #endif // defined(OS_CHROMEOS)
161 162
162 TEST(LanguageOptionsHandlerTest, GetUiLanguageCodeSet) { 163 #if !defined(OS_MACOSX)
164 TEST(LanguageOptionsHandlerTest, GetUILanguageCodeSet) {
163 scoped_ptr<DictionaryValue> dictionary( 165 scoped_ptr<DictionaryValue> dictionary(
164 LanguageOptionsHandler::GetUiLanguageCodeSet()); 166 LanguageOptionsHandler::GetUILanguageCodeSet());
165 EXPECT_TRUE(dictionary->HasKey("en-US")); 167 EXPECT_TRUE(dictionary->HasKey("en-US"));
166 // Note that we don't test a false case, as such an expectation will 168 // Note that we don't test a false case, as such an expectation will
167 // fail when we add support for the language. 169 // fail when we add support for the language.
168 // EXPECT_FALSE(dictionary->HasKey("no")); 170 // EXPECT_FALSE(dictionary->HasKey("no"));
169 } 171 }
172 #endif // !defined(OS_MACOSX)
170 173
171 TEST(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { 174 TEST(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) {
172 scoped_ptr<DictionaryValue> dictionary( 175 scoped_ptr<DictionaryValue> dictionary(
173 LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); 176 LanguageOptionsHandler::GetSpellCheckLanguageCodeSet());
174 EXPECT_TRUE(dictionary->HasKey("en-US")); 177 EXPECT_TRUE(dictionary->HasKey("en-US"));
175 } 178 }
176
177 } // namespace chromeos
178
179 #endif // OS_CHROMEOS
180
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/options/language_options_handler.cc ('k') | chrome/browser/dom_ui/options/options_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698