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 20 matching lines...) Expand all Loading... | |
31 #include "ui/base/accelerators/accelerator.h" | 31 #include "ui/base/accelerators/accelerator.h" |
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[] = "nacl_mozc_us"; |
42 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_us"; | 42 const char kNaclMozcJpId[] = "nacl_mozc_jp"; |
43 const char kNaclMozcJpId[] = | 43 const char kExt2Engine1Id[] = "ext2_engine1-t-i0-engine_id"; |
44 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_jp"; | 44 const char kExt2Engine2Id[] = "ext2_engine2-t-i0-engine_id"; |
45 const char kExt2Engine1Id[] = | 45 const char kPinyinImeId[] = "zh-t-i0-pinyin"; |
46 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine1_engine_id"; | |
47 const char kExt2Engine2Id[] = | |
48 "_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopext2_engine2_engine_id"; | |
49 const char kPinyinImeId[] = | |
50 "_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabzh-t-i0-pinyin"; | |
51 const char kXkbExtId[] = | |
52 #if defined(OFFICIAL_BUILD) | |
53 "jkghodnilhceideoidjikpgommlajknk"; | |
54 #else | |
55 "fgoepimhcoialccpbmpnnblemnepkkao"; | |
56 #endif | |
57 | 46 |
58 // Returns true if |descriptors| contain |target|. | 47 // Returns true if |descriptors| contain |target|. |
59 bool Contain(const InputMethodDescriptors& descriptors, | 48 bool Contain(const InputMethodDescriptors& descriptors, |
60 const InputMethodDescriptor& target) { | 49 const InputMethodDescriptor& target) { |
61 for (size_t i = 0; i < descriptors.size(); ++i) { | 50 for (size_t i = 0; i < descriptors.size(); ++i) { |
62 if (descriptors[i].id() == target.id()) | 51 if (descriptors[i].id() == target.id()) |
63 return true; | 52 return true; |
64 } | 53 } |
65 return false; | 54 return false; |
66 } | 55 } |
67 | 56 |
68 std::string XkbId(const std::string& id) { | 57 std::string Id(const std::string& id) { |
Seigo Nonaka
2014/06/02 03:48:26
Hmm, Id(kNaclMozcUsId) doesn't make sense to me, h
Shu Chen
2014/06/02 04:01:56
Directly using extension_ime_util::GetInputMethodI
| |
69 return extension_ime_util::GetInputMethodIDByKeyboardLayout(id); | 58 return extension_ime_util::GetInputMethodIDByEngineID(id); |
70 } | 59 } |
71 | 60 |
72 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { | 61 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { |
73 public: | 62 public: |
74 InputMethodManagerImplTest() | 63 InputMethodManagerImplTest() |
75 : delegate_(NULL), | 64 : delegate_(NULL), |
76 candidate_window_controller_(NULL), | 65 candidate_window_controller_(NULL), |
77 keyboard_(NULL) { | 66 keyboard_(NULL) { |
78 } | 67 } |
79 virtual ~InputMethodManagerImplTest() {} | 68 virtual ~InputMethodManagerImplTest() {} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 protected: | 110 protected: |
122 // Helper function to initialize component extension stuff for testing. | 111 // Helper function to initialize component extension stuff for testing. |
123 void InitComponentExtension() { | 112 void InitComponentExtension() { |
124 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); | 113 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); |
125 mock_delegate_->set_ime_list(ime_list_); | 114 mock_delegate_->set_ime_list(ime_list_); |
126 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); | 115 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); |
127 | 116 |
128 // Note, for production, these SetEngineHandler are called when | 117 // Note, for production, these SetEngineHandler are called when |
129 // IMEEngineHandlerInterface is initialized via | 118 // IMEEngineHandlerInterface is initialized via |
130 // InitializeComponentextension. | 119 // InitializeComponentextension. |
131 manager_->AddInputMethodExtension(kNaclMozcUsId, | 120 manager_->AddInputMethodExtension(Id(kNaclMozcUsId), |
132 mock_engine_handler_.get()); | 121 mock_engine_handler_.get()); |
133 manager_->AddInputMethodExtension(kNaclMozcJpId, | 122 manager_->AddInputMethodExtension(Id(kNaclMozcJpId), |
134 mock_engine_handler_.get()); | 123 mock_engine_handler_.get()); |
135 manager_->AddInputMethodExtension(kExt2Engine1Id, | 124 manager_->AddInputMethodExtension(Id(kExt2Engine1Id), |
136 mock_engine_handler_.get()); | 125 mock_engine_handler_.get()); |
137 manager_->AddInputMethodExtension(kExt2Engine2Id, | 126 manager_->AddInputMethodExtension(Id(kExt2Engine2Id), |
138 mock_engine_handler_.get()); | 127 mock_engine_handler_.get()); |
139 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); | 128 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); |
140 } | 129 } |
141 | 130 |
142 void InitImeList() { | 131 void InitImeList() { |
143 ime_list_.clear(); | 132 ime_list_.clear(); |
144 | 133 |
145 ComponentExtensionIME ext_xkb; | 134 ComponentExtensionIME ext_xkb; |
146 ext_xkb.id = kXkbExtId; | 135 ext_xkb.id = extension_ime_util::kXkbExtensionId; |
147 ext_xkb.description = "ext_xkb_description"; | 136 ext_xkb.description = "ext_xkb_description"; |
148 ext_xkb.path = base::FilePath("ext_xkb_file_path"); | 137 ext_xkb.path = base::FilePath("ext_xkb_file_path"); |
149 | 138 |
150 ComponentExtensionEngine ext_xkb_engine_us; | 139 ComponentExtensionEngine ext_xkb_engine_us; |
151 ext_xkb_engine_us.engine_id = "xkb:us::eng"; | 140 ext_xkb_engine_us.engine_id = "xkb:us::eng"; |
152 ext_xkb_engine_us.display_name = "xkb:us::eng"; | 141 ext_xkb_engine_us.display_name = "xkb:us::eng"; |
153 ext_xkb_engine_us.language_codes.push_back("en-US"); | 142 ext_xkb_engine_us.language_codes.push_back("en-US"); |
154 ext_xkb_engine_us.layouts.push_back("us"); | 143 ext_xkb_engine_us.layouts.push_back("us"); |
155 ext_xkb.engines.push_back(ext_xkb_engine_us); | 144 ext_xkb.engines.push_back(ext_xkb_engine_us); |
156 | 145 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 ComponentExtensionEngine ext_xkb_engine_hu; | 202 ComponentExtensionEngine ext_xkb_engine_hu; |
214 ext_xkb_engine_hu.engine_id = "xkb:hu::hun"; | 203 ext_xkb_engine_hu.engine_id = "xkb:hu::hun"; |
215 ext_xkb_engine_hu.display_name = "xkb:hu::hun"; | 204 ext_xkb_engine_hu.display_name = "xkb:hu::hun"; |
216 ext_xkb_engine_hu.language_codes.push_back("hu"); | 205 ext_xkb_engine_hu.language_codes.push_back("hu"); |
217 ext_xkb_engine_hu.layouts.push_back("hu"); | 206 ext_xkb_engine_hu.layouts.push_back("hu"); |
218 ext_xkb.engines.push_back(ext_xkb_engine_hu); | 207 ext_xkb.engines.push_back(ext_xkb_engine_hu); |
219 | 208 |
220 ime_list_.push_back(ext_xkb); | 209 ime_list_.push_back(ext_xkb); |
221 | 210 |
222 ComponentExtensionIME ext1; | 211 ComponentExtensionIME ext1; |
223 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; | 212 ext1.id = extension_ime_util::kMozcExtensionId; |
224 ext1.description = "ext1_description"; | 213 ext1.description = "ext1_description"; |
225 ext1.path = base::FilePath("ext1_file_path"); | 214 ext1.path = base::FilePath("ext1_file_path"); |
226 | 215 |
227 ComponentExtensionEngine ext1_engine1; | 216 ComponentExtensionEngine ext1_engine1; |
228 ext1_engine1.engine_id = "nacl_mozc_us"; | 217 ext1_engine1.engine_id = "nacl_mozc_us"; |
229 ext1_engine1.display_name = "ext1_engine_1_display_name"; | 218 ext1_engine1.display_name = "ext1_engine_1_display_name"; |
230 ext1_engine1.language_codes.push_back("ja"); | 219 ext1_engine1.language_codes.push_back("ja"); |
231 ext1_engine1.layouts.push_back("us"); | 220 ext1_engine1.layouts.push_back("us"); |
232 ext1.engines.push_back(ext1_engine1); | 221 ext1.engines.push_back(ext1_engine1); |
233 | 222 |
234 ComponentExtensionEngine ext1_engine2; | 223 ComponentExtensionEngine ext1_engine2; |
235 ext1_engine2.engine_id = "nacl_mozc_jp"; | 224 ext1_engine2.engine_id = "nacl_mozc_jp"; |
236 ext1_engine2.display_name = "ext1_engine_1_display_name"; | 225 ext1_engine2.display_name = "ext1_engine_1_display_name"; |
237 ext1_engine2.language_codes.push_back("ja"); | 226 ext1_engine2.language_codes.push_back("ja"); |
238 ext1_engine2.layouts.push_back("jp"); | 227 ext1_engine2.layouts.push_back("jp"); |
239 ext1.engines.push_back(ext1_engine2); | 228 ext1.engines.push_back(ext1_engine2); |
240 | 229 |
241 ime_list_.push_back(ext1); | 230 ime_list_.push_back(ext1); |
242 | 231 |
243 ComponentExtensionIME ext2; | 232 ComponentExtensionIME ext2; |
244 ext2.id = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 233 ext2.id = extension_ime_util::kT13nExtensionId; |
245 ext2.description = "ext2_description"; | 234 ext2.description = "ext2_description"; |
246 ext2.path = base::FilePath("ext2_file_path"); | 235 ext2.path = base::FilePath("ext2_file_path"); |
247 | 236 |
248 ComponentExtensionEngine ext2_engine1; | 237 ComponentExtensionEngine ext2_engine1; |
249 ext2_engine1.engine_id = "ext2_engine1_engine_id"; | 238 ext2_engine1.engine_id = kExt2Engine1Id; |
250 ext2_engine1.display_name = "ext2_engine_1_display_name"; | 239 ext2_engine1.display_name = "ext2_engine_1_display_name"; |
251 ext2_engine1.language_codes.push_back("en"); | 240 ext2_engine1.language_codes.push_back("en"); |
252 ext2_engine1.layouts.push_back("us"); | 241 ext2_engine1.layouts.push_back("us"); |
253 ext2.engines.push_back(ext2_engine1); | 242 ext2.engines.push_back(ext2_engine1); |
254 | 243 |
255 ComponentExtensionEngine ext2_engine2; | 244 ComponentExtensionEngine ext2_engine2; |
256 ext2_engine2.engine_id = "ext2_engine2_engine_id"; | 245 ext2_engine2.engine_id = kExt2Engine2Id; |
257 ext2_engine2.display_name = "ext2_engine_2_display_name"; | 246 ext2_engine2.display_name = "ext2_engine_2_display_name"; |
258 ext2_engine2.language_codes.push_back("en"); | 247 ext2_engine2.language_codes.push_back("en"); |
259 ext2_engine2.layouts.push_back("us(dvorak)"); | 248 ext2_engine2.layouts.push_back("us(dvorak)"); |
260 ext2.engines.push_back(ext2_engine2); | 249 ext2.engines.push_back(ext2_engine2); |
261 | 250 |
262 ime_list_.push_back(ext2); | 251 ime_list_.push_back(ext2); |
263 } | 252 } |
264 | 253 |
265 TestingBrowserProcess* GetBrowserProcess() { | 254 TestingBrowserProcess* GetBrowserProcess() { |
266 return TestingBrowserProcess::GetGlobal(); | 255 return TestingBrowserProcess::GetGlobal(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 | 350 |
362 TestObserver observer; | 351 TestObserver observer; |
363 InitComponentExtension(); | 352 InitComponentExtension(); |
364 manager_->AddObserver(&observer); | 353 manager_->AddObserver(&observer); |
365 menu_manager_->AddObserver(&observer); | 354 menu_manager_->AddObserver(&observer); |
366 EXPECT_EQ(0, observer.input_method_changed_count_); | 355 EXPECT_EQ(0, observer.input_method_changed_count_); |
367 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 356 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
368 EXPECT_EQ(5U, manager_->GetActiveInputMethods()->size()); | 357 EXPECT_EQ(5U, manager_->GetActiveInputMethods()->size()); |
369 EXPECT_EQ(1, observer.input_method_changed_count_); | 358 EXPECT_EQ(1, observer.input_method_changed_count_); |
370 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); | 359 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
371 manager_->ChangeInputMethod(XkbId("xkb:us:dvorak:eng")); | 360 manager_->ChangeInputMethod(Id("xkb:us:dvorak:eng")); |
372 EXPECT_FALSE(observer.last_show_message_); | 361 EXPECT_FALSE(observer.last_show_message_); |
373 EXPECT_EQ(2, observer.input_method_changed_count_); | 362 EXPECT_EQ(2, observer.input_method_changed_count_); |
374 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 363 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
375 manager_->ChangeInputMethod(XkbId("xkb:us:dvorak:eng")); | 364 manager_->ChangeInputMethod(Id("xkb:us:dvorak:eng")); |
376 EXPECT_FALSE(observer.last_show_message_); | 365 EXPECT_FALSE(observer.last_show_message_); |
377 | 366 |
378 // The observer is always notified even when the same input method ID is | 367 // The observer is always notified even when the same input method ID is |
379 // passed to ChangeInputMethod() more than twice. | 368 // passed to ChangeInputMethod() more than twice. |
380 // TODO(komatsu): Revisit if this is neccessary. | 369 // TODO(komatsu): Revisit if this is neccessary. |
381 EXPECT_EQ(3, observer.input_method_changed_count_); | 370 EXPECT_EQ(3, observer.input_method_changed_count_); |
382 | 371 |
383 // If the same input method ID is passed, PropertyChanged() is not | 372 // If the same input method ID is passed, PropertyChanged() is not |
384 // notified. | 373 // notified. |
385 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 374 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
386 | 375 |
387 manager_->RemoveObserver(&observer); | 376 manager_->RemoveObserver(&observer); |
388 menu_manager_->RemoveObserver(&observer); | 377 menu_manager_->RemoveObserver(&observer); |
389 } | 378 } |
390 | 379 |
391 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { | 380 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { |
392 InitComponentExtension(); | 381 InitComponentExtension(); |
393 InputMethodDescriptors methods; | 382 InputMethodDescriptors methods; |
394 if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) { | 383 methods = manager_->GetComponentExtensionIMEManager() |
395 methods = manager_->GetComponentExtensionIMEManager() | 384 ->GetXkbIMEAsInputMethodDescriptor(); |
396 ->GetXkbIMEAsInputMethodDescriptor(); | |
397 } else { | |
398 methods = *(manager_->GetSupportedInputMethods()); | |
399 } | |
400 // Try to find random 4-5 layuts and IMEs to make sure the returned list is | 385 // Try to find random 4-5 layuts and IMEs to make sure the returned list is |
401 // correct. | 386 // correct. |
402 const InputMethodDescriptor* id_to_find = | 387 const InputMethodDescriptor* id_to_find = |
403 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 388 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
404 kNaclMozcUsId); | 389 Id(kNaclMozcUsId)); |
405 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 390 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
406 XkbId("xkb:us::eng")); | 391 Id("xkb:us::eng")); |
407 EXPECT_TRUE(Contain(methods, *id_to_find)); | 392 EXPECT_TRUE(Contain(methods, *id_to_find)); |
408 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 393 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
409 XkbId("xkb:us:dvorak:eng")); | 394 Id("xkb:us:dvorak:eng")); |
410 EXPECT_TRUE(Contain(methods, *id_to_find)); | 395 EXPECT_TRUE(Contain(methods, *id_to_find)); |
411 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 396 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
412 XkbId("xkb:fr::fra")); | 397 Id("xkb:fr::fra")); |
413 EXPECT_TRUE(Contain(methods, *id_to_find)); | 398 EXPECT_TRUE(Contain(methods, *id_to_find)); |
414 } | 399 } |
415 | 400 |
416 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 401 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
417 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 402 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
418 // ibus_input_method.txt. | 403 // ibus_input_method.txt. |
419 std::vector<std::string> keyboard_layouts; | 404 std::vector<std::string> keyboard_layouts; |
420 | 405 |
421 InitComponentExtension(); | 406 InitComponentExtension(); |
422 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 407 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
423 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 408 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
424 | 409 |
425 // For http://crbug.com/19655#c11 - (5) | 410 // For http://crbug.com/19655#c11 - (5) |
426 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 411 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
427 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 412 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
428 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 413 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
429 } | 414 } |
430 | 415 |
431 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 416 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
432 // For http://crbug.com/329061 | 417 // For http://crbug.com/329061 |
433 std::vector<std::string> keyboard_layouts; | 418 std::vector<std::string> keyboard_layouts; |
434 keyboard_layouts.push_back(XkbId("xkb:se::swe")); | 419 keyboard_layouts.push_back(Id("xkb:se::swe")); |
435 | 420 |
436 InitComponentExtension(); | 421 InitComponentExtension(); |
437 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 422 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
438 const std::string im_id = manager_->GetCurrentInputMethod().id(); | 423 const std::string im_id = manager_->GetCurrentInputMethod().id(); |
439 EXPECT_EQ(XkbId("xkb:se::swe"), im_id); | 424 EXPECT_EQ(Id("xkb:se::swe"), im_id); |
440 } | 425 } |
441 | 426 |
442 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 427 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
443 InitComponentExtension(); | 428 InitComponentExtension(); |
444 // The physical layout is French. | 429 // The physical layout is French. |
445 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 430 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
446 "xkb:fr::fra"); | 431 "xkb:fr::fra"); |
447 manager_->EnableLoginLayouts( | 432 manager_->EnableLoginLayouts( |
448 "en-US", | 433 "en-US", |
449 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 434 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
450 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French | 435 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French |
451 // The physical layout is Japanese. | 436 // The physical layout is Japanese. |
452 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 437 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
453 "xkb:jp::jpn"); | 438 "xkb:jp::jpn"); |
454 manager_->EnableLoginLayouts( | 439 manager_->EnableLoginLayouts( |
455 "ja", | 440 "ja", |
456 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 441 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
457 // "xkb:us::eng" is not needed, hence 1. | 442 // "xkb:us::eng" is not needed, hence 1. |
458 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 443 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
459 | 444 |
460 // The physical layout is Russian. | 445 // The physical layout is Russian. |
461 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 446 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
462 "xkb:ru::rus"); | 447 "xkb:ru::rus"); |
463 manager_->EnableLoginLayouts( | 448 manager_->EnableLoginLayouts( |
464 "ru", | 449 "ru", |
465 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 450 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
466 // "xkb:us::eng" only. | 451 // "xkb:us::eng" only. |
467 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 452 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
468 EXPECT_EQ(XkbId("xkb:us::eng"), | 453 EXPECT_EQ(Id("xkb:us::eng"), |
469 manager_->GetActiveInputMethodIds().front()); | 454 manager_->GetActiveInputMethodIds().front()); |
470 } | 455 } |
471 | 456 |
472 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { | 457 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
473 InitComponentExtension(); | 458 InitComponentExtension(); |
474 // The physical layouts are French and Hungarian. | 459 // The physical layouts are French and Hungarian. |
475 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 460 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
476 "xkb:fr::fra,xkb:hu::hun"); | 461 "xkb:fr::fra,xkb:hu::hun"); |
477 manager_->EnableLoginLayouts( | 462 manager_->EnableLoginLayouts( |
478 "en-US", | 463 "en-US", |
(...skipping 19 matching lines...) Expand all Loading... | |
498 InitComponentExtension(); | 483 InitComponentExtension(); |
499 std::vector<std::string> keyboard_layouts; | 484 std::vector<std::string> keyboard_layouts; |
500 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 485 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
501 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 486 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
502 scoped_ptr<InputMethodDescriptors> methods( | 487 scoped_ptr<InputMethodDescriptors> methods( |
503 manager_->GetActiveInputMethods()); | 488 manager_->GetActiveInputMethods()); |
504 ASSERT_TRUE(methods.get()); | 489 ASSERT_TRUE(methods.get()); |
505 EXPECT_EQ(2U, methods->size()); | 490 EXPECT_EQ(2U, methods->size()); |
506 const InputMethodDescriptor* id_to_find = | 491 const InputMethodDescriptor* id_to_find = |
507 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 492 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
508 XkbId("xkb:us::eng")); | 493 Id("xkb:us::eng")); |
509 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); | 494 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
510 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 495 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
511 XkbId("xkb:jp::jpn")); | 496 Id("xkb:jp::jpn")); |
512 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); | 497 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
513 } | 498 } |
514 | 499 |
515 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 500 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
516 // For http://crbug.com/19655#c11 - (8), step 6. | 501 // For http://crbug.com/19655#c11 - (8), step 6. |
517 TestObserver observer; | 502 TestObserver observer; |
518 manager_->AddObserver(&observer); | 503 manager_->AddObserver(&observer); |
519 InitComponentExtension(); | 504 InitComponentExtension(); |
520 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 505 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
521 std::vector<std::string> ids; | 506 std::vector<std::string> ids; |
522 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 507 ids.push_back(Id("xkb:us:dvorak:eng")); |
523 ids.push_back(XkbId("xkb:us:colemak:eng")); | 508 ids.push_back(Id("xkb:us:colemak:eng")); |
524 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 509 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
525 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 510 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
526 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 511 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
527 // called. | 512 // called. |
528 EXPECT_EQ(1, observer.input_method_changed_count_); | 513 EXPECT_EQ(1, observer.input_method_changed_count_); |
529 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 514 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
530 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 515 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
531 // Disable Dvorak. | 516 // Disable Dvorak. |
532 ids.erase(ids.begin()); | 517 ids.erase(ids.begin()); |
533 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 518 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
534 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 519 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
535 EXPECT_EQ(2, observer.input_method_changed_count_); | 520 EXPECT_EQ(2, observer.input_method_changed_count_); |
536 EXPECT_EQ(XkbId(ids[0]), // colemak | 521 EXPECT_EQ(Id(ids[0]), // colemak |
537 manager_->GetCurrentInputMethod().id()); | 522 manager_->GetCurrentInputMethod().id()); |
538 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 523 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
539 manager_->RemoveObserver(&observer); | 524 manager_->RemoveObserver(&observer); |
540 } | 525 } |
541 | 526 |
542 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 527 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
543 // For http://crbug.com/19655#c11 - (9). | 528 // For http://crbug.com/19655#c11 - (9). |
544 TestObserver observer; | 529 TestObserver observer; |
545 manager_->AddObserver(&observer); | 530 manager_->AddObserver(&observer); |
546 InitComponentExtension(); | 531 InitComponentExtension(); |
547 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 532 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
548 std::vector<std::string> ids; | 533 std::vector<std::string> ids; |
549 ids.push_back(XkbId("xkb:us::eng")); | 534 ids.push_back(Id("xkb:us::eng")); |
550 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 535 ids.push_back(Id("xkb:us:dvorak:eng")); |
551 ids.push_back(XkbId("xkb:us:colemak:eng")); | 536 ids.push_back(Id("xkb:us:colemak:eng")); |
552 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 537 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
553 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 538 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
554 EXPECT_EQ(1, observer.input_method_changed_count_); | 539 EXPECT_EQ(1, observer.input_method_changed_count_); |
555 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 540 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
556 EXPECT_EQ("us", keyboard_->last_layout_); | 541 EXPECT_EQ("us", keyboard_->last_layout_); |
557 // Switch to Dvorak. | 542 // Switch to Dvorak. |
558 manager_->SwitchToNextInputMethod(); | 543 manager_->SwitchToNextInputMethod(); |
559 EXPECT_EQ(2, observer.input_method_changed_count_); | 544 EXPECT_EQ(2, observer.input_method_changed_count_); |
560 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 545 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
561 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 546 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
562 // Disable Dvorak. | 547 // Disable Dvorak. |
563 ids.erase(ids.begin() + 1); | 548 ids.erase(ids.begin() + 1); |
564 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 549 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
565 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 550 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
566 EXPECT_EQ(3, observer.input_method_changed_count_); | 551 EXPECT_EQ(3, observer.input_method_changed_count_); |
567 EXPECT_EQ(XkbId(ids[0]), // US Qwerty | 552 EXPECT_EQ(Id(ids[0]), // US Qwerty |
568 manager_->GetCurrentInputMethod().id()); | 553 manager_->GetCurrentInputMethod().id()); |
569 EXPECT_EQ("us", keyboard_->last_layout_); | 554 EXPECT_EQ("us", keyboard_->last_layout_); |
570 manager_->RemoveObserver(&observer); | 555 manager_->RemoveObserver(&observer); |
571 } | 556 } |
572 | 557 |
573 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 558 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
574 // For http://crbug.com/19655#c11 - (10). | 559 // For http://crbug.com/19655#c11 - (10). |
575 TestObserver observer; | 560 TestObserver observer; |
576 manager_->AddObserver(&observer); | 561 manager_->AddObserver(&observer); |
577 InitComponentExtension(); | 562 InitComponentExtension(); |
578 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 563 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
579 std::vector<std::string> ids; | 564 std::vector<std::string> ids; |
580 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 565 ids.push_back(Id("xkb:us:dvorak:eng")); |
581 ids.push_back(kNaclMozcUsId); | 566 ids.push_back(Id(kNaclMozcUsId)); |
582 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 567 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
583 EXPECT_EQ(1, observer.input_method_changed_count_); | 568 EXPECT_EQ(1, observer.input_method_changed_count_); |
584 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 569 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
585 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 570 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
586 // Switch to Mozc | 571 // Switch to Mozc |
587 manager_->SwitchToNextInputMethod(); | 572 manager_->SwitchToNextInputMethod(); |
588 EXPECT_EQ(2, observer.input_method_changed_count_); | 573 EXPECT_EQ(2, observer.input_method_changed_count_); |
589 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 574 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
590 EXPECT_EQ("us", keyboard_->last_layout_); | 575 EXPECT_EQ("us", keyboard_->last_layout_); |
591 // Disable Mozc. | 576 // Disable Mozc. |
592 ids.erase(ids.begin() + 1); | 577 ids.erase(ids.begin() + 1); |
593 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 578 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
594 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 579 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
595 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 580 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
596 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 581 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
597 } | 582 } |
598 | 583 |
599 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 584 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
600 // For http://crbug.com/19655#c11 - (11). | 585 // For http://crbug.com/19655#c11 - (11). |
601 TestObserver observer; | 586 TestObserver observer; |
602 manager_->AddObserver(&observer); | 587 manager_->AddObserver(&observer); |
603 InitComponentExtension(); | 588 InitComponentExtension(); |
604 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 589 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
605 std::vector<std::string> ids; | 590 std::vector<std::string> ids; |
606 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 591 ids.push_back(Id("xkb:us:dvorak:eng")); |
607 ids.push_back(kNaclMozcUsId); | 592 ids.push_back(Id(kNaclMozcUsId)); |
608 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 593 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
609 EXPECT_EQ(1, observer.input_method_changed_count_); | 594 EXPECT_EQ(1, observer.input_method_changed_count_); |
610 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 595 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
611 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 596 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
612 | 597 |
613 // Disable Dvorak. | 598 // Disable Dvorak. |
614 ids.erase(ids.begin()); | 599 ids.erase(ids.begin()); |
615 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 600 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
616 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 601 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
617 EXPECT_EQ(XkbId(ids[0]), // Mozc | 602 EXPECT_EQ(Id(ids[0]), // Mozc |
618 manager_->GetCurrentInputMethod().id()); | 603 manager_->GetCurrentInputMethod().id()); |
619 EXPECT_EQ("us", keyboard_->last_layout_); | 604 EXPECT_EQ("us", keyboard_->last_layout_); |
620 manager_->RemoveObserver(&observer); | 605 manager_->RemoveObserver(&observer); |
621 } | 606 } |
622 | 607 |
623 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 608 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
624 TestObserver observer; | 609 TestObserver observer; |
625 manager_->AddObserver(&observer); | 610 manager_->AddObserver(&observer); |
626 InitComponentExtension(); | 611 InitComponentExtension(); |
627 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 612 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
628 std::vector<std::string> ids; | 613 std::vector<std::string> ids; |
629 ids.push_back(kExt2Engine1Id); | 614 ids.push_back(Id(kExt2Engine1Id)); |
630 ids.push_back("mozc-dv"); | 615 ids.push_back("mozc-dv"); |
631 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 616 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
632 EXPECT_EQ(1, observer.input_method_changed_count_); | 617 EXPECT_EQ(1, observer.input_method_changed_count_); |
633 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 618 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
634 EXPECT_EQ("us", keyboard_->last_layout_); | 619 EXPECT_EQ("us", keyboard_->last_layout_); |
635 manager_->RemoveObserver(&observer); | 620 manager_->RemoveObserver(&observer); |
636 } | 621 } |
637 | 622 |
638 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 623 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
639 TestObserver observer; | 624 TestObserver observer; |
640 manager_->AddObserver(&observer); | 625 manager_->AddObserver(&observer); |
641 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 626 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
642 std::vector<std::string> ids; | 627 std::vector<std::string> ids; |
643 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 628 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
644 ids.push_back("unknown-super-cool-ime"); | 629 ids.push_back("unknown-super-cool-ime"); |
645 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); | 630 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); |
646 | 631 |
647 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this | 632 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this |
648 // case? | 633 // case? |
649 EXPECT_EQ(0, observer.input_method_changed_count_); | 634 EXPECT_EQ(0, observer.input_method_changed_count_); |
650 | 635 |
651 manager_->RemoveObserver(&observer); | 636 manager_->RemoveObserver(&observer); |
652 } | 637 } |
653 | 638 |
654 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { | 639 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { |
655 // For http://crbug.com/19655#c11 - (14). | 640 // For http://crbug.com/19655#c11 - (14). |
656 TestObserver observer; | 641 TestObserver observer; |
657 manager_->AddObserver(&observer); | 642 manager_->AddObserver(&observer); |
658 InitComponentExtension(); | 643 InitComponentExtension(); |
659 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 644 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
660 std::vector<std::string> ids; | 645 std::vector<std::string> ids; |
661 ids.push_back(XkbId("xkb:us::eng")); | 646 ids.push_back(Id("xkb:us::eng")); |
662 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 647 ids.push_back(Id("xkb:us:dvorak:eng")); |
663 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 648 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
664 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 649 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
665 EXPECT_EQ(1, observer.input_method_changed_count_); | 650 EXPECT_EQ(1, observer.input_method_changed_count_); |
666 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 651 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
667 EXPECT_EQ("us", keyboard_->last_layout_); | 652 EXPECT_EQ("us", keyboard_->last_layout_); |
668 | 653 |
669 // Switch to Dvorak. | 654 // Switch to Dvorak. |
670 manager_->SwitchToNextInputMethod(); | 655 manager_->SwitchToNextInputMethod(); |
671 EXPECT_EQ(2, observer.input_method_changed_count_); | 656 EXPECT_EQ(2, observer.input_method_changed_count_); |
672 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 657 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
673 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 658 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
674 | 659 |
675 // Lock screen | 660 // Lock screen |
676 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 661 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
677 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 662 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
678 EXPECT_EQ(XkbId(ids[1]), // still Dvorak | 663 EXPECT_EQ(Id(ids[1]), // still Dvorak |
679 manager_->GetCurrentInputMethod().id()); | 664 manager_->GetCurrentInputMethod().id()); |
680 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 665 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
681 // Switch back to Qwerty. | 666 // Switch back to Qwerty. |
682 manager_->SwitchToNextInputMethod(); | 667 manager_->SwitchToNextInputMethod(); |
683 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 668 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
684 EXPECT_EQ("us", keyboard_->last_layout_); | 669 EXPECT_EQ("us", keyboard_->last_layout_); |
685 | 670 |
686 // Unlock screen. The original state, Dvorak, is restored. | 671 // Unlock screen. The original state, Dvorak, is restored. |
687 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 672 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
688 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 673 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
689 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 674 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
690 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 675 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
691 | 676 |
692 manager_->RemoveObserver(&observer); | 677 manager_->RemoveObserver(&observer); |
693 } | 678 } |
694 | 679 |
695 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 680 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
696 // For http://crbug.com/19655#c11 - (15). | 681 // For http://crbug.com/19655#c11 - (15). |
697 TestObserver observer; | 682 TestObserver observer; |
698 manager_->AddObserver(&observer); | 683 manager_->AddObserver(&observer); |
699 InitComponentExtension(); | 684 InitComponentExtension(); |
700 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 685 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
701 std::vector<std::string> ids; | 686 std::vector<std::string> ids; |
702 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 687 ids.push_back(Id("xkb:us:dvorak:eng")); |
703 ids.push_back(kExt2Engine2Id); | 688 ids.push_back(Id(kExt2Engine2Id)); |
704 ids.push_back(kExt2Engine1Id); | 689 ids.push_back(Id(kExt2Engine1Id)); |
705 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 690 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
706 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 691 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
707 EXPECT_EQ(1, observer.input_method_changed_count_); | 692 EXPECT_EQ(1, observer.input_method_changed_count_); |
708 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 693 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
709 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 694 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
710 | 695 |
711 // Switch to Mozc. | 696 // Switch to Mozc. |
712 manager_->SwitchToNextInputMethod(); | 697 manager_->SwitchToNextInputMethod(); |
713 EXPECT_EQ(2, observer.input_method_changed_count_); | 698 EXPECT_EQ(2, observer.input_method_changed_count_); |
714 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 699 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
715 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 700 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
716 | 701 |
717 // Lock screen | 702 // Lock screen |
718 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 703 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
719 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. | 704 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. |
720 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), | 705 EXPECT_EQ(Id("xkb:us:dvorak:eng"), |
721 manager_->GetCurrentInputMethod().id()); | 706 manager_->GetCurrentInputMethod().id()); |
722 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 707 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
723 manager_->SwitchToNextInputMethod(); | 708 manager_->SwitchToNextInputMethod(); |
724 EXPECT_EQ(XkbId("xkb:us::eng"), // The hardware keyboard layout. | 709 EXPECT_EQ(Id("xkb:us::eng"), // The hardware keyboard layout. |
725 manager_->GetCurrentInputMethod().id()); | 710 manager_->GetCurrentInputMethod().id()); |
726 EXPECT_EQ("us", keyboard_->last_layout_); | 711 EXPECT_EQ("us", keyboard_->last_layout_); |
727 | 712 |
728 // Unlock screen. The original state, pinyin-dv, is restored. | 713 // Unlock screen. The original state, pinyin-dv, is restored. |
729 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 714 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
730 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. | 715 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. |
731 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); | 716 EXPECT_EQ(Id(ids[1]), manager_->GetCurrentInputMethod().id()); |
732 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 717 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
733 | 718 |
734 manager_->RemoveObserver(&observer); | 719 manager_->RemoveObserver(&observer); |
735 } | 720 } |
736 | 721 |
737 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 722 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
738 // For http://crbug.com/19655#c11 - (8), step 7-11. | 723 // For http://crbug.com/19655#c11 - (8), step 7-11. |
739 InitComponentExtension(); | 724 InitComponentExtension(); |
740 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 725 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
741 std::vector<std::string> ids; | 726 std::vector<std::string> ids; |
742 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 727 ids.push_back(Id("xkb:us:dvorak:eng")); |
743 ids.push_back(XkbId("xkb:us:colemak:eng")); | 728 ids.push_back(Id("xkb:us:colemak:eng")); |
744 ids.push_back(kNaclMozcJpId); | 729 ids.push_back(Id(kNaclMozcJpId)); |
745 ids.push_back(kNaclMozcUsId); | 730 ids.push_back(Id(kNaclMozcUsId)); |
746 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 731 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
747 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); | 732 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); |
748 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); | 733 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); |
749 // See input_methods.txt for an expected XKB layout name. | 734 // See input_methods.txt for an expected XKB layout name. |
750 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 735 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
751 manager_->SwitchToNextInputMethod(); | 736 manager_->SwitchToNextInputMethod(); |
752 EXPECT_EQ(2, keyboard_->set_current_keyboard_layout_by_name_count_); | 737 EXPECT_EQ(2, keyboard_->set_current_keyboard_layout_by_name_count_); |
753 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 738 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
754 manager_->SwitchToNextInputMethod(); | 739 manager_->SwitchToNextInputMethod(); |
755 EXPECT_EQ(3, keyboard_->set_current_keyboard_layout_by_name_count_); | 740 EXPECT_EQ(3, keyboard_->set_current_keyboard_layout_by_name_count_); |
(...skipping 26 matching lines...) Expand all Loading... | |
782 manager_->ActivateInputMethodMenuItem("key2"); | 767 manager_->ActivateInputMethodMenuItem("key2"); |
783 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 768 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
784 } | 769 } |
785 | 770 |
786 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { | 771 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
787 InitComponentExtension(); | 772 InitComponentExtension(); |
788 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 773 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
789 | 774 |
790 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 775 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
791 std::vector<std::string> ids; | 776 std::vector<std::string> ids; |
792 ids.push_back(XkbId("xkb:us::eng")); | 777 ids.push_back(Id("xkb:us::eng")); |
793 ids.push_back(kNaclMozcUsId); | 778 ids.push_back(Id(kNaclMozcUsId)); |
794 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 779 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
795 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 780 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
796 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 781 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
797 manager_->ChangeInputMethod(kNaclMozcUsId); | 782 manager_->ChangeInputMethod(Id(kNaclMozcUsId)); |
798 | 783 |
799 ash::ime::InputMethodMenuItemList current_property_list; | 784 ash::ime::InputMethodMenuItemList current_property_list; |
800 current_property_list.push_back(ash::ime::InputMethodMenuItem( | 785 current_property_list.push_back(ash::ime::InputMethodMenuItem( |
801 "key", "label", false, false)); | 786 "key", "label", false, false)); |
802 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 787 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
803 | 788 |
804 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 789 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
805 EXPECT_EQ("key", | 790 EXPECT_EQ("key", |
806 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 791 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
807 | 792 |
808 manager_->ChangeInputMethod("xkb:us::eng"); | 793 manager_->ChangeInputMethod("xkb:us::eng"); |
809 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 794 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
810 } | 795 } |
811 | 796 |
812 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { | 797 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
813 InitComponentExtension(); | 798 InitComponentExtension(); |
814 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 799 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
815 | 800 |
816 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 801 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
817 std::vector<std::string> ids; | 802 std::vector<std::string> ids; |
818 ids.push_back(kNaclMozcUsId); // Japanese | 803 ids.push_back(Id(kNaclMozcUsId)); // Japanese |
819 ids.push_back(kExt2Engine1Id); // T-Chinese | 804 ids.push_back(Id(kExt2Engine1Id)); // T-Chinese |
820 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 805 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
821 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 806 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
822 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 807 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
823 | 808 |
824 ash::ime::InputMethodMenuItemList current_property_list; | 809 ash::ime::InputMethodMenuItemList current_property_list; |
825 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", | 810 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", |
826 "label", | 811 "label", |
827 false, | 812 false, |
828 false)); | 813 false)); |
829 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 814 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
830 | 815 |
831 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 816 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
832 EXPECT_EQ("key-mozc", | 817 EXPECT_EQ("key-mozc", |
833 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 818 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
834 | 819 |
835 manager_->ChangeInputMethod(kExt2Engine1Id); | 820 manager_->ChangeInputMethod(Id(kExt2Engine1Id)); |
836 // Since the IME is changed, the property for mozc Japanese should be hidden. | 821 // Since the IME is changed, the property for mozc Japanese should be hidden. |
837 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 822 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
838 | 823 |
839 // Asynchronous property update signal from mozc-chewing. | 824 // Asynchronous property update signal from mozc-chewing. |
840 current_property_list.clear(); | 825 current_property_list.clear(); |
841 current_property_list.push_back(ash::ime::InputMethodMenuItem( | 826 current_property_list.push_back(ash::ime::InputMethodMenuItem( |
842 "key-chewing", "label", false, false)); | 827 "key-chewing", "label", false, false)); |
843 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 828 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
844 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 829 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
845 EXPECT_EQ("key-chewing", | 830 EXPECT_EQ("key-chewing", |
846 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 831 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
847 } | 832 } |
848 | 833 |
849 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 834 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
850 TestObserver observer; | 835 TestObserver observer; |
851 manager_->AddObserver(&observer); | 836 manager_->AddObserver(&observer); |
852 InitComponentExtension(); | 837 InitComponentExtension(); |
853 std::vector<std::string> keyboard_layouts; | 838 std::vector<std::string> keyboard_layouts; |
854 keyboard_layouts.push_back(XkbId("xkb:us::eng")); | 839 keyboard_layouts.push_back(Id("xkb:us::eng")); |
855 // For http://crbug.com/19655#c11 - (1) | 840 // For http://crbug.com/19655#c11 - (1) |
856 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 841 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
857 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 842 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
858 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 843 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
859 EXPECT_EQ("us", keyboard_->last_layout_); | 844 EXPECT_EQ("us", keyboard_->last_layout_); |
860 manager_->SwitchToNextInputMethod(); | 845 manager_->SwitchToNextInputMethod(); |
861 EXPECT_TRUE(observer.last_show_message_); | 846 EXPECT_TRUE(observer.last_show_message_); |
862 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); | 847 EXPECT_EQ(Id("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
863 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 848 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
864 manager_->SwitchToNextInputMethod(); | 849 manager_->SwitchToNextInputMethod(); |
865 EXPECT_TRUE(observer.last_show_message_); | 850 EXPECT_TRUE(observer.last_show_message_); |
866 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), | 851 EXPECT_EQ(Id("xkb:us:altgr-intl:eng"), |
867 manager_->GetCurrentInputMethod().id()); | 852 manager_->GetCurrentInputMethod().id()); |
868 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 853 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
869 manager_->SwitchToNextInputMethod(); | 854 manager_->SwitchToNextInputMethod(); |
870 EXPECT_TRUE(observer.last_show_message_); | 855 EXPECT_TRUE(observer.last_show_message_); |
871 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), | 856 EXPECT_EQ(Id("xkb:us:dvorak:eng"), |
872 manager_->GetCurrentInputMethod().id()); | 857 manager_->GetCurrentInputMethod().id()); |
873 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 858 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
874 manager_->SwitchToNextInputMethod(); | 859 manager_->SwitchToNextInputMethod(); |
875 EXPECT_TRUE(observer.last_show_message_); | 860 EXPECT_TRUE(observer.last_show_message_); |
876 EXPECT_EQ(XkbId("xkb:us:colemak:eng"), | 861 EXPECT_EQ(Id("xkb:us:colemak:eng"), |
877 manager_->GetCurrentInputMethod().id()); | 862 manager_->GetCurrentInputMethod().id()); |
878 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 863 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
879 manager_->SwitchToNextInputMethod(); | 864 manager_->SwitchToNextInputMethod(); |
880 EXPECT_TRUE(observer.last_show_message_); | 865 EXPECT_TRUE(observer.last_show_message_); |
881 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 866 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
882 EXPECT_EQ("us", keyboard_->last_layout_); | 867 EXPECT_EQ("us", keyboard_->last_layout_); |
883 | 868 |
884 manager_->RemoveObserver(&observer); | 869 manager_->RemoveObserver(&observer); |
885 } | 870 } |
886 | 871 |
887 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 872 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
888 TestObserver observer; | 873 TestObserver observer; |
889 manager_->AddObserver(&observer); | 874 manager_->AddObserver(&observer); |
890 InitComponentExtension(); | 875 InitComponentExtension(); |
891 | 876 |
892 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 877 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
893 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 878 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
894 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 879 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
895 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 880 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
896 | 881 |
897 std::vector<std::string> keyboard_layouts; | 882 std::vector<std::string> keyboard_layouts; |
898 keyboard_layouts.push_back(XkbId("xkb:us::eng")); | 883 keyboard_layouts.push_back(Id("xkb:us::eng")); |
899 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 884 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
900 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 885 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
901 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 886 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
902 EXPECT_EQ("us", keyboard_->last_layout_); | 887 EXPECT_EQ("us", keyboard_->last_layout_); |
903 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 888 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
904 EXPECT_TRUE(observer.last_show_message_); | 889 EXPECT_TRUE(observer.last_show_message_); |
905 EXPECT_EQ(XkbId("xkb:us:intl:eng"), | 890 EXPECT_EQ(Id("xkb:us:intl:eng"), |
906 manager_->GetCurrentInputMethod().id()); | 891 manager_->GetCurrentInputMethod().id()); |
907 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 892 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
908 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 893 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
909 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 894 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
910 EXPECT_TRUE(observer.last_show_message_); | 895 EXPECT_TRUE(observer.last_show_message_); |
911 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 896 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
912 EXPECT_EQ("us", keyboard_->last_layout_); | 897 EXPECT_EQ("us", keyboard_->last_layout_); |
913 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 898 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
914 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 899 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
915 EXPECT_TRUE(observer.last_show_message_); | 900 EXPECT_TRUE(observer.last_show_message_); |
916 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); | 901 EXPECT_EQ(Id("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
917 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 902 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
918 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 903 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
919 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 904 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
920 EXPECT_TRUE(observer.last_show_message_); | 905 EXPECT_TRUE(observer.last_show_message_); |
921 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 906 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
922 EXPECT_EQ("us", keyboard_->last_layout_); | 907 EXPECT_EQ("us", keyboard_->last_layout_); |
923 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 908 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
924 EXPECT_TRUE(observer.last_show_message_); | 909 EXPECT_TRUE(observer.last_show_message_); |
925 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); | 910 EXPECT_EQ(Id("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
926 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 911 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
927 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 912 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
928 EXPECT_TRUE(observer.last_show_message_); | 913 EXPECT_TRUE(observer.last_show_message_); |
929 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), | 914 EXPECT_EQ(Id("xkb:us:altgr-intl:eng"), |
930 manager_->GetCurrentInputMethod().id()); | 915 manager_->GetCurrentInputMethod().id()); |
931 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 916 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
932 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 917 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
933 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 918 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
934 EXPECT_TRUE(observer.last_show_message_); | 919 EXPECT_TRUE(observer.last_show_message_); |
935 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); | 920 EXPECT_EQ(Id("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
936 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 921 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
937 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 922 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
938 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 923 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
939 EXPECT_TRUE(observer.last_show_message_); | 924 EXPECT_TRUE(observer.last_show_message_); |
940 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), | 925 EXPECT_EQ(Id("xkb:us:altgr-intl:eng"), |
941 manager_->GetCurrentInputMethod().id()); | 926 manager_->GetCurrentInputMethod().id()); |
942 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 927 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
943 | 928 |
944 manager_->RemoveObserver(&observer); | 929 manager_->RemoveObserver(&observer); |
945 } | 930 } |
946 | 931 |
947 TEST_F(InputMethodManagerImplTest, | 932 TEST_F(InputMethodManagerImplTest, |
948 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { | 933 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { |
949 TestObserver observer; | 934 TestObserver observer; |
950 manager_->AddObserver(&observer); | 935 manager_->AddObserver(&observer); |
951 InitComponentExtension(); | 936 InitComponentExtension(); |
952 | 937 |
953 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 938 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
954 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 939 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
955 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 940 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
956 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 941 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
957 | 942 |
958 std::vector<std::string> ids; | 943 std::vector<std::string> ids; |
959 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 944 ids.push_back(Id("xkb:us:dvorak:eng")); |
960 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 945 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
961 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 946 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
962 | 947 |
963 // Ctrl+Space accelerator should not be consumed if there is only one active | 948 // Ctrl+Space accelerator should not be consumed if there is only one active |
964 // input method. | 949 // input method. |
965 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 950 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
966 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 951 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
967 | 952 |
968 manager_->RemoveObserver(&observer); | 953 manager_->RemoveObserver(&observer); |
969 } | 954 } |
970 | 955 |
971 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 956 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
972 std::string expect_id = XkbId("xkb:us::eng"); | 957 std::string expect_id = Id("xkb:us::eng"); |
973 TestObserver observer; | 958 TestObserver observer; |
974 manager_->AddObserver(&observer); | 959 manager_->AddObserver(&observer); |
975 InitComponentExtension(); | 960 InitComponentExtension(); |
976 std::vector<std::string> keyboard_layouts; | 961 std::vector<std::string> keyboard_layouts; |
977 keyboard_layouts.push_back(XkbId("xkb:us::eng")); | 962 keyboard_layouts.push_back(Id("xkb:us::eng")); |
978 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 963 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
979 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 964 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
980 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 965 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
981 EXPECT_EQ("us", keyboard_->last_layout_); | 966 EXPECT_EQ("us", keyboard_->last_layout_); |
982 | 967 |
983 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 968 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
984 // and keyboards are enabled. | 969 // and keyboards are enabled. |
985 EXPECT_FALSE(manager_->SwitchInputMethod( | 970 EXPECT_FALSE(manager_->SwitchInputMethod( |
986 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 971 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
987 EXPECT_FALSE(observer.last_show_message_); | 972 EXPECT_FALSE(observer.last_show_message_); |
(...skipping 18 matching lines...) Expand all Loading... | |
1006 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { | 991 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
1007 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. | 992 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. |
1008 InitComponentExtension(); | 993 InitComponentExtension(); |
1009 | 994 |
1010 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 995 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1011 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 996 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
1012 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 997 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1013 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 998 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
1014 | 999 |
1015 std::vector<std::string> keyboard_layouts; | 1000 std::vector<std::string> keyboard_layouts; |
1016 keyboard_layouts.push_back(XkbId("xkb:us::eng")); | 1001 keyboard_layouts.push_back(Id("xkb:us::eng")); |
1017 manager_->EnableLoginLayouts("ja", keyboard_layouts); | 1002 manager_->EnableLoginLayouts("ja", keyboard_layouts); |
1018 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1003 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1019 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 1004 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
1020 EXPECT_EQ("us", keyboard_->last_layout_); | 1005 EXPECT_EQ("us", keyboard_->last_layout_); |
1021 EXPECT_TRUE(manager_->SwitchInputMethod( | 1006 EXPECT_TRUE(manager_->SwitchInputMethod( |
1022 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1007 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1023 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1008 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1024 EXPECT_EQ("jp", keyboard_->last_layout_); | 1009 EXPECT_EQ("jp", keyboard_->last_layout_); |
1025 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 1010 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
1026 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 1011 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
1027 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 1012 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
1028 EXPECT_EQ("us", keyboard_->last_layout_); | 1013 EXPECT_EQ("us", keyboard_->last_layout_); |
1029 EXPECT_TRUE(manager_->SwitchInputMethod( | 1014 EXPECT_TRUE(manager_->SwitchInputMethod( |
1030 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1015 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1031 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1016 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1032 EXPECT_EQ("jp", keyboard_->last_layout_); | 1017 EXPECT_EQ("jp", keyboard_->last_layout_); |
1033 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 1018 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
1034 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 1019 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
1035 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); | 1020 EXPECT_EQ(Id("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
1036 EXPECT_EQ("us", keyboard_->last_layout_); | 1021 EXPECT_EQ("us", keyboard_->last_layout_); |
1037 EXPECT_TRUE(manager_->SwitchInputMethod( | 1022 EXPECT_TRUE(manager_->SwitchInputMethod( |
1038 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1023 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1039 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1024 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1040 EXPECT_EQ("jp", keyboard_->last_layout_); | 1025 EXPECT_EQ("jp", keyboard_->last_layout_); |
1041 } | 1026 } |
1042 | 1027 |
1043 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 1028 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
1044 InitComponentExtension(); | 1029 InitComponentExtension(); |
1045 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1030 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1046 std::vector<std::string> ids; | 1031 std::vector<std::string> ids; |
1047 ids.push_back(XkbId("xkb:jp::jpn")); | 1032 ids.push_back(Id("xkb:jp::jpn")); |
1048 ids.push_back(kNaclMozcJpId); | 1033 ids.push_back(Id(kNaclMozcJpId)); |
1049 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1034 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1050 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1035 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1051 EXPECT_EQ("jp", keyboard_->last_layout_); | 1036 EXPECT_EQ("jp", keyboard_->last_layout_); |
1052 EXPECT_TRUE(manager_->SwitchInputMethod( | 1037 EXPECT_TRUE(manager_->SwitchInputMethod( |
1053 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1038 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1054 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1039 EXPECT_EQ(Id(kNaclMozcJpId), manager_->GetCurrentInputMethod().id()); |
1055 EXPECT_EQ("jp", keyboard_->last_layout_); | 1040 EXPECT_EQ("jp", keyboard_->last_layout_); |
1056 EXPECT_TRUE(manager_->SwitchInputMethod( | 1041 EXPECT_TRUE(manager_->SwitchInputMethod( |
1057 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1042 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1058 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1043 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1059 EXPECT_EQ("jp", keyboard_->last_layout_); | 1044 EXPECT_EQ("jp", keyboard_->last_layout_); |
1060 EXPECT_TRUE(manager_->SwitchInputMethod( | 1045 EXPECT_TRUE(manager_->SwitchInputMethod( |
1061 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1046 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1062 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1047 EXPECT_EQ(Id(kNaclMozcJpId), manager_->GetCurrentInputMethod().id()); |
1063 EXPECT_EQ("jp", keyboard_->last_layout_); | 1048 EXPECT_EQ("jp", keyboard_->last_layout_); |
1064 EXPECT_TRUE(manager_->SwitchInputMethod( | 1049 EXPECT_TRUE(manager_->SwitchInputMethod( |
1065 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1050 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1066 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1051 EXPECT_EQ(Id(kNaclMozcJpId), manager_->GetCurrentInputMethod().id()); |
1067 EXPECT_EQ("jp", keyboard_->last_layout_); | 1052 EXPECT_EQ("jp", keyboard_->last_layout_); |
1068 EXPECT_TRUE(manager_->SwitchInputMethod( | 1053 EXPECT_TRUE(manager_->SwitchInputMethod( |
1069 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1054 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1070 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1055 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1071 EXPECT_EQ("jp", keyboard_->last_layout_); | 1056 EXPECT_EQ("jp", keyboard_->last_layout_); |
1072 EXPECT_TRUE(manager_->SwitchInputMethod( | 1057 EXPECT_TRUE(manager_->SwitchInputMethod( |
1073 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1058 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1074 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1059 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1075 EXPECT_EQ("jp", keyboard_->last_layout_); | 1060 EXPECT_EQ("jp", keyboard_->last_layout_); |
1076 | 1061 |
1077 // Add Dvorak. | 1062 // Add Dvorak. |
1078 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 1063 ids.push_back(Id("xkb:us:dvorak:eng")); |
1079 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1064 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1080 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1065 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1081 EXPECT_EQ("jp", keyboard_->last_layout_); | 1066 EXPECT_EQ("jp", keyboard_->last_layout_); |
1082 EXPECT_TRUE(manager_->SwitchInputMethod( | 1067 EXPECT_TRUE(manager_->SwitchInputMethod( |
1083 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1068 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1084 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1069 EXPECT_EQ(Id(kNaclMozcJpId), manager_->GetCurrentInputMethod().id()); |
1085 EXPECT_EQ("jp", keyboard_->last_layout_); | 1070 EXPECT_EQ("jp", keyboard_->last_layout_); |
1086 EXPECT_TRUE(manager_->SwitchInputMethod( | 1071 EXPECT_TRUE(manager_->SwitchInputMethod( |
1087 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1072 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1088 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); | 1073 EXPECT_EQ(Id("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
1089 EXPECT_EQ("jp", keyboard_->last_layout_); | 1074 EXPECT_EQ("jp", keyboard_->last_layout_); |
1090 } | 1075 } |
1091 | 1076 |
1092 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 1077 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
1093 TestObserver observer; | 1078 TestObserver observer; |
1094 manager_->AddObserver(&observer); | 1079 manager_->AddObserver(&observer); |
1095 InitComponentExtension(); | 1080 InitComponentExtension(); |
1096 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1081 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1097 std::vector<std::string> ids; | 1082 std::vector<std::string> ids; |
1098 ids.push_back(XkbId("xkb:us:dvorak:eng")); | 1083 ids.push_back(Id("xkb:us:dvorak:eng")); |
1099 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1084 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1100 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1085 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1101 EXPECT_EQ(1, observer.input_method_changed_count_); | 1086 EXPECT_EQ(1, observer.input_method_changed_count_); |
1102 EXPECT_EQ(XkbId(ids[0]), | 1087 EXPECT_EQ(Id(ids[0]), |
1103 manager_->GetCurrentInputMethod().id()); | 1088 manager_->GetCurrentInputMethod().id()); |
1104 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1089 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1105 | 1090 |
1106 // Add two Extension IMEs. | 1091 // Add two Extension IMEs. |
1107 std::vector<std::string> layouts; | 1092 std::vector<std::string> layouts; |
1108 layouts.push_back("us"); | 1093 layouts.push_back("us"); |
1109 std::vector<std::string> languages; | 1094 std::vector<std::string> languages; |
1110 languages.push_back("en-US"); | 1095 languages.push_back("en-US"); |
1111 | 1096 |
1112 const std::string ext1_id = | 1097 const std::string ext1_id = |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1170 manager_->RemoveInputMethodExtension(ext2_id); | 1155 manager_->RemoveInputMethodExtension(ext2_id); |
1171 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1156 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1172 } | 1157 } |
1173 | 1158 |
1174 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 1159 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
1175 TestObserver observer; | 1160 TestObserver observer; |
1176 InitComponentExtension(); | 1161 InitComponentExtension(); |
1177 manager_->AddObserver(&observer); | 1162 manager_->AddObserver(&observer); |
1178 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1163 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1179 std::vector<std::string> ids; | 1164 std::vector<std::string> ids; |
1180 ids.push_back(XkbId("xkb:us::eng")); | 1165 ids.push_back(Id("xkb:us::eng")); |
1181 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1166 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1182 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1167 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1183 EXPECT_EQ(1, observer.input_method_changed_count_); | 1168 EXPECT_EQ(1, observer.input_method_changed_count_); |
1184 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); | 1169 EXPECT_EQ(Id(ids[0]), manager_->GetCurrentInputMethod().id()); |
1185 EXPECT_EQ("us", keyboard_->last_layout_); | 1170 EXPECT_EQ("us", keyboard_->last_layout_); |
1186 | 1171 |
1187 // Add an Extension IME. | 1172 // Add an Extension IME. |
1188 std::vector<std::string> layouts; | 1173 std::vector<std::string> layouts; |
1189 layouts.push_back("us(dvorak)"); | 1174 layouts.push_back("us(dvorak)"); |
1190 std::vector<std::string> languages; | 1175 std::vector<std::string> languages; |
1191 languages.push_back("en-US"); | 1176 languages.push_back("en-US"); |
1192 | 1177 |
1193 const std::string ext_id = | 1178 const std::string ext_id = |
1194 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 1179 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
(...skipping 19 matching lines...) Expand all Loading... | |
1214 | 1199 |
1215 // Switch to the IME. | 1200 // Switch to the IME. |
1216 manager_->SwitchToNextInputMethod(); | 1201 manager_->SwitchToNextInputMethod(); |
1217 EXPECT_EQ(3, observer.input_method_changed_count_); | 1202 EXPECT_EQ(3, observer.input_method_changed_count_); |
1218 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1203 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1219 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1204 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1220 | 1205 |
1221 // Lock the screen. This is for crosbug.com/27049. | 1206 // Lock the screen. This is for crosbug.com/27049. |
1222 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 1207 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
1223 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME | 1208 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME |
1224 EXPECT_EQ(XkbId("xkb:us::eng"), | 1209 EXPECT_EQ(Id("xkb:us::eng"), |
1225 manager_->GetCurrentInputMethod().id()); | 1210 manager_->GetCurrentInputMethod().id()); |
1226 EXPECT_EQ("us", keyboard_->last_layout_); | 1211 EXPECT_EQ("us", keyboard_->last_layout_); |
1227 | 1212 |
1228 // Unlock the screen. | 1213 // Unlock the screen. |
1229 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1214 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1230 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1215 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1231 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1216 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1232 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1217 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1233 { | 1218 { |
1234 // This is for crosbug.com/27052. | 1219 // This is for crosbug.com/27052. |
1235 scoped_ptr<InputMethodDescriptors> methods( | 1220 scoped_ptr<InputMethodDescriptors> methods( |
1236 manager_->GetActiveInputMethods()); | 1221 manager_->GetActiveInputMethods()); |
1237 ASSERT_EQ(2U, methods->size()); | 1222 ASSERT_EQ(2U, methods->size()); |
1238 // Ext. IMEs should be at the end of the list. | 1223 // Ext. IMEs should be at the end of the list. |
1239 EXPECT_EQ(ext_id, methods->at(1).id()); | 1224 EXPECT_EQ(ext_id, methods->at(1).id()); |
1240 } | 1225 } |
1241 manager_->RemoveObserver(&observer); | 1226 manager_->RemoveObserver(&observer); |
1242 } | 1227 } |
1243 | 1228 |
1244 TEST_F(InputMethodManagerImplTest, | 1229 TEST_F(InputMethodManagerImplTest, |
1245 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { | 1230 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { |
1246 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1231 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1247 std::vector<std::string> ids; | 1232 std::vector<std::string> ids; |
1248 ids.push_back(kNaclMozcUsId); | 1233 ids.push_back(Id(kNaclMozcUsId)); |
1249 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1234 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1250 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1235 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1251 manager_->ChangeInputMethod(kNaclMozcUsId); | 1236 manager_->ChangeInputMethod(Id(kNaclMozcUsId)); |
1252 | 1237 |
1253 InitComponentExtension(); | 1238 InitComponentExtension(); |
1254 EXPECT_EQ(kNaclMozcUsId, manager_->GetCurrentInputMethod().id()); | 1239 EXPECT_EQ(Id(kNaclMozcUsId), manager_->GetCurrentInputMethod().id()); |
1255 } | 1240 } |
1256 | 1241 |
1257 TEST_F(InputMethodManagerImplTest, | 1242 TEST_F(InputMethodManagerImplTest, |
1258 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { | 1243 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { |
1259 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1244 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1260 std::vector<std::string> ids; | 1245 std::vector<std::string> ids; |
1261 ids.push_back(kNaclMozcUsId); | 1246 ids.push_back(Id(kNaclMozcUsId)); |
1262 ids.push_back(kNaclMozcJpId); | 1247 ids.push_back(Id(kNaclMozcJpId)); |
1263 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1248 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1264 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1249 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1265 manager_->ChangeInputMethod(kNaclMozcUsId); | 1250 manager_->ChangeInputMethod(Id(kNaclMozcUsId)); |
1266 manager_->ChangeInputMethod(kNaclMozcJpId); | 1251 manager_->ChangeInputMethod(Id(kNaclMozcJpId)); |
1267 | 1252 |
1268 InitComponentExtension(); | 1253 InitComponentExtension(); |
1269 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1254 EXPECT_EQ(Id(kNaclMozcJpId), manager_->GetCurrentInputMethod().id()); |
1270 } | 1255 } |
1271 | 1256 |
1272 TEST_F(InputMethodManagerImplTest, | 1257 TEST_F(InputMethodManagerImplTest, |
1273 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | 1258 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { |
1274 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1259 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1275 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1260 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
1276 ime_list_[1].id, | 1261 ime_list_[1].id, |
1277 ime_list_[1].engines[0].engine_id); | 1262 ime_list_[1].engines[0].engine_id); |
1278 std::vector<std::string> ids; | 1263 std::vector<std::string> ids; |
1279 ids.push_back(ext_id); | 1264 ids.push_back(ext_id); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1333 std::vector<std::string> ids; | 1318 std::vector<std::string> ids; |
1334 ids.push_back(ext_id1); | 1319 ids.push_back(ext_id1); |
1335 ids.push_back(ext_id2); | 1320 ids.push_back(ext_id2); |
1336 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1321 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1337 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1322 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1338 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1323 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); |
1339 manager_->ChangeInputMethod(ext_id2); | 1324 manager_->ChangeInputMethod(ext_id2); |
1340 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1325 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
1341 } | 1326 } |
1342 | 1327 |
1343 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest_1) { | 1328 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest) { |
1344 extension_ime_util::ScopedUseExtensionKeyboardFlagForTesting | |
1345 scoped_flag(true); | |
1346 | |
1347 std::vector<std::string> input_method_ids; | 1329 std::vector<std::string> input_method_ids; |
1348 input_method_ids.push_back("xkb:us::eng"); | 1330 input_method_ids.push_back("xkb:us::eng"); |
1349 input_method_ids.push_back("xkb:fr::fra"); | 1331 input_method_ids.push_back("xkb:fr::fra"); |
1350 input_method_ids.push_back( | 1332 input_method_ids.push_back(Id("xkb:us::eng")); |
1351 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | |
1352 input_method_ids.push_back("xkb:fr::fra"); | 1333 input_method_ids.push_back("xkb:fr::fra"); |
1353 input_method_ids.push_back( | 1334 input_method_ids.push_back(Id("xkb:us::eng")); |
1354 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | |
1355 input_method_ids.push_back("_comp_ime_asdf_pinyin"); | 1335 input_method_ids.push_back("_comp_ime_asdf_pinyin"); |
1356 input_method_ids.push_back(kPinyinImeId); | 1336 input_method_ids.push_back(Id(kPinyinImeId)); |
1357 | 1337 |
1358 manager_->MigrateXkbInputMethods(&input_method_ids); | 1338 manager_->MigrateXkbInputMethods(&input_method_ids); |
1359 | 1339 |
1360 ASSERT_EQ(4U, input_method_ids.size()); | 1340 ASSERT_EQ(4U, input_method_ids.size()); |
1361 | 1341 |
1362 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng", | 1342 EXPECT_EQ(Id("xkb:us::eng"), input_method_ids[0]); |
1363 input_method_ids[0]); | 1343 EXPECT_EQ(Id("xkb:fr::fra"), input_method_ids[1]); |
1364 EXPECT_EQ(std::string("_comp_ime_") + kXkbExtId + "xkb:fr::fra", | |
1365 input_method_ids[1]); | |
1366 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1344 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1367 EXPECT_EQ("_comp_ime_gjaehgfemfahhmlgpdfknkhdnemmolopzh-t-i0-pinyin", | 1345 EXPECT_EQ(Id("zh-t-i0-pinyin"), input_method_ids[3]); |
1368 input_method_ids[3]); | |
1369 } | |
1370 | |
1371 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest_2) { | |
1372 extension_ime_util::ScopedUseExtensionKeyboardFlagForTesting | |
1373 scoped_flag(false); | |
1374 | |
1375 std::vector<std::string> input_method_ids; | |
1376 input_method_ids.push_back("xkb:us::eng"); | |
1377 input_method_ids.push_back("xkb:fr::fra"); | |
1378 input_method_ids.push_back( | |
1379 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | |
1380 input_method_ids.push_back("xkb:fr::fra"); | |
1381 input_method_ids.push_back( | |
1382 std::string("_comp_ime_") + kXkbExtId + "xkb:us::eng"); | |
1383 input_method_ids.push_back("_comp_ime_asdf_pinyin"); | |
1384 | |
1385 manager_->MigrateXkbInputMethods(&input_method_ids); | |
1386 | |
1387 ASSERT_EQ(3U, input_method_ids.size()); | |
1388 | |
1389 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | |
1390 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); | |
1391 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | |
1392 } | 1346 } |
1393 | 1347 |
1394 } // namespace input_method | 1348 } // namespace input_method |
1395 } // namespace chromeos | 1349 } // namespace chromeos |
OLD | NEW |