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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler_unittest.cc

Issue 23297004: Remove ExtraLanguage entries from InputMethodUtil. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove obsolete tests. Created 7 years, 4 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) 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/options/language_options_handler.h" 5 #include "chrome/browser/ui/webui/options/language_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 10 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
(...skipping 17 matching lines...) Expand all
28 chromeos::input_method::Shutdown(); 28 chromeos::input_method::Shutdown();
29 } 29 }
30 30
31 protected: 31 protected:
32 InputMethodDescriptors CreateInputMethodDescriptors() { 32 InputMethodDescriptors CreateInputMethodDescriptors() {
33 InputMethodDescriptors descriptors; 33 InputMethodDescriptors descriptors;
34 descriptors.push_back(GetDesc("xkb:us::eng", "us", "en-US")); 34 descriptors.push_back(GetDesc("xkb:us::eng", "us", "en-US"));
35 descriptors.push_back(GetDesc("xkb:fr::fra", "fr", "fr")); 35 descriptors.push_back(GetDesc("xkb:fr::fra", "fr", "fr"));
36 descriptors.push_back(GetDesc("xkb:be::fra", "be", "fr")); 36 descriptors.push_back(GetDesc("xkb:be::fra", "be", "fr"));
37 descriptors.push_back(GetDesc("xkb:is::ice", "is", "is")); 37 descriptors.push_back(GetDesc("xkb:is::ice", "is", "is"));
38 descriptors.push_back(GetDesc("mozc", "us", "ja"));
39 return descriptors; 38 return descriptors;
40 } 39 }
41 40
42 private: 41 private:
43 InputMethodDescriptor GetDesc(const std::string& id, 42 InputMethodDescriptor GetDesc(const std::string& id,
44 const std::string& raw_layout, 43 const std::string& raw_layout,
45 const std::string& language_code) { 44 const std::string& language_code) {
46 std::vector<std::string> layouts; 45 std::vector<std::string> layouts;
47 layouts.push_back(raw_layout); 46 layouts.push_back(raw_layout);
48 std::vector<std::string> languages; 47 std::vector<std::string> languages;
49 languages.push_back(language_code); 48 languages.push_back(language_code);
50 return InputMethodDescriptor(id, 49 return InputMethodDescriptor(id,
51 "", // name 50 "", // name
52 layouts, 51 layouts,
53 languages, 52 languages,
54 GURL()); // options page url 53 GURL()); // options page url
55 } 54 }
56 }; 55 };
57 56
58 } // namespace 57 } // namespace
59 58
60 TEST_F(CrosLanguageOptionsHandlerTest, GetInputMethodList) { 59 TEST_F(CrosLanguageOptionsHandlerTest, GetInputMethodList) {
61 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); 60 InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
62 scoped_ptr<ListValue> list( 61 scoped_ptr<ListValue> list(
63 chromeos::options::CrosLanguageOptionsHandler::GetInputMethodList( 62 chromeos::options::CrosLanguageOptionsHandler::GetInputMethodList(
64 descriptors)); 63 descriptors));
65 ASSERT_EQ(5U, list->GetSize()); 64 ASSERT_EQ(4U, list->GetSize());
66 65
67 DictionaryValue* entry = NULL; 66 DictionaryValue* entry = NULL;
68 DictionaryValue *language_code_set = NULL; 67 DictionaryValue *language_code_set = NULL;
69 std::string input_method_id; 68 std::string input_method_id;
70 std::string display_name; 69 std::string display_name;
71 std::string language_code; 70 std::string language_code;
72 71
73 // As shown below, the list should be input method ids should appear in 72 // As shown below, the list should be input method ids should appear in
74 // the same order of the descriptors. 73 // the same order of the descriptors.
75 ASSERT_TRUE(list->GetDictionary(0, &entry)); 74 ASSERT_TRUE(list->GetDictionary(0, &entry));
76 ASSERT_TRUE(entry->GetString("id", &input_method_id)); 75 ASSERT_TRUE(entry->GetString("id", &input_method_id));
77 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 76 ASSERT_TRUE(entry->GetString("displayName", &display_name));
78 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); 77 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
79 EXPECT_EQ("xkb:us::eng", input_method_id); 78 EXPECT_EQ("xkb:us::eng", input_method_id);
80 // Commented out as it depends on translation in generated_resources.grd 79 // Commented out as it depends on translation in generated_resources.grd
81 // (i.e. makes the test fragile). 80 // (i.e. makes the test fragile).
82 // EXPECT_EQ("English (USA) keyboard layout", display_name); 81 // EXPECT_EQ("English (USA) keyboard layout", display_name);
83 ASSERT_TRUE(language_code_set->HasKey("en-US")); 82 ASSERT_TRUE(language_code_set->HasKey("en-US"));
84 ASSERT_TRUE(language_code_set->HasKey("id")); // From kExtraLanguages.
85 ASSERT_TRUE(language_code_set->HasKey("fil")); // From kExtraLanguages.
86 83
87 ASSERT_TRUE(list->GetDictionary(1, &entry)); 84 ASSERT_TRUE(list->GetDictionary(1, &entry));
88 ASSERT_TRUE(entry->GetString("id", &input_method_id)); 85 ASSERT_TRUE(entry->GetString("id", &input_method_id));
89 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 86 ASSERT_TRUE(entry->GetString("displayName", &display_name));
90 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); 87 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
91 EXPECT_EQ("xkb:fr::fra", input_method_id); 88 EXPECT_EQ("xkb:fr::fra", input_method_id);
92 // Commented out. See above. 89 // Commented out. See above.
93 // EXPECT_EQ("French keyboard layout", display_name); 90 // EXPECT_EQ("French keyboard layout", display_name);
94 ASSERT_TRUE(language_code_set->HasKey("fr")); 91 ASSERT_TRUE(language_code_set->HasKey("fr"));
95 92
96 ASSERT_TRUE(list->GetDictionary(2, &entry)); 93 ASSERT_TRUE(list->GetDictionary(2, &entry));
97 ASSERT_TRUE(entry->GetString("id", &input_method_id)); 94 ASSERT_TRUE(entry->GetString("id", &input_method_id));
98 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 95 ASSERT_TRUE(entry->GetString("displayName", &display_name));
99 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); 96 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
100 EXPECT_EQ("xkb:be::fra", input_method_id); 97 EXPECT_EQ("xkb:be::fra", input_method_id);
101 // Commented out. See above. 98 // Commented out. See above.
102 // EXPECT_EQ("Belgian keyboard layout", display_name); 99 // EXPECT_EQ("Belgian keyboard layout", display_name);
103 ASSERT_TRUE(language_code_set->HasKey("fr")); 100 ASSERT_TRUE(language_code_set->HasKey("fr"));
104 101
105 ASSERT_TRUE(list->GetDictionary(3, &entry)); 102 ASSERT_TRUE(list->GetDictionary(3, &entry));
106 ASSERT_TRUE(entry->GetString("id", &input_method_id)); 103 ASSERT_TRUE(entry->GetString("id", &input_method_id));
107 ASSERT_TRUE(entry->GetString("displayName", &display_name)); 104 ASSERT_TRUE(entry->GetString("displayName", &display_name));
108 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); 105 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
109 EXPECT_EQ("xkb:is::ice", input_method_id); 106 EXPECT_EQ("xkb:is::ice", input_method_id);
110 // Commented out. See above. 107 // Commented out. See above.
111 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); 108 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name);
112 ASSERT_TRUE(language_code_set->HasKey("is")); 109 ASSERT_TRUE(language_code_set->HasKey("is"));
113
114 ASSERT_TRUE(list->GetDictionary(4, &entry));
115 ASSERT_TRUE(entry->GetString("id", &input_method_id));
116 ASSERT_TRUE(entry->GetString("displayName", &display_name));
117 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
118 EXPECT_EQ("mozc", input_method_id);
119 // Commented out. See above.
120 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name);
121 ASSERT_TRUE(language_code_set->HasKey("ja"));
122 } 110 }
123 111
124 TEST_F(CrosLanguageOptionsHandlerTest, GetUILanguageList) { 112 TEST_F(CrosLanguageOptionsHandlerTest, GetUILanguageList) {
125 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); 113 InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
126 scoped_ptr<ListValue> list( 114 scoped_ptr<ListValue> list(
127 chromeos::options::CrosLanguageOptionsHandler::GetUILanguageList( 115 chromeos::options::CrosLanguageOptionsHandler::GetUILanguageList(
128 descriptors)); 116 descriptors));
129 117
130 for (size_t i = 0; i < list->GetSize(); ++i) { 118 for (size_t i = 0; i < list->GetSize(); ++i) {
131 base::DictionaryValue* dict; 119 base::DictionaryValue* dict;
132 ASSERT_TRUE(list->GetDictionary(i, &dict)); 120 ASSERT_TRUE(list->GetDictionary(i, &dict));
133 std::string code; 121 std::string code;
134 ASSERT_TRUE(dict->GetString("code", &code)); 122 ASSERT_TRUE(dict->GetString("code", &code));
135 EXPECT_NE("is", code) 123 EXPECT_NE("is", code)
136 << "Icelandic is an example language which has input method " 124 << "Icelandic is an example language which has input method "
137 << "but can't use it as UI language."; 125 << "but can't use it as UI language.";
138 } 126 }
139 } 127 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc ('k') | chromeos/ime/input_method_whitelist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698