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

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

Issue 232333002: ozone: Rename XKeyboard to KeyboardController & use fake under ozone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename to ImeKeyboard & rebase Created 6 years, 8 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"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" 18 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
19 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller. h" 19 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller. h"
20 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h" 20 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h"
21 #include "chromeos/ime/extension_ime_util.h" 21 #include "chromeos/ime/extension_ime_util.h"
22 #include "chromeos/ime/fake_ime_keyboard.h"
22 #include "chromeos/ime/fake_input_method_delegate.h" 23 #include "chromeos/ime/fake_input_method_delegate.h"
23 #include "chromeos/ime/fake_xkeyboard.h"
24 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" 24 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/base/accelerators/accelerator.h" 26 #include "ui/base/accelerators/accelerator.h"
27 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h" 27 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h"
28 #include "ui/events/keycodes/keyboard_codes.h" 28 #include "ui/events/keycodes/keyboard_codes.h"
29 29
30 namespace chromeos { 30 namespace chromeos {
31 31
32 namespace input_method { 32 namespace input_method {
33 namespace { 33 namespace {
(...skipping 27 matching lines...) Expand all
61 61
62 std::string XkbId(const std::string& id) { 62 std::string XkbId(const std::string& id) {
63 return extension_ime_util::GetInputMethodIDByKeyboardLayout(id); 63 return extension_ime_util::GetInputMethodIDByKeyboardLayout(id);
64 } 64 }
65 65
66 class InputMethodManagerImplTest : public testing::Test { 66 class InputMethodManagerImplTest : public testing::Test {
67 public: 67 public:
68 InputMethodManagerImplTest() 68 InputMethodManagerImplTest()
69 : delegate_(NULL), 69 : delegate_(NULL),
70 candidate_window_controller_(NULL), 70 candidate_window_controller_(NULL),
71 xkeyboard_(NULL) { 71 keyboard_(NULL) {
72 } 72 }
73 virtual ~InputMethodManagerImplTest() {} 73 virtual ~InputMethodManagerImplTest() {}
74 74
75 virtual void SetUp() OVERRIDE { 75 virtual void SetUp() OVERRIDE {
76 delegate_ = new FakeInputMethodDelegate(); 76 delegate_ = new FakeInputMethodDelegate();
77 manager_.reset(new InputMethodManagerImpl( 77 manager_.reset(new InputMethodManagerImpl(
78 scoped_ptr<InputMethodDelegate>(delegate_))); 78 scoped_ptr<InputMethodDelegate>(delegate_)));
79 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); 79 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache();
80 candidate_window_controller_ = new MockCandidateWindowController; 80 candidate_window_controller_ = new MockCandidateWindowController;
81 manager_->SetCandidateWindowControllerForTesting( 81 manager_->SetCandidateWindowControllerForTesting(
82 candidate_window_controller_); 82 candidate_window_controller_);
83 xkeyboard_ = new FakeXKeyboard; 83 keyboard_ = new FakeImeKeyboard;
84 manager_->SetXKeyboardForTesting(xkeyboard_); 84 manager_->SetImeKeyboardForTesting(keyboard_);
85 mock_engine_handler_.reset(new MockIMEEngineHandler()); 85 mock_engine_handler_.reset(new MockIMEEngineHandler());
86 IMEBridge::Initialize(); 86 IMEBridge::Initialize();
87 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); 87 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get());
88 88
89 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); 89 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance();
90 90
91 ime_list_.clear(); 91 ime_list_.clear();
92 92
93 ComponentExtensionIME ext_xkb; 93 ComponentExtensionIME ext_xkb;
94 ext_xkb.id = kXkbExtId; 94 ext_xkb.id = kXkbExtId;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ext2_engine2.language_codes.push_back("en"); 206 ext2_engine2.language_codes.push_back("en");
207 ext2_engine2.layouts.push_back("us(dvorak)"); 207 ext2_engine2.layouts.push_back("us(dvorak)");
208 ext2.engines.push_back(ext2_engine2); 208 ext2.engines.push_back(ext2_engine2);
209 209
210 ime_list_.push_back(ext2); 210 ime_list_.push_back(ext2);
211 } 211 }
212 212
213 virtual void TearDown() OVERRIDE { 213 virtual void TearDown() OVERRIDE {
214 delegate_ = NULL; 214 delegate_ = NULL;
215 candidate_window_controller_ = NULL; 215 candidate_window_controller_ = NULL;
216 xkeyboard_ = NULL; 216 keyboard_ = NULL;
217 manager_.reset(); 217 manager_.reset();
218 218
219 IMEBridge::Get()->SetCurrentEngineHandler(NULL); 219 IMEBridge::Get()->SetCurrentEngineHandler(NULL);
220 IMEBridge::Shutdown(); 220 IMEBridge::Shutdown();
221 } 221 }
222 222
223 protected: 223 protected:
224 // Helper function to initialize component extension stuff for testing. 224 // Helper function to initialize component extension stuff for testing.
225 void InitComponentExtension() { 225 void InitComponentExtension() {
226 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); 226 mock_delegate_ = new MockComponentExtIMEManagerDelegate();
(...skipping 10 matching lines...) Expand all
237 mock_engine_handler_.get()); 237 mock_engine_handler_.get());
238 IMEBridge::Get()->SetEngineHandler(kExt2Engine2Id, 238 IMEBridge::Get()->SetEngineHandler(kExt2Engine2Id,
239 mock_engine_handler_.get()); 239 mock_engine_handler_.get());
240 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); 240 manager_->InitializeComponentExtensionForTesting(delegate.Pass());
241 } 241 }
242 242
243 scoped_ptr<InputMethodManagerImpl> manager_; 243 scoped_ptr<InputMethodManagerImpl> manager_;
244 FakeInputMethodDelegate* delegate_; 244 FakeInputMethodDelegate* delegate_;
245 MockCandidateWindowController* candidate_window_controller_; 245 MockCandidateWindowController* candidate_window_controller_;
246 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; 246 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_;
247 FakeXKeyboard* xkeyboard_; 247 FakeImeKeyboard* keyboard_;
248 base::MessageLoop message_loop_; 248 base::MessageLoop message_loop_;
249 MockComponentExtIMEManagerDelegate* mock_delegate_; 249 MockComponentExtIMEManagerDelegate* mock_delegate_;
250 std::vector<ComponentExtensionIME> ime_list_; 250 std::vector<ComponentExtensionIME> ime_list_;
251 ash::ime::InputMethodMenuManager* menu_manager_; 251 ash::ime::InputMethodMenuManager* menu_manager_;
252 252
253 private: 253 private:
254 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); 254 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest);
255 }; 255 };
256 256
257 class TestObserver : public InputMethodManager::Observer, 257 class TestObserver : public InputMethodManager::Observer,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 int candidate_window_opened_count_; 301 int candidate_window_opened_count_;
302 int candidate_window_closed_count_; 302 int candidate_window_closed_count_;
303 303
304 private: 304 private:
305 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); 305 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver);
306 }; 306 };
307 } // namespace 307 } // namespace
308 308
309 TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) { 309 TEST_F(InputMethodManagerImplTest, TestGetImeKeyboard) {
310 EXPECT_TRUE(manager_->GetXKeyboard()); 310 EXPECT_TRUE(manager_->GetImeKeyboard());
311 EXPECT_EQ(xkeyboard_, manager_->GetXKeyboard()); 311 EXPECT_EQ(keyboard_, manager_->GetImeKeyboard());
312 } 312 }
313 313
314 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { 314 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) {
315 TestCandidateWindowObserver observer; 315 TestCandidateWindowObserver observer;
316 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop 316 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop
317 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop 317 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop
318 manager_->AddCandidateWindowObserver(&observer); 318 manager_->AddCandidateWindowObserver(&observer);
319 candidate_window_controller_->NotifyCandidateWindowOpened(); 319 candidate_window_controller_->NotifyCandidateWindowOpened();
320 EXPECT_EQ(1, observer.candidate_window_opened_count_); 320 EXPECT_EQ(1, observer.candidate_window_opened_count_);
321 candidate_window_controller_->NotifyCandidateWindowClosed(); 321 candidate_window_controller_->NotifyCandidateWindowClosed();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 494 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
495 std::vector<std::string> ids; 495 std::vector<std::string> ids;
496 ids.push_back(XkbId("xkb:us:dvorak:eng")); 496 ids.push_back(XkbId("xkb:us:dvorak:eng"));
497 ids.push_back(XkbId("xkb:us:colemak:eng")); 497 ids.push_back(XkbId("xkb:us:colemak:eng"));
498 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 498 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
499 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 499 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
500 // Since all the IDs added avobe are keyboard layouts, Start() should not be 500 // Since all the IDs added avobe are keyboard layouts, Start() should not be
501 // called. 501 // called.
502 EXPECT_EQ(1, observer.input_method_changed_count_); 502 EXPECT_EQ(1, observer.input_method_changed_count_);
503 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 503 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
504 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 504 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
505 // Disable Dvorak. 505 // Disable Dvorak.
506 ids.erase(ids.begin()); 506 ids.erase(ids.begin());
507 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 507 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
508 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 508 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
509 EXPECT_EQ(2, observer.input_method_changed_count_); 509 EXPECT_EQ(2, observer.input_method_changed_count_);
510 EXPECT_EQ(XkbId(ids[0]), // colemak 510 EXPECT_EQ(XkbId(ids[0]), // colemak
511 manager_->GetCurrentInputMethod().id()); 511 manager_->GetCurrentInputMethod().id());
512 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 512 EXPECT_EQ("us(colemak)", keyboard_->last_layout_);
513 manager_->RemoveObserver(&observer); 513 manager_->RemoveObserver(&observer);
514 } 514 }
515 515
516 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { 516 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) {
517 // For http://crbug.com/19655#c11 - (9). 517 // For http://crbug.com/19655#c11 - (9).
518 TestObserver observer; 518 TestObserver observer;
519 manager_->AddObserver(&observer); 519 manager_->AddObserver(&observer);
520 InitComponentExtension(); 520 InitComponentExtension();
521 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 521 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
522 std::vector<std::string> ids; 522 std::vector<std::string> ids;
523 ids.push_back(XkbId("xkb:us::eng")); 523 ids.push_back(XkbId("xkb:us::eng"));
524 ids.push_back(XkbId("xkb:us:dvorak:eng")); 524 ids.push_back(XkbId("xkb:us:dvorak:eng"));
525 ids.push_back(XkbId("xkb:us:colemak:eng")); 525 ids.push_back(XkbId("xkb:us:colemak:eng"));
526 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 526 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
527 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 527 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
528 EXPECT_EQ(1, observer.input_method_changed_count_); 528 EXPECT_EQ(1, observer.input_method_changed_count_);
529 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 529 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
530 EXPECT_EQ("us", xkeyboard_->last_layout_); 530 EXPECT_EQ("us", keyboard_->last_layout_);
531 // Switch to Dvorak. 531 // Switch to Dvorak.
532 manager_->SwitchToNextInputMethod(); 532 manager_->SwitchToNextInputMethod();
533 EXPECT_EQ(2, observer.input_method_changed_count_); 533 EXPECT_EQ(2, observer.input_method_changed_count_);
534 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 534 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
535 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 535 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
536 // Disable Dvorak. 536 // Disable Dvorak.
537 ids.erase(ids.begin() + 1); 537 ids.erase(ids.begin() + 1);
538 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 538 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
539 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 539 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
540 EXPECT_EQ(3, observer.input_method_changed_count_); 540 EXPECT_EQ(3, observer.input_method_changed_count_);
541 EXPECT_EQ(XkbId(ids[0]), // US Qwerty 541 EXPECT_EQ(XkbId(ids[0]), // US Qwerty
542 manager_->GetCurrentInputMethod().id()); 542 manager_->GetCurrentInputMethod().id());
543 EXPECT_EQ("us", xkeyboard_->last_layout_); 543 EXPECT_EQ("us", keyboard_->last_layout_);
544 manager_->RemoveObserver(&observer); 544 manager_->RemoveObserver(&observer);
545 } 545 }
546 546
547 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { 547 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) {
548 // For http://crbug.com/19655#c11 - (10). 548 // For http://crbug.com/19655#c11 - (10).
549 TestObserver observer; 549 TestObserver observer;
550 manager_->AddObserver(&observer); 550 manager_->AddObserver(&observer);
551 InitComponentExtension(); 551 InitComponentExtension();
552 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 552 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
553 std::vector<std::string> ids; 553 std::vector<std::string> ids;
554 ids.push_back(XkbId("xkb:us:dvorak:eng")); 554 ids.push_back(XkbId("xkb:us:dvorak:eng"));
555 ids.push_back(kNaclMozcUsId); 555 ids.push_back(kNaclMozcUsId);
556 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 556 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
557 EXPECT_EQ(1, observer.input_method_changed_count_); 557 EXPECT_EQ(1, observer.input_method_changed_count_);
558 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 558 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
559 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 559 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
560 // Switch to Mozc 560 // Switch to Mozc
561 manager_->SwitchToNextInputMethod(); 561 manager_->SwitchToNextInputMethod();
562 EXPECT_EQ(2, observer.input_method_changed_count_); 562 EXPECT_EQ(2, observer.input_method_changed_count_);
563 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 563 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
564 EXPECT_EQ("us", xkeyboard_->last_layout_); 564 EXPECT_EQ("us", keyboard_->last_layout_);
565 // Disable Mozc. 565 // Disable Mozc.
566 ids.erase(ids.begin() + 1); 566 ids.erase(ids.begin() + 1);
567 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 567 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
568 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 568 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
569 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 569 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
570 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 570 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
571 } 571 }
572 572
573 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { 573 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) {
574 // For http://crbug.com/19655#c11 - (11). 574 // For http://crbug.com/19655#c11 - (11).
575 TestObserver observer; 575 TestObserver observer;
576 manager_->AddObserver(&observer); 576 manager_->AddObserver(&observer);
577 InitComponentExtension(); 577 InitComponentExtension();
578 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 578 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
579 std::vector<std::string> ids; 579 std::vector<std::string> ids;
580 ids.push_back(XkbId("xkb:us:dvorak:eng")); 580 ids.push_back(XkbId("xkb:us:dvorak:eng"));
581 ids.push_back(kNaclMozcUsId); 581 ids.push_back(kNaclMozcUsId);
582 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 582 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
583 EXPECT_EQ(1, observer.input_method_changed_count_); 583 EXPECT_EQ(1, observer.input_method_changed_count_);
584 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 584 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
585 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 585 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
586 586
587 // Disable Dvorak. 587 // Disable Dvorak.
588 ids.erase(ids.begin()); 588 ids.erase(ids.begin());
589 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 589 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
590 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 590 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
591 EXPECT_EQ(XkbId(ids[0]), // Mozc 591 EXPECT_EQ(XkbId(ids[0]), // Mozc
592 manager_->GetCurrentInputMethod().id()); 592 manager_->GetCurrentInputMethod().id());
593 EXPECT_EQ("us", xkeyboard_->last_layout_); 593 EXPECT_EQ("us", keyboard_->last_layout_);
594 manager_->RemoveObserver(&observer); 594 manager_->RemoveObserver(&observer);
595 } 595 }
596 596
597 TEST_F(InputMethodManagerImplTest, TestEnableImes) { 597 TEST_F(InputMethodManagerImplTest, TestEnableImes) {
598 TestObserver observer; 598 TestObserver observer;
599 manager_->AddObserver(&observer); 599 manager_->AddObserver(&observer);
600 InitComponentExtension(); 600 InitComponentExtension();
601 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 601 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
602 std::vector<std::string> ids; 602 std::vector<std::string> ids;
603 ids.push_back(kExt2Engine1Id); 603 ids.push_back(kExt2Engine1Id);
604 ids.push_back("mozc-dv"); 604 ids.push_back("mozc-dv");
605 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 605 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
606 EXPECT_EQ(1, observer.input_method_changed_count_); 606 EXPECT_EQ(1, observer.input_method_changed_count_);
607 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 607 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
608 EXPECT_EQ("us", xkeyboard_->last_layout_); 608 EXPECT_EQ("us", keyboard_->last_layout_);
609 manager_->RemoveObserver(&observer); 609 manager_->RemoveObserver(&observer);
610 } 610 }
611 611
612 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { 612 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) {
613 TestObserver observer; 613 TestObserver observer;
614 manager_->AddObserver(&observer); 614 manager_->AddObserver(&observer);
615 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 615 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
616 std::vector<std::string> ids; 616 std::vector<std::string> ids;
617 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. 617 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported.
618 ids.push_back("unknown-super-cool-ime"); 618 ids.push_back("unknown-super-cool-ime");
(...skipping 12 matching lines...) Expand all
631 manager_->AddObserver(&observer); 631 manager_->AddObserver(&observer);
632 InitComponentExtension(); 632 InitComponentExtension();
633 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 633 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
634 std::vector<std::string> ids; 634 std::vector<std::string> ids;
635 ids.push_back(XkbId("xkb:us::eng")); 635 ids.push_back(XkbId("xkb:us::eng"));
636 ids.push_back(XkbId("xkb:us:dvorak:eng")); 636 ids.push_back(XkbId("xkb:us:dvorak:eng"));
637 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 637 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
638 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 638 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
639 EXPECT_EQ(1, observer.input_method_changed_count_); 639 EXPECT_EQ(1, observer.input_method_changed_count_);
640 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 640 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
641 EXPECT_EQ("us", xkeyboard_->last_layout_); 641 EXPECT_EQ("us", keyboard_->last_layout_);
642 642
643 // Switch to Dvorak. 643 // Switch to Dvorak.
644 manager_->SwitchToNextInputMethod(); 644 manager_->SwitchToNextInputMethod();
645 EXPECT_EQ(2, observer.input_method_changed_count_); 645 EXPECT_EQ(2, observer.input_method_changed_count_);
646 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 646 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
647 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 647 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
648 648
649 // Lock screen 649 // Lock screen
650 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); 650 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
651 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 651 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
652 EXPECT_EQ(XkbId(ids[1]), // still Dvorak 652 EXPECT_EQ(XkbId(ids[1]), // still Dvorak
653 manager_->GetCurrentInputMethod().id()); 653 manager_->GetCurrentInputMethod().id());
654 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 654 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
655 // Switch back to Qwerty. 655 // Switch back to Qwerty.
656 manager_->SwitchToNextInputMethod(); 656 manager_->SwitchToNextInputMethod();
657 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 657 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
658 EXPECT_EQ("us", xkeyboard_->last_layout_); 658 EXPECT_EQ("us", keyboard_->last_layout_);
659 659
660 // Unlock screen. The original state, Dvorak, is restored. 660 // Unlock screen. The original state, Dvorak, is restored.
661 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 661 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
662 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 662 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
663 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 663 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
664 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 664 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
665 665
666 manager_->RemoveObserver(&observer); 666 manager_->RemoveObserver(&observer);
667 } 667 }
668 668
669 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { 669 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) {
670 // For http://crbug.com/19655#c11 - (15). 670 // For http://crbug.com/19655#c11 - (15).
671 TestObserver observer; 671 TestObserver observer;
672 manager_->AddObserver(&observer); 672 manager_->AddObserver(&observer);
673 InitComponentExtension(); 673 InitComponentExtension();
674 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 674 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
675 std::vector<std::string> ids; 675 std::vector<std::string> ids;
676 ids.push_back(XkbId("xkb:us:dvorak:eng")); 676 ids.push_back(XkbId("xkb:us:dvorak:eng"));
677 ids.push_back(kExt2Engine2Id); 677 ids.push_back(kExt2Engine2Id);
678 ids.push_back(kExt2Engine1Id); 678 ids.push_back(kExt2Engine1Id);
679 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 679 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
680 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 680 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
681 EXPECT_EQ(1, observer.input_method_changed_count_); 681 EXPECT_EQ(1, observer.input_method_changed_count_);
682 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 682 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
683 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 683 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
684 684
685 // Switch to Mozc. 685 // Switch to Mozc.
686 manager_->SwitchToNextInputMethod(); 686 manager_->SwitchToNextInputMethod();
687 EXPECT_EQ(2, observer.input_method_changed_count_); 687 EXPECT_EQ(2, observer.input_method_changed_count_);
688 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 688 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
689 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 689 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
690 690
691 // Lock screen 691 // Lock screen
692 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); 692 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
693 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. 693 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak.
694 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), 694 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"),
695 manager_->GetCurrentInputMethod().id()); 695 manager_->GetCurrentInputMethod().id());
696 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 696 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
697 manager_->SwitchToNextInputMethod(); 697 manager_->SwitchToNextInputMethod();
698 EXPECT_EQ(XkbId("xkb:us::eng"), // The hardware keyboard layout. 698 EXPECT_EQ(XkbId("xkb:us::eng"), // The hardware keyboard layout.
699 manager_->GetCurrentInputMethod().id()); 699 manager_->GetCurrentInputMethod().id());
700 EXPECT_EQ("us", xkeyboard_->last_layout_); 700 EXPECT_EQ("us", keyboard_->last_layout_);
701 701
702 // Unlock screen. The original state, pinyin-dv, is restored. 702 // Unlock screen. The original state, pinyin-dv, is restored.
703 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 703 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
704 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. 704 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs.
705 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); 705 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id());
706 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 706 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
707 707
708 manager_->RemoveObserver(&observer); 708 manager_->RemoveObserver(&observer);
709 } 709 }
710 710
711 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { 711 TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
712 // For http://crbug.com/19655#c11 - (8), step 7-11. 712 // For http://crbug.com/19655#c11 - (8), step 7-11.
713 InitComponentExtension(); 713 InitComponentExtension();
714 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 714 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
715 std::vector<std::string> ids; 715 std::vector<std::string> ids;
716 ids.push_back(XkbId("xkb:us:dvorak:eng")); 716 ids.push_back(XkbId("xkb:us:dvorak:eng"));
717 ids.push_back(XkbId("xkb:us:colemak:eng")); 717 ids.push_back(XkbId("xkb:us:colemak:eng"));
718 ids.push_back(kNaclMozcJpId); 718 ids.push_back(kNaclMozcJpId);
719 ids.push_back(kNaclMozcUsId); 719 ids.push_back(kNaclMozcUsId);
720 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 720 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
721 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); 721 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods());
722 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); 722 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_);
723 // See input_methods.txt for an expected XKB layout name. 723 // See input_methods.txt for an expected XKB layout name.
724 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 724 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
725 manager_->SwitchToNextInputMethod(); 725 manager_->SwitchToNextInputMethod();
726 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); 726 EXPECT_EQ(2, keyboard_->set_current_keyboard_layout_by_name_count_);
727 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 727 EXPECT_EQ("us(colemak)", keyboard_->last_layout_);
728 manager_->SwitchToNextInputMethod(); 728 manager_->SwitchToNextInputMethod();
729 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); 729 EXPECT_EQ(3, keyboard_->set_current_keyboard_layout_by_name_count_);
730 EXPECT_EQ("jp", xkeyboard_->last_layout_); 730 EXPECT_EQ("jp", keyboard_->last_layout_);
731 manager_->SwitchToNextInputMethod(); 731 manager_->SwitchToNextInputMethod();
732 EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_); 732 EXPECT_EQ(4, keyboard_->set_current_keyboard_layout_by_name_count_);
733 EXPECT_EQ("us", xkeyboard_->last_layout_); 733 EXPECT_EQ("us", keyboard_->last_layout_);
734 manager_->SwitchToNextInputMethod(); 734 manager_->SwitchToNextInputMethod();
735 EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_); 735 EXPECT_EQ(5, keyboard_->set_current_keyboard_layout_by_name_count_);
736 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 736 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
737 // Disable Dvorak. 737 // Disable Dvorak.
738 ids.erase(ids.begin()); 738 ids.erase(ids.begin());
739 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 739 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
740 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); 740 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
741 EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_); 741 EXPECT_EQ(6, keyboard_->set_current_keyboard_layout_by_name_count_);
742 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 742 EXPECT_EQ("us(colemak)", keyboard_->last_layout_);
743 } 743 }
744 744
745 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) { 745 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) {
746 const std::string kKey = "key"; 746 const std::string kKey = "key";
747 ash::ime::InputMethodMenuItemList menu_list; 747 ash::ime::InputMethodMenuItemList menu_list;
748 menu_list.push_back(ash::ime::InputMethodMenuItem( 748 menu_list.push_back(ash::ime::InputMethodMenuItem(
749 kKey, "label", false, false)); 749 kKey, "label", false, false));
750 menu_manager_->SetCurrentInputMethodMenuItemList(menu_list); 750 menu_manager_->SetCurrentInputMethodMenuItemList(menu_list);
751 751
752 manager_->ActivateInputMethodMenuItem(kKey); 752 manager_->ActivateInputMethodMenuItem(kKey);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { 823 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) {
824 TestObserver observer; 824 TestObserver observer;
825 manager_->AddObserver(&observer); 825 manager_->AddObserver(&observer);
826 InitComponentExtension(); 826 InitComponentExtension();
827 std::vector<std::string> keyboard_layouts; 827 std::vector<std::string> keyboard_layouts;
828 keyboard_layouts.push_back(XkbId("xkb:us::eng")); 828 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
829 // For http://crbug.com/19655#c11 - (1) 829 // For http://crbug.com/19655#c11 - (1)
830 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 830 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
831 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 831 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
832 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 832 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
833 EXPECT_EQ("us", xkeyboard_->last_layout_); 833 EXPECT_EQ("us", keyboard_->last_layout_);
834 manager_->SwitchToNextInputMethod(); 834 manager_->SwitchToNextInputMethod();
835 EXPECT_TRUE(observer.last_show_message_); 835 EXPECT_TRUE(observer.last_show_message_);
836 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); 836 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id());
837 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 837 EXPECT_EQ("us(intl)", keyboard_->last_layout_);
838 manager_->SwitchToNextInputMethod(); 838 manager_->SwitchToNextInputMethod();
839 EXPECT_TRUE(observer.last_show_message_); 839 EXPECT_TRUE(observer.last_show_message_);
840 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), 840 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"),
841 manager_->GetCurrentInputMethod().id()); 841 manager_->GetCurrentInputMethod().id());
842 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); 842 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_);
843 manager_->SwitchToNextInputMethod(); 843 manager_->SwitchToNextInputMethod();
844 EXPECT_TRUE(observer.last_show_message_); 844 EXPECT_TRUE(observer.last_show_message_);
845 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), 845 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"),
846 manager_->GetCurrentInputMethod().id()); 846 manager_->GetCurrentInputMethod().id());
847 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 847 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
848 manager_->SwitchToNextInputMethod(); 848 manager_->SwitchToNextInputMethod();
849 EXPECT_TRUE(observer.last_show_message_); 849 EXPECT_TRUE(observer.last_show_message_);
850 EXPECT_EQ(XkbId("xkb:us:colemak:eng"), 850 EXPECT_EQ(XkbId("xkb:us:colemak:eng"),
851 manager_->GetCurrentInputMethod().id()); 851 manager_->GetCurrentInputMethod().id());
852 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); 852 EXPECT_EQ("us(colemak)", keyboard_->last_layout_);
853 manager_->SwitchToNextInputMethod(); 853 manager_->SwitchToNextInputMethod();
854 EXPECT_TRUE(observer.last_show_message_); 854 EXPECT_TRUE(observer.last_show_message_);
855 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 855 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
856 EXPECT_EQ("us", xkeyboard_->last_layout_); 856 EXPECT_EQ("us", keyboard_->last_layout_);
857 857
858 manager_->RemoveObserver(&observer); 858 manager_->RemoveObserver(&observer);
859 } 859 }
860 860
861 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { 861 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) {
862 TestObserver observer; 862 TestObserver observer;
863 manager_->AddObserver(&observer); 863 manager_->AddObserver(&observer);
864 InitComponentExtension(); 864 InitComponentExtension();
865 865
866 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 866 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
867 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); 867 keydown_accelerator.set_type(ui::ET_KEY_PRESSED);
868 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 868 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
869 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); 869 keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
870 870
871 std::vector<std::string> keyboard_layouts; 871 std::vector<std::string> keyboard_layouts;
872 keyboard_layouts.push_back(XkbId("xkb:us::eng")); 872 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
873 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 873 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
874 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 874 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
875 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 875 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
876 EXPECT_EQ("us", xkeyboard_->last_layout_); 876 EXPECT_EQ("us", keyboard_->last_layout_);
877 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); 877 EXPECT_TRUE(manager_->SwitchToNextInputMethod());
878 EXPECT_TRUE(observer.last_show_message_); 878 EXPECT_TRUE(observer.last_show_message_);
879 EXPECT_EQ(XkbId("xkb:us:intl:eng"), 879 EXPECT_EQ(XkbId("xkb:us:intl:eng"),
880 manager_->GetCurrentInputMethod().id()); 880 manager_->GetCurrentInputMethod().id());
881 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 881 EXPECT_EQ("us(intl)", keyboard_->last_layout_);
882 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 882 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
883 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 883 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
884 EXPECT_TRUE(observer.last_show_message_); 884 EXPECT_TRUE(observer.last_show_message_);
885 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 885 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
886 EXPECT_EQ("us", xkeyboard_->last_layout_); 886 EXPECT_EQ("us", keyboard_->last_layout_);
887 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 887 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
888 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 888 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
889 EXPECT_TRUE(observer.last_show_message_); 889 EXPECT_TRUE(observer.last_show_message_);
890 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); 890 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id());
891 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 891 EXPECT_EQ("us(intl)", keyboard_->last_layout_);
892 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 892 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
893 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 893 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
894 EXPECT_TRUE(observer.last_show_message_); 894 EXPECT_TRUE(observer.last_show_message_);
895 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 895 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
896 EXPECT_EQ("us", xkeyboard_->last_layout_); 896 EXPECT_EQ("us", keyboard_->last_layout_);
897 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); 897 EXPECT_TRUE(manager_->SwitchToNextInputMethod());
898 EXPECT_TRUE(observer.last_show_message_); 898 EXPECT_TRUE(observer.last_show_message_);
899 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); 899 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id());
900 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 900 EXPECT_EQ("us(intl)", keyboard_->last_layout_);
901 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); 901 EXPECT_TRUE(manager_->SwitchToNextInputMethod());
902 EXPECT_TRUE(observer.last_show_message_); 902 EXPECT_TRUE(observer.last_show_message_);
903 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), 903 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"),
904 manager_->GetCurrentInputMethod().id()); 904 manager_->GetCurrentInputMethod().id());
905 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); 905 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_);
906 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 906 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
907 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 907 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
908 EXPECT_TRUE(observer.last_show_message_); 908 EXPECT_TRUE(observer.last_show_message_);
909 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); 909 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id());
910 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); 910 EXPECT_EQ("us(intl)", keyboard_->last_layout_);
911 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 911 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
912 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 912 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
913 EXPECT_TRUE(observer.last_show_message_); 913 EXPECT_TRUE(observer.last_show_message_);
914 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), 914 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"),
915 manager_->GetCurrentInputMethod().id()); 915 manager_->GetCurrentInputMethod().id());
916 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); 916 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_);
917 917
918 manager_->RemoveObserver(&observer); 918 manager_->RemoveObserver(&observer);
919 } 919 }
920 920
921 TEST_F(InputMethodManagerImplTest, 921 TEST_F(InputMethodManagerImplTest,
922 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { 922 TestSwitchToPreviousInputMethodForOneActiveInputMethod) {
923 TestObserver observer; 923 TestObserver observer;
924 manager_->AddObserver(&observer); 924 manager_->AddObserver(&observer);
925 InitComponentExtension(); 925 InitComponentExtension();
926 926
(...skipping 18 matching lines...) Expand all
945 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { 945 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) {
946 std::string expect_id = XkbId("xkb:us::eng"); 946 std::string expect_id = XkbId("xkb:us::eng");
947 TestObserver observer; 947 TestObserver observer;
948 manager_->AddObserver(&observer); 948 manager_->AddObserver(&observer);
949 InitComponentExtension(); 949 InitComponentExtension();
950 std::vector<std::string> keyboard_layouts; 950 std::vector<std::string> keyboard_layouts;
951 keyboard_layouts.push_back(XkbId("xkb:us::eng")); 951 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
952 manager_->EnableLoginLayouts("en-US", keyboard_layouts); 952 manager_->EnableLoginLayouts("en-US", keyboard_layouts);
953 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); 953 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
954 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 954 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
955 EXPECT_EQ("us", xkeyboard_->last_layout_); 955 EXPECT_EQ("us", keyboard_->last_layout_);
956 956
957 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs 957 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs
958 // and keyboards are enabled. 958 // and keyboards are enabled.
959 EXPECT_FALSE(manager_->SwitchInputMethod( 959 EXPECT_FALSE(manager_->SwitchInputMethod(
960 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 960 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
961 EXPECT_FALSE(observer.last_show_message_); 961 EXPECT_FALSE(observer.last_show_message_);
962 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 962 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
963 EXPECT_EQ("us", xkeyboard_->last_layout_); 963 EXPECT_EQ("us", keyboard_->last_layout_);
964 EXPECT_FALSE(manager_->SwitchInputMethod( 964 EXPECT_FALSE(manager_->SwitchInputMethod(
965 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 965 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
966 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 966 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
967 EXPECT_EQ("us", xkeyboard_->last_layout_); 967 EXPECT_EQ("us", keyboard_->last_layout_);
968 EXPECT_FALSE(manager_->SwitchInputMethod( 968 EXPECT_FALSE(manager_->SwitchInputMethod(
969 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 969 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
970 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 970 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
971 EXPECT_EQ("us", xkeyboard_->last_layout_); 971 EXPECT_EQ("us", keyboard_->last_layout_);
972 EXPECT_FALSE(manager_->SwitchInputMethod( 972 EXPECT_FALSE(manager_->SwitchInputMethod(
973 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 973 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
974 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); 974 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id());
975 EXPECT_EQ("us", xkeyboard_->last_layout_); 975 EXPECT_EQ("us", keyboard_->last_layout_);
976 976
977 manager_->RemoveObserver(&observer); 977 manager_->RemoveObserver(&observer);
978 } 978 }
979 979
980 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { 980 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) {
981 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. 981 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku.
982 InitComponentExtension(); 982 InitComponentExtension();
983 983
984 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 984 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
985 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); 985 keydown_accelerator.set_type(ui::ET_KEY_PRESSED);
986 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 986 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
987 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); 987 keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
988 988
989 std::vector<std::string> keyboard_layouts; 989 std::vector<std::string> keyboard_layouts;
990 keyboard_layouts.push_back(XkbId("xkb:us::eng")); 990 keyboard_layouts.push_back(XkbId("xkb:us::eng"));
991 manager_->EnableLoginLayouts("ja", keyboard_layouts); 991 manager_->EnableLoginLayouts("ja", keyboard_layouts);
992 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 992 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
993 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 993 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
994 EXPECT_EQ("us", xkeyboard_->last_layout_); 994 EXPECT_EQ("us", keyboard_->last_layout_);
995 EXPECT_TRUE(manager_->SwitchInputMethod( 995 EXPECT_TRUE(manager_->SwitchInputMethod(
996 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 996 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
997 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 997 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
998 EXPECT_EQ("jp", xkeyboard_->last_layout_); 998 EXPECT_EQ("jp", keyboard_->last_layout_);
999 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 999 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
1000 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 1000 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
1001 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 1001 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
1002 EXPECT_EQ("us", xkeyboard_->last_layout_); 1002 EXPECT_EQ("us", keyboard_->last_layout_);
1003 EXPECT_TRUE(manager_->SwitchInputMethod( 1003 EXPECT_TRUE(manager_->SwitchInputMethod(
1004 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 1004 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
1005 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1005 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1006 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1006 EXPECT_EQ("jp", keyboard_->last_layout_);
1007 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); 1007 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
1008 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); 1008 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
1009 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); 1009 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id());
1010 EXPECT_EQ("us", xkeyboard_->last_layout_); 1010 EXPECT_EQ("us", keyboard_->last_layout_);
1011 EXPECT_TRUE(manager_->SwitchInputMethod( 1011 EXPECT_TRUE(manager_->SwitchInputMethod(
1012 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1012 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
1013 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1013 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1014 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1014 EXPECT_EQ("jp", keyboard_->last_layout_);
1015 } 1015 }
1016 1016
1017 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { 1017 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) {
1018 InitComponentExtension(); 1018 InitComponentExtension();
1019 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1019 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1020 std::vector<std::string> ids; 1020 std::vector<std::string> ids;
1021 ids.push_back(XkbId("xkb:jp::jpn")); 1021 ids.push_back(XkbId("xkb:jp::jpn"));
1022 ids.push_back(kNaclMozcJpId); 1022 ids.push_back(kNaclMozcJpId);
1023 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1023 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1024 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1024 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1025 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1025 EXPECT_EQ("jp", keyboard_->last_layout_);
1026 EXPECT_TRUE(manager_->SwitchInputMethod( 1026 EXPECT_TRUE(manager_->SwitchInputMethod(
1027 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1027 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
1028 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1028 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1029 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1029 EXPECT_EQ("jp", keyboard_->last_layout_);
1030 EXPECT_TRUE(manager_->SwitchInputMethod( 1030 EXPECT_TRUE(manager_->SwitchInputMethod(
1031 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); 1031 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
1032 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1032 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1033 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1033 EXPECT_EQ("jp", keyboard_->last_layout_);
1034 EXPECT_TRUE(manager_->SwitchInputMethod( 1034 EXPECT_TRUE(manager_->SwitchInputMethod(
1035 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 1035 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
1036 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1036 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1037 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1037 EXPECT_EQ("jp", keyboard_->last_layout_);
1038 EXPECT_TRUE(manager_->SwitchInputMethod( 1038 EXPECT_TRUE(manager_->SwitchInputMethod(
1039 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); 1039 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
1040 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1040 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1041 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1041 EXPECT_EQ("jp", keyboard_->last_layout_);
1042 EXPECT_TRUE(manager_->SwitchInputMethod( 1042 EXPECT_TRUE(manager_->SwitchInputMethod(
1043 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 1043 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
1044 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1044 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1045 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1045 EXPECT_EQ("jp", keyboard_->last_layout_);
1046 EXPECT_TRUE(manager_->SwitchInputMethod( 1046 EXPECT_TRUE(manager_->SwitchInputMethod(
1047 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); 1047 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
1048 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1048 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1049 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1049 EXPECT_EQ("jp", keyboard_->last_layout_);
1050 1050
1051 // Add Dvorak. 1051 // Add Dvorak.
1052 ids.push_back(XkbId("xkb:us:dvorak:eng")); 1052 ids.push_back(XkbId("xkb:us:dvorak:eng"));
1053 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1053 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1054 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1054 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1055 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1055 EXPECT_EQ("jp", keyboard_->last_layout_);
1056 EXPECT_TRUE(manager_->SwitchInputMethod( 1056 EXPECT_TRUE(manager_->SwitchInputMethod(
1057 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 1057 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
1058 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); 1058 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
1059 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1059 EXPECT_EQ("jp", keyboard_->last_layout_);
1060 EXPECT_TRUE(manager_->SwitchInputMethod( 1060 EXPECT_TRUE(manager_->SwitchInputMethod(
1061 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); 1061 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
1062 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); 1062 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id());
1063 EXPECT_EQ("jp", xkeyboard_->last_layout_); 1063 EXPECT_EQ("jp", keyboard_->last_layout_);
1064 } 1064 }
1065 1065
1066 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { 1066 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
1067 TestObserver observer; 1067 TestObserver observer;
1068 manager_->AddObserver(&observer); 1068 manager_->AddObserver(&observer);
1069 InitComponentExtension(); 1069 InitComponentExtension();
1070 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1070 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1071 std::vector<std::string> ids; 1071 std::vector<std::string> ids;
1072 ids.push_back(XkbId("xkb:us:dvorak:eng")); 1072 ids.push_back(XkbId("xkb:us:dvorak:eng"));
1073 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1073 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1074 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1074 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1075 EXPECT_EQ(1, observer.input_method_changed_count_); 1075 EXPECT_EQ(1, observer.input_method_changed_count_);
1076 EXPECT_EQ(XkbId(ids[0]), 1076 EXPECT_EQ(XkbId(ids[0]),
1077 manager_->GetCurrentInputMethod().id()); 1077 manager_->GetCurrentInputMethod().id());
1078 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 1078 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
1079 1079
1080 // Add two Extension IMEs. 1080 // Add two Extension IMEs.
1081 std::vector<std::string> layouts; 1081 std::vector<std::string> layouts;
1082 layouts.push_back("us"); 1082 layouts.push_back("us");
1083 std::vector<std::string> languages; 1083 std::vector<std::string> languages;
1084 languages.push_back("en-US"); 1084 languages.push_back("en-US");
1085 1085
1086 const std::string ext1_id = 1086 const std::string ext1_id =
1087 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); 1087 extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
1088 const InputMethodDescriptor descriptor1(ext1_id, 1088 const InputMethodDescriptor descriptor1(ext1_id,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 TestObserver observer; 1149 TestObserver observer;
1150 InitComponentExtension(); 1150 InitComponentExtension();
1151 manager_->AddObserver(&observer); 1151 manager_->AddObserver(&observer);
1152 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1152 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1153 std::vector<std::string> ids; 1153 std::vector<std::string> ids;
1154 ids.push_back(XkbId("xkb:us::eng")); 1154 ids.push_back(XkbId("xkb:us::eng"));
1155 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); 1155 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids));
1156 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); 1156 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
1157 EXPECT_EQ(1, observer.input_method_changed_count_); 1157 EXPECT_EQ(1, observer.input_method_changed_count_);
1158 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); 1158 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id());
1159 EXPECT_EQ("us", xkeyboard_->last_layout_); 1159 EXPECT_EQ("us", keyboard_->last_layout_);
1160 1160
1161 // Add an Extension IME. 1161 // Add an Extension IME.
1162 std::vector<std::string> layouts; 1162 std::vector<std::string> layouts;
1163 layouts.push_back("us(dvorak)"); 1163 layouts.push_back("us(dvorak)");
1164 std::vector<std::string> languages; 1164 std::vector<std::string> languages;
1165 languages.push_back("en-US"); 1165 languages.push_back("en-US");
1166 1166
1167 const std::string ext_id = 1167 const std::string ext_id =
1168 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); 1168 extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
1169 const InputMethodDescriptor descriptor(ext_id, 1169 const InputMethodDescriptor descriptor(ext_id,
(...skipping 13 matching lines...) Expand all
1183 1183
1184 std::vector<std::string> extension_ime_ids; 1184 std::vector<std::string> extension_ime_ids;
1185 extension_ime_ids.push_back(ext_id); 1185 extension_ime_ids.push_back(ext_id);
1186 manager_->SetEnabledExtensionImes(&extension_ime_ids); 1186 manager_->SetEnabledExtensionImes(&extension_ime_ids);
1187 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1187 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1188 1188
1189 // Switch to the IME. 1189 // Switch to the IME.
1190 manager_->SwitchToNextInputMethod(); 1190 manager_->SwitchToNextInputMethod();
1191 EXPECT_EQ(3, observer.input_method_changed_count_); 1191 EXPECT_EQ(3, observer.input_method_changed_count_);
1192 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); 1192 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
1193 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 1193 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
1194 1194
1195 // Lock the screen. This is for crosbug.com/27049. 1195 // Lock the screen. This is for crosbug.com/27049.
1196 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); 1196 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
1197 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME 1197 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME
1198 EXPECT_EQ(XkbId("xkb:us::eng"), 1198 EXPECT_EQ(XkbId("xkb:us::eng"),
1199 manager_->GetCurrentInputMethod().id()); 1199 manager_->GetCurrentInputMethod().id());
1200 EXPECT_EQ("us", xkeyboard_->last_layout_); 1200 EXPECT_EQ("us", keyboard_->last_layout_);
1201 1201
1202 // Unlock the screen. 1202 // Unlock the screen.
1203 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); 1203 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
1204 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); 1204 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
1205 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); 1205 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
1206 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); 1206 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_);
1207 { 1207 {
1208 // This is for crosbug.com/27052. 1208 // This is for crosbug.com/27052.
1209 scoped_ptr<InputMethodDescriptors> methods( 1209 scoped_ptr<InputMethodDescriptors> methods(
1210 manager_->GetActiveInputMethods()); 1210 manager_->GetActiveInputMethods());
1211 ASSERT_EQ(2U, methods->size()); 1211 ASSERT_EQ(2U, methods->size());
1212 // Ext. IMEs should be at the end of the list. 1212 // Ext. IMEs should be at the end of the list.
1213 EXPECT_EQ(ext_id, methods->at(1).id()); 1213 EXPECT_EQ(ext_id, methods->at(1).id());
1214 } 1214 }
1215 manager_->RemoveObserver(&observer); 1215 manager_->RemoveObserver(&observer);
1216 } 1216 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1360
1361 ASSERT_EQ(3U, input_method_ids.size()); 1361 ASSERT_EQ(3U, input_method_ids.size());
1362 1362
1363 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); 1363 EXPECT_EQ("xkb:us::eng", input_method_ids[0]);
1364 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); 1364 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]);
1365 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); 1365 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]);
1366 } 1366 }
1367 1367
1368 } // namespace input_method 1368 } // namespace input_method
1369 } // namespace chromeos 1369 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698