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

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

Issue 17266002: Replace Chinese Input with migration code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 7 years, 6 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 ComponentExtensionEngine ext1_engine2; 91 ComponentExtensionEngine ext1_engine2;
92 ext1_engine2.engine_id = "nacl_mozc_jp"; 92 ext1_engine2.engine_id = "nacl_mozc_jp";
93 ext1_engine2.display_name = "ext1_engine_1_display_name"; 93 ext1_engine2.display_name = "ext1_engine_1_display_name";
94 ext1_engine2.language_code = "ja"; 94 ext1_engine2.language_code = "ja";
95 ext1_engine2.layouts.push_back("jp"); 95 ext1_engine2.layouts.push_back("jp");
96 ext1.engines.push_back(ext1_engine2); 96 ext1.engines.push_back(ext1_engine2);
97 97
98 ime_list_.push_back(ext1); 98 ime_list_.push_back(ext1);
99 99
100 ComponentExtensionIME ext2; 100 ComponentExtensionIME ext2;
101 ext2.id = "ext2_id"; 101 ext2.id = "nmblnjkfdkabgdofidlkienfnnbjhnab";
102 ext2.description = "ext2_description"; 102 ext2.description = "ext2_description";
103 ext2.path = base::FilePath("ext2_file_path"); 103 ext2.path = base::FilePath("ext2_file_path");
104 104
105 ComponentExtensionEngine ext2_engine1; 105 ComponentExtensionEngine ext2_engine1;
106 ext2_engine1.engine_id = "ext2_engine1_engine_id"; 106 ext2_engine1.engine_id = "ext2_engine1_engine_id";
107 ext2_engine1.display_name = "ext2_engine_1_display_name"; 107 ext2_engine1.display_name = "ext2_engine_1_display_name";
108 ext2_engine1.language_code = "en"; 108 ext2_engine1.language_code = "en";
109 ext2_engine1.layouts.push_back("us"); 109 ext2_engine1.layouts.push_back("us");
110 ext2.engines.push_back(ext2_engine1); 110 ext2.engines.push_back(ext2_engine1);
111 111
112 ComponentExtensionEngine ext2_engine2;
113 ext2_engine2.engine_id = "ext2_engine2_engine_id";
114 ext2_engine2.display_name = "ext2_engine_2_display_name";
115 ext2_engine2.language_code = "en";
116 ext2_engine2.layouts.push_back("us(dvorak)");
117 ext2.engines.push_back(ext2_engine2);
118
112 ime_list_.push_back(ext2); 119 ime_list_.push_back(ext2);
113 120
114 mock_ibus_daemon_controller_->EmulateConnect(); 121 mock_ibus_daemon_controller_->EmulateConnect();
115 } 122 }
116 123
117 virtual void TearDown() OVERRIDE { 124 virtual void TearDown() OVERRIDE {
118 mock_ibus_daemon_controller_->EmulateDisconnect(); 125 mock_ibus_daemon_controller_->EmulateDisconnect();
119 delegate_ = NULL; 126 delegate_ = NULL;
120 controller_ = NULL; 127 controller_ = NULL;
121 candidate_window_controller_ = NULL; 128 candidate_window_controller_ = NULL;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 EXPECT_EQ(3, observer.input_method_property_changed_count_); 271 EXPECT_EQ(3, observer.input_method_property_changed_count_);
265 272
266 controller_->NotifyPropertyChangedForTesting(); 273 controller_->NotifyPropertyChangedForTesting();
267 EXPECT_EQ(4, observer.input_method_property_changed_count_); 274 EXPECT_EQ(4, observer.input_method_property_changed_count_);
268 controller_->NotifyPropertyChangedForTesting(); 275 controller_->NotifyPropertyChangedForTesting();
269 EXPECT_EQ(5, observer.input_method_property_changed_count_); 276 EXPECT_EQ(5, observer.input_method_property_changed_count_);
270 manager_->RemoveObserver(&observer); 277 manager_->RemoveObserver(&observer);
271 } 278 }
272 279
273 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { 280 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
281 InitComponentExtension();
282 InitIBusBus();
274 scoped_ptr<InputMethodDescriptors> methods( 283 scoped_ptr<InputMethodDescriptors> methods(
275 manager_->GetSupportedInputMethods()); 284 manager_->GetSupportedInputMethods());
276 ASSERT_TRUE(methods.get()); 285 ASSERT_TRUE(methods.get());
277 // Try to find random 4-5 layuts and IMEs to make sure the returned list is 286 // Try to find random 4-5 layuts and IMEs to make sure the returned list is
278 // correct. 287 // correct.
279 const InputMethodDescriptor* id_to_find = 288 const InputMethodDescriptor* id_to_find =
280 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 289 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
281 nacl_mozc_us_id); 290 nacl_mozc_us_id);
282 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 291 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
283 "mozc-chewing");
284 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
285 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
286 "xkb:us::eng"); 292 "xkb:us::eng");
287 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 293 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
288 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 294 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
289 "xkb:us:dvorak:eng"); 295 "xkb:us:dvorak:eng");
290 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 296 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
291 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( 297 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
292 "xkb:fr::fra"); 298 "xkb:fr::fra");
293 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); 299 EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
294 } 300 }
295 301
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 manager_->RemoveObserver(&observer); 498 manager_->RemoveObserver(&observer);
493 } 499 }
494 500
495 TEST_F(InputMethodManagerImplTest, TestEnableImes) { 501 TEST_F(InputMethodManagerImplTest, TestEnableImes) {
496 TestObserver observer; 502 TestObserver observer;
497 manager_->AddObserver(&observer); 503 manager_->AddObserver(&observer);
498 InitComponentExtension(); 504 InitComponentExtension();
499 InitIBusBus(); 505 InitIBusBus();
500 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 506 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
501 std::vector<std::string> ids; 507 std::vector<std::string> ids;
502 ids.push_back("mozc-chewing"); 508 ids.push_back("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_engine1_engine_i d");
503 ids.push_back("mozc-dv"); 509 ids.push_back("mozc-dv");
504 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 510 EXPECT_TRUE(manager_->EnableInputMethods(ids));
505 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); 511 EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count());
506 EXPECT_EQ(1, observer.input_method_changed_count_); 512 EXPECT_EQ(1, observer.input_method_changed_count_);
507 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); 513 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
508 EXPECT_EQ("us", xkeyboard_->last_layout_); 514 EXPECT_EQ("us", xkeyboard_->last_layout_);
509 manager_->RemoveObserver(&observer); 515 manager_->RemoveObserver(&observer);
510 } 516 }
511 517
512 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { 518 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 566
561 // Unlock screen. The original state, Dvorak, is restored. 567 // Unlock screen. The original state, Dvorak, is restored.
562 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 568 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
563 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 569 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
564 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); 570 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
565 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 571 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
566 572
567 manager_->RemoveObserver(&observer); 573 manager_->RemoveObserver(&observer);
568 } 574 }
569 575
570 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndImeThenLock) { 576 TEST_F(InputMethodManagerImplTest, SwithchInputMethodTest) {
571 // For http://crbug.com/19655#c11 - (15). 577 // For http://crbug.com/19655#c11 - (15).
572 TestObserver observer; 578 TestObserver observer;
573 manager_->AddObserver(&observer); 579 manager_->AddObserver(&observer);
574 InitComponentExtension(); 580 InitComponentExtension();
575 InitIBusBus(); 581 InitIBusBus();
576 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 582 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
577 std::vector<std::string> ids; 583 std::vector<std::string> ids;
578 ids.push_back("xkb:us:dvorak:eng"); 584 ids.push_back("xkb:us:dvorak:eng");
579 ids.push_back("pinyin-dv"); 585 ids.push_back("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_engine2_engine_i d");
580 ids.push_back("mozc-chewing"); 586 ids.push_back("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_engine1_engine_i d");
581 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 587 EXPECT_TRUE(manager_->EnableInputMethods(ids));
582 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 588 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
583 EXPECT_EQ(1, observer.input_method_changed_count_); 589 EXPECT_EQ(1, observer.input_method_changed_count_);
584 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); 590 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
585 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 591 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
586 592
587 // Switch to Mozc. 593 // Switch to Mozc.
588 manager_->SwitchToNextInputMethod(); 594 manager_->SwitchToNextInputMethod();
589 EXPECT_EQ(2, observer.input_method_changed_count_); 595 EXPECT_EQ(2, observer.input_method_changed_count_);
590 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); 596 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 699 }
694 700
695 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { 701 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
696 InitComponentExtension(); 702 InitComponentExtension();
697 InitIBusBus(); 703 InitIBusBus();
698 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 704 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
699 705
700 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 706 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
701 std::vector<std::string> ids; 707 std::vector<std::string> ids;
702 ids.push_back(nacl_mozc_us_id); // Japanese 708 ids.push_back(nacl_mozc_us_id); // Japanese
703 ids.push_back("mozc-chewing"); // T-Chinese 709 ids.push_back("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_engine1_engine_i d"); // T-Chinese
704 EXPECT_TRUE(manager_->EnableInputMethods(ids)); 710 EXPECT_TRUE(manager_->EnableInputMethods(ids));
705 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 711 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
706 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 712 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
707 713
708 InputMethodPropertyList current_property_list; 714 InputMethodPropertyList current_property_list;
709 current_property_list.push_back(InputMethodProperty("key-mozc", 715 current_property_list.push_back(InputMethodProperty("key-mozc",
710 "label", 716 "label",
711 false, 717 false,
712 false)); 718 false));
713 controller_->SetCurrentPropertiesForTesting(current_property_list); 719 controller_->SetCurrentPropertiesForTesting(current_property_list);
714 controller_->NotifyPropertyChangedForTesting(); 720 controller_->NotifyPropertyChangedForTesting();
715 721
716 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); 722 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
717 EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key); 723 EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key);
718 724
719 manager_->ChangeInputMethod("mozc-chewing"); 725 manager_->ChangeInputMethod("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_en gine1_engine_id");
720 // Since the IME is changed, the property for mozc Japanese should be hidden. 726 // Since the IME is changed, the property for mozc Japanese should be hidden.
721 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); 727 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
722 728
723 // Asynchronous property update signal from mozc-chewing. 729 // Asynchronous property update signal from mozc-chewing.
724 current_property_list.clear(); 730 current_property_list.clear();
725 current_property_list.push_back(InputMethodProperty("key-chewing", 731 current_property_list.push_back(InputMethodProperty("key-chewing",
726 "label", 732 "label",
727 false, 733 false,
728 false)); 734 false));
729 controller_->SetCurrentPropertiesForTesting(current_property_list); 735 controller_->SetCurrentPropertiesForTesting(current_property_list);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 EXPECT_EQ(fallback_id, manager_->GetCurrentInputMethod().id()); 1360 EXPECT_EQ(fallback_id, manager_->GetCurrentInputMethod().id());
1355 1361
1356 // After component extension IME is initialized, previous specified input 1362 // After component extension IME is initialized, previous specified input
1357 // method should be automatically enabled. 1363 // method should be automatically enabled.
1358 InitComponentExtension(); 1364 InitComponentExtension();
1359 EXPECT_EQ(xkb_id, manager_->GetCurrentInputMethod().id()); 1365 EXPECT_EQ(xkb_id, manager_->GetCurrentInputMethod().id());
1360 } 1366 }
1361 1367
1362 } // namespace input_method 1368 } // namespace input_method
1363 } // namespace chromeos 1369 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698