Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 | 51 |
| 52 class InputMethodManagerImplTest : public testing::Test { | 52 class InputMethodManagerImplTest : public testing::Test { |
| 53 public: | 53 public: |
| 54 InputMethodManagerImplTest() | 54 InputMethodManagerImplTest() |
| 55 : delegate_(NULL), | 55 : delegate_(NULL), |
| 56 candidate_window_controller_(NULL), | 56 candidate_window_controller_(NULL), |
| 57 xkeyboard_(NULL) { | 57 xkeyboard_(NULL) { |
| 58 } | 58 } |
| 59 virtual ~InputMethodManagerImplTest() {} | 59 virtual ~InputMethodManagerImplTest() { |
| 60 InputMethodManager::Shutdown(); | |
| 61 } | |
| 60 | 62 |
| 61 virtual void SetUp() OVERRIDE { | 63 virtual void SetUp() OVERRIDE { |
| 62 delegate_ = new FakeInputMethodDelegate(); | 64 delegate_ = new FakeInputMethodDelegate(); |
| 63 manager_.reset(new InputMethodManagerImpl( | 65 InputMethodManager::Shutdown(); |
| 64 scoped_ptr<InputMethodDelegate>(delegate_))); | 66 InputMethodManager::Initialize( |
| 67 new InputMethodManagerImpl(scoped_ptr<InputMethodDelegate>(delegate_))); | |
| 65 candidate_window_controller_ = new MockCandidateWindowController; | 68 candidate_window_controller_ = new MockCandidateWindowController; |
| 66 manager_->SetCandidateWindowControllerForTesting( | 69 manager()->SetCandidateWindowControllerForTesting( |
| 67 candidate_window_controller_); | 70 candidate_window_controller_); |
| 68 xkeyboard_ = new MockXKeyboard; | 71 xkeyboard_ = new MockXKeyboard; |
| 69 manager_->SetXKeyboardForTesting(xkeyboard_); | 72 manager()->SetXKeyboardForTesting(xkeyboard_); |
| 70 mock_engine_handler_.reset(new MockIMEEngineHandler()); | 73 mock_engine_handler_.reset(new MockIMEEngineHandler()); |
| 71 IBusBridge::Initialize(); | 74 IBusBridge::Initialize(); |
| 72 IBusBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); | 75 IBusBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
| 73 | 76 |
| 74 ime_list_.clear(); | 77 ime_list_.clear(); |
| 75 | 78 |
| 76 ComponentExtensionIME ext1; | 79 ComponentExtensionIME ext1; |
| 77 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; | 80 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; |
| 78 ext1.description = "ext1_description"; | 81 ext1.description = "ext1_description"; |
| 79 ext1.path = base::FilePath("ext1_file_path"); | 82 ext1.path = base::FilePath("ext1_file_path"); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 ext2_engine2.layouts.push_back("us(dvorak)"); | 116 ext2_engine2.layouts.push_back("us(dvorak)"); |
| 114 ext2.engines.push_back(ext2_engine2); | 117 ext2.engines.push_back(ext2_engine2); |
| 115 | 118 |
| 116 ime_list_.push_back(ext2); | 119 ime_list_.push_back(ext2); |
| 117 } | 120 } |
| 118 | 121 |
| 119 virtual void TearDown() OVERRIDE { | 122 virtual void TearDown() OVERRIDE { |
| 120 delegate_ = NULL; | 123 delegate_ = NULL; |
| 121 candidate_window_controller_ = NULL; | 124 candidate_window_controller_ = NULL; |
| 122 xkeyboard_ = NULL; | 125 xkeyboard_ = NULL; |
| 123 manager_.reset(); | 126 InputMethodManager::Shutdown(); |
| 124 IBusBridge::Get()->SetCurrentEngineHandler(NULL); | 127 IBusBridge::Get()->SetCurrentEngineHandler(NULL); |
| 125 IBusBridge::Shutdown(); | 128 IBusBridge::Shutdown(); |
| 126 } | 129 } |
| 127 | 130 |
| 128 protected: | 131 protected: |
| 129 // Helper function to initialize component extension stuff for testing. | 132 // Helper function to initialize component extension stuff for testing. |
| 130 void InitComponentExtension() { | 133 void InitComponentExtension() { |
| 131 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); | 134 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); |
| 132 mock_delegate_->set_ime_list(ime_list_); | 135 mock_delegate_->set_ime_list(ime_list_); |
| 133 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); | 136 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); |
| 134 // Note, for production, these SetEngineHandler are called when | 137 // Note, for production, these SetEngineHandler are called when |
| 135 // IBusEngineHandlerInterface is initialized via | 138 // IBusEngineHandlerInterface is initialized via |
| 136 // InitializeComponentextension. | 139 // InitializeComponentextension. |
| 137 IBusBridge::Get()->SetEngineHandler(kNaclMozcUsId, | 140 IBusBridge::Get()->SetEngineHandler(kNaclMozcUsId, |
| 138 mock_engine_handler_.get()); | 141 mock_engine_handler_.get()); |
| 139 IBusBridge::Get()->SetEngineHandler(kNaclMozcJpId, | 142 IBusBridge::Get()->SetEngineHandler(kNaclMozcJpId, |
| 140 mock_engine_handler_.get()); | 143 mock_engine_handler_.get()); |
| 141 IBusBridge::Get()->SetEngineHandler(kExt2Engine1Id, | 144 IBusBridge::Get()->SetEngineHandler(kExt2Engine1Id, |
| 142 mock_engine_handler_.get()); | 145 mock_engine_handler_.get()); |
| 143 IBusBridge::Get()->SetEngineHandler(kExt2Engine2Id, | 146 IBusBridge::Get()->SetEngineHandler(kExt2Engine2Id, |
| 144 mock_engine_handler_.get()); | 147 mock_engine_handler_.get()); |
| 145 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); | 148 manager()->InitializeComponentExtensionForTesting(delegate.Pass()); |
| 146 } | 149 } |
| 147 | 150 |
| 148 scoped_ptr<InputMethodManagerImpl> manager_; | 151 InputMethodManagerImpl* manager() const { |
|
Hiro Komatsu
2014/01/27 05:12:21
If this is no longer necessary, please use manager
Alexander Alekseev
2014/01/27 12:50:14
Done.
| |
| 152 return static_cast<InputMethodManagerImpl*>(InputMethodManager::Get()); | |
| 153 } | |
| 154 | |
| 149 FakeInputMethodDelegate* delegate_; | 155 FakeInputMethodDelegate* delegate_; |
| 150 MockCandidateWindowController* candidate_window_controller_; | 156 MockCandidateWindowController* candidate_window_controller_; |
| 151 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; | 157 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; |
| 152 MockXKeyboard* xkeyboard_; | 158 MockXKeyboard* xkeyboard_; |
| 153 base::MessageLoop message_loop_; | 159 base::MessageLoop message_loop_; |
| 154 MockComponentExtIMEManagerDelegate* mock_delegate_; | 160 MockComponentExtIMEManagerDelegate* mock_delegate_; |
| 155 std::vector<ComponentExtensionIME> ime_list_; | 161 std::vector<ComponentExtensionIME> ime_list_; |
| 156 | 162 |
| 157 private: | 163 private: |
| 158 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); | 164 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 | 209 |
| 204 int candidate_window_opened_count_; | 210 int candidate_window_opened_count_; |
| 205 int candidate_window_closed_count_; | 211 int candidate_window_closed_count_; |
| 206 | 212 |
| 207 private: | 213 private: |
| 208 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); | 214 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); |
| 209 }; | 215 }; |
| 210 } // namespace | 216 } // namespace |
| 211 | 217 |
| 212 TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) { | 218 TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) { |
| 213 EXPECT_TRUE(manager_->GetXKeyboard()); | 219 EXPECT_TRUE(manager()->GetXKeyboard()); |
| 214 EXPECT_EQ(xkeyboard_, manager_->GetXKeyboard()); | 220 EXPECT_EQ(xkeyboard_, manager()->GetXKeyboard()); |
| 215 } | 221 } |
| 216 | 222 |
| 217 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { | 223 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { |
| 218 TestCandidateWindowObserver observer; | 224 TestCandidateWindowObserver observer; |
| 219 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop | 225 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop |
| 220 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop | 226 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop |
| 221 manager_->AddCandidateWindowObserver(&observer); | 227 manager()->AddCandidateWindowObserver(&observer); |
| 222 candidate_window_controller_->NotifyCandidateWindowOpened(); | 228 candidate_window_controller_->NotifyCandidateWindowOpened(); |
| 223 EXPECT_EQ(1, observer.candidate_window_opened_count_); | 229 EXPECT_EQ(1, observer.candidate_window_opened_count_); |
| 224 candidate_window_controller_->NotifyCandidateWindowClosed(); | 230 candidate_window_controller_->NotifyCandidateWindowClosed(); |
| 225 EXPECT_EQ(1, observer.candidate_window_closed_count_); | 231 EXPECT_EQ(1, observer.candidate_window_closed_count_); |
| 226 candidate_window_controller_->NotifyCandidateWindowOpened(); | 232 candidate_window_controller_->NotifyCandidateWindowOpened(); |
| 227 EXPECT_EQ(2, observer.candidate_window_opened_count_); | 233 EXPECT_EQ(2, observer.candidate_window_opened_count_); |
| 228 candidate_window_controller_->NotifyCandidateWindowClosed(); | 234 candidate_window_controller_->NotifyCandidateWindowClosed(); |
| 229 EXPECT_EQ(2, observer.candidate_window_closed_count_); | 235 EXPECT_EQ(2, observer.candidate_window_closed_count_); |
| 230 manager_->RemoveCandidateWindowObserver(&observer); | 236 manager()->RemoveCandidateWindowObserver(&observer); |
| 231 } | 237 } |
| 232 | 238 |
| 233 TEST_F(InputMethodManagerImplTest, TestObserver) { | 239 TEST_F(InputMethodManagerImplTest, TestObserver) { |
| 234 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is | 240 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is |
| 235 // also for the scenario. | 241 // also for the scenario. |
| 236 TestObserver observer; | 242 TestObserver observer; |
| 237 InitComponentExtension(); | 243 InitComponentExtension(); |
| 238 manager_->AddObserver(&observer); | 244 manager()->AddObserver(&observer); |
| 239 EXPECT_EQ(0, observer.input_method_changed_count_); | 245 EXPECT_EQ(0, observer.input_method_changed_count_); |
| 240 manager_->EnableLayouts("en-US", "xkb:us::eng"); | 246 manager()->EnableLoginLayouts("en-US", "xkb:us::eng"); |
| 241 EXPECT_EQ(1, observer.input_method_changed_count_); | 247 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 242 EXPECT_EQ(1, observer.input_method_property_changed_count_); | 248 EXPECT_EQ(1, observer.input_method_property_changed_count_); |
| 243 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 249 manager()->ChangeInputMethod("xkb:us:dvorak:eng"); |
| 244 EXPECT_FALSE(observer.last_show_message_); | 250 EXPECT_FALSE(observer.last_show_message_); |
| 245 EXPECT_EQ(2, observer.input_method_changed_count_); | 251 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 246 EXPECT_EQ(2, observer.input_method_property_changed_count_); | 252 EXPECT_EQ(2, observer.input_method_property_changed_count_); |
| 247 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 253 manager()->ChangeInputMethod("xkb:us:dvorak:eng"); |
| 248 EXPECT_FALSE(observer.last_show_message_); | 254 EXPECT_FALSE(observer.last_show_message_); |
| 249 | 255 |
| 250 // The observer is always notified even when the same input method ID is | 256 // The observer is always notified even when the same input method ID is |
| 251 // passed to ChangeInputMethod() more than twice. | 257 // passed to ChangeInputMethod() more than twice. |
| 252 // TODO(komatsu): Revisit if this is neccessary. | 258 // TODO(komatsu): Revisit if this is neccessary. |
| 253 EXPECT_EQ(3, observer.input_method_changed_count_); | 259 EXPECT_EQ(3, observer.input_method_changed_count_); |
| 254 | 260 |
| 255 // If the same input method ID is passed, PropertyChanged() is not | 261 // If the same input method ID is passed, PropertyChanged() is not |
| 256 // notified. | 262 // notified. |
| 257 EXPECT_EQ(2, observer.input_method_property_changed_count_); | 263 EXPECT_EQ(2, observer.input_method_property_changed_count_); |
| 258 | 264 |
| 259 manager_->RemoveObserver(&observer); | 265 manager()->RemoveObserver(&observer); |
| 260 } | 266 } |
| 261 | 267 |
| 262 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { | 268 TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { |
| 263 InitComponentExtension(); | 269 InitComponentExtension(); |
| 264 scoped_ptr<InputMethodDescriptors> methods( | 270 scoped_ptr<InputMethodDescriptors> methods( |
| 265 manager_->GetSupportedInputMethods()); | 271 manager()->GetSupportedInputMethods()); |
| 266 ASSERT_TRUE(methods.get()); | 272 ASSERT_TRUE(methods.get()); |
| 267 // Try to find random 4-5 layuts and IMEs to make sure the returned list is | 273 // Try to find random 4-5 layuts and IMEs to make sure the returned list is |
| 268 // correct. | 274 // correct. |
| 269 const InputMethodDescriptor* id_to_find = | 275 const InputMethodDescriptor* id_to_find = |
| 270 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 276 manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 271 kNaclMozcUsId); | 277 kNaclMozcUsId); |
| 272 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 278 id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 273 "xkb:us::eng"); | 279 "xkb:us::eng"); |
| 274 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 280 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 275 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 281 id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 276 "xkb:us:dvorak:eng"); | 282 "xkb:us:dvorak:eng"); |
| 277 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 283 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 278 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 284 id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 279 "xkb:fr::fra"); | 285 "xkb:fr::fra"); |
| 280 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 286 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 281 } | 287 } |
| 282 | 288 |
| 283 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 289 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
| 284 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 290 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
| 285 // ibus_input_method.txt. | 291 // ibus_input_method.txt. |
| 286 InitComponentExtension(); | 292 InitComponentExtension(); |
| 287 manager_->EnableLayouts("en-US", ""); | 293 manager()->EnableLoginLayouts("en-US", ""); |
| 288 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 294 EXPECT_EQ(5U, manager()->GetNumActiveInputMethods()); |
| 289 for (size_t i = 0; i < manager_->GetActiveInputMethodIds().size(); ++i) | 295 for (size_t i = 0; i < manager()->GetActiveInputMethodIds().size(); ++i) |
| 290 LOG(ERROR) << manager_->GetActiveInputMethodIds().at(i); | 296 LOG(ERROR) << manager()->GetActiveInputMethodIds().at(i); |
| 291 | 297 |
| 292 // For http://crbug.com/19655#c11 - (5) | 298 // For http://crbug.com/19655#c11 - (5) |
| 293 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 299 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
| 294 manager_->EnableLayouts("ja", ""); // Japanese | 300 manager()->EnableLoginLayouts("ja", ""); // Japanese |
| 295 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 301 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 296 } | 302 } |
| 297 | 303 |
| 298 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 304 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
| 299 // For http://crbug.com/329061 | 305 // For http://crbug.com/329061 |
| 300 manager_->EnableLayouts("en-US", "xkb:se::swe"); | 306 manager()->EnableLoginLayouts("en-US", "xkb:se::swe"); |
| 301 const std::string im_id = manager_->GetCurrentInputMethod().id(); | 307 const std::string im_id = manager()->GetCurrentInputMethod().id(); |
| 302 EXPECT_EQ("xkb:se::swe", im_id); | 308 EXPECT_EQ("xkb:se::swe", im_id); |
| 303 } | 309 } |
| 304 | 310 |
| 305 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 311 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
| 306 // The physical layout is French. | 312 // The physical layout is French. |
| 307 delegate_->set_hardware_keyboard_layout("xkb:fr::fra"); | 313 delegate_->set_hardware_keyboard_layout("xkb:fr::fra"); |
| 308 manager_->EnableLayouts("en-US", ""); | 314 manager()->EnableLoginLayouts("en-US", ""); |
| 309 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French | 315 EXPECT_EQ(6U, manager()->GetNumActiveInputMethods()); // 5 + French |
| 310 // The physical layout is Japanese. | 316 // The physical layout is Japanese. |
| 311 delegate_->set_hardware_keyboard_layout("xkb:jp::jpn"); | 317 delegate_->set_hardware_keyboard_layout("xkb:jp::jpn"); |
| 312 manager_->EnableLayouts("ja", ""); | 318 manager()->EnableLoginLayouts("ja", ""); |
| 313 // "xkb:us::eng" is not needed, hence 1. | 319 // "xkb:us::eng" is not needed, hence 1. |
| 314 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 320 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 321 | |
| 322 // The physical layout is Russian. | |
| 323 delegate_->set_hardware_keyboard_layout("xkb:ru::rus"); | |
| 324 manager()->EnableLoginLayouts("ru", ""); | |
| 325 // "xkb:us::eng" only. | |
| 326 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); | |
| 327 EXPECT_TRUE(manager()->GetActiveInputMethodIds().front() == "xkb:us::eng"); | |
|
Hiro Komatsu
2014/01/27 05:12:21
EXPECT_EQ?
Alexander Alekseev
2014/01/27 12:50:14
Done.
| |
| 315 } | 328 } |
| 316 | 329 |
| 317 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { | 330 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { |
| 318 manager_->EnableLayouts("ja", ""); // Japanese | 331 manager()->EnableLoginLayouts("ja", ""); // Japanese |
| 319 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 332 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 320 scoped_ptr<InputMethodDescriptors> methods( | 333 scoped_ptr<InputMethodDescriptors> methods( |
| 321 manager_->GetActiveInputMethods()); | 334 manager()->GetActiveInputMethods()); |
| 322 ASSERT_TRUE(methods.get()); | 335 ASSERT_TRUE(methods.get()); |
| 323 EXPECT_EQ(2U, methods->size()); | 336 EXPECT_EQ(2U, methods->size()); |
| 324 const InputMethodDescriptor* id_to_find = | 337 const InputMethodDescriptor* id_to_find = |
| 325 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 338 manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 326 "xkb:us::eng"); | 339 "xkb:us::eng"); |
| 327 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 340 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 328 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 341 id_to_find = manager()->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 329 "xkb:jp::jpn"); | 342 "xkb:jp::jpn"); |
| 330 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 343 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 331 } | 344 } |
| 332 | 345 |
| 333 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 346 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
| 334 // For http://crbug.com/19655#c11 - (8), step 6. | 347 // For http://crbug.com/19655#c11 - (8), step 6. |
| 335 TestObserver observer; | 348 TestObserver observer; |
| 336 manager_->AddObserver(&observer); | 349 manager()->AddObserver(&observer); |
| 337 InitComponentExtension(); | 350 InitComponentExtension(); |
| 338 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 351 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 339 std::vector<std::string> ids; | 352 std::vector<std::string> ids; |
| 340 ids.push_back("xkb:us:dvorak:eng"); | 353 ids.push_back("xkb:us:dvorak:eng"); |
| 341 ids.push_back("xkb:us:colemak:eng"); | 354 ids.push_back("xkb:us:colemak:eng"); |
| 342 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 355 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 343 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 356 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 344 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 357 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
| 345 // called. | 358 // called. |
| 346 EXPECT_EQ(1, observer.input_method_changed_count_); | 359 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 347 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 360 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 348 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 361 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 349 // Disable Dvorak. | 362 // Disable Dvorak. |
| 350 ids.erase(ids.begin()); | 363 ids.erase(ids.begin()); |
| 351 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 364 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 352 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 365 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 353 EXPECT_EQ(2, observer.input_method_changed_count_); | 366 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 354 EXPECT_EQ(ids[0], // colemak | 367 EXPECT_EQ(ids[0], // colemak |
| 355 manager_->GetCurrentInputMethod().id()); | 368 manager()->GetCurrentInputMethod().id()); |
| 356 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 369 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 357 manager_->RemoveObserver(&observer); | 370 manager()->RemoveObserver(&observer); |
| 358 } | 371 } |
| 359 | 372 |
| 360 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 373 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
| 361 // For http://crbug.com/19655#c11 - (9). | 374 // For http://crbug.com/19655#c11 - (9). |
| 362 TestObserver observer; | 375 TestObserver observer; |
| 363 manager_->AddObserver(&observer); | 376 manager()->AddObserver(&observer); |
| 364 InitComponentExtension(); | 377 InitComponentExtension(); |
| 365 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 378 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 366 std::vector<std::string> ids; | 379 std::vector<std::string> ids; |
| 367 ids.push_back("xkb:us::eng"); | 380 ids.push_back("xkb:us::eng"); |
| 368 ids.push_back("xkb:us:dvorak:eng"); | 381 ids.push_back("xkb:us:dvorak:eng"); |
| 369 ids.push_back("xkb:us:colemak:eng"); | 382 ids.push_back("xkb:us:colemak:eng"); |
| 370 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 383 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 371 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 384 EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); |
| 372 EXPECT_EQ(1, observer.input_method_changed_count_); | 385 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 373 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 386 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 374 EXPECT_EQ("us", xkeyboard_->last_layout_); | 387 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 375 // Switch to Dvorak. | 388 // Switch to Dvorak. |
| 376 manager_->SwitchToNextInputMethod(); | 389 manager()->SwitchToNextInputMethod(); |
| 377 EXPECT_EQ(2, observer.input_method_changed_count_); | 390 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 378 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 391 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 379 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 392 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 380 // Disable Dvorak. | 393 // Disable Dvorak. |
| 381 ids.erase(ids.begin() + 1); | 394 ids.erase(ids.begin() + 1); |
| 382 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 395 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 383 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 396 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 384 EXPECT_EQ(3, observer.input_method_changed_count_); | 397 EXPECT_EQ(3, observer.input_method_changed_count_); |
| 385 EXPECT_EQ(ids[0], // US Qwerty | 398 EXPECT_EQ(ids[0], // US Qwerty |
| 386 manager_->GetCurrentInputMethod().id()); | 399 manager()->GetCurrentInputMethod().id()); |
| 387 EXPECT_EQ("us", xkeyboard_->last_layout_); | 400 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 388 manager_->RemoveObserver(&observer); | 401 manager()->RemoveObserver(&observer); |
| 389 } | 402 } |
| 390 | 403 |
| 391 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 404 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
| 392 // For http://crbug.com/19655#c11 - (10). | 405 // For http://crbug.com/19655#c11 - (10). |
| 393 TestObserver observer; | 406 TestObserver observer; |
| 394 manager_->AddObserver(&observer); | 407 manager()->AddObserver(&observer); |
| 395 InitComponentExtension(); | 408 InitComponentExtension(); |
| 396 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 409 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 397 std::vector<std::string> ids; | 410 std::vector<std::string> ids; |
| 398 ids.push_back("xkb:us:dvorak:eng"); | 411 ids.push_back("xkb:us:dvorak:eng"); |
| 399 ids.push_back(kNaclMozcUsId); | 412 ids.push_back(kNaclMozcUsId); |
| 400 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 413 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 401 EXPECT_EQ(1, observer.input_method_changed_count_); | 414 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 402 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 415 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 403 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 416 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 404 // Switch to Mozc | 417 // Switch to Mozc |
| 405 manager_->SwitchToNextInputMethod(); | 418 manager()->SwitchToNextInputMethod(); |
| 406 EXPECT_EQ(2, observer.input_method_changed_count_); | 419 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 407 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 420 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 408 EXPECT_EQ("us", xkeyboard_->last_layout_); | 421 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 409 // Disable Mozc. | 422 // Disable Mozc. |
| 410 ids.erase(ids.begin() + 1); | 423 ids.erase(ids.begin() + 1); |
| 411 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 424 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 412 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 425 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 413 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 426 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 414 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 427 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 415 } | 428 } |
| 416 | 429 |
| 417 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 430 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
| 418 // For http://crbug.com/19655#c11 - (11). | 431 // For http://crbug.com/19655#c11 - (11). |
| 419 TestObserver observer; | 432 TestObserver observer; |
| 420 manager_->AddObserver(&observer); | 433 manager()->AddObserver(&observer); |
| 421 InitComponentExtension(); | 434 InitComponentExtension(); |
| 422 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 435 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 423 std::vector<std::string> ids; | 436 std::vector<std::string> ids; |
| 424 ids.push_back("xkb:us:dvorak:eng"); | 437 ids.push_back("xkb:us:dvorak:eng"); |
| 425 ids.push_back(kNaclMozcUsId); | 438 ids.push_back(kNaclMozcUsId); |
| 426 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 439 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 427 EXPECT_EQ(1, observer.input_method_changed_count_); | 440 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 428 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 441 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 429 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 442 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 430 | 443 |
| 431 // Disable Dvorak. | 444 // Disable Dvorak. |
| 432 ids.erase(ids.begin()); | 445 ids.erase(ids.begin()); |
| 433 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 446 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 434 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 447 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 435 EXPECT_EQ(ids[0], // Mozc | 448 EXPECT_EQ(ids[0], // Mozc |
| 436 manager_->GetCurrentInputMethod().id()); | 449 manager()->GetCurrentInputMethod().id()); |
| 437 EXPECT_EQ("us", xkeyboard_->last_layout_); | 450 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 438 manager_->RemoveObserver(&observer); | 451 manager()->RemoveObserver(&observer); |
| 439 } | 452 } |
| 440 | 453 |
| 441 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 454 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
| 442 TestObserver observer; | 455 TestObserver observer; |
| 443 manager_->AddObserver(&observer); | 456 manager()->AddObserver(&observer); |
| 444 InitComponentExtension(); | 457 InitComponentExtension(); |
| 445 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 458 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 446 std::vector<std::string> ids; | 459 std::vector<std::string> ids; |
| 447 ids.push_back(kExt2Engine1Id); | 460 ids.push_back(kExt2Engine1Id); |
| 448 ids.push_back("mozc-dv"); | 461 ids.push_back("mozc-dv"); |
| 449 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 462 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 450 EXPECT_EQ(1, observer.input_method_changed_count_); | 463 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 451 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 464 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 452 EXPECT_EQ("us", xkeyboard_->last_layout_); | 465 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 453 manager_->RemoveObserver(&observer); | 466 manager()->RemoveObserver(&observer); |
| 454 } | 467 } |
| 455 | 468 |
| 456 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 469 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
| 457 TestObserver observer; | 470 TestObserver observer; |
| 458 manager_->AddObserver(&observer); | 471 manager()->AddObserver(&observer); |
| 459 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 472 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 460 std::vector<std::string> ids; | 473 std::vector<std::string> ids; |
| 461 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 474 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
| 462 ids.push_back("unknown-super-cool-ime"); | 475 ids.push_back("unknown-super-cool-ime"); |
| 463 EXPECT_FALSE(manager_->EnableInputMethods(ids)); | 476 EXPECT_FALSE(manager()->EnableInputMethods(ids)); |
| 464 | 477 |
| 465 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this | 478 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this |
| 466 // case? | 479 // case? |
| 467 EXPECT_EQ(0, observer.input_method_changed_count_); | 480 EXPECT_EQ(0, observer.input_method_changed_count_); |
| 468 | 481 |
| 469 manager_->RemoveObserver(&observer); | 482 manager()->RemoveObserver(&observer); |
| 470 } | 483 } |
| 471 | 484 |
| 472 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { | 485 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { |
| 473 // For http://crbug.com/19655#c11 - (14). | 486 // For http://crbug.com/19655#c11 - (14). |
| 474 TestObserver observer; | 487 TestObserver observer; |
| 475 manager_->AddObserver(&observer); | 488 manager()->AddObserver(&observer); |
| 476 InitComponentExtension(); | 489 InitComponentExtension(); |
| 477 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 490 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 478 std::vector<std::string> ids; | 491 std::vector<std::string> ids; |
| 479 ids.push_back("xkb:us::eng"); | 492 ids.push_back("xkb:us::eng"); |
| 480 ids.push_back("xkb:us:dvorak:eng"); | 493 ids.push_back("xkb:us:dvorak:eng"); |
| 481 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 494 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 482 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 495 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 483 EXPECT_EQ(1, observer.input_method_changed_count_); | 496 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 484 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 497 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 485 EXPECT_EQ("us", xkeyboard_->last_layout_); | 498 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 486 | 499 |
| 487 // Switch to Dvorak. | 500 // Switch to Dvorak. |
| 488 manager_->SwitchToNextInputMethod(); | 501 manager()->SwitchToNextInputMethod(); |
| 489 EXPECT_EQ(2, observer.input_method_changed_count_); | 502 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 490 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 503 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 491 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 504 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 492 | 505 |
| 493 // Lock screen | 506 // Lock screen |
| 494 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 507 manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
| 495 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 508 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 496 EXPECT_EQ(ids[1], // still Dvorak | 509 EXPECT_EQ(ids[1], // still Dvorak |
| 497 manager_->GetCurrentInputMethod().id()); | 510 manager()->GetCurrentInputMethod().id()); |
| 498 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 511 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 499 // Switch back to Qwerty. | 512 // Switch back to Qwerty. |
| 500 manager_->SwitchToNextInputMethod(); | 513 manager()->SwitchToNextInputMethod(); |
| 501 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 514 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 502 EXPECT_EQ("us", xkeyboard_->last_layout_); | 515 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 503 | 516 |
| 504 // Unlock screen. The original state, Dvorak, is restored. | 517 // Unlock screen. The original state, Dvorak, is restored. |
| 505 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 518 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 506 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 519 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 507 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 520 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 508 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 521 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 509 | 522 |
| 510 manager_->RemoveObserver(&observer); | 523 manager()->RemoveObserver(&observer); |
| 511 } | 524 } |
| 512 | 525 |
| 513 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 526 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
| 514 // For http://crbug.com/19655#c11 - (15). | 527 // For http://crbug.com/19655#c11 - (15). |
| 515 TestObserver observer; | 528 TestObserver observer; |
| 516 manager_->AddObserver(&observer); | 529 manager()->AddObserver(&observer); |
| 517 InitComponentExtension(); | 530 InitComponentExtension(); |
| 518 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 531 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 519 std::vector<std::string> ids; | 532 std::vector<std::string> ids; |
| 520 ids.push_back("xkb:us:dvorak:eng"); | 533 ids.push_back("xkb:us:dvorak:eng"); |
| 521 ids.push_back(kExt2Engine2Id); | 534 ids.push_back(kExt2Engine2Id); |
| 522 ids.push_back(kExt2Engine1Id); | 535 ids.push_back(kExt2Engine1Id); |
| 523 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 536 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 524 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 537 EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); |
| 525 EXPECT_EQ(1, observer.input_method_changed_count_); | 538 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 526 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 539 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 527 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 540 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 528 | 541 |
| 529 // Switch to Mozc. | 542 // Switch to Mozc. |
| 530 manager_->SwitchToNextInputMethod(); | 543 manager()->SwitchToNextInputMethod(); |
| 531 EXPECT_EQ(2, observer.input_method_changed_count_); | 544 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 532 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 545 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 533 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 546 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 534 | 547 |
| 535 // Lock screen | 548 // Lock screen |
| 536 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 549 manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
| 537 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. | 550 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); // Qwerty+Dvorak. |
| 538 EXPECT_EQ("xkb:us:dvorak:eng", | 551 EXPECT_EQ("xkb:us:dvorak:eng", manager()->GetCurrentInputMethod().id()); |
| 539 manager_->GetCurrentInputMethod().id()); | 552 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 540 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 553 manager()->SwitchToNextInputMethod(); |
| 541 manager_->SwitchToNextInputMethod(); | |
| 542 EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout. | 554 EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout. |
| 543 manager_->GetCurrentInputMethod().id()); | 555 manager()->GetCurrentInputMethod().id()); |
| 544 EXPECT_EQ("us", xkeyboard_->last_layout_); | 556 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 545 | 557 |
| 546 // Unlock screen. The original state, pinyin-dv, is restored. | 558 // Unlock screen. The original state, pinyin-dv, is restored. |
| 547 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 559 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 548 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. | 560 EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. |
| 549 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 561 EXPECT_EQ(ids[1], manager()->GetCurrentInputMethod().id()); |
| 550 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 562 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 551 | 563 |
| 552 manager_->RemoveObserver(&observer); | 564 manager()->RemoveObserver(&observer); |
| 553 } | 565 } |
| 554 | 566 |
| 555 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 567 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
| 556 // For http://crbug.com/19655#c11 - (8), step 7-11. | 568 // For http://crbug.com/19655#c11 - (8), step 7-11. |
| 557 InitComponentExtension(); | 569 InitComponentExtension(); |
| 558 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 570 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 559 std::vector<std::string> ids; | 571 std::vector<std::string> ids; |
| 560 ids.push_back("xkb:us:dvorak:eng"); | 572 ids.push_back("xkb:us:dvorak:eng"); |
| 561 ids.push_back("xkb:us:colemak:eng"); | 573 ids.push_back("xkb:us:colemak:eng"); |
| 562 ids.push_back(kNaclMozcJpId); | 574 ids.push_back(kNaclMozcJpId); |
| 563 ids.push_back(kNaclMozcUsId); | 575 ids.push_back(kNaclMozcUsId); |
| 564 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 576 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 565 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); | 577 EXPECT_EQ(4U, manager()->GetNumActiveInputMethods()); |
| 566 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 578 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 567 // See input_methods.txt for an expected XKB layout name. | 579 // See input_methods.txt for an expected XKB layout name. |
| 568 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 580 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 569 manager_->SwitchToNextInputMethod(); | 581 manager()->SwitchToNextInputMethod(); |
| 570 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 582 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 571 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 583 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 572 manager_->SwitchToNextInputMethod(); | 584 manager()->SwitchToNextInputMethod(); |
| 573 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 585 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 574 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 586 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 575 manager_->SwitchToNextInputMethod(); | 587 manager()->SwitchToNextInputMethod(); |
| 576 EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 588 EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 577 EXPECT_EQ("us", xkeyboard_->last_layout_); | 589 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 578 manager_->SwitchToNextInputMethod(); | 590 manager()->SwitchToNextInputMethod(); |
| 579 EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 591 EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 580 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 592 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 581 // Disable Dvorak. | 593 // Disable Dvorak. |
| 582 ids.erase(ids.begin()); | 594 ids.erase(ids.begin()); |
| 583 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 595 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 584 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 596 EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); |
| 585 EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 597 EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 586 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 598 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 587 } | 599 } |
| 588 | 600 |
| 589 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { | 601 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { |
| 590 const std::string kKey = "key"; | 602 const std::string kKey = "key"; |
| 591 InputMethodPropertyList property_list; | 603 InputMethodPropertyList property_list; |
| 592 property_list.push_back(InputMethodProperty(kKey, "label", false, false)); | 604 property_list.push_back(InputMethodProperty(kKey, "label", false, false)); |
| 593 manager_->SetCurrentInputMethodProperties(property_list); | 605 manager()->SetCurrentInputMethodProperties(property_list); |
| 594 | 606 |
| 595 manager_->ActivateInputMethodProperty(kKey); | 607 manager()->ActivateInputMethodProperty(kKey); |
| 596 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 608 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
| 597 | 609 |
| 598 // Key2 is not registered, so activated property should not be changed. | 610 // Key2 is not registered, so activated property should not be changed. |
| 599 manager_->ActivateInputMethodProperty("key2"); | 611 manager()->ActivateInputMethodProperty("key2"); |
| 600 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 612 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
| 601 } | 613 } |
| 602 | 614 |
| 603 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { | 615 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
| 604 InitComponentExtension(); | 616 InitComponentExtension(); |
| 605 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 617 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 606 | 618 |
| 607 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 619 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 608 std::vector<std::string> ids; | 620 std::vector<std::string> ids; |
| 609 ids.push_back("xkb:us::eng"); | 621 ids.push_back("xkb:us::eng"); |
| 610 ids.push_back(kNaclMozcUsId); | 622 ids.push_back(kNaclMozcUsId); |
| 611 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 623 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 612 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 624 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 613 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 625 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 614 manager_->ChangeInputMethod(kNaclMozcUsId); | 626 manager()->ChangeInputMethod(kNaclMozcUsId); |
| 615 | 627 |
| 616 InputMethodPropertyList current_property_list; | 628 InputMethodPropertyList current_property_list; |
| 617 current_property_list.push_back(InputMethodProperty("key", | 629 current_property_list.push_back(InputMethodProperty("key", |
| 618 "label", | 630 "label", |
| 619 false, | 631 false, |
| 620 false)); | 632 false)); |
| 621 manager_->SetCurrentInputMethodProperties(current_property_list); | 633 manager()->SetCurrentInputMethodProperties(current_property_list); |
| 622 | 634 |
| 623 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); | 635 ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size()); |
| 624 EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); | 636 EXPECT_EQ("key", manager()->GetCurrentInputMethodProperties().at(0).key); |
| 625 | 637 |
| 626 manager_->ChangeInputMethod("xkb:us::eng"); | 638 manager()->ChangeInputMethod("xkb:us::eng"); |
| 627 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 639 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 628 } | 640 } |
| 629 | 641 |
| 630 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { | 642 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
| 631 InitComponentExtension(); | 643 InitComponentExtension(); |
| 632 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 644 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 633 | 645 |
| 634 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 646 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 635 std::vector<std::string> ids; | 647 std::vector<std::string> ids; |
| 636 ids.push_back(kNaclMozcUsId); // Japanese | 648 ids.push_back(kNaclMozcUsId); // Japanese |
| 637 ids.push_back(kExt2Engine1Id); // T-Chinese | 649 ids.push_back(kExt2Engine1Id); // T-Chinese |
| 638 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 650 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 639 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 651 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 640 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 652 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 641 | 653 |
| 642 InputMethodPropertyList current_property_list; | 654 InputMethodPropertyList current_property_list; |
| 643 current_property_list.push_back(InputMethodProperty("key-mozc", | 655 current_property_list.push_back(InputMethodProperty("key-mozc", |
| 644 "label", | 656 "label", |
| 645 false, | 657 false, |
| 646 false)); | 658 false)); |
| 647 manager_->SetCurrentInputMethodProperties(current_property_list); | 659 manager()->SetCurrentInputMethodProperties(current_property_list); |
| 648 | 660 |
| 649 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); | 661 ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size()); |
| 650 EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key); | 662 EXPECT_EQ("key-mozc", manager()->GetCurrentInputMethodProperties().at(0).key); |
| 651 | 663 |
| 652 manager_->ChangeInputMethod(kExt2Engine1Id); | 664 manager()->ChangeInputMethod(kExt2Engine1Id); |
| 653 // Since the IME is changed, the property for mozc Japanese should be hidden. | 665 // Since the IME is changed, the property for mozc Japanese should be hidden. |
| 654 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 666 EXPECT_TRUE(manager()->GetCurrentInputMethodProperties().empty()); |
| 655 | 667 |
| 656 // Asynchronous property update signal from mozc-chewing. | 668 // Asynchronous property update signal from mozc-chewing. |
| 657 current_property_list.clear(); | 669 current_property_list.clear(); |
| 658 current_property_list.push_back(InputMethodProperty("key-chewing", | 670 current_property_list.push_back(InputMethodProperty("key-chewing", |
| 659 "label", | 671 "label", |
| 660 false, | 672 false, |
| 661 false)); | 673 false)); |
| 662 manager_->SetCurrentInputMethodProperties(current_property_list); | 674 manager()->SetCurrentInputMethodProperties(current_property_list); |
| 663 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); | 675 ASSERT_EQ(1U, manager()->GetCurrentInputMethodProperties().size()); |
| 664 EXPECT_EQ("key-chewing", | 676 EXPECT_EQ("key-chewing", |
| 665 manager_->GetCurrentInputMethodProperties().at(0).key); | 677 manager()->GetCurrentInputMethodProperties().at(0).key); |
| 666 } | 678 } |
| 667 | 679 |
| 668 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 680 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
| 669 TestObserver observer; | 681 TestObserver observer; |
| 670 manager_->AddObserver(&observer); | 682 manager()->AddObserver(&observer); |
| 671 InitComponentExtension(); | 683 InitComponentExtension(); |
| 672 // For http://crbug.com/19655#c11 - (1) | 684 // For http://crbug.com/19655#c11 - (1) |
| 673 manager_->EnableLayouts("en-US", "xkb:us::eng"); | 685 manager()->EnableLoginLayouts("en-US", "xkb:us::eng"); |
| 674 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 686 EXPECT_EQ(5U, manager()->GetNumActiveInputMethods()); |
| 675 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 687 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 676 EXPECT_EQ("us", xkeyboard_->last_layout_); | 688 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 677 manager_->SwitchToNextInputMethod(); | 689 manager()->SwitchToNextInputMethod(); |
| 678 EXPECT_TRUE(observer.last_show_message_); | 690 EXPECT_TRUE(observer.last_show_message_); |
| 679 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 691 EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id()); |
| 680 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 692 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 681 manager_->SwitchToNextInputMethod(); | 693 manager()->SwitchToNextInputMethod(); |
| 682 EXPECT_TRUE(observer.last_show_message_); | 694 EXPECT_TRUE(observer.last_show_message_); |
| 683 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 695 EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id()); |
| 684 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 696 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
| 685 manager_->SwitchToNextInputMethod(); | 697 manager()->SwitchToNextInputMethod(); |
| 686 EXPECT_TRUE(observer.last_show_message_); | 698 EXPECT_TRUE(observer.last_show_message_); |
| 687 EXPECT_EQ("xkb:us:dvorak:eng", manager_->GetCurrentInputMethod().id()); | 699 EXPECT_EQ("xkb:us:dvorak:eng", manager()->GetCurrentInputMethod().id()); |
| 688 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 700 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 689 manager_->SwitchToNextInputMethod(); | 701 manager()->SwitchToNextInputMethod(); |
| 690 EXPECT_TRUE(observer.last_show_message_); | 702 EXPECT_TRUE(observer.last_show_message_); |
| 691 EXPECT_EQ("xkb:us:colemak:eng", manager_->GetCurrentInputMethod().id()); | 703 EXPECT_EQ("xkb:us:colemak:eng", manager()->GetCurrentInputMethod().id()); |
| 692 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 704 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 693 manager_->SwitchToNextInputMethod(); | 705 manager()->SwitchToNextInputMethod(); |
| 694 EXPECT_TRUE(observer.last_show_message_); | 706 EXPECT_TRUE(observer.last_show_message_); |
| 695 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 707 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 696 EXPECT_EQ("us", xkeyboard_->last_layout_); | 708 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 697 | 709 |
| 698 manager_->RemoveObserver(&observer); | 710 manager()->RemoveObserver(&observer); |
| 699 } | 711 } |
| 700 | 712 |
| 701 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 713 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
| 702 TestObserver observer; | 714 TestObserver observer; |
| 703 manager_->AddObserver(&observer); | 715 manager()->AddObserver(&observer); |
| 704 InitComponentExtension(); | 716 InitComponentExtension(); |
| 705 | 717 |
| 706 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 718 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 707 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 719 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 708 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 720 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 709 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 721 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 710 | 722 |
| 711 manager_->EnableLayouts("en-US", "xkb:us::eng"); | 723 manager()->EnableLoginLayouts("en-US", "xkb:us::eng"); |
| 712 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 724 EXPECT_EQ(5U, manager()->GetNumActiveInputMethods()); |
| 713 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 725 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 714 EXPECT_EQ("us", xkeyboard_->last_layout_); | 726 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 715 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 727 EXPECT_TRUE(manager()->SwitchToNextInputMethod()); |
| 716 EXPECT_TRUE(observer.last_show_message_); | 728 EXPECT_TRUE(observer.last_show_message_); |
| 717 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 729 EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id()); |
| 718 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 730 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 719 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 731 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 720 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 732 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 721 EXPECT_TRUE(observer.last_show_message_); | 733 EXPECT_TRUE(observer.last_show_message_); |
| 722 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 734 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 723 EXPECT_EQ("us", xkeyboard_->last_layout_); | 735 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 724 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 736 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 725 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 737 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 726 EXPECT_TRUE(observer.last_show_message_); | 738 EXPECT_TRUE(observer.last_show_message_); |
| 727 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 739 EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id()); |
| 728 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 740 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 729 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 741 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 730 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 742 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 731 EXPECT_TRUE(observer.last_show_message_); | 743 EXPECT_TRUE(observer.last_show_message_); |
| 732 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 744 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 733 EXPECT_EQ("us", xkeyboard_->last_layout_); | 745 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 734 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 746 EXPECT_TRUE(manager()->SwitchToNextInputMethod()); |
| 735 EXPECT_TRUE(observer.last_show_message_); | 747 EXPECT_TRUE(observer.last_show_message_); |
| 736 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 748 EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id()); |
| 737 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 749 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 738 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 750 EXPECT_TRUE(manager()->SwitchToNextInputMethod()); |
| 739 EXPECT_TRUE(observer.last_show_message_); | 751 EXPECT_TRUE(observer.last_show_message_); |
| 740 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 752 EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id()); |
| 741 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 753 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
| 742 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 754 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 743 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 755 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 744 EXPECT_TRUE(observer.last_show_message_); | 756 EXPECT_TRUE(observer.last_show_message_); |
| 745 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 757 EXPECT_EQ("xkb:us:intl:eng", manager()->GetCurrentInputMethod().id()); |
| 746 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 758 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 747 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 759 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 748 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 760 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 749 EXPECT_TRUE(observer.last_show_message_); | 761 EXPECT_TRUE(observer.last_show_message_); |
| 750 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 762 EXPECT_EQ("xkb:us:altgr-intl:eng", manager()->GetCurrentInputMethod().id()); |
| 751 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 763 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
| 752 | 764 |
| 753 manager_->RemoveObserver(&observer); | 765 manager()->RemoveObserver(&observer); |
| 754 } | 766 } |
| 755 | 767 |
| 756 TEST_F(InputMethodManagerImplTest, | 768 TEST_F(InputMethodManagerImplTest, |
| 757 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { | 769 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { |
| 758 TestObserver observer; | 770 TestObserver observer; |
| 759 manager_->AddObserver(&observer); | 771 manager()->AddObserver(&observer); |
| 760 InitComponentExtension(); | 772 InitComponentExtension(); |
| 761 | 773 |
| 762 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 774 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 763 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 775 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 764 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 776 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 765 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 777 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 766 | 778 |
| 767 std::vector<std::string> ids; | 779 std::vector<std::string> ids; |
| 768 ids.push_back("xkb:us:dvorak:eng"); | 780 ids.push_back("xkb:us:dvorak:eng"); |
| 769 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 781 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 770 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 782 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 771 | 783 |
| 772 // Ctrl+Space accelerator should not be consumed if there is only one active | 784 // Ctrl+Space accelerator should not be consumed if there is only one active |
| 773 // input method. | 785 // input method. |
| 774 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 786 EXPECT_FALSE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 775 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 787 EXPECT_FALSE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 776 | 788 |
| 777 manager_->RemoveObserver(&observer); | 789 manager()->RemoveObserver(&observer); |
| 778 } | 790 } |
| 779 | 791 |
| 780 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 792 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
| 781 TestObserver observer; | 793 TestObserver observer; |
| 782 manager_->AddObserver(&observer); | 794 manager()->AddObserver(&observer); |
| 783 InitComponentExtension(); | 795 InitComponentExtension(); |
| 784 manager_->EnableLayouts("en-US", "xkb:us::eng"); | 796 manager()->EnableLoginLayouts("en-US", "xkb:us::eng"); |
| 785 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 797 EXPECT_EQ(5U, manager()->GetNumActiveInputMethods()); |
| 786 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 798 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 787 EXPECT_EQ("us", xkeyboard_->last_layout_); | 799 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 788 | 800 |
| 789 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 801 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
| 790 // and keyboards are enabled. | 802 // and keyboards are enabled. |
| 791 EXPECT_FALSE(manager_->SwitchInputMethod( | 803 EXPECT_FALSE(manager()->SwitchInputMethod( |
| 792 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 804 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 793 EXPECT_FALSE(observer.last_show_message_); | 805 EXPECT_FALSE(observer.last_show_message_); |
| 794 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 806 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 795 EXPECT_EQ("us", xkeyboard_->last_layout_); | 807 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 796 EXPECT_FALSE(manager_->SwitchInputMethod( | 808 EXPECT_FALSE(manager()->SwitchInputMethod( |
| 797 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 809 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 798 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 810 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 799 EXPECT_EQ("us", xkeyboard_->last_layout_); | 811 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 800 EXPECT_FALSE(manager_->SwitchInputMethod( | 812 EXPECT_FALSE(manager()->SwitchInputMethod( |
| 801 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 813 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 802 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 814 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 803 EXPECT_EQ("us", xkeyboard_->last_layout_); | 815 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 804 EXPECT_FALSE(manager_->SwitchInputMethod( | 816 EXPECT_FALSE(manager()->SwitchInputMethod( |
| 805 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 817 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 806 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 818 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 807 EXPECT_EQ("us", xkeyboard_->last_layout_); | 819 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 808 | 820 |
| 809 manager_->RemoveObserver(&observer); | 821 manager()->RemoveObserver(&observer); |
| 810 } | 822 } |
| 811 | 823 |
| 812 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { | 824 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
| 813 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. | 825 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. |
| 814 InitComponentExtension(); | 826 InitComponentExtension(); |
| 815 | 827 |
| 816 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 828 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 817 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 829 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 818 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 830 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 819 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 831 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 820 | 832 |
| 821 manager_->EnableLayouts("ja", "xkb:us::eng"); | 833 manager()->EnableLoginLayouts("ja", "xkb:us::eng"); |
| 822 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 834 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 823 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 835 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 824 EXPECT_EQ("us", xkeyboard_->last_layout_); | 836 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 825 EXPECT_TRUE(manager_->SwitchInputMethod( | 837 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 826 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 838 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 827 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 839 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 828 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 840 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 829 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 841 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 830 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 842 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 831 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 843 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 832 EXPECT_EQ("us", xkeyboard_->last_layout_); | 844 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 833 EXPECT_TRUE(manager_->SwitchInputMethod( | 845 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 834 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 846 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 835 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 847 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 836 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 848 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 837 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 849 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 838 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 850 EXPECT_TRUE(manager()->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 839 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 851 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 840 EXPECT_EQ("us", xkeyboard_->last_layout_); | 852 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 841 EXPECT_TRUE(manager_->SwitchInputMethod( | 853 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 842 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 854 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 843 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 855 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 844 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 856 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 845 } | 857 } |
| 846 | 858 |
| 847 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 859 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
| 848 InitComponentExtension(); | 860 InitComponentExtension(); |
| 849 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 861 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 850 std::vector<std::string> ids; | 862 std::vector<std::string> ids; |
| 851 ids.push_back("xkb:jp::jpn"); | 863 ids.push_back("xkb:jp::jpn"); |
| 852 ids.push_back(kNaclMozcJpId); | 864 ids.push_back(kNaclMozcJpId); |
| 853 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 865 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 854 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 866 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 855 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 867 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 856 EXPECT_TRUE(manager_->SwitchInputMethod( | 868 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 857 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 869 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 858 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 870 EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id()); |
| 859 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 871 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 860 EXPECT_TRUE(manager_->SwitchInputMethod( | 872 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 861 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 873 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 862 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 874 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 863 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 875 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 864 EXPECT_TRUE(manager_->SwitchInputMethod( | 876 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 865 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 877 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 866 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 878 EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id()); |
| 867 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 879 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 868 EXPECT_TRUE(manager_->SwitchInputMethod( | 880 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 869 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 881 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 870 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 882 EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id()); |
| 871 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 883 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 872 EXPECT_TRUE(manager_->SwitchInputMethod( | 884 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 873 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 885 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 874 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 886 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 875 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 887 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 876 EXPECT_TRUE(manager_->SwitchInputMethod( | 888 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 877 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 889 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 878 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 890 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 879 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 891 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 880 | 892 |
| 881 // Add Dvorak. | 893 // Add Dvorak. |
| 882 ids.push_back("xkb:us:dvorak:eng"); | 894 ids.push_back("xkb:us:dvorak:eng"); |
| 883 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 895 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 884 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 896 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 885 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 897 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 886 EXPECT_TRUE(manager_->SwitchInputMethod( | 898 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 887 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 899 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 888 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 900 EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id()); |
| 889 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 901 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 890 EXPECT_TRUE(manager_->SwitchInputMethod( | 902 EXPECT_TRUE(manager()->SwitchInputMethod( |
| 891 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 903 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 892 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 904 EXPECT_EQ("xkb:jp::jpn", manager()->GetCurrentInputMethod().id()); |
| 893 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 905 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 894 } | 906 } |
| 895 | 907 |
| 896 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 908 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
| 897 TestObserver observer; | 909 TestObserver observer; |
| 898 manager_->AddObserver(&observer); | 910 manager()->AddObserver(&observer); |
| 899 InitComponentExtension(); | 911 InitComponentExtension(); |
| 900 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 912 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 901 std::vector<std::string> ids; | 913 std::vector<std::string> ids; |
| 902 ids.push_back("xkb:us:dvorak:eng"); | 914 ids.push_back("xkb:us:dvorak:eng"); |
| 903 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 915 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 904 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 916 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 905 EXPECT_EQ(1, observer.input_method_changed_count_); | 917 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 906 EXPECT_EQ(ids[0], | 918 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 907 manager_->GetCurrentInputMethod().id()); | |
| 908 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 919 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 909 | 920 |
| 910 // Add two Extension IMEs. | 921 // Add two Extension IMEs. |
| 911 std::vector<std::string> layouts; | 922 std::vector<std::string> layouts; |
| 912 layouts.push_back("us"); | 923 layouts.push_back("us"); |
| 913 std::vector<std::string> languages; | 924 std::vector<std::string> languages; |
| 914 languages.push_back("en-US"); | 925 languages.push_back("en-US"); |
| 915 | 926 |
| 916 const std::string ext1_id = | 927 const std::string ext1_id = |
| 917 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 928 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
| 918 const InputMethodDescriptor descriptor1(ext1_id, | 929 const InputMethodDescriptor descriptor1(ext1_id, |
| 919 "deadbeef input method", | 930 "deadbeef input method", |
| 920 layouts, | 931 layouts, |
| 921 languages, | 932 languages, |
| 922 false, // is_login_keyboard | 933 false, // is_login_keyboard |
| 923 GURL(), | 934 GURL(), |
| 924 GURL()); | 935 GURL()); |
| 925 MockInputMethodEngine engine(descriptor1); | 936 MockInputMethodEngine engine(descriptor1); |
| 926 manager_->AddInputMethodExtension(ext1_id, &engine); | 937 manager()->AddInputMethodExtension(ext1_id, &engine); |
| 927 | 938 |
| 928 // Extension IMEs are not enabled by default. | 939 // Extension IMEs are not enabled by default. |
| 929 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 940 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 930 | 941 |
| 931 std::vector<std::string> extension_ime_ids; | 942 std::vector<std::string> extension_ime_ids; |
| 932 extension_ime_ids.push_back(ext1_id); | 943 extension_ime_ids.push_back(ext1_id); |
| 933 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 944 manager()->SetEnabledExtensionImes(&extension_ime_ids); |
| 934 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 945 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 935 | 946 |
| 936 { | 947 { |
| 937 scoped_ptr<InputMethodDescriptors> methods( | 948 scoped_ptr<InputMethodDescriptors> methods( |
| 938 manager_->GetActiveInputMethods()); | 949 manager()->GetActiveInputMethods()); |
| 939 ASSERT_EQ(2U, methods->size()); | 950 ASSERT_EQ(2U, methods->size()); |
| 940 // Ext IMEs should be at the end of the list. | 951 // Ext IMEs should be at the end of the list. |
| 941 EXPECT_EQ(ext1_id, methods->at(1).id()); | 952 EXPECT_EQ(ext1_id, methods->at(1).id()); |
| 942 } | 953 } |
| 943 | 954 |
| 944 const std::string ext2_id = | 955 const std::string ext2_id = |
| 945 extension_ime_util::GetInputMethodID("cafebabe", "engine_id"); | 956 extension_ime_util::GetInputMethodID("cafebabe", "engine_id"); |
| 946 const InputMethodDescriptor descriptor2(ext2_id, | 957 const InputMethodDescriptor descriptor2(ext2_id, |
| 947 "cafebabe input method", | 958 "cafebabe input method", |
| 948 layouts, | 959 layouts, |
| 949 languages, | 960 languages, |
| 950 false, // is_login_keyboard | 961 false, // is_login_keyboard |
| 951 GURL(), | 962 GURL(), |
| 952 GURL()); | 963 GURL()); |
| 953 MockInputMethodEngine engine2(descriptor2); | 964 MockInputMethodEngine engine2(descriptor2); |
| 954 manager_->AddInputMethodExtension(ext2_id, &engine2); | 965 manager()->AddInputMethodExtension(ext2_id, &engine2); |
| 955 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 966 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 956 | 967 |
| 957 extension_ime_ids.push_back(ext2_id); | 968 extension_ime_ids.push_back(ext2_id); |
| 958 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 969 manager()->SetEnabledExtensionImes(&extension_ime_ids); |
| 959 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 970 EXPECT_EQ(3U, manager()->GetNumActiveInputMethods()); |
| 960 { | 971 { |
| 961 scoped_ptr<InputMethodDescriptors> methods( | 972 scoped_ptr<InputMethodDescriptors> methods( |
| 962 manager_->GetActiveInputMethods()); | 973 manager()->GetActiveInputMethods()); |
| 963 ASSERT_EQ(3U, methods->size()); | 974 ASSERT_EQ(3U, methods->size()); |
| 964 // Ext IMEs should be at the end of the list. | 975 // Ext IMEs should be at the end of the list. |
| 965 EXPECT_EQ(ext1_id, methods->at(1).id()); | 976 EXPECT_EQ(ext1_id, methods->at(1).id()); |
| 966 EXPECT_EQ(ext2_id, methods->at(2).id()); | 977 EXPECT_EQ(ext2_id, methods->at(2).id()); |
| 967 } | 978 } |
| 968 | 979 |
| 969 // Remove them. | 980 // Remove them. |
| 970 manager_->RemoveInputMethodExtension(ext1_id); | 981 manager()->RemoveInputMethodExtension(ext1_id); |
| 971 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 982 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 972 manager_->RemoveInputMethodExtension(ext2_id); | 983 manager()->RemoveInputMethodExtension(ext2_id); |
| 973 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 984 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 974 } | 985 } |
| 975 | 986 |
| 976 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 987 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
| 977 TestObserver observer; | 988 TestObserver observer; |
| 978 InitComponentExtension(); | 989 InitComponentExtension(); |
| 979 manager_->AddObserver(&observer); | 990 manager()->AddObserver(&observer); |
| 980 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 991 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 981 std::vector<std::string> ids; | 992 std::vector<std::string> ids; |
| 982 ids.push_back("xkb:us::eng"); | 993 ids.push_back("xkb:us::eng"); |
| 983 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 994 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 984 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 995 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 985 EXPECT_EQ(1, observer.input_method_changed_count_); | 996 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 986 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 997 EXPECT_EQ(ids[0], manager()->GetCurrentInputMethod().id()); |
| 987 EXPECT_EQ("us", xkeyboard_->last_layout_); | 998 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 988 | 999 |
| 989 // Add an Extension IME. | 1000 // Add an Extension IME. |
| 990 std::vector<std::string> layouts; | 1001 std::vector<std::string> layouts; |
| 991 layouts.push_back("us(dvorak)"); | 1002 layouts.push_back("us(dvorak)"); |
| 992 std::vector<std::string> languages; | 1003 std::vector<std::string> languages; |
| 993 languages.push_back("en-US"); | 1004 languages.push_back("en-US"); |
| 994 | 1005 |
| 995 const std::string ext_id = | 1006 const std::string ext_id = |
| 996 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 1007 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
| 997 const InputMethodDescriptor descriptor(ext_id, | 1008 const InputMethodDescriptor descriptor(ext_id, |
| 998 "deadbeef input method", | 1009 "deadbeef input method", |
| 999 layouts, | 1010 layouts, |
| 1000 languages, | 1011 languages, |
| 1001 false, // is_login_keyboard | 1012 false, // is_login_keyboard |
| 1002 GURL(), | 1013 GURL(), |
| 1003 GURL()); | 1014 GURL()); |
| 1004 MockInputMethodEngine engine(descriptor); | 1015 MockInputMethodEngine engine(descriptor); |
| 1005 manager_->AddInputMethodExtension(ext_id, &engine); | 1016 manager()->AddInputMethodExtension(ext_id, &engine); |
| 1006 | 1017 |
| 1007 // Extension IME is not enabled by default. | 1018 // Extension IME is not enabled by default. |
| 1008 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1019 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 1009 EXPECT_EQ(1, observer.input_method_changed_count_); | 1020 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 1010 | 1021 |
| 1011 std::vector<std::string> extension_ime_ids; | 1022 std::vector<std::string> extension_ime_ids; |
| 1012 extension_ime_ids.push_back(ext_id); | 1023 extension_ime_ids.push_back(ext_id); |
| 1013 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 1024 manager()->SetEnabledExtensionImes(&extension_ime_ids); |
| 1014 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1025 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 1015 | 1026 |
| 1016 // Switch to the IME. | 1027 // Switch to the IME. |
| 1017 manager_->SwitchToNextInputMethod(); | 1028 manager()->SwitchToNextInputMethod(); |
| 1018 EXPECT_EQ(3, observer.input_method_changed_count_); | 1029 EXPECT_EQ(3, observer.input_method_changed_count_); |
| 1019 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1030 EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id()); |
| 1020 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 1031 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 1021 | 1032 |
| 1022 // Lock the screen. This is for crosbug.com/27049. | 1033 // Lock the screen. This is for crosbug.com/27049. |
| 1023 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 1034 manager()->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
| 1024 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME | 1035 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); // Qwerty. No Ext. IME |
| 1025 EXPECT_EQ("xkb:us::eng", | 1036 EXPECT_EQ("xkb:us::eng", manager()->GetCurrentInputMethod().id()); |
| 1026 manager_->GetCurrentInputMethod().id()); | |
| 1027 EXPECT_EQ("us", xkeyboard_->last_layout_); | 1037 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 1028 | 1038 |
| 1029 // Unlock the screen. | 1039 // Unlock the screen. |
| 1030 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1040 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1031 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1041 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 1032 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1042 EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id()); |
| 1033 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 1043 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 1034 { | 1044 { |
| 1035 // This is for crosbug.com/27052. | 1045 // This is for crosbug.com/27052. |
| 1036 scoped_ptr<InputMethodDescriptors> methods( | 1046 scoped_ptr<InputMethodDescriptors> methods( |
| 1037 manager_->GetActiveInputMethods()); | 1047 manager()->GetActiveInputMethods()); |
| 1038 ASSERT_EQ(2U, methods->size()); | 1048 ASSERT_EQ(2U, methods->size()); |
| 1039 // Ext. IMEs should be at the end of the list. | 1049 // Ext. IMEs should be at the end of the list. |
| 1040 EXPECT_EQ(ext_id, methods->at(1).id()); | 1050 EXPECT_EQ(ext_id, methods->at(1).id()); |
| 1041 } | 1051 } |
| 1042 manager_->RemoveObserver(&observer); | 1052 manager()->RemoveObserver(&observer); |
| 1043 } | 1053 } |
| 1044 | 1054 |
| 1045 TEST_F(InputMethodManagerImplTest, | 1055 TEST_F(InputMethodManagerImplTest, |
| 1046 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { | 1056 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { |
| 1047 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1057 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1048 std::vector<std::string> ids; | 1058 std::vector<std::string> ids; |
| 1049 ids.push_back(kNaclMozcUsId); | 1059 ids.push_back(kNaclMozcUsId); |
| 1050 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1060 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1051 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1061 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 1052 manager_->ChangeInputMethod(kNaclMozcUsId); | 1062 manager()->ChangeInputMethod(kNaclMozcUsId); |
| 1053 | 1063 |
| 1054 InitComponentExtension(); | 1064 InitComponentExtension(); |
| 1055 EXPECT_EQ(kNaclMozcUsId, manager_->GetCurrentInputMethod().id()); | 1065 EXPECT_EQ(kNaclMozcUsId, manager()->GetCurrentInputMethod().id()); |
| 1056 } | 1066 } |
| 1057 | 1067 |
| 1058 TEST_F(InputMethodManagerImplTest, | 1068 TEST_F(InputMethodManagerImplTest, |
| 1059 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { | 1069 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { |
| 1060 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1070 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1061 std::vector<std::string> ids; | 1071 std::vector<std::string> ids; |
| 1062 ids.push_back(kNaclMozcUsId); | 1072 ids.push_back(kNaclMozcUsId); |
| 1063 ids.push_back(kNaclMozcJpId); | 1073 ids.push_back(kNaclMozcJpId); |
| 1064 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1074 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1065 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1075 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 1066 manager_->ChangeInputMethod(kNaclMozcUsId); | 1076 manager()->ChangeInputMethod(kNaclMozcUsId); |
| 1067 manager_->ChangeInputMethod(kNaclMozcJpId); | 1077 manager()->ChangeInputMethod(kNaclMozcJpId); |
| 1068 | 1078 |
| 1069 InitComponentExtension(); | 1079 InitComponentExtension(); |
| 1070 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1080 EXPECT_EQ(kNaclMozcJpId, manager()->GetCurrentInputMethod().id()); |
| 1071 } | 1081 } |
| 1072 | 1082 |
| 1073 TEST_F(InputMethodManagerImplTest, | 1083 TEST_F(InputMethodManagerImplTest, |
| 1074 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | 1084 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { |
| 1075 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1085 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1076 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1086 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1077 ime_list_[0].id, | 1087 ime_list_[0].id, |
| 1078 ime_list_[0].engines[0].engine_id); | 1088 ime_list_[0].engines[0].engine_id); |
| 1079 std::vector<std::string> ids; | 1089 std::vector<std::string> ids; |
| 1080 ids.push_back(ext_id); | 1090 ids.push_back(ext_id); |
| 1081 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1091 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1082 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1092 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 1083 manager_->ChangeInputMethod(ext_id); | 1093 manager()->ChangeInputMethod(ext_id); |
| 1084 | 1094 |
| 1085 InitComponentExtension(); | 1095 InitComponentExtension(); |
| 1086 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1096 EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id()); |
| 1087 } | 1097 } |
| 1088 | 1098 |
| 1089 TEST_F(InputMethodManagerImplTest, | 1099 TEST_F(InputMethodManagerImplTest, |
| 1090 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { | 1100 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { |
| 1091 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1101 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1092 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1102 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1093 ime_list_[0].id, | 1103 ime_list_[0].id, |
| 1094 ime_list_[0].engines[0].engine_id); | 1104 ime_list_[0].engines[0].engine_id); |
| 1095 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1105 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1096 ime_list_[1].id, | 1106 ime_list_[1].id, |
| 1097 ime_list_[1].engines[0].engine_id); | 1107 ime_list_[1].engines[0].engine_id); |
| 1098 std::vector<std::string> ids; | 1108 std::vector<std::string> ids; |
| 1099 ids.push_back(ext_id1); | 1109 ids.push_back(ext_id1); |
| 1100 ids.push_back(ext_id2); | 1110 ids.push_back(ext_id2); |
| 1101 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1111 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1102 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1112 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 1103 manager_->ChangeInputMethod(ext_id1); | 1113 manager()->ChangeInputMethod(ext_id1); |
| 1104 manager_->ChangeInputMethod(ext_id2); | 1114 manager()->ChangeInputMethod(ext_id2); |
| 1105 | 1115 |
| 1106 InitComponentExtension(); | 1116 InitComponentExtension(); |
| 1107 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1117 EXPECT_EQ(ext_id2, manager()->GetCurrentInputMethod().id()); |
| 1108 } | 1118 } |
| 1109 | 1119 |
| 1110 TEST_F(InputMethodManagerImplTest, | 1120 TEST_F(InputMethodManagerImplTest, |
| 1111 ChangeInputMethod_ComponenteExtensionOneIME) { | 1121 ChangeInputMethod_ComponenteExtensionOneIME) { |
| 1112 InitComponentExtension(); | 1122 InitComponentExtension(); |
| 1113 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1123 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1114 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1124 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1115 ime_list_[0].id, | 1125 ime_list_[0].id, |
| 1116 ime_list_[0].engines[0].engine_id); | 1126 ime_list_[0].engines[0].engine_id); |
| 1117 std::vector<std::string> ids; | 1127 std::vector<std::string> ids; |
| 1118 ids.push_back(ext_id); | 1128 ids.push_back(ext_id); |
| 1119 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1129 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1120 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1130 EXPECT_EQ(1U, manager()->GetNumActiveInputMethods()); |
| 1121 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1131 EXPECT_EQ(ext_id, manager()->GetCurrentInputMethod().id()); |
| 1122 } | 1132 } |
| 1123 | 1133 |
| 1124 TEST_F(InputMethodManagerImplTest, | 1134 TEST_F(InputMethodManagerImplTest, |
| 1125 ChangeInputMethod_ComponenteExtensionTwoIME) { | 1135 ChangeInputMethod_ComponenteExtensionTwoIME) { |
| 1126 InitComponentExtension(); | 1136 InitComponentExtension(); |
| 1127 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1137 manager()->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1128 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1138 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1129 ime_list_[0].id, | 1139 ime_list_[0].id, |
| 1130 ime_list_[0].engines[0].engine_id); | 1140 ime_list_[0].engines[0].engine_id); |
| 1131 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1141 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1132 ime_list_[1].id, | 1142 ime_list_[1].id, |
| 1133 ime_list_[1].engines[0].engine_id); | 1143 ime_list_[1].engines[0].engine_id); |
| 1134 std::vector<std::string> ids; | 1144 std::vector<std::string> ids; |
| 1135 ids.push_back(ext_id1); | 1145 ids.push_back(ext_id1); |
| 1136 ids.push_back(ext_id2); | 1146 ids.push_back(ext_id2); |
| 1137 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1147 EXPECT_TRUE(manager()->EnableInputMethods(ids)); |
| 1138 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1148 EXPECT_EQ(2U, manager()->GetNumActiveInputMethods()); |
| 1139 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1149 EXPECT_EQ(ext_id1, manager()->GetCurrentInputMethod().id()); |
| 1140 manager_->ChangeInputMethod(ext_id2); | 1150 manager()->ChangeInputMethod(ext_id2); |
| 1141 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1151 EXPECT_EQ(ext_id2, manager()->GetCurrentInputMethod().id()); |
| 1142 } | 1152 } |
| 1143 | 1153 |
| 1144 } // namespace input_method | 1154 } // namespace input_method |
| 1145 } // namespace chromeos | 1155 } // namespace chromeos |
| OLD | NEW |