| 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/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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 InputMethodDescriptor desc = GetDesc("mozc", "us", "ja"); | 105 InputMethodDescriptor desc = GetDesc("mozc", "us", "ja"); |
| 106 EXPECT_EQ(UTF8ToUTF16("\xe3\x81\x82"), | 106 EXPECT_EQ(UTF8ToUTF16("\xe3\x81\x82"), |
| 107 util_.GetInputMethodShortName(desc)); | 107 util_.GetInputMethodShortName(desc)); |
| 108 } | 108 } |
| 109 { | 109 { |
| 110 InputMethodDescriptor desc = GetDesc("mozc-jp", "jp", "ja"); | 110 InputMethodDescriptor desc = GetDesc("mozc-jp", "jp", "ja"); |
| 111 EXPECT_EQ(UTF8ToUTF16("\xe3\x81\x82"), | 111 EXPECT_EQ(UTF8ToUTF16("\xe3\x81\x82"), |
| 112 util_.GetInputMethodShortName(desc)); | 112 util_.GetInputMethodShortName(desc)); |
| 113 } | 113 } |
| 114 { | 114 { |
| 115 InputMethodDescriptor desc = GetDesc("zinnia-japanese", "us", "ja"); | |
| 116 EXPECT_EQ(UTF8ToUTF16("\xe6\x89\x8b"), | |
| 117 util_.GetInputMethodShortName(desc)); | |
| 118 } | |
| 119 { | |
| 120 InputMethodDescriptor desc = GetDesc("pinyin", "us", "zh-CN"); | 115 InputMethodDescriptor desc = GetDesc("pinyin", "us", "zh-CN"); |
| 121 EXPECT_EQ(UTF8ToUTF16("\xe6\x8b\xbc"), | 116 EXPECT_EQ(UTF8ToUTF16("\xe6\x8b\xbc"), |
| 122 util_.GetInputMethodShortName(desc)); | 117 util_.GetInputMethodShortName(desc)); |
| 123 } | 118 } |
| 124 { | 119 { |
| 125 InputMethodDescriptor desc = GetDesc("pinyin-dv", "us(dvorak)", "zh-CN"); | 120 InputMethodDescriptor desc = GetDesc("pinyin-dv", "us(dvorak)", "zh-CN"); |
| 126 EXPECT_EQ(UTF8ToUTF16("\xe6\x8b\xbc"), | 121 EXPECT_EQ(UTF8ToUTF16("\xe6\x8b\xbc"), |
| 127 util_.GetInputMethodShortName(desc)); | 122 util_.GetInputMethodShortName(desc)); |
| 128 } | 123 } |
| 129 { | 124 { |
| 130 InputMethodDescriptor desc = GetDesc("mozc-chewing", "us", "zh-TW"); | 125 InputMethodDescriptor desc = GetDesc("mozc-chewing", "us", "zh-TW"); |
| 131 EXPECT_EQ(UTF8ToUTF16("\xe9\x85\xb7"), | 126 EXPECT_EQ(UTF8ToUTF16("\xe9\x85\xb7"), |
| 132 util_.GetInputMethodShortName(desc)); | 127 util_.GetInputMethodShortName(desc)); |
| 133 } | 128 } |
| 134 { | 129 { |
| 135 InputMethodDescriptor desc = GetDesc("m17n:zh:cangjie", "us", "zh-TW"); | 130 InputMethodDescriptor desc = GetDesc("m17n:zh:cangjie", "us", "zh-TW"); |
| 136 EXPECT_EQ(UTF8ToUTF16("\xe5\x80\x89"), | 131 EXPECT_EQ(UTF8ToUTF16("\xe5\x80\x89"), |
| 137 util_.GetInputMethodShortName(desc)); | 132 util_.GetInputMethodShortName(desc)); |
| 138 } | 133 } |
| 139 { | 134 { |
| 140 InputMethodDescriptor desc = GetDesc("m17n:zh:quick", "us", "zh-TW"); | 135 InputMethodDescriptor desc = GetDesc("m17n:zh:quick", "us", "zh-TW"); |
| 141 EXPECT_EQ(UTF8ToUTF16("\xe9\x80\x9f"), | 136 EXPECT_EQ(UTF8ToUTF16("\xe9\x80\x9f"), |
| 142 util_.GetInputMethodShortName(desc)); | 137 util_.GetInputMethodShortName(desc)); |
| 143 } | 138 } |
| 144 } | 139 } |
| 145 | 140 |
| 141 TEST_F(InputMethodUtilTest, GetInputMethodMediumNameTest) { |
| 142 { |
| 143 // input methods with medium name equal to short name |
| 144 const char * input_method_id[] = { |
| 145 "xkb:us:altgr-intl:eng", |
| 146 "xkb:us:dvorak:eng", |
| 147 "xkb:us:intl:eng", |
| 148 "xkb:us:colemak:eng", |
| 149 "english-m", |
| 150 "xkb:de:neo:ger", |
| 151 "xkb:es:cat:cat", |
| 152 "xkb:gb:dvorak:eng", |
| 153 }; |
| 154 const int len = ARRAYSIZE_UNSAFE(input_method_id); |
| 155 for (int i=0; i<len; ++i) { |
| 156 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", ""); |
| 157 string16 medium_name = util_.GetInputMethodMediumName(desc); |
| 158 string16 short_name = util_.GetInputMethodShortName(desc); |
| 159 EXPECT_EQ(medium_name,short_name); |
| 160 } |
| 161 } |
| 162 { |
| 163 // input methods with medium name not equal to short name |
| 164 const char * input_method_id[] = { |
| 165 "m17n:zh:cangjie", |
| 166 "m17n:zh:quick", |
| 167 "mozc", |
| 168 "mozc-chewing", |
| 169 "mozc-dv", |
| 170 "mozc-hangul", |
| 171 "mozc-jp", |
| 172 "pinyin", |
| 173 "pinyin-dv", |
| 174 }; |
| 175 const int len = ARRAYSIZE_UNSAFE(input_method_id); |
| 176 for (int i=0; i<len; ++i) { |
| 177 InputMethodDescriptor desc = GetDesc(input_method_id[i], "", ""); |
| 178 string16 medium_name = util_.GetInputMethodMediumName(desc); |
| 179 string16 short_name = util_.GetInputMethodShortName(desc); |
| 180 EXPECT_NE(medium_name,short_name); |
| 181 } |
| 182 } |
| 183 } |
| 184 |
| 146 TEST_F(InputMethodUtilTest, GetInputMethodLongNameTest) { | 185 TEST_F(InputMethodUtilTest, GetInputMethodLongNameTest) { |
| 147 // For most languages input method or keyboard layout name is returned. | 186 // For most languages input method or keyboard layout name is returned. |
| 148 // See below for exceptions. | 187 // See below for exceptions. |
| 149 { | 188 { |
| 150 InputMethodDescriptor desc = GetDesc("m17n:fa:isiri", "us", "fa"); | 189 InputMethodDescriptor desc = GetDesc("m17n:fa:isiri", "us", "fa"); |
| 151 EXPECT_EQ(ASCIIToUTF16("Persian input method (ISIRI 2901 layout)"), | 190 EXPECT_EQ(ASCIIToUTF16("Persian input method (ISIRI 2901 layout)"), |
| 152 util_.GetInputMethodLongName(desc)); | 191 util_.GetInputMethodLongName(desc)); |
| 153 } | 192 } |
| 154 { | 193 { |
| 155 InputMethodDescriptor desc = GetDesc("mozc-hangul", "us", "ko"); | 194 InputMethodDescriptor desc = GetDesc("mozc-hangul", "us", "ko"); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 EXPECT_FALSE(display_name.empty()) | 560 EXPECT_FALSE(display_name.empty()) |
| 522 << "Invalid language code " << language_code; | 561 << "Invalid language code " << language_code; |
| 523 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. | 562 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. |
| 524 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) | 563 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) |
| 525 << "Invalid language code " << language_code; | 564 << "Invalid language code " << language_code; |
| 526 } | 565 } |
| 527 } | 566 } |
| 528 | 567 |
| 529 } // namespace input_method | 568 } // namespace input_method |
| 530 } // namespace chromeos | 569 } // namespace chromeos |
| OLD | NEW |