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

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

Issue 14564007: Remove mozc from whitelist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TestUpdate Created 7 years, 7 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 "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 13 matching lines...) Expand all
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/base/accelerators/accelerator.h" 25 #include "ui/base/accelerators/accelerator.h"
26 #include "ui/base/ime/text_input_test_support.h" 26 #include "ui/base/ime/text_input_test_support.h"
27 #include "ui/base/keycodes/keyboard_codes.h" 27 #include "ui/base/keycodes/keyboard_codes.h"
28 28
29 namespace chromeos { 29 namespace chromeos {
30 30
31 namespace input_method { 31 namespace input_method {
32 namespace { 32 namespace {
33 33
34 const char nacl_mozc_us_id[] =
35 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_us";
36 const char nacl_mozc_jp_id[] =
37 "_comp_ime_fpfbhcjppmaeaijcidgiibchfbnhbeljnacl_mozc_jp";
38
34 // Returns true if |descriptors| contain |target|. 39 // Returns true if |descriptors| contain |target|.
35 bool Contain(const InputMethodDescriptors& descriptors, 40 bool Contain(const InputMethodDescriptors& descriptors,
36 const InputMethodDescriptor& target) { 41 const InputMethodDescriptor& target) {
37 for (size_t i = 0; i < descriptors.size(); ++i) { 42 for (size_t i = 0; i < descriptors.size(); ++i) {
38 if (descriptors[i].id() == target.id()) 43 if (descriptors[i].id() == target.id())
39 return true; 44 return true;
40 } 45 }
41 return false; 46 return false;
42 } 47 }
43 48
(...skipping 25 matching lines...) Expand all
69 manager_->SetIBusControllerForTesting(controller_); 74 manager_->SetIBusControllerForTesting(controller_);
70 candidate_window_controller_ = new MockCandidateWindowController; 75 candidate_window_controller_ = new MockCandidateWindowController;
71 manager_->SetCandidateWindowControllerForTesting( 76 manager_->SetCandidateWindowControllerForTesting(
72 candidate_window_controller_); 77 candidate_window_controller_);
73 xkeyboard_ = new MockXKeyboard; 78 xkeyboard_ = new MockXKeyboard;
74 manager_->SetXKeyboardForTesting(xkeyboard_); 79 manager_->SetXKeyboardForTesting(xkeyboard_);
75 80
76 ime_list_.clear(); 81 ime_list_.clear();
77 82
78 ComponentExtensionIME ext1; 83 ComponentExtensionIME ext1;
79 ext1.id = "ext1_id"; 84 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj";
80 ext1.description = "ext1_description"; 85 ext1.description = "ext1_description";
81 ext1.path = base::FilePath("ext1_file_path"); 86 ext1.path = base::FilePath("ext1_file_path");
82 87
83 ComponentExtensionEngine ext1_engine1; 88 ComponentExtensionEngine ext1_engine1;
84 ext1_engine1.engine_id = "ext1_engine1_engine_id"; 89 ext1_engine1.engine_id = "nacl_mozc_us";
85 ext1_engine1.display_name = "ext1_engine_1_display_name"; 90 ext1_engine1.display_name = "ext1_engine_1_display_name";
86 ext1_engine1.language_code = "en"; 91 ext1_engine1.language_code = "ja";
87 ext1_engine1.layouts.push_back("us"); 92 ext1_engine1.layouts.push_back("us");
88 ext1.engines.push_back(ext1_engine1); 93 ext1.engines.push_back(ext1_engine1);
89 94
95 ComponentExtensionEngine ext1_engine2;
96 ext1_engine2.engine_id = "nacl_mozc_jp";
97 ext1_engine2.display_name = "ext1_engine_1_display_name";
98 ext1_engine2.language_code = "ja";
99 ext1_engine2.layouts.push_back("jp");
100 ext1.engines.push_back(ext1_engine2);
101
90 ime_list_.push_back(ext1); 102 ime_list_.push_back(ext1);
91 103
92 ComponentExtensionIME ext2; 104 ComponentExtensionIME ext2;
93 ext2.id = "ext2_id"; 105 ext2.id = "ext2_id";
94 ext2.description = "ext2_description"; 106 ext2.description = "ext2_description";
95 ext2.path = base::FilePath("ext2_file_path"); 107 ext2.path = base::FilePath("ext2_file_path");
96 108
97 ComponentExtensionEngine ext2_engine1; 109 ComponentExtensionEngine ext2_engine1;
98 ext2_engine1.engine_id = "ext2_engine1_engine_id"; 110 ext2_engine1.engine_id = "ext2_engine1_engine_id";
99 ext2_engine1.display_name = "ext2_engine_1_display_name"; 111 ext2_engine1.display_name = "ext2_engine_1_display_name";
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 manager_->RemoveObserver(&observer); 258 manager_->RemoveObserver(&observer);
247 } 259 }
248 260
249 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { 261 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
250 scoped_ptr<InputMethodDescriptors> methods( 262 scoped_ptr<InputMethodDescriptors> methods(
251 manager_->GetSupportedInputMethods()); 263 manager_->GetSupportedInputMethods());
252 ASSERT_TRUE(methods.get()); 264 ASSERT_TRUE(methods.get());
253 // Try to find random 4-5 layuts and IMEs to make sure the returned list is 265 // Try to find random 4-5 layuts and IMEs to make sure the returned list is
254 // correct. 266 // correct.
255 const InputMethodDescriptor* id_to_find = 267 const InputMethodDescriptor* id_to_find =
256 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc"); 268 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
269 nacl_mozc_us_id);
257 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 270 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
258 "mozc-chewing"); 271 "mozc-chewing");
259 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 272 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
260 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 273 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
261 "xkb:us::eng"); 274 "xkb:us::eng");
262 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 275 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
263 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 276 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
264 "xkb:us:dvorak:eng"); 277 "xkb:us:dvorak:eng");
265 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 278 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
266 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 279 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 416 }
404 417
405 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { 418 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) {
406 // For http://crbug.com/19655#c11 - (10). 419 // For http://crbug.com/19655#c11 - (10).
407 TestObserver observer; 420 TestObserver observer;
408 manager_->AddObserver(&observer); 421 manager_->AddObserver(&observer);
409 ComponentExtensionInitialize(); 422 ComponentExtensionInitialize();
410 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 423 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
411 std::vector<std::string> ids; 424 std::vector<std::string> ids;
412 ids.push_back("xkb:us:dvorak:eng"); 425 ids.push_back("xkb:us:dvorak:eng");
413 ids.push_back("mozc"); 426 ids.push_back(nacl_mozc_us_id);
414 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 427 EXPECT_TRUE(manager_->EnableInputMethods(ids));
415 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); 428 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count());
416 EXPECT_EQ(1, observer.input_method_changed_count_); 429 EXPECT_EQ(1, observer.input_method_changed_count_);
417 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); 430 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
418 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 431 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
419 // Switch to Mozc 432 // Switch to Mozc
420 manager_->SwitchToNextInputMethod(); 433 manager_->SwitchToNextInputMethod();
421 EXPECT_EQ(2, observer.input_method_changed_count_); 434 EXPECT_EQ(2, observer.input_method_changed_count_);
422 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); 435 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
423 EXPECT_EQ("us", xkeyboard_->last_layout_); 436 EXPECT_EQ("us", xkeyboard_->last_layout_);
(...skipping 14 matching lines...) Expand all
438 } 451 }
439 452
440 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { 453 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) {
441 // For http://crbug.com/19655#c11 - (11). 454 // For http://crbug.com/19655#c11 - (11).
442 TestObserver observer; 455 TestObserver observer;
443 manager_->AddObserver(&observer); 456 manager_->AddObserver(&observer);
444 ComponentExtensionInitialize(); 457 ComponentExtensionInitialize();
445 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 458 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
446 std::vector<std::string> ids; 459 std::vector<std::string> ids;
447 ids.push_back("xkb:us:dvorak:eng"); 460 ids.push_back("xkb:us:dvorak:eng");
448 ids.push_back("mozc"); 461 ids.push_back(nacl_mozc_us_id);
449 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 462 EXPECT_TRUE(manager_->EnableInputMethods(ids));
450 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); 463 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count());
451 EXPECT_EQ(1, observer.input_method_changed_count_); 464 EXPECT_EQ(1, observer.input_method_changed_count_);
452 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); 465 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
453 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 466 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
454 467
455 // Disable Dvorak. 468 // Disable Dvorak.
456 ids.erase(ids.begin()); 469 ids.erase(ids.begin());
457 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 470 EXPECT_TRUE(manager_->EnableInputMethods(ids));
458 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 471 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 549 }
537 550
538 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndImeThenLock) { 551 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndImeThenLock) {
539 // For http://crbug.com/19655#c11 - (15). 552 // For http://crbug.com/19655#c11 - (15).
540 TestObserver observer; 553 TestObserver observer;
541 manager_->AddObserver(&observer); 554 manager_->AddObserver(&observer);
542 ComponentExtensionInitialize(); 555 ComponentExtensionInitialize();
543 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 556 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
544 std::vector<std::string> ids; 557 std::vector<std::string> ids;
545 ids.push_back("xkb:us:dvorak:eng"); 558 ids.push_back("xkb:us:dvorak:eng");
546 ids.push_back("mozc-dv"); 559 ids.push_back("pinyin-dv");
547 ids.push_back("mozc-chewing"); 560 ids.push_back("mozc-chewing");
548 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 561 EXPECT_TRUE(manager_->EnableInputMethods(ids));
549 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 562 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
550 EXPECT_EQ(1, observer.input_method_changed_count_); 563 EXPECT_EQ(1, observer.input_method_changed_count_);
551 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); 564 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
552 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 565 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
553 566
554 // Switch to Mozc. 567 // Switch to Mozc.
555 manager_->SwitchToNextInputMethod(); 568 manager_->SwitchToNextInputMethod();
556 EXPECT_EQ(2, observer.input_method_changed_count_); 569 EXPECT_EQ(2, observer.input_method_changed_count_);
557 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); 570 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
558 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 571 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
559 572
560 // Lock screen 573 // Lock screen
561 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); 574 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
562 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. 575 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak.
563 EXPECT_EQ("xkb:us:dvorak:eng", 576 EXPECT_EQ("xkb:us:dvorak:eng",
564 manager_->GetCurrentInputMethod().id()); 577 manager_->GetCurrentInputMethod().id());
565 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 578 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
566 // controller_->Stop() should never be called when the screen is locked even 579 // controller_->Stop() should never be called when the screen is locked even
567 // after crosbug.com/27051 is fixed. 580 // after crosbug.com/27051 is fixed.
568 EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); 581 EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count());
569 manager_->SwitchToNextInputMethod(); 582 manager_->SwitchToNextInputMethod();
570 EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout. 583 EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout.
571 manager_->GetCurrentInputMethod().id()); 584 manager_->GetCurrentInputMethod().id());
572 EXPECT_EQ("us", xkeyboard_->last_layout_); 585 EXPECT_EQ("us", xkeyboard_->last_layout_);
573 586
574 // Unlock screen. The original state, mozc-dv, is restored. 587 // Unlock screen. The original state, pinyin-dv, is restored.
575 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 588 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
576 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. 589 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs.
577 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); 590 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
578 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 591 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
579 592
580 manager_->RemoveObserver(&observer); 593 manager_->RemoveObserver(&observer);
581 } 594 }
582 595
583 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { 596 TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
584 // For http://crbug.com/19655#c11 - (8), step 7-11. 597 // For http://crbug.com/19655#c11 - (8), step 7-11.
585 ComponentExtensionInitialize(); 598 ComponentExtensionInitialize();
586 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 599 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
587 std::vector<std::string> ids; 600 std::vector<std::string> ids;
588 ids.push_back("xkb:us:dvorak:eng"); 601 ids.push_back("xkb:us:dvorak:eng");
589 ids.push_back("xkb:us:colemak:eng"); 602 ids.push_back("xkb:us:colemak:eng");
590 ids.push_back("mozc-jp"); 603 ids.push_back(nacl_mozc_jp_id);
591 ids.push_back("mozc"); 604 ids.push_back(nacl_mozc_us_id);
592 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 605 EXPECT_TRUE(manager_->EnableInputMethods(ids));
593 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); 606 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods());
594 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); 607 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_);
595 // See input_methods.txt for an expected XKB layout name. 608 // See input_methods.txt for an expected XKB layout name.
596 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 609 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
597 manager_->SwitchToNextInputMethod(); 610 manager_->SwitchToNextInputMethod();
598 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); 611 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_);
599 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 612 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
600 manager_->SwitchToNextInputMethod(); 613 manager_->SwitchToNextInputMethod();
601 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); 614 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_);
(...skipping 21 matching lines...) Expand all
623 EXPECT_EQ("key2", controller_->activate_input_method_property_key_); 636 EXPECT_EQ("key2", controller_->activate_input_method_property_key_);
624 } 637 }
625 638
626 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { 639 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
627 ComponentExtensionInitialize(); 640 ComponentExtensionInitialize();
628 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 641 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
629 642
630 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 643 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
631 std::vector<std::string> ids; 644 std::vector<std::string> ids;
632 ids.push_back("xkb:us::eng"); 645 ids.push_back("xkb:us::eng");
633 ids.push_back("mozc"); 646 ids.push_back(nacl_mozc_us_id);
634 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 647 EXPECT_TRUE(manager_->EnableInputMethods(ids));
635 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 648 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
636 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 649 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
637 manager_->ChangeInputMethod("mozc"); 650 manager_->ChangeInputMethod(nacl_mozc_us_id);
638 651
639 InputMethodPropertyList current_property_list; 652 InputMethodPropertyList current_property_list;
640 current_property_list.push_back(InputMethodProperty("key", 653 current_property_list.push_back(InputMethodProperty("key",
641 "label", 654 "label",
642 false, 655 false,
643 false)); 656 false));
644 controller_->SetCurrentPropertiesForTesting(current_property_list); 657 controller_->SetCurrentPropertiesForTesting(current_property_list);
645 controller_->NotifyPropertyChangedForTesting(); 658 controller_->NotifyPropertyChangedForTesting();
646 659
647 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); 660 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
648 EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); 661 EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key);
649 662
650 manager_->ChangeInputMethod("xkb:us::eng"); 663 manager_->ChangeInputMethod("xkb:us::eng");
651 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 664 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
652 665
653 // Delayed asynchronous property update signal from the Mozc IME. 666 // Delayed asynchronous property update signal from the Mozc IME.
654 controller_->NotifyPropertyChangedForTesting(); 667 controller_->NotifyPropertyChangedForTesting();
655 // When XKB layout is in use, GetCurrentInputMethodProperties() should always 668 // When XKB layout is in use, GetCurrentInputMethodProperties() should always
656 // return an empty list. 669 // return an empty list.
657 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 670 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
658 } 671 }
659 672
660 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { 673 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
661 ComponentExtensionInitialize(); 674 ComponentExtensionInitialize();
662 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 675 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
663 676
664 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 677 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
665 std::vector<std::string> ids; 678 std::vector<std::string> ids;
666 ids.push_back("mozc"); // Japanese 679 ids.push_back(nacl_mozc_us_id); // Japanese
667 ids.push_back("mozc-chewing"); // T-Chinese 680 ids.push_back("mozc-chewing"); // T-Chinese
668 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 681 EXPECT_TRUE(manager_->EnableInputMethods(ids));
669 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 682 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
670 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 683 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
671 684
672 InputMethodPropertyList current_property_list; 685 InputMethodPropertyList current_property_list;
673 current_property_list.push_back(InputMethodProperty("key-mozc", 686 current_property_list.push_back(InputMethodProperty("key-mozc",
674 "label", 687 "label",
675 false, 688 false,
676 false)); 689 false));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 ui::Accelerator(ui::VKEY_HANGUL, ui::EF_NONE))); 870 ui::Accelerator(ui::VKEY_HANGUL, ui::EF_NONE)));
858 EXPECT_EQ("xkb:kr:kr104:kor", manager_->GetCurrentInputMethod().id()); 871 EXPECT_EQ("xkb:kr:kr104:kor", manager_->GetCurrentInputMethod().id());
859 EXPECT_EQ("kr(kr104)", xkeyboard_->last_layout_); 872 EXPECT_EQ("kr(kr104)", xkeyboard_->last_layout_);
860 } 873 }
861 874
862 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { 875 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) {
863 ComponentExtensionInitialize(); 876 ComponentExtensionInitialize();
864 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 877 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
865 std::vector<std::string> ids; 878 std::vector<std::string> ids;
866 ids.push_back("xkb:jp::jpn"); 879 ids.push_back("xkb:jp::jpn");
867 ids.push_back("mozc-jp"); 880 ids.push_back(nacl_mozc_jp_id);
868 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 881 EXPECT_TRUE(manager_->EnableInputMethods(ids));
869 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 882 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
870 EXPECT_EQ("jp", xkeyboard_->last_layout_); 883 EXPECT_EQ("jp", xkeyboard_->last_layout_);
871 EXPECT_TRUE(manager_->SwitchInputMethod( 884 EXPECT_TRUE(manager_->SwitchInputMethod(
872 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 885 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
873 EXPECT_EQ("mozc-jp", manager_->GetCurrentInputMethod().id()); 886 EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id());
874 EXPECT_EQ("jp", xkeyboard_->last_layout_); 887 EXPECT_EQ("jp", xkeyboard_->last_layout_);
875 EXPECT_TRUE(manager_->SwitchInputMethod( 888 EXPECT_TRUE(manager_->SwitchInputMethod(
876 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 889 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
877 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 890 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
878 EXPECT_EQ("jp", xkeyboard_->last_layout_); 891 EXPECT_EQ("jp", xkeyboard_->last_layout_);
879 EXPECT_TRUE(manager_->SwitchInputMethod( 892 EXPECT_TRUE(manager_->SwitchInputMethod(
880 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 893 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
881 EXPECT_EQ("mozc-jp", manager_->GetCurrentInputMethod().id()); 894 EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id());
882 EXPECT_EQ("jp", xkeyboard_->last_layout_); 895 EXPECT_EQ("jp", xkeyboard_->last_layout_);
883 EXPECT_TRUE(manager_->SwitchInputMethod( 896 EXPECT_TRUE(manager_->SwitchInputMethod(
884 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 897 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
885 EXPECT_EQ("mozc-jp", manager_->GetCurrentInputMethod().id()); 898 EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id());
886 EXPECT_EQ("jp", xkeyboard_->last_layout_); 899 EXPECT_EQ("jp", xkeyboard_->last_layout_);
887 EXPECT_TRUE(manager_->SwitchInputMethod( 900 EXPECT_TRUE(manager_->SwitchInputMethod(
888 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 901 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
889 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 902 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
890 EXPECT_EQ("jp", xkeyboard_->last_layout_); 903 EXPECT_EQ("jp", xkeyboard_->last_layout_);
891 EXPECT_TRUE(manager_->SwitchInputMethod( 904 EXPECT_TRUE(manager_->SwitchInputMethod(
892 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 905 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
893 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 906 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
894 EXPECT_EQ("jp", xkeyboard_->last_layout_); 907 EXPECT_EQ("jp", xkeyboard_->last_layout_);
895 908
896 // Add Dvorak. 909 // Add Dvorak.
897 ids.push_back("xkb:us:dvorak:eng"); 910 ids.push_back("xkb:us:dvorak:eng");
898 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 911 EXPECT_TRUE(manager_->EnableInputMethods(ids));
899 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 912 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
900 EXPECT_EQ("jp", xkeyboard_->last_layout_); 913 EXPECT_EQ("jp", xkeyboard_->last_layout_);
901 EXPECT_TRUE(manager_->SwitchInputMethod( 914 EXPECT_TRUE(manager_->SwitchInputMethod(
902 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 915 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
903 EXPECT_EQ("mozc-jp", manager_->GetCurrentInputMethod().id()); 916 EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id());
904 EXPECT_EQ("jp", xkeyboard_->last_layout_); 917 EXPECT_EQ("jp", xkeyboard_->last_layout_);
905 EXPECT_TRUE(manager_->SwitchInputMethod( 918 EXPECT_TRUE(manager_->SwitchInputMethod(
906 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 919 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
907 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); 920 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
908 EXPECT_EQ("jp", xkeyboard_->last_layout_); 921 EXPECT_EQ("jp", xkeyboard_->last_layout_);
909 } 922 }
910 923
911 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithKoIme) { 924 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithKoIme) {
912 ComponentExtensionInitialize(); 925 ComponentExtensionInitialize();
913 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 926 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 methods->at(1).id()); 1076 methods->at(1).id());
1064 } 1077 }
1065 manager_->RemoveObserver(&observer); 1078 manager_->RemoveObserver(&observer);
1066 } 1079 }
1067 1080
1068 TEST_F(InputMethodManagerImplTest, TestReset) { 1081 TEST_F(InputMethodManagerImplTest, TestReset) {
1069 ComponentExtensionInitialize(); 1082 ComponentExtensionInitialize();
1070 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1083 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1071 std::vector<std::string> ids; 1084 std::vector<std::string> ids;
1072 ids.push_back("xkb:us::eng"); 1085 ids.push_back("xkb:us::eng");
1073 ids.push_back("mozc"); 1086 ids.push_back(nacl_mozc_us_id);
1074 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 1087 EXPECT_TRUE(manager_->EnableInputMethods(ids));
1075 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1088 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1076 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count()); 1089 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count());
1077 manager_->ChangeInputMethod("mozc"); 1090 manager_->ChangeInputMethod(nacl_mozc_us_id);
1078 EXPECT_EQ(1, controller_->change_input_method_count_); 1091 EXPECT_EQ(1, controller_->change_input_method_count_);
1079 EXPECT_EQ("mozc", controller_->change_input_method_id_); 1092 EXPECT_EQ(nacl_mozc_us_id, controller_->change_input_method_id_);
1080 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count()); 1093 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count());
1081 manager_->ChangeInputMethod("xkb:us::eng"); 1094 manager_->ChangeInputMethod("xkb:us::eng");
1082 EXPECT_EQ(2, controller_->change_input_method_count_); 1095 EXPECT_EQ(2, controller_->change_input_method_count_);
1083 EXPECT_EQ("mozc", controller_->change_input_method_id_); 1096 EXPECT_EQ(nacl_mozc_us_id, controller_->change_input_method_id_);
1084 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count()); 1097 EXPECT_EQ(1, mock_ibus_input_context_client_->reset_call_count());
1085 } 1098 }
1086 1099
1087 TEST_F(InputMethodManagerImplTest, 1100 TEST_F(InputMethodManagerImplTest,
1088 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { 1101 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) {
1089 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1102 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1090 std::vector<std::string> ids; 1103 std::vector<std::string> ids;
1091 ids.push_back("mozc"); 1104 ids.push_back(nacl_mozc_us_id);
1092 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 1105 EXPECT_TRUE(manager_->EnableInputMethods(ids));
1093 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1106 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1094 manager_->ChangeInputMethod("mozc"); 1107 manager_->ChangeInputMethod(nacl_mozc_us_id);
1095 EXPECT_EQ(0, controller_->change_input_method_count_); 1108 EXPECT_EQ(0, controller_->change_input_method_count_);
1096 1109
1097 ComponentExtensionInitialize(); 1110 ComponentExtensionInitialize();
1098 EXPECT_EQ(1, controller_->change_input_method_count_); 1111 EXPECT_EQ(1, controller_->change_input_method_count_);
1099 EXPECT_EQ("mozc", controller_->change_input_method_id_); 1112 EXPECT_EQ(nacl_mozc_us_id, controller_->change_input_method_id_);
1100 } 1113 }
1101 1114
1102 TEST_F(InputMethodManagerImplTest, 1115 TEST_F(InputMethodManagerImplTest,
1103 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { 1116 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) {
1104 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1117 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1105 std::vector<std::string> ids; 1118 std::vector<std::string> ids;
1106 ids.push_back("mozc"); 1119 ids.push_back(nacl_mozc_us_id);
1107 ids.push_back("m17n:kn:itrans"); 1120 ids.push_back("m17n:kn:itrans");
1108 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 1121 EXPECT_TRUE(manager_->EnableInputMethods(ids));
1109 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1122 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1110 manager_->ChangeInputMethod("mozc"); 1123 manager_->ChangeInputMethod(nacl_mozc_us_id);
1111 EXPECT_EQ(0, controller_->change_input_method_count_); 1124 EXPECT_EQ(0, controller_->change_input_method_count_);
1112 manager_->ChangeInputMethod("m17n:kn:itrans"); 1125 manager_->ChangeInputMethod("m17n:kn:itrans");
1113 EXPECT_EQ(0, controller_->change_input_method_count_); 1126 EXPECT_EQ(0, controller_->change_input_method_count_);
1114 1127
1115 ComponentExtensionInitialize(); 1128 ComponentExtensionInitialize();
1116 EXPECT_EQ(1, controller_->change_input_method_count_); 1129 EXPECT_EQ(1, controller_->change_input_method_count_);
1117 EXPECT_EQ("m17n:kn:itrans", controller_->change_input_method_id_); 1130 EXPECT_EQ("m17n:kn:itrans", controller_->change_input_method_id_);
1118 } 1131 }
1119 1132
1120 TEST_F(InputMethodManagerImplTest, 1133 TEST_F(InputMethodManagerImplTest,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1210 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1198 EXPECT_EQ(1, controller_->change_input_method_count_); 1211 EXPECT_EQ(1, controller_->change_input_method_count_);
1199 EXPECT_EQ(ext_id1, controller_->change_input_method_id_); 1212 EXPECT_EQ(ext_id1, controller_->change_input_method_id_);
1200 manager_->ChangeInputMethod(ext_id2); 1213 manager_->ChangeInputMethod(ext_id2);
1201 EXPECT_EQ(2, controller_->change_input_method_count_); 1214 EXPECT_EQ(2, controller_->change_input_method_count_);
1202 EXPECT_EQ(ext_id2, controller_->change_input_method_id_); 1215 EXPECT_EQ(ext_id2, controller_->change_input_method_id_);
1203 } 1216 }
1204 1217
1205 } // namespace input_method 1218 } // namespace input_method
1206 } // namespace chromeos 1219 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698