| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 60 |
| 61 virtual void SetUp() OVERRIDE { | 61 virtual void SetUp() OVERRIDE { |
| 62 delegate_ = new FakeInputMethodDelegate(); | 62 delegate_ = new FakeInputMethodDelegate(); |
| 63 manager_.reset(new InputMethodManagerImpl( | 63 manager_.reset(new InputMethodManagerImpl( |
| 64 scoped_ptr<InputMethodDelegate>(delegate_))); | 64 scoped_ptr<InputMethodDelegate>(delegate_))); |
| 65 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); |
| 65 candidate_window_controller_ = new MockCandidateWindowController; | 66 candidate_window_controller_ = new MockCandidateWindowController; |
| 66 manager_->SetCandidateWindowControllerForTesting( | 67 manager_->SetCandidateWindowControllerForTesting( |
| 67 candidate_window_controller_); | 68 candidate_window_controller_); |
| 68 xkeyboard_ = new FakeXKeyboard; | 69 xkeyboard_ = new FakeXKeyboard; |
| 69 manager_->SetXKeyboardForTesting(xkeyboard_); | 70 manager_->SetXKeyboardForTesting(xkeyboard_); |
| 70 mock_engine_handler_.reset(new MockIMEEngineHandler()); | 71 mock_engine_handler_.reset(new MockIMEEngineHandler()); |
| 71 IMEBridge::Initialize(); | 72 IMEBridge::Initialize(); |
| 72 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); | 73 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
| 73 | 74 |
| 74 ime_list_.clear(); | 75 ime_list_.clear(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 candidate_window_controller_->NotifyCandidateWindowOpened(); | 227 candidate_window_controller_->NotifyCandidateWindowOpened(); |
| 227 EXPECT_EQ(2, observer.candidate_window_opened_count_); | 228 EXPECT_EQ(2, observer.candidate_window_opened_count_); |
| 228 candidate_window_controller_->NotifyCandidateWindowClosed(); | 229 candidate_window_controller_->NotifyCandidateWindowClosed(); |
| 229 EXPECT_EQ(2, observer.candidate_window_closed_count_); | 230 EXPECT_EQ(2, observer.candidate_window_closed_count_); |
| 230 manager_->RemoveCandidateWindowObserver(&observer); | 231 manager_->RemoveCandidateWindowObserver(&observer); |
| 231 } | 232 } |
| 232 | 233 |
| 233 TEST_F(InputMethodManagerImplTest, TestObserver) { | 234 TEST_F(InputMethodManagerImplTest, TestObserver) { |
| 234 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is | 235 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is |
| 235 // also for the scenario. | 236 // also for the scenario. |
| 237 std::vector<std::string> keyboard_layouts; |
| 238 keyboard_layouts.push_back("xkb:us::eng"); |
| 239 |
| 236 TestObserver observer; | 240 TestObserver observer; |
| 237 InitComponentExtension(); | 241 InitComponentExtension(); |
| 238 manager_->AddObserver(&observer); | 242 manager_->AddObserver(&observer); |
| 239 EXPECT_EQ(0, observer.input_method_changed_count_); | 243 EXPECT_EQ(0, observer.input_method_changed_count_); |
| 240 manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); | 244 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 241 EXPECT_EQ(1, observer.input_method_changed_count_); | 245 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 242 EXPECT_EQ(1, observer.input_method_property_changed_count_); | 246 EXPECT_EQ(1, observer.input_method_property_changed_count_); |
| 243 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 247 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); |
| 244 EXPECT_FALSE(observer.last_show_message_); | 248 EXPECT_FALSE(observer.last_show_message_); |
| 245 EXPECT_EQ(2, observer.input_method_changed_count_); | 249 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 246 EXPECT_EQ(2, observer.input_method_property_changed_count_); | 250 EXPECT_EQ(2, observer.input_method_property_changed_count_); |
| 247 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 251 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); |
| 248 EXPECT_FALSE(observer.last_show_message_); | 252 EXPECT_FALSE(observer.last_show_message_); |
| 249 | 253 |
| 250 // The observer is always notified even when the same input method ID is | 254 // The observer is always notified even when the same input method ID is |
| (...skipping 25 matching lines...) Expand all Loading... |
| 276 "xkb:us:dvorak:eng"); | 280 "xkb:us:dvorak:eng"); |
| 277 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 281 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 278 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 282 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 279 "xkb:fr::fra"); | 283 "xkb:fr::fra"); |
| 280 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 284 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 281 } | 285 } |
| 282 | 286 |
| 283 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 287 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
| 284 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 288 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
| 285 // ibus_input_method.txt. | 289 // ibus_input_method.txt. |
| 290 std::vector<std::string> keyboard_layouts; |
| 291 |
| 286 InitComponentExtension(); | 292 InitComponentExtension(); |
| 287 manager_->EnableLoginLayouts("en-US", ""); | 293 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 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_->EnableLoginLayouts("ja", ""); // Japanese | 300 manager_->EnableLoginLayouts("ja", keyboard_layouts); // 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_->EnableLoginLayouts("en-US", "xkb:se::swe"); | 306 std::vector<std::string> keyboard_layouts; |
| 307 keyboard_layouts.push_back("xkb:se::swe"); |
| 308 |
| 309 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 301 const std::string im_id = manager_->GetCurrentInputMethod().id(); | 310 const std::string im_id = manager_->GetCurrentInputMethod().id(); |
| 302 EXPECT_EQ("xkb:se::swe", im_id); | 311 EXPECT_EQ("xkb:se::swe", im_id); |
| 303 } | 312 } |
| 304 | 313 |
| 305 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 314 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
| 306 // The physical layout is French. | 315 // The physical layout is French. |
| 307 delegate_->set_hardware_keyboard_layout("xkb:fr::fra"); | 316 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
| 308 manager_->EnableLoginLayouts("en-US", ""); | 317 "xkb:fr::fra"); |
| 318 manager_->EnableLoginLayouts( |
| 319 "en-US", |
| 320 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
| 309 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French | 321 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French |
| 310 // The physical layout is Japanese. | 322 // The physical layout is Japanese. |
| 311 delegate_->set_hardware_keyboard_layout("xkb:jp::jpn"); | 323 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
| 312 manager_->EnableLoginLayouts("ja", ""); | 324 "xkb:jp::jpn"); |
| 325 manager_->EnableLoginLayouts( |
| 326 "ja", |
| 327 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
| 313 // "xkb:us::eng" is not needed, hence 1. | 328 // "xkb:us::eng" is not needed, hence 1. |
| 314 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 329 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 315 | 330 |
| 316 // The physical layout is Russian. | 331 // The physical layout is Russian. |
| 317 delegate_->set_hardware_keyboard_layout("xkb:ru::rus"); | 332 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
| 318 manager_->EnableLoginLayouts("ru", ""); | 333 "xkb:ru::rus"); |
| 334 manager_->EnableLoginLayouts( |
| 335 "ru", |
| 336 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
| 319 // "xkb:us::eng" only. | 337 // "xkb:us::eng" only. |
| 320 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 338 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 321 EXPECT_EQ("xkb:us::eng", manager_->GetActiveInputMethodIds().front()); | 339 EXPECT_EQ("xkb:us::eng", manager_->GetActiveInputMethodIds().front()); |
| 322 } | 340 } |
| 323 | 341 |
| 342 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
| 343 // The physical layouts are French and Hungarian. |
| 344 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
| 345 "xkb:fr::fra,xkb:hu::hun"); |
| 346 manager_->EnableLoginLayouts( |
| 347 "en-US", |
| 348 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
| 349 // 5 + French + Hungarian |
| 350 EXPECT_EQ(7U, manager_->GetNumActiveInputMethods()); |
| 351 } |
| 352 |
| 353 TEST_F(InputMethodManagerImplTest, |
| 354 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
| 355 // The physical layouts are English (US) and Russian. |
| 356 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
| 357 "xkb:us::eng,xkb:ru::rus"); |
| 358 manager_->EnableLoginLayouts( |
| 359 "ru", |
| 360 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
| 361 // xkb:us:eng |
| 362 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 363 } |
| 364 |
| 324 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { | 365 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { |
| 325 manager_->EnableLoginLayouts("ja", ""); // Japanese | 366 std::vector<std::string> keyboard_layouts; |
| 367 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
| 326 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 368 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 327 scoped_ptr<InputMethodDescriptors> methods( | 369 scoped_ptr<InputMethodDescriptors> methods( |
| 328 manager_->GetActiveInputMethods()); | 370 manager_->GetActiveInputMethods()); |
| 329 ASSERT_TRUE(methods.get()); | 371 ASSERT_TRUE(methods.get()); |
| 330 EXPECT_EQ(2U, methods->size()); | 372 EXPECT_EQ(2U, methods->size()); |
| 331 const InputMethodDescriptor* id_to_find = | 373 const InputMethodDescriptor* id_to_find = |
| 332 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 374 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 333 "xkb:us::eng"); | 375 "xkb:us::eng"); |
| 334 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 376 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 335 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 377 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 336 "xkb:jp::jpn"); | 378 "xkb:jp::jpn"); |
| 337 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 379 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); |
| 338 } | 380 } |
| 339 | 381 |
| 340 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 382 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
| 341 // For http://crbug.com/19655#c11 - (8), step 6. | 383 // For http://crbug.com/19655#c11 - (8), step 6. |
| 342 TestObserver observer; | 384 TestObserver observer; |
| 343 manager_->AddObserver(&observer); | 385 manager_->AddObserver(&observer); |
| 344 InitComponentExtension(); | 386 InitComponentExtension(); |
| 345 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 387 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 346 std::vector<std::string> ids; | 388 std::vector<std::string> ids; |
| 347 ids.push_back("xkb:us:dvorak:eng"); | 389 ids.push_back("xkb:us:dvorak:eng"); |
| 348 ids.push_back("xkb:us:colemak:eng"); | 390 ids.push_back("xkb:us:colemak:eng"); |
| 349 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 391 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 350 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 392 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 351 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 393 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
| 352 // called. | 394 // called. |
| 353 EXPECT_EQ(1, observer.input_method_changed_count_); | 395 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 354 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 396 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 355 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 397 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 356 // Disable Dvorak. | 398 // Disable Dvorak. |
| 357 ids.erase(ids.begin()); | 399 ids.erase(ids.begin()); |
| 358 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 400 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 359 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 401 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 360 EXPECT_EQ(2, observer.input_method_changed_count_); | 402 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 361 EXPECT_EQ(ids[0], // colemak | 403 EXPECT_EQ(ids[0], // colemak |
| 362 manager_->GetCurrentInputMethod().id()); | 404 manager_->GetCurrentInputMethod().id()); |
| 363 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 405 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 364 manager_->RemoveObserver(&observer); | 406 manager_->RemoveObserver(&observer); |
| 365 } | 407 } |
| 366 | 408 |
| 367 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 409 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
| 368 // For http://crbug.com/19655#c11 - (9). | 410 // For http://crbug.com/19655#c11 - (9). |
| 369 TestObserver observer; | 411 TestObserver observer; |
| 370 manager_->AddObserver(&observer); | 412 manager_->AddObserver(&observer); |
| 371 InitComponentExtension(); | 413 InitComponentExtension(); |
| 372 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 414 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 373 std::vector<std::string> ids; | 415 std::vector<std::string> ids; |
| 374 ids.push_back("xkb:us::eng"); | 416 ids.push_back("xkb:us::eng"); |
| 375 ids.push_back("xkb:us:dvorak:eng"); | 417 ids.push_back("xkb:us:dvorak:eng"); |
| 376 ids.push_back("xkb:us:colemak:eng"); | 418 ids.push_back("xkb:us:colemak:eng"); |
| 377 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 419 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 378 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 420 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
| 379 EXPECT_EQ(1, observer.input_method_changed_count_); | 421 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 380 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 422 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 381 EXPECT_EQ("us", xkeyboard_->last_layout_); | 423 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 382 // Switch to Dvorak. | 424 // Switch to Dvorak. |
| 383 manager_->SwitchToNextInputMethod(); | 425 manager_->SwitchToNextInputMethod(); |
| 384 EXPECT_EQ(2, observer.input_method_changed_count_); | 426 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 385 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 427 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); |
| 386 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 428 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 387 // Disable Dvorak. | 429 // Disable Dvorak. |
| 388 ids.erase(ids.begin() + 1); | 430 ids.erase(ids.begin() + 1); |
| 389 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 431 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 390 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 432 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 391 EXPECT_EQ(3, observer.input_method_changed_count_); | 433 EXPECT_EQ(3, observer.input_method_changed_count_); |
| 392 EXPECT_EQ(ids[0], // US Qwerty | 434 EXPECT_EQ(ids[0], // US Qwerty |
| 393 manager_->GetCurrentInputMethod().id()); | 435 manager_->GetCurrentInputMethod().id()); |
| 394 EXPECT_EQ("us", xkeyboard_->last_layout_); | 436 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 395 manager_->RemoveObserver(&observer); | 437 manager_->RemoveObserver(&observer); |
| 396 } | 438 } |
| 397 | 439 |
| 398 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 440 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
| 399 // For http://crbug.com/19655#c11 - (10). | 441 // For http://crbug.com/19655#c11 - (10). |
| 400 TestObserver observer; | 442 TestObserver observer; |
| 401 manager_->AddObserver(&observer); | 443 manager_->AddObserver(&observer); |
| 402 InitComponentExtension(); | 444 InitComponentExtension(); |
| 403 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 445 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 404 std::vector<std::string> ids; | 446 std::vector<std::string> ids; |
| 405 ids.push_back("xkb:us:dvorak:eng"); | 447 ids.push_back("xkb:us:dvorak:eng"); |
| 406 ids.push_back(kNaclMozcUsId); | 448 ids.push_back(kNaclMozcUsId); |
| 407 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 449 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 408 EXPECT_EQ(1, observer.input_method_changed_count_); | 450 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 409 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 451 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 410 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 452 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 411 // Switch to Mozc | 453 // Switch to Mozc |
| 412 manager_->SwitchToNextInputMethod(); | 454 manager_->SwitchToNextInputMethod(); |
| 413 EXPECT_EQ(2, observer.input_method_changed_count_); | 455 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 414 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 456 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); |
| 415 EXPECT_EQ("us", xkeyboard_->last_layout_); | 457 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 416 // Disable Mozc. | 458 // Disable Mozc. |
| 417 ids.erase(ids.begin() + 1); | 459 ids.erase(ids.begin() + 1); |
| 418 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 460 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 419 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 461 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 420 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 462 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 421 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 463 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 422 } | 464 } |
| 423 | 465 |
| 424 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 466 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
| 425 // For http://crbug.com/19655#c11 - (11). | 467 // For http://crbug.com/19655#c11 - (11). |
| 426 TestObserver observer; | 468 TestObserver observer; |
| 427 manager_->AddObserver(&observer); | 469 manager_->AddObserver(&observer); |
| 428 InitComponentExtension(); | 470 InitComponentExtension(); |
| 429 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 471 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 430 std::vector<std::string> ids; | 472 std::vector<std::string> ids; |
| 431 ids.push_back("xkb:us:dvorak:eng"); | 473 ids.push_back("xkb:us:dvorak:eng"); |
| 432 ids.push_back(kNaclMozcUsId); | 474 ids.push_back(kNaclMozcUsId); |
| 433 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 475 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 434 EXPECT_EQ(1, observer.input_method_changed_count_); | 476 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 435 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 477 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 436 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 478 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 437 | 479 |
| 438 // Disable Dvorak. | 480 // Disable Dvorak. |
| 439 ids.erase(ids.begin()); | 481 ids.erase(ids.begin()); |
| 440 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 482 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 441 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 483 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 442 EXPECT_EQ(ids[0], // Mozc | 484 EXPECT_EQ(ids[0], // Mozc |
| 443 manager_->GetCurrentInputMethod().id()); | 485 manager_->GetCurrentInputMethod().id()); |
| 444 EXPECT_EQ("us", xkeyboard_->last_layout_); | 486 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 445 manager_->RemoveObserver(&observer); | 487 manager_->RemoveObserver(&observer); |
| 446 } | 488 } |
| 447 | 489 |
| 448 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 490 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
| 449 TestObserver observer; | 491 TestObserver observer; |
| 450 manager_->AddObserver(&observer); | 492 manager_->AddObserver(&observer); |
| 451 InitComponentExtension(); | 493 InitComponentExtension(); |
| 452 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 494 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 453 std::vector<std::string> ids; | 495 std::vector<std::string> ids; |
| 454 ids.push_back(kExt2Engine1Id); | 496 ids.push_back(kExt2Engine1Id); |
| 455 ids.push_back("mozc-dv"); | 497 ids.push_back("mozc-dv"); |
| 456 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 498 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 457 EXPECT_EQ(1, observer.input_method_changed_count_); | 499 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 458 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 500 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 459 EXPECT_EQ("us", xkeyboard_->last_layout_); | 501 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 460 manager_->RemoveObserver(&observer); | 502 manager_->RemoveObserver(&observer); |
| 461 } | 503 } |
| 462 | 504 |
| 463 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 505 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
| 464 TestObserver observer; | 506 TestObserver observer; |
| 465 manager_->AddObserver(&observer); | 507 manager_->AddObserver(&observer); |
| 466 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 508 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 467 std::vector<std::string> ids; | 509 std::vector<std::string> ids; |
| 468 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 510 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
| 469 ids.push_back("unknown-super-cool-ime"); | 511 ids.push_back("unknown-super-cool-ime"); |
| 470 EXPECT_FALSE(manager_->EnableInputMethods(ids)); | 512 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); |
| 471 | 513 |
| 472 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this | 514 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this |
| 473 // case? | 515 // case? |
| 474 EXPECT_EQ(0, observer.input_method_changed_count_); | 516 EXPECT_EQ(0, observer.input_method_changed_count_); |
| 475 | 517 |
| 476 manager_->RemoveObserver(&observer); | 518 manager_->RemoveObserver(&observer); |
| 477 } | 519 } |
| 478 | 520 |
| 479 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { | 521 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { |
| 480 // For http://crbug.com/19655#c11 - (14). | 522 // For http://crbug.com/19655#c11 - (14). |
| 481 TestObserver observer; | 523 TestObserver observer; |
| 482 manager_->AddObserver(&observer); | 524 manager_->AddObserver(&observer); |
| 483 InitComponentExtension(); | 525 InitComponentExtension(); |
| 484 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 526 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 485 std::vector<std::string> ids; | 527 std::vector<std::string> ids; |
| 486 ids.push_back("xkb:us::eng"); | 528 ids.push_back("xkb:us::eng"); |
| 487 ids.push_back("xkb:us:dvorak:eng"); | 529 ids.push_back("xkb:us:dvorak:eng"); |
| 488 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 530 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 489 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 531 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 490 EXPECT_EQ(1, observer.input_method_changed_count_); | 532 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 491 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 533 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 492 EXPECT_EQ("us", xkeyboard_->last_layout_); | 534 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 493 | 535 |
| 494 // Switch to Dvorak. | 536 // Switch to Dvorak. |
| 495 manager_->SwitchToNextInputMethod(); | 537 manager_->SwitchToNextInputMethod(); |
| 496 EXPECT_EQ(2, observer.input_method_changed_count_); | 538 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 497 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 539 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); |
| 498 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 540 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 520 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 562 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
| 521 // For http://crbug.com/19655#c11 - (15). | 563 // For http://crbug.com/19655#c11 - (15). |
| 522 TestObserver observer; | 564 TestObserver observer; |
| 523 manager_->AddObserver(&observer); | 565 manager_->AddObserver(&observer); |
| 524 InitComponentExtension(); | 566 InitComponentExtension(); |
| 525 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 567 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 526 std::vector<std::string> ids; | 568 std::vector<std::string> ids; |
| 527 ids.push_back("xkb:us:dvorak:eng"); | 569 ids.push_back("xkb:us:dvorak:eng"); |
| 528 ids.push_back(kExt2Engine2Id); | 570 ids.push_back(kExt2Engine2Id); |
| 529 ids.push_back(kExt2Engine1Id); | 571 ids.push_back(kExt2Engine1Id); |
| 530 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 572 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 531 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 573 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
| 532 EXPECT_EQ(1, observer.input_method_changed_count_); | 574 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 533 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 575 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 534 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 576 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 535 | 577 |
| 536 // Switch to Mozc. | 578 // Switch to Mozc. |
| 537 manager_->SwitchToNextInputMethod(); | 579 manager_->SwitchToNextInputMethod(); |
| 538 EXPECT_EQ(2, observer.input_method_changed_count_); | 580 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 539 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 581 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); |
| 540 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 582 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 561 | 603 |
| 562 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 604 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
| 563 // For http://crbug.com/19655#c11 - (8), step 7-11. | 605 // For http://crbug.com/19655#c11 - (8), step 7-11. |
| 564 InitComponentExtension(); | 606 InitComponentExtension(); |
| 565 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 607 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 566 std::vector<std::string> ids; | 608 std::vector<std::string> ids; |
| 567 ids.push_back("xkb:us:dvorak:eng"); | 609 ids.push_back("xkb:us:dvorak:eng"); |
| 568 ids.push_back("xkb:us:colemak:eng"); | 610 ids.push_back("xkb:us:colemak:eng"); |
| 569 ids.push_back(kNaclMozcJpId); | 611 ids.push_back(kNaclMozcJpId); |
| 570 ids.push_back(kNaclMozcUsId); | 612 ids.push_back(kNaclMozcUsId); |
| 571 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 613 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 572 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); | 614 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); |
| 573 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 615 EXPECT_EQ(1, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 574 // See input_methods.txt for an expected XKB layout name. | 616 // See input_methods.txt for an expected XKB layout name. |
| 575 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 617 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 576 manager_->SwitchToNextInputMethod(); | 618 manager_->SwitchToNextInputMethod(); |
| 577 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 619 EXPECT_EQ(2, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 578 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 620 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 579 manager_->SwitchToNextInputMethod(); | 621 manager_->SwitchToNextInputMethod(); |
| 580 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 622 EXPECT_EQ(3, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 581 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 623 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 582 manager_->SwitchToNextInputMethod(); | 624 manager_->SwitchToNextInputMethod(); |
| 583 EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 625 EXPECT_EQ(4, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 584 EXPECT_EQ("us", xkeyboard_->last_layout_); | 626 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 585 manager_->SwitchToNextInputMethod(); | 627 manager_->SwitchToNextInputMethod(); |
| 586 EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 628 EXPECT_EQ(5, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 587 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 629 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 588 // Disable Dvorak. | 630 // Disable Dvorak. |
| 589 ids.erase(ids.begin()); | 631 ids.erase(ids.begin()); |
| 590 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 632 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 591 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 633 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
| 592 EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_); | 634 EXPECT_EQ(6, xkeyboard_->set_current_keyboard_layout_by_name_count_); |
| 593 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 635 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
| 594 } | 636 } |
| 595 | 637 |
| 596 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { | 638 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { |
| 597 const std::string kKey = "key"; | 639 const std::string kKey = "key"; |
| 598 InputMethodPropertyList property_list; | 640 InputMethodPropertyList property_list; |
| 599 property_list.push_back(InputMethodProperty(kKey, "label", false, false)); | 641 property_list.push_back(InputMethodProperty(kKey, "label", false, false)); |
| 600 manager_->SetCurrentInputMethodProperties(property_list); | 642 manager_->SetCurrentInputMethodProperties(property_list); |
| 601 | 643 |
| 602 manager_->ActivateInputMethodProperty(kKey); | 644 manager_->ActivateInputMethodProperty(kKey); |
| 603 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 645 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
| 604 | 646 |
| 605 // Key2 is not registered, so activated property should not be changed. | 647 // Key2 is not registered, so activated property should not be changed. |
| 606 manager_->ActivateInputMethodProperty("key2"); | 648 manager_->ActivateInputMethodProperty("key2"); |
| 607 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 649 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
| 608 } | 650 } |
| 609 | 651 |
| 610 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { | 652 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
| 611 InitComponentExtension(); | 653 InitComponentExtension(); |
| 612 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 654 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
| 613 | 655 |
| 614 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 656 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 615 std::vector<std::string> ids; | 657 std::vector<std::string> ids; |
| 616 ids.push_back("xkb:us::eng"); | 658 ids.push_back("xkb:us::eng"); |
| 617 ids.push_back(kNaclMozcUsId); | 659 ids.push_back(kNaclMozcUsId); |
| 618 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 660 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 619 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 661 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 620 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 662 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
| 621 manager_->ChangeInputMethod(kNaclMozcUsId); | 663 manager_->ChangeInputMethod(kNaclMozcUsId); |
| 622 | 664 |
| 623 InputMethodPropertyList current_property_list; | 665 InputMethodPropertyList current_property_list; |
| 624 current_property_list.push_back(InputMethodProperty("key", | 666 current_property_list.push_back(InputMethodProperty("key", |
| 625 "label", | 667 "label", |
| 626 false, | 668 false, |
| 627 false)); | 669 false)); |
| 628 manager_->SetCurrentInputMethodProperties(current_property_list); | 670 manager_->SetCurrentInputMethodProperties(current_property_list); |
| 629 | 671 |
| 630 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); | 672 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); |
| 631 EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); | 673 EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); |
| 632 | 674 |
| 633 manager_->ChangeInputMethod("xkb:us::eng"); | 675 manager_->ChangeInputMethod("xkb:us::eng"); |
| 634 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 676 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
| 635 } | 677 } |
| 636 | 678 |
| 637 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { | 679 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
| 638 InitComponentExtension(); | 680 InitComponentExtension(); |
| 639 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 681 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
| 640 | 682 |
| 641 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 683 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 642 std::vector<std::string> ids; | 684 std::vector<std::string> ids; |
| 643 ids.push_back(kNaclMozcUsId); // Japanese | 685 ids.push_back(kNaclMozcUsId); // Japanese |
| 644 ids.push_back(kExt2Engine1Id); // T-Chinese | 686 ids.push_back(kExt2Engine1Id); // T-Chinese |
| 645 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 687 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 646 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 688 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 647 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); | 689 EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
| 648 | 690 |
| 649 InputMethodPropertyList current_property_list; | 691 InputMethodPropertyList current_property_list; |
| 650 current_property_list.push_back(InputMethodProperty("key-mozc", | 692 current_property_list.push_back(InputMethodProperty("key-mozc", |
| 651 "label", | 693 "label", |
| 652 false, | 694 false, |
| 653 false)); | 695 false)); |
| 654 manager_->SetCurrentInputMethodProperties(current_property_list); | 696 manager_->SetCurrentInputMethodProperties(current_property_list); |
| 655 | 697 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 669 manager_->SetCurrentInputMethodProperties(current_property_list); | 711 manager_->SetCurrentInputMethodProperties(current_property_list); |
| 670 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); | 712 ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); |
| 671 EXPECT_EQ("key-chewing", | 713 EXPECT_EQ("key-chewing", |
| 672 manager_->GetCurrentInputMethodProperties().at(0).key); | 714 manager_->GetCurrentInputMethodProperties().at(0).key); |
| 673 } | 715 } |
| 674 | 716 |
| 675 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 717 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
| 676 TestObserver observer; | 718 TestObserver observer; |
| 677 manager_->AddObserver(&observer); | 719 manager_->AddObserver(&observer); |
| 678 InitComponentExtension(); | 720 InitComponentExtension(); |
| 721 std::vector<std::string> keyboard_layouts; |
| 722 keyboard_layouts.push_back("xkb:us::eng"); |
| 679 // For http://crbug.com/19655#c11 - (1) | 723 // For http://crbug.com/19655#c11 - (1) |
| 680 manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); | 724 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 681 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 725 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
| 682 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 726 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| 683 EXPECT_EQ("us", xkeyboard_->last_layout_); | 727 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 684 manager_->SwitchToNextInputMethod(); | 728 manager_->SwitchToNextInputMethod(); |
| 685 EXPECT_TRUE(observer.last_show_message_); | 729 EXPECT_TRUE(observer.last_show_message_); |
| 686 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 730 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); |
| 687 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 731 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 688 manager_->SwitchToNextInputMethod(); | 732 manager_->SwitchToNextInputMethod(); |
| 689 EXPECT_TRUE(observer.last_show_message_); | 733 EXPECT_TRUE(observer.last_show_message_); |
| 690 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 734 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 708 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 752 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
| 709 TestObserver observer; | 753 TestObserver observer; |
| 710 manager_->AddObserver(&observer); | 754 manager_->AddObserver(&observer); |
| 711 InitComponentExtension(); | 755 InitComponentExtension(); |
| 712 | 756 |
| 713 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 757 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 714 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 758 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 715 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 759 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 716 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 760 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 717 | 761 |
| 718 manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); | 762 std::vector<std::string> keyboard_layouts; |
| 763 keyboard_layouts.push_back("xkb:us::eng"); |
| 764 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 719 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 765 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
| 720 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 766 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| 721 EXPECT_EQ("us", xkeyboard_->last_layout_); | 767 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 722 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 768 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
| 723 EXPECT_TRUE(observer.last_show_message_); | 769 EXPECT_TRUE(observer.last_show_message_); |
| 724 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 770 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); |
| 725 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 771 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
| 726 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 772 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 727 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 773 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 728 EXPECT_TRUE(observer.last_show_message_); | 774 EXPECT_TRUE(observer.last_show_message_); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 manager_->AddObserver(&observer); | 812 manager_->AddObserver(&observer); |
| 767 InitComponentExtension(); | 813 InitComponentExtension(); |
| 768 | 814 |
| 769 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 815 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 770 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 816 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 771 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 817 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 772 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 818 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 773 | 819 |
| 774 std::vector<std::string> ids; | 820 std::vector<std::string> ids; |
| 775 ids.push_back("xkb:us:dvorak:eng"); | 821 ids.push_back("xkb:us:dvorak:eng"); |
| 776 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 822 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 777 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 823 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 778 | 824 |
| 779 // Ctrl+Space accelerator should not be consumed if there is only one active | 825 // Ctrl+Space accelerator should not be consumed if there is only one active |
| 780 // input method. | 826 // input method. |
| 781 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 827 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 782 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 828 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 783 | 829 |
| 784 manager_->RemoveObserver(&observer); | 830 manager_->RemoveObserver(&observer); |
| 785 } | 831 } |
| 786 | 832 |
| 787 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 833 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
| 788 TestObserver observer; | 834 TestObserver observer; |
| 789 manager_->AddObserver(&observer); | 835 manager_->AddObserver(&observer); |
| 790 InitComponentExtension(); | 836 InitComponentExtension(); |
| 791 manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); | 837 std::vector<std::string> keyboard_layouts; |
| 838 keyboard_layouts.push_back("xkb:us::eng"); |
| 839 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 792 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 840 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
| 793 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 841 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| 794 EXPECT_EQ("us", xkeyboard_->last_layout_); | 842 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 795 | 843 |
| 796 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 844 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
| 797 // and keyboards are enabled. | 845 // and keyboards are enabled. |
| 798 EXPECT_FALSE(manager_->SwitchInputMethod( | 846 EXPECT_FALSE(manager_->SwitchInputMethod( |
| 799 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 847 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 800 EXPECT_FALSE(observer.last_show_message_); | 848 EXPECT_FALSE(observer.last_show_message_); |
| 801 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 849 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 818 | 866 |
| 819 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { | 867 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
| 820 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. | 868 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. |
| 821 InitComponentExtension(); | 869 InitComponentExtension(); |
| 822 | 870 |
| 823 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 871 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 824 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 872 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
| 825 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 873 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 826 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 874 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
| 827 | 875 |
| 828 manager_->EnableLoginLayouts("ja", "xkb:us::eng"); | 876 std::vector<std::string> keyboard_layouts; |
| 877 keyboard_layouts.push_back("xkb:us::eng"); |
| 878 manager_->EnableLoginLayouts("ja", keyboard_layouts); |
| 829 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 879 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 830 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 880 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| 831 EXPECT_EQ("us", xkeyboard_->last_layout_); | 881 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 832 EXPECT_TRUE(manager_->SwitchInputMethod( | 882 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 833 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 883 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 834 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 884 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 835 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 885 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 836 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 886 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
| 837 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 887 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
| 838 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 888 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 850 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 900 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 851 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 901 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 852 } | 902 } |
| 853 | 903 |
| 854 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 904 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
| 855 InitComponentExtension(); | 905 InitComponentExtension(); |
| 856 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 906 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 857 std::vector<std::string> ids; | 907 std::vector<std::string> ids; |
| 858 ids.push_back("xkb:jp::jpn"); | 908 ids.push_back("xkb:jp::jpn"); |
| 859 ids.push_back(kNaclMozcJpId); | 909 ids.push_back(kNaclMozcJpId); |
| 860 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 910 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 861 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 911 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 862 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 912 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 863 EXPECT_TRUE(manager_->SwitchInputMethod( | 913 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 864 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 914 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 865 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 915 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
| 866 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 916 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 867 EXPECT_TRUE(manager_->SwitchInputMethod( | 917 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 868 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 918 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 869 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 919 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 870 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 920 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 871 EXPECT_TRUE(manager_->SwitchInputMethod( | 921 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 872 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 922 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 873 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 923 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
| 874 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 924 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 875 EXPECT_TRUE(manager_->SwitchInputMethod( | 925 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 876 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 926 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
| 877 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 927 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
| 878 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 928 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 879 EXPECT_TRUE(manager_->SwitchInputMethod( | 929 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 880 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 930 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 881 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 931 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 882 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 932 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 883 EXPECT_TRUE(manager_->SwitchInputMethod( | 933 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 884 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 934 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
| 885 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 935 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 886 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 936 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 887 | 937 |
| 888 // Add Dvorak. | 938 // Add Dvorak. |
| 889 ids.push_back("xkb:us:dvorak:eng"); | 939 ids.push_back("xkb:us:dvorak:eng"); |
| 890 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 940 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 891 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 941 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 892 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 942 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 893 EXPECT_TRUE(manager_->SwitchInputMethod( | 943 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 894 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 944 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 895 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 945 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
| 896 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 946 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 897 EXPECT_TRUE(manager_->SwitchInputMethod( | 947 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 898 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 948 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 899 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 949 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); |
| 900 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 950 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
| 901 } | 951 } |
| 902 | 952 |
| 903 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 953 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
| 904 TestObserver observer; | 954 TestObserver observer; |
| 905 manager_->AddObserver(&observer); | 955 manager_->AddObserver(&observer); |
| 906 InitComponentExtension(); | 956 InitComponentExtension(); |
| 907 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 957 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 908 std::vector<std::string> ids; | 958 std::vector<std::string> ids; |
| 909 ids.push_back("xkb:us:dvorak:eng"); | 959 ids.push_back("xkb:us:dvorak:eng"); |
| 910 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 960 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 911 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 961 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 912 EXPECT_EQ(1, observer.input_method_changed_count_); | 962 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 913 EXPECT_EQ(ids[0], | 963 EXPECT_EQ(ids[0], |
| 914 manager_->GetCurrentInputMethod().id()); | 964 manager_->GetCurrentInputMethod().id()); |
| 915 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 965 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
| 916 | 966 |
| 917 // Add two Extension IMEs. | 967 // Add two Extension IMEs. |
| 918 std::vector<std::string> layouts; | 968 std::vector<std::string> layouts; |
| 919 layouts.push_back("us"); | 969 layouts.push_back("us"); |
| 920 std::vector<std::string> languages; | 970 std::vector<std::string> languages; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1032 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 983 } | 1033 } |
| 984 | 1034 |
| 985 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 1035 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
| 986 TestObserver observer; | 1036 TestObserver observer; |
| 987 InitComponentExtension(); | 1037 InitComponentExtension(); |
| 988 manager_->AddObserver(&observer); | 1038 manager_->AddObserver(&observer); |
| 989 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1039 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 990 std::vector<std::string> ids; | 1040 std::vector<std::string> ids; |
| 991 ids.push_back("xkb:us::eng"); | 1041 ids.push_back("xkb:us::eng"); |
| 992 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1042 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 993 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1043 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 994 EXPECT_EQ(1, observer.input_method_changed_count_); | 1044 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 995 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 1045 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); |
| 996 EXPECT_EQ("us", xkeyboard_->last_layout_); | 1046 EXPECT_EQ("us", xkeyboard_->last_layout_); |
| 997 | 1047 |
| 998 // Add an Extension IME. | 1048 // Add an Extension IME. |
| 999 std::vector<std::string> layouts; | 1049 std::vector<std::string> layouts; |
| 1000 layouts.push_back("us(dvorak)"); | 1050 layouts.push_back("us(dvorak)"); |
| 1001 std::vector<std::string> languages; | 1051 std::vector<std::string> languages; |
| 1002 languages.push_back("en-US"); | 1052 languages.push_back("en-US"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 EXPECT_EQ(ext_id, methods->at(1).id()); | 1100 EXPECT_EQ(ext_id, methods->at(1).id()); |
| 1051 } | 1101 } |
| 1052 manager_->RemoveObserver(&observer); | 1102 manager_->RemoveObserver(&observer); |
| 1053 } | 1103 } |
| 1054 | 1104 |
| 1055 TEST_F(InputMethodManagerImplTest, | 1105 TEST_F(InputMethodManagerImplTest, |
| 1056 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { | 1106 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { |
| 1057 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1107 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1058 std::vector<std::string> ids; | 1108 std::vector<std::string> ids; |
| 1059 ids.push_back(kNaclMozcUsId); | 1109 ids.push_back(kNaclMozcUsId); |
| 1060 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1110 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1061 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1111 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1062 manager_->ChangeInputMethod(kNaclMozcUsId); | 1112 manager_->ChangeInputMethod(kNaclMozcUsId); |
| 1063 | 1113 |
| 1064 InitComponentExtension(); | 1114 InitComponentExtension(); |
| 1065 EXPECT_EQ(kNaclMozcUsId, manager_->GetCurrentInputMethod().id()); | 1115 EXPECT_EQ(kNaclMozcUsId, manager_->GetCurrentInputMethod().id()); |
| 1066 } | 1116 } |
| 1067 | 1117 |
| 1068 TEST_F(InputMethodManagerImplTest, | 1118 TEST_F(InputMethodManagerImplTest, |
| 1069 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { | 1119 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { |
| 1070 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1120 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1071 std::vector<std::string> ids; | 1121 std::vector<std::string> ids; |
| 1072 ids.push_back(kNaclMozcUsId); | 1122 ids.push_back(kNaclMozcUsId); |
| 1073 ids.push_back(kNaclMozcJpId); | 1123 ids.push_back(kNaclMozcJpId); |
| 1074 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1124 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1075 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1125 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1076 manager_->ChangeInputMethod(kNaclMozcUsId); | 1126 manager_->ChangeInputMethod(kNaclMozcUsId); |
| 1077 manager_->ChangeInputMethod(kNaclMozcJpId); | 1127 manager_->ChangeInputMethod(kNaclMozcJpId); |
| 1078 | 1128 |
| 1079 InitComponentExtension(); | 1129 InitComponentExtension(); |
| 1080 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1130 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
| 1081 } | 1131 } |
| 1082 | 1132 |
| 1083 TEST_F(InputMethodManagerImplTest, | 1133 TEST_F(InputMethodManagerImplTest, |
| 1084 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | 1134 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { |
| 1085 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1135 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1086 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1136 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1087 ime_list_[0].id, | 1137 ime_list_[0].id, |
| 1088 ime_list_[0].engines[0].engine_id); | 1138 ime_list_[0].engines[0].engine_id); |
| 1089 std::vector<std::string> ids; | 1139 std::vector<std::string> ids; |
| 1090 ids.push_back(ext_id); | 1140 ids.push_back(ext_id); |
| 1091 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1141 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1092 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1142 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1093 manager_->ChangeInputMethod(ext_id); | 1143 manager_->ChangeInputMethod(ext_id); |
| 1094 | 1144 |
| 1095 InitComponentExtension(); | 1145 InitComponentExtension(); |
| 1096 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1146 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1097 } | 1147 } |
| 1098 | 1148 |
| 1099 TEST_F(InputMethodManagerImplTest, | 1149 TEST_F(InputMethodManagerImplTest, |
| 1100 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { | 1150 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { |
| 1101 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1151 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1102 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1152 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1103 ime_list_[0].id, | 1153 ime_list_[0].id, |
| 1104 ime_list_[0].engines[0].engine_id); | 1154 ime_list_[0].engines[0].engine_id); |
| 1105 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1155 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1106 ime_list_[1].id, | 1156 ime_list_[1].id, |
| 1107 ime_list_[1].engines[0].engine_id); | 1157 ime_list_[1].engines[0].engine_id); |
| 1108 std::vector<std::string> ids; | 1158 std::vector<std::string> ids; |
| 1109 ids.push_back(ext_id1); | 1159 ids.push_back(ext_id1); |
| 1110 ids.push_back(ext_id2); | 1160 ids.push_back(ext_id2); |
| 1111 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1161 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1112 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1162 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1113 manager_->ChangeInputMethod(ext_id1); | 1163 manager_->ChangeInputMethod(ext_id1); |
| 1114 manager_->ChangeInputMethod(ext_id2); | 1164 manager_->ChangeInputMethod(ext_id2); |
| 1115 | 1165 |
| 1116 InitComponentExtension(); | 1166 InitComponentExtension(); |
| 1117 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1167 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
| 1118 } | 1168 } |
| 1119 | 1169 |
| 1120 TEST_F(InputMethodManagerImplTest, | 1170 TEST_F(InputMethodManagerImplTest, |
| 1121 ChangeInputMethod_ComponenteExtensionOneIME) { | 1171 ChangeInputMethod_ComponenteExtensionOneIME) { |
| 1122 InitComponentExtension(); | 1172 InitComponentExtension(); |
| 1123 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1173 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1124 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1174 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1125 ime_list_[0].id, | 1175 ime_list_[0].id, |
| 1126 ime_list_[0].engines[0].engine_id); | 1176 ime_list_[0].engines[0].engine_id); |
| 1127 std::vector<std::string> ids; | 1177 std::vector<std::string> ids; |
| 1128 ids.push_back(ext_id); | 1178 ids.push_back(ext_id); |
| 1129 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1179 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1130 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1180 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1131 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1181 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1132 } | 1182 } |
| 1133 | 1183 |
| 1134 TEST_F(InputMethodManagerImplTest, | 1184 TEST_F(InputMethodManagerImplTest, |
| 1135 ChangeInputMethod_ComponenteExtensionTwoIME) { | 1185 ChangeInputMethod_ComponenteExtensionTwoIME) { |
| 1136 InitComponentExtension(); | 1186 InitComponentExtension(); |
| 1137 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1187 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1138 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1188 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1139 ime_list_[0].id, | 1189 ime_list_[0].id, |
| 1140 ime_list_[0].engines[0].engine_id); | 1190 ime_list_[0].engines[0].engine_id); |
| 1141 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1191 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1142 ime_list_[1].id, | 1192 ime_list_[1].id, |
| 1143 ime_list_[1].engines[0].engine_id); | 1193 ime_list_[1].engines[0].engine_id); |
| 1144 std::vector<std::string> ids; | 1194 std::vector<std::string> ids; |
| 1145 ids.push_back(ext_id1); | 1195 ids.push_back(ext_id1); |
| 1146 ids.push_back(ext_id2); | 1196 ids.push_back(ext_id2); |
| 1147 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1197 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1148 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1198 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1149 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1199 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); |
| 1150 manager_->ChangeInputMethod(ext_id2); | 1200 manager_->ChangeInputMethod(ext_id2); |
| 1151 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1201 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
| 1152 } | 1202 } |
| 1153 | 1203 |
| 1154 } // namespace input_method | 1204 } // namespace input_method |
| 1155 } // namespace chromeos | 1205 } // namespace chromeos |
| OLD | NEW |