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_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h" | 32 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h" |
33 #include "ui/base/ime/input_method_initializer.h" | 33 #include "ui/base/ime/input_method_initializer.h" |
34 #include "ui/events/keycodes/keyboard_codes.h" | 34 #include "ui/events/keycodes/keyboard_codes.h" |
35 | 35 |
36 namespace chromeos { | 36 namespace chromeos { |
37 | 37 |
38 namespace input_method { | 38 namespace input_method { |
39 namespace { | 39 namespace { |
40 | 40 |
41 const char kNaclMozcUsId[] = | 41 const char kNaclMozcUsId[] = |
42 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_us"; | 42 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopnacl_mozc_us"; |
43 const char kNaclMozcJpId[] = | 43 const char kNaclMozcJpId[] = |
44 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_jp"; | 44 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopnacl_mozc_jp"; |
45 const char kExt2Engine1Id[] = | 45 const char kExt2Engine1Id[] = |
46 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine1_engine_id"; | 46 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine1_engine_id"; |
47 const char kExt2Engine2Id[] = | 47 const char kExt2Engine2Id[] = |
48 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine2_engine_id"; | 48 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine2_engine_id"; |
49 const char kPinyinImeId[] = | |
50 "_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabzh-t-i0-pinyin"; | |
51 const char kXkbExtId[] = | 49 const char kXkbExtId[] = |
52 #if defined(OFFICIAL_BUILD) | 50 #if defined(OFFICIAL_BUILD) |
53 "jkghodnilhceideoidjikpgommlajknk"; | 51 "jkghodnilhceideoidjikpgommlajknk"; |
54 #else | 52 #else |
55 "fgoepimhcoialccpbmpnnblemnepkkao"; | 53 "fgoepimhcoialccpbmpnnblemnepkkao"; |
56 #endif | 54 #endif |
57 | 55 |
58 // Returns true if |descriptors| contain |target|. | 56 // Returns true if |descriptors| contain |target|. |
59 bool Contain(const InputMethodDescriptors& descriptors, | 57 bool Contain(const InputMethodDescriptors& descriptors, |
60 const InputMethodDescriptor& target) { | 58 const InputMethodDescriptor& target) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 ComponentExtensionEngine ext_xkb_engine_hu; | 211 ComponentExtensionEngine ext_xkb_engine_hu; |
214 ext_xkb_engine_hu.engine_id = "xkb:hu::hun"; | 212 ext_xkb_engine_hu.engine_id = "xkb:hu::hun"; |
215 ext_xkb_engine_hu.display_name = "xkb:hu::hun"; | 213 ext_xkb_engine_hu.display_name = "xkb:hu::hun"; |
216 ext_xkb_engine_hu.language_codes.push_back("hu"); | 214 ext_xkb_engine_hu.language_codes.push_back("hu"); |
217 ext_xkb_engine_hu.layouts.push_back("hu"); | 215 ext_xkb_engine_hu.layouts.push_back("hu"); |
218 ext_xkb.engines.push_back(ext_xkb_engine_hu); | 216 ext_xkb.engines.push_back(ext_xkb_engine_hu); |
219 | 217 |
220 ime_list_.push_back(ext_xkb); | 218 ime_list_.push_back(ext_xkb); |
221 | 219 |
222 ComponentExtensionIME ext1; | 220 ComponentExtensionIME ext1; |
223 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; | 221 ext1.id = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
224 ext1.description = "ext1_description"; | 222 ext1.description = "ext1_description"; |
225 ext1.path = base::FilePath("ext1_file_path"); | 223 ext1.path = base::FilePath("ext1_file_path"); |
226 | 224 |
227 ComponentExtensionEngine ext1_engine1; | 225 ComponentExtensionEngine ext1_engine1; |
228 ext1_engine1.engine_id = "nacl_mozc_us"; | 226 ext1_engine1.engine_id = "nacl_mozc_us"; |
229 ext1_engine1.display_name = "ext1_engine_1_display_name"; | 227 ext1_engine1.display_name = "ext1_engine_1_display_name"; |
230 ext1_engine1.language_codes.push_back("ja"); | 228 ext1_engine1.language_codes.push_back("ja"); |
231 ext1_engine1.layouts.push_back("us"); | 229 ext1_engine1.layouts.push_back("us"); |
232 ext1.engines.push_back(ext1_engine1); | 230 ext1.engines.push_back(ext1_engine1); |
233 | 231 |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 | 1344 |
1347 std::vector<std::string> input_method_ids; | 1345 std::vector<std::string> input_method_ids; |
1348 input_method_ids.push_back("xkb:us::eng"); | 1346 input_method_ids.push_back("xkb:us::eng"); |
1349 input_method_ids.push_back("xkb:fr::fra"); | 1347 input_method_ids.push_back("xkb:fr::fra"); |
1350 input_method_ids.push_back( | 1348 input_method_ids.push_back( |
1351 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | 1349 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); |
1352 input_method_ids.push_back("xkb:fr::fra"); | 1350 input_method_ids.push_back("xkb:fr::fra"); |
1353 input_method_ids.push_back( | 1351 input_method_ids.push_back( |
1354 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | 1352 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); |
1355 input_method_ids.push_back("_comp_ime_asdf_pinyin"); | 1353 input_method_ids.push_back("_comp_ime_asdf_pinyin"); |
1356 input_method_ids.push_back(kPinyinImeId); | 1354 input_method_ids.push_back(kNaclMozcUsId); |
1357 | 1355 |
1358 manager_->MigrateXkbInputMethods(&input_method_ids); | 1356 manager_->MigrateInputMethods(&input_method_ids); |
1359 | 1357 |
1360 ASSERT_EQ(4U, input_method_ids.size()); | 1358 ASSERT_EQ(4U, input_method_ids.size()); |
1361 | 1359 |
1362 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng", | 1360 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng", |
1363 input_method_ids[0]); | 1361 input_method_ids[0]); |
1364 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:fr::fra", | 1362 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:fr::fra", |
1365 input_method_ids[1]); | 1363 input_method_ids[1]); |
1366 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1364 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1367 EXPECT_EQ("_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopzh-t-i0-pinyin", | 1365 EXPECT_EQ("_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopnacl_mozc_us", |
1368 input_method_ids[3]); | 1366 input_method_ids[3]); |
1369 } | 1367 } |
1370 | 1368 |
1371 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest_2) { | 1369 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest_2) { |
1372 extension_ime_util::ScopedUseExtensionKeyboardFlagForTesting | 1370 extension_ime_util::ScopedUseExtensionKeyboardFlagForTesting |
1373 scoped_flag(false); | 1371 scoped_flag(false); |
1374 | 1372 |
1375 std::vector<std::string> input_method_ids; | 1373 std::vector<std::string> input_method_ids; |
1376 input_method_ids.push_back("xkb:us::eng"); | 1374 input_method_ids.push_back("xkb:us::eng"); |
1377 input_method_ids.push_back("xkb:fr::fra"); | 1375 input_method_ids.push_back("xkb:fr::fra"); |
1378 input_method_ids.push_back( | 1376 input_method_ids.push_back( |
1379 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | 1377 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); |
1380 input_method_ids.push_back("xkb:fr::fra"); | 1378 input_method_ids.push_back("xkb:fr::fra"); |
1381 input_method_ids.push_back( | 1379 input_method_ids.push_back( |
1382 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | 1380 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); |
1383 input_method_ids.push_back("_comp_ime_asdf_pinyin"); | 1381 input_method_ids.push_back("_comp_ime_asdf_pinyin"); |
1384 | 1382 |
1385 manager_->MigrateXkbInputMethods(&input_method_ids); | 1383 manager_->MigrateInputMethods(&input_method_ids); |
1386 | 1384 |
1387 ASSERT_EQ(3U, input_method_ids.size()); | 1385 ASSERT_EQ(3U, input_method_ids.size()); |
1388 | 1386 |
1389 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 1387 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
1390 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); | 1388 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); |
1391 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1389 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1392 } | 1390 } |
1393 | 1391 |
1394 } // namespace input_method | 1392 } // namespace input_method |
1395 } // namespace chromeos | 1393 } // namespace chromeos |
OLD | NEW |