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

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

Issue 190033005: [IME] Removes the duplicated IMEs in chrome://settings/languages, and support async component IMEs … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try to make test green. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ext_xkb.description = "ext_xkb_description"; 87 ext_xkb.description = "ext_xkb_description";
88 ext_xkb.path = base::FilePath("ext_xkb_file_path"); 88 ext_xkb.path = base::FilePath("ext_xkb_file_path");
89 89
90 ComponentExtensionEngine ext_xkb_engine_us; 90 ComponentExtensionEngine ext_xkb_engine_us;
91 ext_xkb_engine_us.engine_id = "xkb:us::eng"; 91 ext_xkb_engine_us.engine_id = "xkb:us::eng";
92 ext_xkb_engine_us.display_name = "xkb:us::eng"; 92 ext_xkb_engine_us.display_name = "xkb:us::eng";
93 ext_xkb_engine_us.language_codes.push_back("en-US"); 93 ext_xkb_engine_us.language_codes.push_back("en-US");
94 ext_xkb_engine_us.layouts.push_back("us"); 94 ext_xkb_engine_us.layouts.push_back("us");
95 ext_xkb.engines.push_back(ext_xkb_engine_us); 95 ext_xkb.engines.push_back(ext_xkb_engine_us);
96 96
97 ComponentExtensionEngine ext_xkb_engine_dvorak;
98 ext_xkb_engine_dvorak.engine_id = "xkb:us:dvorak:eng";
99 ext_xkb_engine_dvorak.display_name = "xkb:us:dvorak:eng";
100 ext_xkb_engine_dvorak.language_codes.push_back("en-US");
101 ext_xkb_engine_dvorak.layouts.push_back("us(dvorak)");
102 ext_xkb.engines.push_back(ext_xkb_engine_dvorak);
103
104 ComponentExtensionEngine ext_xkb_engine_intl; 97 ComponentExtensionEngine ext_xkb_engine_intl;
105 ext_xkb_engine_intl.engine_id = "xkb:us:intl:eng"; 98 ext_xkb_engine_intl.engine_id = "xkb:us:intl:eng";
106 ext_xkb_engine_intl.display_name = "xkb:us:intl:eng"; 99 ext_xkb_engine_intl.display_name = "xkb:us:intl:eng";
107 ext_xkb_engine_intl.language_codes.push_back("en-US"); 100 ext_xkb_engine_intl.language_codes.push_back("en-US");
108 ext_xkb_engine_intl.layouts.push_back("us(intl)"); 101 ext_xkb_engine_intl.layouts.push_back("us(intl)");
109 ext_xkb.engines.push_back(ext_xkb_engine_intl); 102 ext_xkb.engines.push_back(ext_xkb_engine_intl);
110 103
111 ComponentExtensionEngine ext_xkb_engine_altgr_intl; 104 ComponentExtensionEngine ext_xkb_engine_altgr_intl;
112 ext_xkb_engine_altgr_intl.engine_id = "xkb:us:altgr-intl:eng"; 105 ext_xkb_engine_altgr_intl.engine_id = "xkb:us:altgr-intl:eng";
113 ext_xkb_engine_altgr_intl.display_name = "xkb:us:altgr-intl:eng"; 106 ext_xkb_engine_altgr_intl.display_name = "xkb:us:altgr-intl:eng";
114 ext_xkb_engine_altgr_intl.language_codes.push_back("en-US"); 107 ext_xkb_engine_altgr_intl.language_codes.push_back("en-US");
115 ext_xkb_engine_altgr_intl.layouts.push_back("us(altgr-intl)"); 108 ext_xkb_engine_altgr_intl.layouts.push_back("us(altgr-intl)");
116 ext_xkb.engines.push_back(ext_xkb_engine_altgr_intl); 109 ext_xkb.engines.push_back(ext_xkb_engine_altgr_intl);
117 110
118 ComponentExtensionEngine ext_xkb_engine_fr; 111 ComponentExtensionEngine ext_xkb_engine_dvorak;
119 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; 112 ext_xkb_engine_dvorak.engine_id = "xkb:us:dvorak:eng";
120 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; 113 ext_xkb_engine_dvorak.display_name = "xkb:us:dvorak:eng";
121 ext_xkb_engine_fr.language_codes.push_back("fr"); 114 ext_xkb_engine_dvorak.language_codes.push_back("en-US");
122 ext_xkb_engine_fr.layouts.push_back("fr"); 115 ext_xkb_engine_dvorak.layouts.push_back("us(dvorak)");
123 ext_xkb.engines.push_back(ext_xkb_engine_fr); 116 ext_xkb.engines.push_back(ext_xkb_engine_dvorak);
124 117
125 ComponentExtensionEngine ext_xkb_engine_colemak; 118 ComponentExtensionEngine ext_xkb_engine_colemak;
126 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; 119 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng";
127 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; 120 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng";
128 ext_xkb_engine_colemak.language_codes.push_back("en-US"); 121 ext_xkb_engine_colemak.language_codes.push_back("en-US");
129 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); 122 ext_xkb_engine_colemak.layouts.push_back("us(colemak)");
130 ext_xkb.engines.push_back(ext_xkb_engine_colemak); 123 ext_xkb.engines.push_back(ext_xkb_engine_colemak);
131 124
125 ComponentExtensionEngine ext_xkb_engine_fr;
126 ext_xkb_engine_fr.engine_id = "xkb:fr::fra";
127 ext_xkb_engine_fr.display_name = "xkb:fr::fra";
128 ext_xkb_engine_fr.language_codes.push_back("fr");
129 ext_xkb_engine_fr.layouts.push_back("fr");
130 ext_xkb.engines.push_back(ext_xkb_engine_fr);
131
132 ComponentExtensionEngine ext_xkb_engine_se; 132 ComponentExtensionEngine ext_xkb_engine_se;
133 ext_xkb_engine_se.engine_id = "xkb:se::swe"; 133 ext_xkb_engine_se.engine_id = "xkb:se::swe";
134 ext_xkb_engine_se.display_name = "xkb:se::swe"; 134 ext_xkb_engine_se.display_name = "xkb:se::swe";
135 ext_xkb_engine_se.language_codes.push_back("sv"); 135 ext_xkb_engine_se.language_codes.push_back("sv");
136 ext_xkb_engine_se.layouts.push_back("se"); 136 ext_xkb_engine_se.layouts.push_back("se");
137 ext_xkb.engines.push_back(ext_xkb_engine_se); 137 ext_xkb.engines.push_back(ext_xkb_engine_se);
138 138
139 ComponentExtensionEngine ext_xkb_engine_jp; 139 ComponentExtensionEngine ext_xkb_engine_jp;
140 ext_xkb_engine_jp.engine_id = "xkb:jp::jpn"; 140 ext_xkb_engine_jp.engine_id = "xkb:jp::jpn";
141 ext_xkb_engine_jp.display_name = "xkb:jp::jpn"; 141 ext_xkb_engine_jp.display_name = "xkb:jp::jpn";
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // If the same input method ID is passed, PropertyChanged() is not 349 // If the same input method ID is passed, PropertyChanged() is not
350 // notified. 350 // notified.
351 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); 351 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_);
352 352
353 manager_->RemoveObserver(&observer); 353 manager_->RemoveObserver(&observer);
354 menu_manager_->RemoveObserver(&observer); 354 menu_manager_->RemoveObserver(&observer);
355 } 355 }
356 356
357 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { 357 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
358 InitComponentExtension(); 358 InitComponentExtension();
359 scoped_ptr<InputMethodDescriptors> methods( 359 InputMethodDescriptors methods;
360 manager_->GetSupportedInputMethods()); 360 if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) {
361 ASSERT_TRUE(methods.get()); 361 methods = manager_->GetComponentExtensionIMEManager()
362 ->GetXkbIMEAsInputMethodDescriptor();
363 } else {
364 methods = *(manager_->GetSupportedInputMethods());
365 }
362 // Try to find random 4-5 layuts and IMEs to make sure the returned list is 366 // Try to find random 4-5 layuts and IMEs to make sure the returned list is
363 // correct. 367 // correct.
364 const InputMethodDescriptor* id_to_find = 368 const InputMethodDescriptor* id_to_find =
365 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 369 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
366 kNaclMozcUsId); 370 kNaclMozcUsId);
367 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 371 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
368 "xkb:us::eng"); 372 XkbId("xkb:us::eng"));
369 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 373 EXPECT_TRUE(Contain(methods, *id_to_find));
370 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 374 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
371 "xkb:us:dvorak:eng"); 375 XkbId("xkb:us:dvorak:eng"));
372 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 376 EXPECT_TRUE(Contain(methods, *id_to_find));
373 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 377 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
374 "xkb:fr::fra"); 378 XkbId("xkb:fr::fra"));
375 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 379 EXPECT_TRUE(Contain(methods, *id_to_find));
376 } 380 }
377 381
378 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { 382 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
379 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See 383 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See
380 // ibus_input_method.txt. 384 // ibus_input_method.txt.
381 std::vector<std::string> keyboard_layouts; 385 std::vector<std::string> keyboard_layouts;
382 386
383 InitComponentExtension(); 387 InitComponentExtension();
384 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 388 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
385 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 389 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
386 390
387 // For http://crbug.com/19655#c11 - (5) 391 // For http://crbug.com/19655#c11 - (5)
388 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. 392 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U.
389 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese 393 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese
390 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 394 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
391 } 395 }
392 396
393 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { 397 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) {
394 // For http://crbug.com/329061 398 // For http://crbug.com/329061
395 std::vector<std::string> keyboard_layouts; 399 std::vector<std::string> keyboard_layouts;
396 keyboard_layouts.push_back("xkb:se::swe"); 400 keyboard_layouts.push_back(XkbId("xkb:se::swe"));
397 401
398 InitComponentExtension(); 402 InitComponentExtension();
399 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 403 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
400 const std::string im_id = manager_->GetCurrentInputMethod().id(); 404 const std::string im_id = manager_->GetCurrentInputMethod().id();
401 EXPECT_EQ(XkbId("xkb:se::swe"), im_id); 405 EXPECT_EQ(XkbId("xkb:se::swe"), im_id);
402 } 406 }
403 407
404 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { 408 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) {
405 InitComponentExtension(); 409 InitComponentExtension();
406 // The physical layout is French. 410 // The physical layout is French.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); 478 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find));
475 } 479 }
476 480
477 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { 481 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) {
478 // For http://crbug.com/19655#c11 - (8), step 6. 482 // For http://crbug.com/19655#c11 - (8), step 6.
479 TestObserver observer; 483 TestObserver observer;
480 manager_->AddObserver(&observer); 484 manager_->AddObserver(&observer);
481 InitComponentExtension(); 485 InitComponentExtension();
482 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 486 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
483 std::vector<std::string> ids; 487 std::vector<std::string> ids;
484 ids.push_back("xkb:us:dvorak:eng"); 488 ids.push_back(XkbId("xkb:us:dvorak:eng"));
485 ids.push_back("xkb:us:colemak:eng"); 489 ids.push_back(XkbId("xkb:us:colemak:eng"));
486 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 490 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
487 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 491 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
488 // Since all the IDs added avobe are keyboard layouts, Start() should not be 492 // Since all the IDs added avobe are keyboard layouts, Start() should not be
489 // called. 493 // called.
490 EXPECT_EQ(1, observer.input_method_changed_count_); 494 EXPECT_EQ(1, observer.input_method_changed_count_);
491 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 495 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
492 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 496 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
493 // Disable Dvorak. 497 // Disable Dvorak.
494 ids.erase(ids.begin()); 498 ids.erase(ids.begin());
495 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 499 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
496 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 500 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
497 EXPECT_EQ(2, observer.input_method_changed_count_); 501 EXPECT_EQ(2, observer.input_method_changed_count_);
498 EXPECT_EQ(XkbId(ids[0]), // colemak 502 EXPECT_EQ(XkbId(ids[0]), // colemak
499 manager_->GetCurrentInputMethod().id()); 503 manager_->GetCurrentInputMethod().id());
500 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 504 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
501 manager_->RemoveObserver(&observer); 505 manager_->RemoveObserver(&observer);
502 } 506 }
503 507
504 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { 508 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) {
505 // For http://crbug.com/19655#c11 - (9). 509 // For http://crbug.com/19655#c11 - (9).
506 TestObserver observer; 510 TestObserver observer;
507 manager_->AddObserver(&observer); 511 manager_->AddObserver(&observer);
508 InitComponentExtension(); 512 InitComponentExtension();
509 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 513 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
510 std::vector<std::string> ids; 514 std::vector<std::string> ids;
511 ids.push_back("xkb:us::eng"); 515 ids.push_back(XkbId("xkb:us::eng"));
512 ids.push_back("xkb:us:dvorak:eng"); 516 ids.push_back(XkbId("xkb:us:dvorak:eng"));
513 ids.push_back("xkb:us:colemak:eng"); 517 ids.push_back(XkbId("xkb:us:colemak:eng"));
514 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 518 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
515 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 519 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
516 EXPECT_EQ(1, observer.input_method_changed_count_); 520 EXPECT_EQ(1, observer.input_method_changed_count_);
517 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 521 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
518 EXPECT_EQ("us", xkeyboard_->last_layout_); 522 EXPECT_EQ("us", xkeyboard_->last_layout_);
519 // Switch to Dvorak. 523 // Switch to Dvorak.
520 manager_->SwitchToNextInputMethod(); 524 manager_->SwitchToNextInputMethod();
521 EXPECT_EQ(2, observer.input_method_changed_count_); 525 EXPECT_EQ(2, observer.input_method_changed_count_);
522 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 526 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
523 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 527 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
524 // Disable Dvorak. 528 // Disable Dvorak.
525 ids.erase(ids.begin() + 1); 529 ids.erase(ids.begin() + 1);
526 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 530 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
527 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 531 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
528 EXPECT_EQ(3, observer.input_method_changed_count_); 532 EXPECT_EQ(3, observer.input_method_changed_count_);
529 EXPECT_EQ(XkbId(ids[0]), // US Qwerty 533 EXPECT_EQ(XkbId(ids[0]), // US Qwerty
530 manager_->GetCurrentInputMethod().id()); 534 manager_->GetCurrentInputMethod().id());
531 EXPECT_EQ("us", xkeyboard_->last_layout_); 535 EXPECT_EQ("us", xkeyboard_->last_layout_);
532 manager_->RemoveObserver(&observer); 536 manager_->RemoveObserver(&observer);
533 } 537 }
534 538
535 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { 539 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) {
536 // For http://crbug.com/19655#c11 - (10). 540 // For http://crbug.com/19655#c11 - (10).
537 TestObserver observer; 541 TestObserver observer;
538 manager_->AddObserver(&observer); 542 manager_->AddObserver(&observer);
539 InitComponentExtension(); 543 InitComponentExtension();
540 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 544 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
541 std::vector<std::string> ids; 545 std::vector<std::string> ids;
542 ids.push_back("xkb:us:dvorak:eng"); 546 ids.push_back(XkbId("xkb:us:dvorak:eng"));
543 ids.push_back(kNaclMozcUsId); 547 ids.push_back(kNaclMozcUsId);
544 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 548 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
545 EXPECT_EQ(1, observer.input_method_changed_count_); 549 EXPECT_EQ(1, observer.input_method_changed_count_);
546 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 550 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
547 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 551 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
548 // Switch to Mozc 552 // Switch to Mozc
549 manager_->SwitchToNextInputMethod(); 553 manager_->SwitchToNextInputMethod();
550 EXPECT_EQ(2, observer.input_method_changed_count_); 554 EXPECT_EQ(2, observer.input_method_changed_count_);
551 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 555 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
552 EXPECT_EQ("us", xkeyboard_->last_layout_); 556 EXPECT_EQ("us", xkeyboard_->last_layout_);
553 // Disable Mozc. 557 // Disable Mozc.
554 ids.erase(ids.begin() + 1); 558 ids.erase(ids.begin() + 1);
555 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 559 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
556 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 560 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
557 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 561 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
558 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 562 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
559 } 563 }
560 564
561 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { 565 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) {
562 // For http://crbug.com/19655#c11 - (11). 566 // For http://crbug.com/19655#c11 - (11).
563 TestObserver observer; 567 TestObserver observer;
564 manager_->AddObserver(&observer); 568 manager_->AddObserver(&observer);
565 InitComponentExtension(); 569 InitComponentExtension();
566 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 570 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
567 std::vector<std::string> ids; 571 std::vector<std::string> ids;
568 ids.push_back("xkb:us:dvorak:eng"); 572 ids.push_back(XkbId("xkb:us:dvorak:eng"));
569 ids.push_back(kNaclMozcUsId); 573 ids.push_back(kNaclMozcUsId);
570 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 574 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
571 EXPECT_EQ(1, observer.input_method_changed_count_); 575 EXPECT_EQ(1, observer.input_method_changed_count_);
572 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 576 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
573 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 577 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
574 578
575 // Disable Dvorak. 579 // Disable Dvorak.
576 ids.erase(ids.begin()); 580 ids.erase(ids.begin());
577 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 581 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
578 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 582 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 manager_->RemoveObserver(&observer); 617 manager_->RemoveObserver(&observer);
614 } 618 }
615 619
616 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { 620 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) {
617 // For http://crbug.com/19655#c11 - (14). 621 // For http://crbug.com/19655#c11 - (14).
618 TestObserver observer; 622 TestObserver observer;
619 manager_->AddObserver(&observer); 623 manager_->AddObserver(&observer);
620 InitComponentExtension(); 624 InitComponentExtension();
621 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 625 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
622 std::vector<std::string> ids; 626 std::vector<std::string> ids;
623 ids.push_back("xkb:us::eng"); 627 ids.push_back(XkbId("xkb:us::eng"));
624 ids.push_back("xkb:us:dvorak:eng"); 628 ids.push_back(XkbId("xkb:us:dvorak:eng"));
625 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 629 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
626 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 630 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
627 EXPECT_EQ(1, observer.input_method_changed_count_); 631 EXPECT_EQ(1, observer.input_method_changed_count_);
628 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 632 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
629 EXPECT_EQ("us", xkeyboard_->last_layout_); 633 EXPECT_EQ("us", xkeyboard_->last_layout_);
630 634
631 // Switch to Dvorak. 635 // Switch to Dvorak.
632 manager_->SwitchToNextInputMethod(); 636 manager_->SwitchToNextInputMethod();
633 EXPECT_EQ(2, observer.input_method_changed_count_); 637 EXPECT_EQ(2, observer.input_method_changed_count_);
634 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 638 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
(...skipping 19 matching lines...) Expand all
654 manager_->RemoveObserver(&observer); 658 manager_->RemoveObserver(&observer);
655 } 659 }
656 660
657 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { 661 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) {
658 // For http://crbug.com/19655#c11 - (15). 662 // For http://crbug.com/19655#c11 - (15).
659 TestObserver observer; 663 TestObserver observer;
660 manager_->AddObserver(&observer); 664 manager_->AddObserver(&observer);
661 InitComponentExtension(); 665 InitComponentExtension();
662 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 666 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
663 std::vector<std::string> ids; 667 std::vector<std::string> ids;
664 ids.push_back("xkb:us:dvorak:eng"); 668 ids.push_back(XkbId("xkb:us:dvorak:eng"));
665 ids.push_back(kExt2Engine2Id); 669 ids.push_back(kExt2Engine2Id);
666 ids.push_back(kExt2Engine1Id); 670 ids.push_back(kExt2Engine1Id);
667 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 671 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
668 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 672 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
669 EXPECT_EQ(1, observer.input_method_changed_count_); 673 EXPECT_EQ(1, observer.input_method_changed_count_);
670 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 674 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
671 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 675 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
672 676
673 // Switch to Mozc. 677 // Switch to Mozc.
674 manager_->SwitchToNextInputMethod(); 678 manager_->SwitchToNextInputMethod();
(...skipping 19 matching lines...) Expand all
694 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 698 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
695 699
696 manager_->RemoveObserver(&observer); 700 manager_->RemoveObserver(&observer);
697 } 701 }
698 702
699 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { 703 TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
700 // For http://crbug.com/19655#c11 - (8), step 7-11. 704 // For http://crbug.com/19655#c11 - (8), step 7-11.
701 InitComponentExtension(); 705 InitComponentExtension();
702 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 706 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
703 std::vector<std::string> ids; 707 std::vector<std::string> ids;
704 ids.push_back("xkb:us:dvorak:eng"); 708 ids.push_back(XkbId("xkb:us:dvorak:eng"));
705 ids.push_back("xkb:us:colemak:eng"); 709 ids.push_back(XkbId("xkb:us:colemak:eng"));
706 ids.push_back(kNaclMozcJpId); 710 ids.push_back(kNaclMozcJpId);
707 ids.push_back(kNaclMozcUsId); 711 ids.push_back(kNaclMozcUsId);
708 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 712 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
709 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); 713 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods());
710 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); 714 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_);
711 // See input_methods.txt for an expected XKB layout name. 715 // See input_methods.txt for an expected XKB layout name.
712 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 716 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
713 manager_->SwitchToNextInputMethod(); 717 manager_->SwitchToNextInputMethod();
714 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); 718 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_);
715 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 719 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
(...skipping 28 matching lines...) Expand all
744 manager_->ActivateInputMethodMenuItem("key2"); 748 manager_->ActivateInputMethodMenuItem("key2");
745 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); 749 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
746 } 750 }
747 751
748 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { 752 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
749 InitComponentExtension(); 753 InitComponentExtension();
750 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); 754 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
751 755
752 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 756 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
753 std::vector<std::string> ids; 757 std::vector<std::string> ids;
754 ids.push_back("xkb:us::eng"); 758 ids.push_back(XkbId("xkb:us::eng"));
755 ids.push_back(kNaclMozcUsId); 759 ids.push_back(kNaclMozcUsId);
756 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 760 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
757 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 761 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
758 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); 762 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
759 manager_->ChangeInputMethod(kNaclMozcUsId); 763 manager_->ChangeInputMethod(kNaclMozcUsId);
760 764
761 ash::ime::InputMethodMenuItemList current_property_list; 765 ash::ime::InputMethodMenuItemList current_property_list;
762 current_property_list.push_back(ash::ime::InputMethodMenuItem( 766 current_property_list.push_back(ash::ime::InputMethodMenuItem(
763 "key", "label", false, false)); 767 "key", "label", false, false));
764 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); 768 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); 810 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size());
807 EXPECT_EQ("key-chewing", 811 EXPECT_EQ("key-chewing",
808 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); 812 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key);
809 } 813 }
810 814
811 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { 815 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) {
812 TestObserver observer; 816 TestObserver observer;
813 manager_->AddObserver(&observer); 817 manager_->AddObserver(&observer);
814 InitComponentExtension(); 818 InitComponentExtension();
815 std::vector<std::string> keyboard_layouts; 819 std::vector<std::string> keyboard_layouts;
816 keyboard_layouts.push_back("xkb:us::eng"); 820 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
817 // For http://crbug.com/19655#c11 - (1) 821 // For http://crbug.com/19655#c11 - (1)
818 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 822 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
819 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 823 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
820 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 824 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
821 EXPECT_EQ("us", xkeyboard_->last_layout_); 825 EXPECT_EQ("us", xkeyboard_->last_layout_);
822 manager_->SwitchToNextInputMethod(); 826 manager_->SwitchToNextInputMethod();
823 EXPECT_TRUE(observer.last_show_message_); 827 EXPECT_TRUE(observer.last_show_message_);
824 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); 828 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id());
825 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 829 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
826 manager_->SwitchToNextInputMethod(); 830 manager_->SwitchToNextInputMethod();
(...skipping 23 matching lines...) Expand all
850 TestObserver observer; 854 TestObserver observer;
851 manager_->AddObserver(&observer); 855 manager_->AddObserver(&observer);
852 InitComponentExtension(); 856 InitComponentExtension();
853 857
854 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 858 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
855 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); 859 keydown_accelerator.set_type(ui::ET_KEY_PRESSED);
856 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 860 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
857 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); 861 keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
858 862
859 std::vector<std::string> keyboard_layouts; 863 std::vector<std::string> keyboard_layouts;
860 keyboard_layouts.push_back("xkb:us::eng"); 864 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
861 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 865 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
862 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 866 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
863 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 867 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
864 EXPECT_EQ("us", xkeyboard_->last_layout_); 868 EXPECT_EQ("us", xkeyboard_->last_layout_);
865 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); 869 EXPECT_TRUE(manager_->SwitchToNextInputMethod());
866 EXPECT_TRUE(observer.last_show_message_); 870 EXPECT_TRUE(observer.last_show_message_);
867 EXPECT_EQ(XkbId("xkb:us:intl:eng"), 871 EXPECT_EQ(XkbId("xkb:us:intl:eng"),
868 manager_->GetCurrentInputMethod().id()); 872 manager_->GetCurrentInputMethod().id());
869 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 873 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
870 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 874 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 TestObserver observer; 915 TestObserver observer;
912 manager_->AddObserver(&observer); 916 manager_->AddObserver(&observer);
913 InitComponentExtension(); 917 InitComponentExtension();
914 918
915 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 919 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
916 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); 920 keydown_accelerator.set_type(ui::ET_KEY_PRESSED);
917 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 921 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
918 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); 922 keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
919 923
920 std::vector<std::string> ids; 924 std::vector<std::string> ids;
921 ids.push_back("xkb:us:dvorak:eng"); 925 ids.push_back(XkbId("xkb:us:dvorak:eng"));
922 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 926 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
923 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 927 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
924 928
925 // Ctrl+Space accelerator should not be consumed if there is only one active 929 // Ctrl+Space accelerator should not be consumed if there is only one active
926 // input method. 930 // input method.
927 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 931 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
928 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 932 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
929 933
930 manager_->RemoveObserver(&observer); 934 manager_->RemoveObserver(&observer);
931 } 935 }
932 936
933 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { 937 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) {
934 std::string expect_id = XkbId("xkb:us::eng"); 938 std::string expect_id = XkbId("xkb:us::eng");
935 TestObserver observer; 939 TestObserver observer;
936 manager_->AddObserver(&observer); 940 manager_->AddObserver(&observer);
937 InitComponentExtension(); 941 InitComponentExtension();
938 std::vector<std::string> keyboard_layouts; 942 std::vector<std::string> keyboard_layouts;
939 keyboard_layouts.push_back("xkb:us::eng"); 943 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
940 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 944 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
941 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 945 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
942 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 946 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
943 EXPECT_EQ("us", xkeyboard_->last_layout_); 947 EXPECT_EQ("us", xkeyboard_->last_layout_);
944 948
945 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs 949 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs
946 // and keyboards are enabled. 950 // and keyboards are enabled.
947 EXPECT_FALSE(manager_->SwitchInputMethod( 951 EXPECT_FALSE(manager_->SwitchInputMethod(
948 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 952 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
949 EXPECT_FALSE(observer.last_show_message_); 953 EXPECT_FALSE(observer.last_show_message_);
(...skipping 18 matching lines...) Expand all
968 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { 972 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) {
969 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. 973 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku.
970 InitComponentExtension(); 974 InitComponentExtension();
971 975
972 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 976 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
973 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); 977 keydown_accelerator.set_type(ui::ET_KEY_PRESSED);
974 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 978 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
975 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); 979 keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
976 980
977 std::vector<std::string> keyboard_layouts; 981 std::vector<std::string> keyboard_layouts;
978 keyboard_layouts.push_back("xkb:us::eng"); 982 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
979 manager_->EnableLoginLayouts("ja", keyboard_layouts); 983 manager_->EnableLoginLayouts("ja", keyboard_layouts);
980 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 984 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
981 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 985 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
982 EXPECT_EQ("us", xkeyboard_->last_layout_); 986 EXPECT_EQ("us", xkeyboard_->last_layout_);
983 EXPECT_TRUE(manager_->SwitchInputMethod( 987 EXPECT_TRUE(manager_->SwitchInputMethod(
984 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 988 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
985 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 989 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
986 EXPECT_EQ("jp", xkeyboard_->last_layout_); 990 EXPECT_EQ("jp", xkeyboard_->last_layout_);
987 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 991 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
988 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 992 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
(...skipping 10 matching lines...) Expand all
999 EXPECT_TRUE(manager_->SwitchInputMethod( 1003 EXPECT_TRUE(manager_->SwitchInputMethod(
1000 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1004 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
1001 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1005 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1002 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1006 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1003 } 1007 }
1004 1008
1005 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { 1009 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) {
1006 InitComponentExtension(); 1010 InitComponentExtension();
1007 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1011 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1008 std::vector<std::string> ids; 1012 std::vector<std::string> ids;
1009 ids.push_back("xkb:jp::jpn"); 1013 ids.push_back(XkbId("xkb:jp::jpn"));
1010 ids.push_back(kNaclMozcJpId); 1014 ids.push_back(kNaclMozcJpId);
1011 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1015 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1012 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1016 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1013 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1017 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1014 EXPECT_TRUE(manager_->SwitchInputMethod( 1018 EXPECT_TRUE(manager_->SwitchInputMethod(
1015 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1019 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
1016 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1020 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1017 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1021 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1018 EXPECT_TRUE(manager_->SwitchInputMethod( 1022 EXPECT_TRUE(manager_->SwitchInputMethod(
1019 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1023 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
(...skipping 10 matching lines...) Expand all
1030 EXPECT_TRUE(manager_->SwitchInputMethod( 1034 EXPECT_TRUE(manager_->SwitchInputMethod(
1031 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 1035 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
1032 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1036 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1033 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1037 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1034 EXPECT_TRUE(manager_->SwitchInputMethod( 1038 EXPECT_TRUE(manager_->SwitchInputMethod(
1035 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 1039 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
1036 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1040 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1037 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1041 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1038 1042
1039 // Add Dvorak. 1043 // Add Dvorak.
1040 ids.push_back("xkb:us:dvorak:eng"); 1044 ids.push_back(XkbId("xkb:us:dvorak:eng"));
1041 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1045 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1042 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1046 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1043 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1047 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1044 EXPECT_TRUE(manager_->SwitchInputMethod( 1048 EXPECT_TRUE(manager_->SwitchInputMethod(
1045 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 1049 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
1046 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1050 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1047 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1051 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1048 EXPECT_TRUE(manager_->SwitchInputMethod( 1052 EXPECT_TRUE(manager_->SwitchInputMethod(
1049 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 1053 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
1050 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1054 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1051 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1055 EXPECT_EQ("jp", xkeyboard_->last_layout_);
1052 } 1056 }
1053 1057
1054 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { 1058 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
1055 TestObserver observer; 1059 TestObserver observer;
1056 manager_->AddObserver(&observer); 1060 manager_->AddObserver(&observer);
1057 InitComponentExtension(); 1061 InitComponentExtension();
1058 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1062 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1059 std::vector<std::string> ids; 1063 std::vector<std::string> ids;
1060 ids.push_back("xkb:us:dvorak:eng"); 1064 ids.push_back(XkbId("xkb:us:dvorak:eng"));
1061 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1065 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1062 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1066 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1063 EXPECT_EQ(1, observer.input_method_changed_count_); 1067 EXPECT_EQ(1, observer.input_method_changed_count_);
1064 EXPECT_EQ(XkbId(ids[0]), 1068 EXPECT_EQ(XkbId(ids[0]),
1065 manager_->GetCurrentInputMethod().id()); 1069 manager_->GetCurrentInputMethod().id());
1066 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 1070 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
1067 1071
1068 // Add two Extension IMEs. 1072 // Add two Extension IMEs.
1069 std::vector<std::string> layouts; 1073 std::vector<std::string> layouts;
1070 layouts.push_back("us"); 1074 layouts.push_back("us");
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 manager_->RemoveInputMethodExtension(ext2_id); 1136 manager_->RemoveInputMethodExtension(ext2_id);
1133 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1137 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1134 } 1138 }
1135 1139
1136 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { 1140 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
1137 TestObserver observer; 1141 TestObserver observer;
1138 InitComponentExtension(); 1142 InitComponentExtension();
1139 manager_->AddObserver(&observer); 1143 manager_->AddObserver(&observer);
1140 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1144 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1141 std::vector<std::string> ids; 1145 std::vector<std::string> ids;
1142 ids.push_back("xkb:us::eng"); 1146 ids.push_back(XkbId("xkb:us::eng"));
1143 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1147 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1144 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1148 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1145 EXPECT_EQ(1, observer.input_method_changed_count_); 1149 EXPECT_EQ(1, observer.input_method_changed_count_);
1146 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 1150 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
1147 EXPECT_EQ("us", xkeyboard_->last_layout_); 1151 EXPECT_EQ("us", xkeyboard_->last_layout_);
1148 1152
1149 // Add an Extension IME. 1153 // Add an Extension IME.
1150 std::vector<std::string> layouts; 1154 std::vector<std::string> layouts;
1151 layouts.push_back("us(dvorak)"); 1155 layouts.push_back("us(dvorak)");
1152 std::vector<std::string> languages; 1156 std::vector<std::string> languages;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 1349
1346 ASSERT_EQ(3U, input_method_ids.size()); 1350 ASSERT_EQ(3U, input_method_ids.size());
1347 1351
1348 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); 1352 EXPECT_EQ("xkb:us::eng", input_method_ids[0]);
1349 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); 1353 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]);
1350 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); 1354 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]);
1351 } 1355 }
1352 1356
1353 } // namespace input_method 1357 } // namespace input_method
1354 } // namespace chromeos 1358 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698