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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util_unittest.cc

Issue 1313533003: Fix some extern usage in .cc files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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/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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/base/ime/chromeos/extension_ime_util.h" 13 #include "ui/base/ime/chromeos/extension_ime_util.h"
14 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" 14 #include "ui/base/ime/chromeos/fake_input_method_delegate.h"
15 #include "ui/base/ime/chromeos/input_method_manager.h" 15 #include "ui/base/ime/chromeos/input_method_manager.h"
16 #include "ui/base/ime/chromeos/input_method_whitelist.h" 16 #include "ui/base/ime/chromeos/input_method_whitelist.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 18
19 using base::ASCIIToUTF16; 19 using base::ASCIIToUTF16;
20 20
21 namespace chromeos { 21 namespace chromeos {
22 22
23 extern const char* kExtensionImePrefix;
24
25 namespace input_method { 23 namespace input_method {
26 24
27 namespace { 25 namespace {
28 26
29 const char pinyin_ime_id[] = "zh-t-i0-pinyin"; 27 const char pinyin_ime_id[] = "zh-t-i0-pinyin";
30 const char zhuyin_ime_id[] = "zh-hant-t-i0-und"; 28 const char zhuyin_ime_id[] = "zh-hant-t-i0-und";
31 29
32 class TestableInputMethodUtil : public InputMethodUtil { 30 class TestableInputMethodUtil : public InputMethodUtil {
33 public: 31 public:
34 explicit TestableInputMethodUtil(InputMethodDelegate* delegate, 32 explicit TestableInputMethodUtil(InputMethodDelegate* delegate,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return InputMethodDescriptor(Id(id), 100 return InputMethodDescriptor(Id(id),
103 "", // Description. 101 "", // Description.
104 indicator, // Short name used for indicator. 102 indicator, // Short name used for indicator.
105 layouts, 103 layouts,
106 languages, 104 languages,
107 true, 105 true,
108 GURL(), // options page url 106 GURL(), // options page url
109 GURL()); // input view page url 107 GURL()); // input view page url
110 } 108 }
111 109
112 static base::string16 GetDisplayLanguageName(const std::string& language_code) { 110 static base::string16 GetDisplayLanguageName(
111 const std::string& language_code) {
113 return l10n_util::GetDisplayNameForLocale(language_code, "en", true); 112 return l10n_util::GetDisplayNameForLocale(language_code, "en", true);
114 } 113 }
115 114
116 FakeInputMethodDelegate delegate_; 115 FakeInputMethodDelegate delegate_;
117 InputMethodWhitelist whitelist_; 116 InputMethodWhitelist whitelist_;
118 TestableInputMethodUtil util_; 117 TestableInputMethodUtil util_;
119 }; 118 };
120 119
121 TEST_F(InputMethodUtilTest, GetInputMethodShortNameTest) { 120 TEST_F(InputMethodUtilTest, GetInputMethodShortNameTest) {
122 // Test invalid cases. Two-letter language code should be returned. 121 // Test invalid cases. Two-letter language code should be returned.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 InputMethodDescriptor desc = 166 InputMethodDescriptor desc =
168 GetDesc(zhuyin_ime_id, "us", "zh-TW", "\xE6\xB3\xA8"); 167 GetDesc(zhuyin_ime_id, "us", "zh-TW", "\xE6\xB3\xA8");
169 EXPECT_EQ(base::UTF8ToUTF16("\xE6\xB3\xA8"), 168 EXPECT_EQ(base::UTF8ToUTF16("\xE6\xB3\xA8"),
170 util_.GetInputMethodShortName(desc)); 169 util_.GetInputMethodShortName(desc));
171 } 170 }
172 } 171 }
173 172
174 TEST_F(InputMethodUtilTest, GetInputMethodMediumNameTest) { 173 TEST_F(InputMethodUtilTest, GetInputMethodMediumNameTest) {
175 { 174 {
176 // input methods with medium name equal to short name 175 // input methods with medium name equal to short name
177 const char * input_method_id[] = { 176 const char* const input_method_id[] = {
178 "xkb:us:altgr-intl:eng", 177 "xkb:us:altgr-intl:eng", "xkb:us:dvorak:eng", "xkb:us:intl:eng",
179 "xkb:us:dvorak:eng", 178 "xkb:us:colemak:eng", "xkb:de:neo:ger", "xkb:es:cat:cat",
180 "xkb:us:intl:eng", 179 "xkb:gb:dvorak:eng",
181 "xkb:us:colemak:eng",
182 "xkb:de:neo:ger",
183 "xkb:es:cat:cat",
184 "xkb:gb:dvorak:eng",
185 }; 180 };
186 const int len = arraysize(input_method_id); 181 const int len = arraysize(input_method_id);
187 for (int i=0; i<len; ++i) { 182 for (int i = 0; i < len; ++i) {
188 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", ""); 183 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", "");
189 base::string16 medium_name = util_.GetInputMethodMediumName(desc); 184 base::string16 medium_name = util_.GetInputMethodMediumName(desc);
190 base::string16 short_name = util_.GetInputMethodShortName(desc); 185 base::string16 short_name = util_.GetInputMethodShortName(desc);
191 EXPECT_EQ(medium_name,short_name); 186 EXPECT_EQ(medium_name, short_name);
192 } 187 }
193 } 188 }
194 { 189 {
195 // input methods with medium name not equal to short name 190 // input methods with medium name not equal to short name
196 const char * input_method_id[] = { 191 const char* const input_method_id[] = {
197 pinyin_ime_id, 192 pinyin_ime_id, zhuyin_ime_id,
198 zhuyin_ime_id,
199 }; 193 };
200 const int len = arraysize(input_method_id); 194 const int len = arraysize(input_method_id);
201 for (int i=0; i<len; ++i) { 195 for (int i = 0; i < len; ++i) {
202 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", ""); 196 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", "");
203 base::string16 medium_name = util_.GetInputMethodMediumName(desc); 197 base::string16 medium_name = util_.GetInputMethodMediumName(desc);
204 base::string16 short_name = util_.GetInputMethodShortName(desc); 198 base::string16 short_name = util_.GetInputMethodShortName(desc);
205 EXPECT_NE(medium_name,short_name); 199 EXPECT_NE(medium_name, short_name);
206 } 200 }
207 } 201 }
208 } 202 }
209 203
210 TEST_F(InputMethodUtilTest, GetInputMethodLongNameTest) { 204 TEST_F(InputMethodUtilTest, GetInputMethodLongNameTest) {
211 // For most languages input method or keyboard layout name is returned. 205 // For most languages input method or keyboard layout name is returned.
212 // See below for exceptions. 206 // See below for exceptions.
213 { 207 {
214 InputMethodDescriptor desc = GetDesc("xkb:jp::jpn", "jp", "ja", ""); 208 InputMethodDescriptor desc = GetDesc("xkb:jp::jpn", "jp", "ja", "");
215 EXPECT_EQ(ASCIIToUTF16("Japanese"), 209 EXPECT_EQ(ASCIIToUTF16("Japanese"),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 EXPECT_EQ("xkb:us::eng", extension_ime_util::GetComponentIDByInputMethodID( 524 EXPECT_EQ("xkb:us::eng", extension_ime_util::GetComponentIDByInputMethodID(
531 input_method_ids[0])); 525 input_method_ids[0]));
532 EXPECT_EQ("xkb:ru::rus", extension_ime_util::GetComponentIDByInputMethodID( 526 EXPECT_EQ("xkb:ru::rus", extension_ime_util::GetComponentIDByInputMethodID(
533 input_method_ids[1])); 527 input_method_ids[1]));
534 EXPECT_EQ("xkb:us::eng", extension_ime_util::GetComponentIDByInputMethodID( 528 EXPECT_EQ("xkb:us::eng", extension_ime_util::GetComponentIDByInputMethodID(
535 login_input_method_ids[0])); 529 login_input_method_ids[0]));
536 } 530 }
537 531
538 } // namespace input_method 532 } // namespace input_method
539 } // namespace chromeos 533 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/cookies/cookies_api_constants.cc » ('j') | content/browser/browser_main.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698