| Index: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
|
| diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
|
| index 3fe0b0f645d6e3ae29a40b9c76cf9362414be995..1a4167193bc18d67bc2dd59b39d42aee08220693 100644
|
| --- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
|
| +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
|
| @@ -56,17 +56,20 @@ class InputMethodManagerImplTest : public testing::Test {
|
| candidate_window_controller_(NULL),
|
| xkeyboard_(NULL) {
|
| }
|
| - virtual ~InputMethodManagerImplTest() {}
|
| + virtual ~InputMethodManagerImplTest() {
|
| + InputMethodManager::Shutdown();
|
| + }
|
|
|
| virtual void SetUp() OVERRIDE {
|
| delegate_ = new FakeInputMethodDelegate();
|
| - manager_.reset(new InputMethodManagerImpl(
|
| - scoped_ptr<InputMethodDelegate>(delegate_)));
|
| + InputMethodManager::Shutdown();
|
| + InputMethodManager::Initialize(
|
| + new InputMethodManagerImpl(scoped_ptr<InputMethodDelegate>(delegate_)));
|
| candidate_window_controller_ = new MockCandidateWindowController;
|
| - manager_->SetCandidateWindowControllerForTesting(
|
| + manager()->SetCandidateWindowControllerForTesting(
|
| candidate_window_controller_);
|
| xkeyboard_ = new MockXKeyboard;
|
| - manager_->SetXKeyboardForTesting(xkeyboard_);
|
| + manager()->SetXKeyboardForTesting(xkeyboard_);
|
| mock_engine_handler_.reset(new MockIMEEngineHandler());
|
| IBusBridge::Initialize();
|
| IBusBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get());
|
| @@ -120,7 +123,7 @@ class InputMethodManagerImplTest : public testing::Test {
|
| delegate_ = NULL;
|
| candidate_window_controller_ = NULL;
|
| xkeyboard_ = NULL;
|
| - manager_.reset();
|
| + InputMethodManager::Shutdown();
|
| IBusBridge::Get()->SetCurrentEngineHandler(NULL);
|
| IBusBridge::Shutdown();
|
| }
|
| @@ -142,10 +145,13 @@ class InputMethodManagerImplTest : public testing::Test {
|
| mock_engine_handler_.get());
|
| IBusBridge::Get()->SetEngineHandler(kExt2Engine2Id,
|
| mock_engine_handler_.get());
|
| - manager_->InitializeComponentExtensionForTesting(delegate.Pass());
|
| + manager()->InitializeComponentExtensionForTesting(delegate.Pass());
|
| + }
|
| +
|
| + InputMethodManagerImpl* manager() const {
|
| + return static_cast<InputMethodManagerImpl*>(InputMethodManager::Get());
|
| }
|
|
|
| - scoped_ptr<InputMethodManagerImpl> manager_;
|
| FakeInputMethodDelegate* delegate_;
|
| MockCandidateWindowController* candidate_window_controller_;
|
| scoped_ptr<MockIMEEngineHandler> mock_engine_handler_;
|
| @@ -210,15 +216,15 @@ class TestCandidateWindowObserver
|
| } // namespace
|
|
|
| TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) {
|
| - EXPECT_TRUE(manager_->GetXKeyboard());
|
| - EXPECT_EQ(xkeyboard_, manager_->GetXKeyboard());
|
| + EXPECT_TRUE(manager()->GetXKeyboard());
|
| + EXPECT_EQ(xkeyboard_, manager()->GetXKeyboard());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) {
|
| TestCandidateWindowObserver observer;
|
| candidate_window_controller_->NotifyCandidateWindowOpened(); // nop
|
| candidate_window_controller_->NotifyCandidateWindowClosed(); // nop
|
| - manager_->AddCandidateWindowObserver(&observer);
|
| + manager()->AddCandidateWindowObserver(&observer);
|
| candidate_window_controller_->NotifyCandidateWindowOpened();
|
| EXPECT_EQ(1, observer.candidate_window_opened_count_);
|
| candidate_window_controller_->NotifyCandidateWindowClosed();
|
| @@ -227,7 +233,7 @@ TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) {
|
| EXPECT_EQ(2, observer.candidate_window_opened_count_);
|
| candidate_window_controller_->NotifyCandidateWindowClosed();
|
| EXPECT_EQ(2, observer.candidate_window_closed_count_);
|
| - manager_->RemoveCandidateWindowObserver(&observer);
|
| + manager()->RemoveCandidateWindowObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestObserver) {
|
| @@ -235,16 +241,16 @@ TEST_F(InputMethodManagerImplTest, TestObserver) {
|
| // also for the scenario.
|
| TestObserver observer;
|
| InitComponentExtension();
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| EXPECT_EQ(0, observer.input_method_changed_count_);
|
| - manager_->EnableLayouts("en-US", "xkb:us::eng");
|
| + manager()->EnableLayouts("en-US", "xkb:us::eng", true);
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| EXPECT_EQ(1, observer.input_method_property_changed_count_);
|
| - manager_->ChangeInputMethod("xkb:us:dvorak:eng");
|
| + manager()->ChangeInputMethod("xkb:us:dvorak:eng");
|
| EXPECT_FALSE(observer.last_show_message_);
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| EXPECT_EQ(2, observer.input_method_property_changed_count_);
|
| - manager_->ChangeInputMethod("xkb:us:dvorak:eng");
|
| + manager()->ChangeInputMethod("xkb:us:dvorak:eng");
|
| EXPECT_FALSE(observer.last_show_message_);
|
|
|
| // The observer is always notified even when the same input method ID is
|
| @@ -256,26 +262,26 @@ TEST_F(InputMethodManagerImplTest, TestObserver) {
|
| // notified.
|
| EXPECT_EQ(2, observer.input_method_property_changed_count_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
|
| InitComponentExtension();
|
| scoped_ptr<InputMethodDescriptors> methods(
|
| - manager_->GetSupportedInputMethods());
|
| + manager()->GetSupportedInputMethods());
|
| ASSERT_TRUE(methods.get());
|
| // Try to find random 4-5 layuts and IMEs to make sure the returned list is
|
| // correct.
|
| const InputMethodDescriptor* id_to_find =
|
| - manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| kNaclMozcUsId);
|
| - id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| "xkb:us::eng");
|
| EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
|
| - id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| "xkb:us:dvorak:eng");
|
| EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
|
| - id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| "xkb:fr::fra");
|
| EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
|
| }
|
| @@ -284,48 +290,68 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
|
| // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See
|
| // ibus_input_method.txt.
|
| InitComponentExtension();
|
| - manager_->EnableLayouts("en-US", "");
|
| - EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
|
| - for (size_t i = 0; i < manager_->GetActiveInputMethodIds().size(); ++i)
|
| - LOG(ERROR) << manager_->GetActiveInputMethodIds().at(i);
|
| + manager()->EnableLayouts("en-US", "", true);
|
| + EXPECT_EQ(5U, manager()->GetNumActiveInputMethods());
|
| + for (size_t i = 0; i < manager()->GetActiveInputMethodIds().size(); ++i)
|
| + LOG(ERROR) << manager()->GetActiveInputMethodIds().at(i);
|
|
|
| // For http://crbug.com/19655#c11 - (5)
|
| // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U.
|
| - manager_->EnableLayouts("ja", ""); // Japanese
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->EnableLayouts("ja", "", true); // Japanese
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) {
|
| // For http://crbug.com/329061
|
| - manager_->EnableLayouts("en-US", "xkb:se::swe");
|
| - const std::string im_id = manager_->GetCurrentInputMethod().id();
|
| + manager()->EnableLayouts("en-US", "xkb:se::swe", true);
|
| + const std::string im_id = manager()->GetCurrentInputMethod().id();
|
| EXPECT_EQ("xkb:se::swe", im_id);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) {
|
| // The physical layout is French.
|
| delegate_->set_hardware_keyboard_layout("xkb:fr::fra");
|
| - manager_->EnableLayouts("en-US", "");
|
| - EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French
|
| + manager()->EnableLayouts("en-US", "", true);
|
| + EXPECT_EQ(6U, manager()->GetNumActiveInputMethods()); // 5 + French
|
| // The physical layout is Japanese.
|
| delegate_->set_hardware_keyboard_layout("xkb:jp::jpn");
|
| - manager_->EnableLayouts("ja", "");
|
| + manager()->EnableLayouts("ja", "", true);
|
| // "xkb:us::eng" is not needed, hence 1.
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| +
|
| + // The physical layout is Russian.
|
| + delegate_->set_hardware_keyboard_layout("xkb:ru::rus");
|
| + manager()->EnableLayouts("ru", "", true);
|
| + // "xkb:us::eng" only.
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().front() == "xkb:us::eng");
|
| + manager()->EnableLayouts("ru", "", false);
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(0) == "xkb:ru::rus");
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(1) ==
|
| + "xkb:ru:phonetic:rus");
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(2) == "xkb:us::eng");
|
| + // "xkb:us::eng" is Hardware Login Layout for Russian locale
|
| + manager()->EnableLayouts("ru", "xkb:us::eng", false);
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(0) == "xkb:us::eng");
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(1) == "xkb:ru::rus");
|
| + EXPECT_TRUE(manager()->GetActiveInputMethodIds().at(2) ==
|
| + "xkb:ru:phonetic:rus");
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
|
| - manager_->EnableLayouts("ja", ""); // Japanese
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->EnableLayouts("ja", "", true); // Japanese
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| scoped_ptr<InputMethodDescriptors> methods(
|
| - manager_->GetActiveInputMethods());
|
| + manager()->GetActiveInputMethods());
|
| ASSERT_TRUE(methods.get());
|
| EXPECT_EQ(2U, methods->size());
|
| const InputMethodDescriptor* id_to_find =
|
| - manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| "xkb:us::eng");
|
| EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
|
| - id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| + id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
|
| "xkb:jp::jpn");
|
| EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
|
| }
|
| @@ -333,255 +359,254 @@ TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
|
| TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) {
|
| // For http://crbug.com/19655#c11 - (8), step 6.
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back("xkb:us:colemak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| // Since all the IDs added avobe are keyboard layouts, Start() should not be
|
| // called.
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| // Disable Dvorak.
|
| ids.erase(ids.begin());
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| EXPECT_EQ(ids[0], // colemak
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) {
|
| // For http://crbug.com/19655#c11 - (9).
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us::eng");
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back("xkb:us:colemak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| // Switch to Dvorak.
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| // Disable Dvorak.
|
| ids.erase(ids.begin() + 1);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(3, observer.input_method_changed_count_);
|
| EXPECT_EQ(ids[0], // US Qwerty
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) {
|
| // For http://crbug.com/19655#c11 - (10).
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back(kNaclMozcUsId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| // Switch to Mozc
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| // Disable Mozc.
|
| ids.erase(ids.begin() + 1);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) {
|
| // For http://crbug.com/19655#c11 - (11).
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back(kNaclMozcUsId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Disable Dvorak.
|
| ids.erase(ids.begin());
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(ids[0], // Mozc
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableImes) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back(kExt2Engine1Id);
|
| ids.push_back("mozc-dv");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->AddObserver(&observer);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported.
|
| ids.push_back("unknown-super-cool-ime");
|
| - EXPECT_FALSE(manager_->EnableInputMethods(ids));
|
| + EXPECT_FALSE(manager()->EnableInputMethods(ids));
|
|
|
| // TODO(yusukes): Should we fall back to the hardware keyboard layout in this
|
| // case?
|
| EXPECT_EQ(0, observer.input_method_changed_count_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) {
|
| // For http://crbug.com/19655#c11 - (14).
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us::eng");
|
| ids.push_back("xkb:us:dvorak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Switch to Dvorak.
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Lock screen
|
| - manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(ids[1], // still Dvorak
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| // Switch back to Qwerty.
|
| - manager_->SwitchToNextInputMethod();
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + manager()->SwitchToNextInputMethod();
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Unlock screen. The original state, Dvorak, is restored.
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) {
|
| // For http://crbug.com/19655#c11 - (15).
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back(kExt2Engine2Id);
|
| ids.push_back(kExt2Engine1Id);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Switch to Mozc.
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(2, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Lock screen
|
| - manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak.
|
| - EXPECT_EQ("xkb:us:dvorak:eng",
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); // Qwerty+Dvorak.
|
| + EXPECT_EQ("xkb:us:dvorak:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout.
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Unlock screen. The original state, pinyin-dv, is restored.
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| - EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs.
|
| - EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id());
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); // Dvorak and 2 IMEs.
|
| + EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
|
| // For http://crbug.com/19655#c11 - (8), step 7-11.
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| ids.push_back("xkb:us:colemak:eng");
|
| ids.push_back(kNaclMozcJpId);
|
| ids.push_back(kNaclMozcUsId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(4U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(4U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| // See input_methods.txt for an expected XKB layout name.
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| // Disable Dvorak.
|
| ids.erase(ids.begin());
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_);
|
| EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
|
| }
|
| @@ -590,68 +615,68 @@ TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) {
|
| const std::string kKey = "key";
|
| InputMethodPropertyList property_list;
|
| property_list.push_back(InputMethodProperty(kKey, "label", false, false));
|
| - manager_->SetCurrentInputMethodProperties(property_list);
|
| + manager()->SetCurrentInputMethodProperties(property_list);
|
|
|
| - manager_->ActivateInputMethodProperty(kKey);
|
| + manager()->ActivateInputMethodProperty(kKey);
|
| EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
|
|
|
| // Key2 is not registered, so activated property should not be changed.
|
| - manager_->ActivateInputMethodProperty("key2");
|
| + manager()->ActivateInputMethodProperty("key2");
|
| EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
|
| InitComponentExtension();
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
|
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us::eng");
|
| ids.push_back(kNaclMozcUsId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| - manager_->ChangeInputMethod(kNaclMozcUsId);
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
| + manager()->ChangeInputMethod(kNaclMozcUsId);
|
|
|
| InputMethodPropertyList current_property_list;
|
| current_property_list.push_back(InputMethodProperty("key",
|
| "label",
|
| false,
|
| false));
|
| - manager_->SetCurrentInputMethodProperties(current_property_list);
|
| + manager()->SetCurrentInputMethodProperties(current_property_list);
|
|
|
| - ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
|
| - EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key);
|
| + ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size());
|
| + EXPECT_EQ("key", manager()->GetCurrentInputMethodProperties().at(0).key);
|
|
|
| - manager_->ChangeInputMethod("xkb:us::eng");
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| + manager()->ChangeInputMethod("xkb:us::eng");
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
|
| InitComponentExtension();
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
|
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back(kNaclMozcUsId); // Japanese
|
| ids.push_back(kExt2Engine1Id); // T-Chinese
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
|
|
| InputMethodPropertyList current_property_list;
|
| current_property_list.push_back(InputMethodProperty("key-mozc",
|
| "label",
|
| false,
|
| false));
|
| - manager_->SetCurrentInputMethodProperties(current_property_list);
|
| + manager()->SetCurrentInputMethodProperties(current_property_list);
|
|
|
| - ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
|
| - EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key);
|
| + ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size());
|
| + EXPECT_EQ("key-mozc", manager()->GetCurrentInputMethodProperties().at(0).key);
|
|
|
| - manager_->ChangeInputMethod(kExt2Engine1Id);
|
| + manager()->ChangeInputMethod(kExt2Engine1Id);
|
| // Since the IME is changed, the property for mozc Japanese should be hidden.
|
| - EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
|
| + EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty());
|
|
|
| // Asynchronous property update signal from mozc-chewing.
|
| current_property_list.clear();
|
| @@ -659,48 +684,48 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
|
| "label",
|
| false,
|
| false));
|
| - manager_->SetCurrentInputMethodProperties(current_property_list);
|
| - ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
|
| + manager()->SetCurrentInputMethodProperties(current_property_list);
|
| + ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size());
|
| EXPECT_EQ("key-chewing",
|
| - manager_->GetCurrentInputMethodProperties().at(0).key);
|
| + manager()->GetCurrentInputMethodProperties().at(0).key);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestNextInputMethod) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| // For http://crbug.com/19655#c11 - (1)
|
| - manager_->EnableLayouts("en-US", "xkb:us::eng");
|
| - EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + manager()->EnableLayouts("en-US", "xkb:us::eng", true);
|
| + EXPECT_EQ(5U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:dvorak:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:dvorak:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:colemak:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:colemak:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
|
|
| ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
|
| @@ -708,55 +733,55 @@ TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) {
|
| ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
|
| keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
|
|
|
| - manager_->EnableLayouts("en-US", "xkb:us::eng");
|
| - EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + manager()->EnableLayouts("en-US", "xkb:us::eng", true);
|
| + EXPECT_EQ(5U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToNextInputMethod());
|
| + EXPECT_TRUE(manager()->SwitchToNextInputMethod());
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToNextInputMethod());
|
| + EXPECT_TRUE(manager()->SwitchToNextInputMethod());
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToNextInputMethod());
|
| + EXPECT_TRUE(manager()->SwitchToNextInputMethod());
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(intl)", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| EXPECT_TRUE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| TestSwitchToPreviousInputMethodForOneActiveInputMethod) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
|
|
| ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
|
| @@ -766,47 +791,47 @@ TEST_F(InputMethodManagerImplTest,
|
|
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
|
|
| // Ctrl+Space accelerator should not be consumed if there is only one active
|
| // input method.
|
| - EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_FALSE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_FALSE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->EnableLayouts("en-US", "xkb:us::eng");
|
| - EXPECT_EQ(5U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + manager()->EnableLayouts("en-US", "xkb:us::eng", true);
|
| + EXPECT_EQ(5U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs
|
| // and keyboards are enabled.
|
| - EXPECT_FALSE(manager_->SwitchInputMethod(
|
| + EXPECT_FALSE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
|
| EXPECT_FALSE(observer.last_show_message_);
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_FALSE(manager_->SwitchInputMethod(
|
| + EXPECT_FALSE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_FALSE(manager_->SwitchInputMethod(
|
| + EXPECT_FALSE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_FALSE(manager_->SwitchInputMethod(
|
| + EXPECT_FALSE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) {
|
| @@ -818,93 +843,92 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) {
|
| ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
|
| keyup_accelerator.set_type(ui::ET_KEY_RELEASED);
|
|
|
| - manager_->EnableLayouts("ja", "xkb:us::eng");
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + manager()->EnableLayouts("ja", "xkb:us::eng", true);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator));
|
| - EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator));
|
| - EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator));
|
| + EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator));
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) {
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:jp::jpn");
|
| ids.push_back(kNaclMozcJpId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
|
|
| // Add Dvorak.
|
| ids.push_back("xkb:us:dvorak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| - EXPECT_TRUE(manager_->SwitchInputMethod(
|
| + EXPECT_TRUE(manager()->SwitchInputMethod(
|
| ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE)));
|
| - EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("jp", xkeyboard_->last_layout_);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
|
| TestObserver observer;
|
| - manager_->AddObserver(&observer);
|
| + manager()->AddObserver(&observer);
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us:dvorak:eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0],
|
| - manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Add two Extension IMEs.
|
| @@ -923,19 +947,19 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
|
| GURL(),
|
| GURL());
|
| MockInputMethodEngine engine(descriptor1);
|
| - manager_->AddInputMethodExtension(ext1_id, &engine);
|
| + manager()->AddInputMethodExtension(ext1_id, &engine);
|
|
|
| // Extension IMEs are not enabled by default.
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
|
|
| std::vector<std::string> extension_ime_ids;
|
| extension_ime_ids.push_back(ext1_id);
|
| - manager_->SetEnabledExtensionImes(&extension_ime_ids);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->SetEnabledExtensionImes(&extension_ime_ids);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
|
|
| {
|
| scoped_ptr<InputMethodDescriptors> methods(
|
| - manager_->GetActiveInputMethods());
|
| + manager()->GetActiveInputMethods());
|
| ASSERT_EQ(2U, methods->size());
|
| // Ext IMEs should be at the end of the list.
|
| EXPECT_EQ(ext1_id, methods->at(1).id());
|
| @@ -951,15 +975,15 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
|
| GURL(),
|
| GURL());
|
| MockInputMethodEngine engine2(descriptor2);
|
| - manager_->AddInputMethodExtension(ext2_id, &engine2);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->AddInputMethodExtension(ext2_id, &engine2);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
|
|
| extension_ime_ids.push_back(ext2_id);
|
| - manager_->SetEnabledExtensionImes(&extension_ime_ids);
|
| - EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
|
| + manager()->SetEnabledExtensionImes(&extension_ime_ids);
|
| + EXPECT_EQ(3U, manager()->GetNumActiveInputMethods());
|
| {
|
| scoped_ptr<InputMethodDescriptors> methods(
|
| - manager_->GetActiveInputMethods());
|
| + manager()->GetActiveInputMethods());
|
| ASSERT_EQ(3U, methods->size());
|
| // Ext IMEs should be at the end of the list.
|
| EXPECT_EQ(ext1_id, methods->at(1).id());
|
| @@ -967,23 +991,23 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
|
| }
|
|
|
| // Remove them.
|
| - manager_->RemoveInputMethodExtension(ext1_id);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - manager_->RemoveInputMethodExtension(ext2_id);
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + manager()->RemoveInputMethodExtension(ext1_id);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + manager()->RemoveInputMethodExtension(ext2_id);
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
|
| TestObserver observer;
|
| InitComponentExtension();
|
| - manager_->AddObserver(&observer);
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->AddObserver(&observer);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back("xkb:us::eng");
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Add an Extension IME.
|
| @@ -1002,93 +1026,92 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
|
| GURL(),
|
| GURL());
|
| MockInputMethodEngine engine(descriptor);
|
| - manager_->AddInputMethodExtension(ext_id, &engine);
|
| + manager()->AddInputMethodExtension(ext_id, &engine);
|
|
|
| // Extension IME is not enabled by default.
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| EXPECT_EQ(1, observer.input_method_changed_count_);
|
|
|
| std::vector<std::string> extension_ime_ids;
|
| extension_ime_ids.push_back(ext_id);
|
| - manager_->SetEnabledExtensionImes(&extension_ime_ids);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| + manager()->SetEnabledExtensionImes(&extension_ime_ids);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
|
|
| // Switch to the IME.
|
| - manager_->SwitchToNextInputMethod();
|
| + manager()->SwitchToNextInputMethod();
|
| EXPECT_EQ(3, observer.input_method_changed_count_);
|
| - EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
|
|
| // Lock the screen. This is for crosbug.com/27049.
|
| - manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME
|
| - EXPECT_EQ("xkb:us::eng",
|
| - manager_->GetCurrentInputMethod().id());
|
| + manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN);
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); // Qwerty. No Ext. IME
|
| + EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us", xkeyboard_->last_layout_);
|
|
|
| // Unlock the screen.
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id());
|
| EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
|
| {
|
| // This is for crosbug.com/27052.
|
| scoped_ptr<InputMethodDescriptors> methods(
|
| - manager_->GetActiveInputMethods());
|
| + manager()->GetActiveInputMethods());
|
| ASSERT_EQ(2U, methods->size());
|
| // Ext. IMEs should be at the end of the list.
|
| EXPECT_EQ(ext_id, methods->at(1).id());
|
| }
|
| - manager_->RemoveObserver(&observer);
|
| + manager()->RemoveObserver(&observer);
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) {
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back(kNaclMozcUsId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| - manager_->ChangeInputMethod(kNaclMozcUsId);
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| + manager()->ChangeInputMethod(kNaclMozcUsId);
|
|
|
| InitComponentExtension();
|
| - EXPECT_EQ(kNaclMozcUsId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcUsId, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) {
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| std::vector<std::string> ids;
|
| ids.push_back(kNaclMozcUsId);
|
| ids.push_back(kNaclMozcJpId);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - manager_->ChangeInputMethod(kNaclMozcUsId);
|
| - manager_->ChangeInputMethod(kNaclMozcJpId);
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + manager()->ChangeInputMethod(kNaclMozcUsId);
|
| + manager()->ChangeInputMethod(kNaclMozcJpId);
|
|
|
| InitComponentExtension();
|
| - EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) {
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| const std::string ext_id = extension_ime_util::GetComponentInputMethodID(
|
| ime_list_[0].id,
|
| ime_list_[0].engines[0].engine_id);
|
| std::vector<std::string> ids;
|
| ids.push_back(ext_id);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| - manager_->ChangeInputMethod(ext_id);
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| + manager()->ChangeInputMethod(ext_id);
|
|
|
| InitComponentExtension();
|
| - EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) {
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID(
|
| ime_list_[0].id,
|
| ime_list_[0].engines[0].engine_id);
|
| @@ -1098,33 +1121,33 @@ TEST_F(InputMethodManagerImplTest,
|
| std::vector<std::string> ids;
|
| ids.push_back(ext_id1);
|
| ids.push_back(ext_id2);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - manager_->ChangeInputMethod(ext_id1);
|
| - manager_->ChangeInputMethod(ext_id2);
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + manager()->ChangeInputMethod(ext_id1);
|
| + manager()->ChangeInputMethod(ext_id2);
|
|
|
| InitComponentExtension();
|
| - EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_EQ(ext_id2, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethod_ComponenteExtensionOneIME) {
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| const std::string ext_id = extension_ime_util::GetComponentInputMethodID(
|
| ime_list_[0].id,
|
| ime_list_[0].engines[0].engine_id);
|
| std::vector<std::string> ids;
|
| ids.push_back(ext_id);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(1U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| TEST_F(InputMethodManagerImplTest,
|
| ChangeInputMethod_ComponenteExtensionTwoIME) {
|
| InitComponentExtension();
|
| - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| + manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
|
| const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID(
|
| ime_list_[0].id,
|
| ime_list_[0].engines[0].engine_id);
|
| @@ -1134,11 +1157,11 @@ TEST_F(InputMethodManagerImplTest,
|
| std::vector<std::string> ids;
|
| ids.push_back(ext_id1);
|
| ids.push_back(ext_id2);
|
| - EXPECT_TRUE(manager_->EnableInputMethods(ids));
|
| - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
|
| - EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id());
|
| - manager_->ChangeInputMethod(ext_id2);
|
| - EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id());
|
| + EXPECT_TRUE(manager()->EnableInputMethods(ids));
|
| + EXPECT_EQ(2U, manager()->GetNumActiveInputMethods());
|
| + EXPECT_EQ(ext_id1, manager()->GetCurrentInputMethod().id());
|
| + manager()->ChangeInputMethod(ext_id2);
|
| + EXPECT_EQ(ext_id2, manager()->GetCurrentInputMethod().id());
|
| }
|
|
|
| } // namespace input_method
|
|
|