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 "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 profile_manager_.reset(); | 161 profile_manager_.reset(); |
162 } | 162 } |
163 | 163 |
164 protected: | 164 protected: |
165 // Helper function to initialize component extension stuff for testing. | 165 // Helper function to initialize component extension stuff for testing. |
166 void InitComponentExtension() { | 166 void InitComponentExtension() { |
167 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); | 167 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); |
168 mock_delegate_->set_ime_list(ime_list_); | 168 mock_delegate_->set_ime_list(ime_list_); |
169 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); | 169 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); |
170 | 170 |
| 171 manager_->SetState(manager_->GetDefaultState(NULL /* profile */)); |
| 172 |
171 std::vector<std::string> layouts; | 173 std::vector<std::string> layouts; |
172 layouts.push_back("us"); | 174 layouts.push_back("us"); |
173 std::vector<std::string> languages; | 175 std::vector<std::string> languages; |
174 languages.push_back("en-US"); | 176 languages.push_back("en-US"); |
175 | 177 |
176 // Note, for production, these SetEngineHandler are called when | 178 // Note, for production, these SetEngineHandler are called when |
177 // IMEEngineHandlerInterface is initialized via | 179 // IMEEngineHandlerInterface is initialized via |
178 // InitializeComponentextension. | 180 // InitializeComponentextension. |
179 InputMethodDescriptors descriptors; | 181 InputMethodDescriptors descriptors; |
180 manager_->AddInputMethodExtension(ImeIdFromEngineId(kNaclMozcUsId), | 182 manager_->GetActiveIMEState()->AddInputMethodExtension( |
181 descriptors, | 183 ImeIdFromEngineId(kNaclMozcUsId), |
182 mock_engine_handler_.get()); | 184 descriptors, |
183 manager_->AddInputMethodExtension(ImeIdFromEngineId(kExt2Engine1Id), | 185 mock_engine_handler_.get()); |
184 descriptors, | 186 manager_->GetActiveIMEState()->AddInputMethodExtension( |
185 mock_engine_handler_.get()); | 187 ImeIdFromEngineId(kExt2Engine1Id), |
| 188 descriptors, |
| 189 mock_engine_handler_.get()); |
186 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); | 190 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); |
187 } | 191 } |
188 | 192 |
189 void InitImeList() { | 193 void InitImeList() { |
190 ime_list_.clear(); | 194 ime_list_.clear(); |
191 | 195 |
192 ComponentExtensionIME ext_xkb; | 196 ComponentExtensionIME ext_xkb; |
193 ext_xkb.id = extension_ime_util::kXkbExtensionId; | 197 ext_xkb.id = extension_ime_util::kXkbExtensionId; |
194 ext_xkb.description = "ext_xkb_description"; | 198 ext_xkb.description = "ext_xkb_description"; |
195 ext_xkb.path = base::FilePath("ext_xkb_file_path"); | 199 ext_xkb.path = base::FilePath("ext_xkb_file_path"); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is | 356 // For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is |
353 // also for the scenario. | 357 // also for the scenario. |
354 std::vector<std::string> keyboard_layouts; | 358 std::vector<std::string> keyboard_layouts; |
355 keyboard_layouts.push_back("xkb:us::eng"); | 359 keyboard_layouts.push_back("xkb:us::eng"); |
356 | 360 |
357 TestObserver observer; | 361 TestObserver observer; |
358 InitComponentExtension(); | 362 InitComponentExtension(); |
359 manager_->AddObserver(&observer); | 363 manager_->AddObserver(&observer); |
360 menu_manager_->AddObserver(&observer); | 364 menu_manager_->AddObserver(&observer); |
361 EXPECT_EQ(0, observer.input_method_changed_count_); | 365 EXPECT_EQ(0, observer.input_method_changed_count_); |
362 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 366 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
363 EXPECT_EQ(5U, manager_->GetActiveInputMethods()->size()); | 367 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetActiveInputMethods()->size()); |
364 EXPECT_EQ(1, observer.input_method_changed_count_); | 368 EXPECT_EQ(1, observer.input_method_changed_count_); |
365 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); | 369 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
366 manager_->ChangeInputMethod(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 370 manager_->GetActiveIMEState()->ChangeInputMethod( |
| 371 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
367 EXPECT_FALSE(observer.last_show_message_); | 372 EXPECT_FALSE(observer.last_show_message_); |
368 EXPECT_EQ(2, observer.input_method_changed_count_); | 373 EXPECT_EQ(2, observer.input_method_changed_count_); |
369 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 374 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
370 manager_->ChangeInputMethod(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 375 manager_->GetActiveIMEState()->ChangeInputMethod( |
| 376 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
371 EXPECT_FALSE(observer.last_show_message_); | 377 EXPECT_FALSE(observer.last_show_message_); |
372 | 378 |
373 // The observer is always notified even when the same input method ID is | 379 // The observer is always notified even when the same input method ID is |
374 // passed to ChangeInputMethod() more than twice. | 380 // passed to ChangeInputMethod() more than twice. |
375 // TODO(komatsu): Revisit if this is neccessary. | 381 // TODO(komatsu): Revisit if this is neccessary. |
376 EXPECT_EQ(3, observer.input_method_changed_count_); | 382 EXPECT_EQ(3, observer.input_method_changed_count_); |
377 | 383 |
378 // If the same input method ID is passed, PropertyChanged() is not | 384 // If the same input method ID is passed, PropertyChanged() is not |
379 // notified. | 385 // notified. |
380 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 386 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
(...skipping 22 matching lines...) Expand all Loading... |
403 ImeIdFromEngineId("xkb:fr::fra")); | 409 ImeIdFromEngineId("xkb:fr::fra")); |
404 EXPECT_TRUE(Contain(methods, *id_to_find)); | 410 EXPECT_TRUE(Contain(methods, *id_to_find)); |
405 } | 411 } |
406 | 412 |
407 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 413 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
408 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 414 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
409 // ibus_input_method.txt. | 415 // ibus_input_method.txt. |
410 std::vector<std::string> keyboard_layouts; | 416 std::vector<std::string> keyboard_layouts; |
411 | 417 |
412 InitComponentExtension(); | 418 InitComponentExtension(); |
413 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 419 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
414 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 420 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
415 | 421 |
416 // For http://crbug.com/19655#c11 - (5) | 422 // For http://crbug.com/19655#c11 - (5) |
417 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 423 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
418 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 424 manager_->GetActiveIMEState()->EnableLoginLayouts( |
419 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 425 "ja", keyboard_layouts); // Japanese |
| 426 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
420 } | 427 } |
421 | 428 |
422 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 429 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
423 // For http://crbug.com/329061 | 430 // For http://crbug.com/329061 |
424 std::vector<std::string> keyboard_layouts; | 431 std::vector<std::string> keyboard_layouts; |
425 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); | 432 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); |
426 | 433 |
427 InitComponentExtension(); | 434 InitComponentExtension(); |
428 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 435 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
429 const std::string im_id = manager_->GetCurrentInputMethod().id(); | 436 const std::string im_id = |
| 437 manager_->GetActiveIMEState()->GetCurrentInputMethod().id(); |
430 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); | 438 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); |
431 } | 439 } |
432 | 440 |
433 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 441 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
434 InitComponentExtension(); | 442 InitComponentExtension(); |
435 // The physical layout is French. | 443 // The physical layout is French. |
436 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 444 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
437 "xkb:fr::fra"); | 445 "xkb:fr::fra"); |
438 manager_->EnableLoginLayouts( | 446 manager_->GetActiveIMEState()->EnableLoginLayouts( |
439 "en-US", | 447 "en-US", |
440 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 448 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
441 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French | 449 EXPECT_EQ( |
| 450 6U, |
| 451 manager_->GetActiveIMEState()->GetNumActiveInputMethods()); // 5 + French |
442 // The physical layout is Japanese. | 452 // The physical layout is Japanese. |
443 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 453 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
444 "xkb:jp::jpn"); | 454 "xkb:jp::jpn"); |
445 manager_->EnableLoginLayouts( | 455 manager_->GetActiveIMEState()->EnableLoginLayouts( |
446 "ja", | 456 "ja", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
447 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | |
448 // "xkb:us::eng" is not needed, hence 1. | 457 // "xkb:us::eng" is not needed, hence 1. |
449 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 458 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
450 | 459 |
451 // The physical layout is Russian. | 460 // The physical layout is Russian. |
452 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 461 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
453 "xkb:ru::rus"); | 462 "xkb:ru::rus"); |
454 manager_->EnableLoginLayouts( | 463 manager_->GetActiveIMEState()->EnableLoginLayouts( |
455 "ru", | 464 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
456 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | |
457 // "xkb:us::eng" only. | 465 // "xkb:us::eng" only. |
458 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 466 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
459 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 467 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
460 manager_->GetActiveInputMethodIds().front()); | 468 manager_->GetActiveIMEState()->GetActiveInputMethodIds().front()); |
461 } | 469 } |
462 | 470 |
463 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { | 471 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
464 InitComponentExtension(); | 472 InitComponentExtension(); |
465 // The physical layouts are French and Hungarian. | 473 // The physical layouts are French and Hungarian. |
466 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 474 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
467 "xkb:fr::fra,xkb:hu::hun"); | 475 "xkb:fr::fra,xkb:hu::hun"); |
468 manager_->EnableLoginLayouts( | 476 manager_->GetActiveIMEState()->EnableLoginLayouts( |
469 "en-US", | 477 "en-US", |
470 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 478 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
471 // 5 + French + Hungarian | 479 // 5 + French + Hungarian |
472 EXPECT_EQ(7U, manager_->GetNumActiveInputMethods()); | 480 EXPECT_EQ(7U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
473 } | 481 } |
474 | 482 |
475 TEST_F(InputMethodManagerImplTest, | 483 TEST_F(InputMethodManagerImplTest, |
476 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { | 484 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
477 InitComponentExtension(); | 485 InitComponentExtension(); |
478 // The physical layouts are English (US) and Russian. | 486 // The physical layouts are English (US) and Russian. |
479 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 487 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
480 "xkb:us::eng,xkb:ru::rus"); | 488 "xkb:us::eng,xkb:ru::rus"); |
481 manager_->EnableLoginLayouts( | 489 manager_->GetActiveIMEState()->EnableLoginLayouts( |
482 "ru", | 490 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
483 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | |
484 // xkb:us:eng | 491 // xkb:us:eng |
485 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 492 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
486 } | 493 } |
487 | 494 |
488 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { | 495 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { |
489 InitComponentExtension(); | 496 InitComponentExtension(); |
490 std::vector<std::string> keyboard_layouts; | 497 std::vector<std::string> keyboard_layouts; |
491 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 498 manager_->GetActiveIMEState()->EnableLoginLayouts( |
492 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 499 "ja", keyboard_layouts); // Japanese |
| 500 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
493 scoped_ptr<InputMethodDescriptors> methods( | 501 scoped_ptr<InputMethodDescriptors> methods( |
494 manager_->GetActiveInputMethods()); | 502 manager_->GetActiveIMEState()->GetActiveInputMethods()); |
495 ASSERT_TRUE(methods.get()); | 503 ASSERT_TRUE(methods.get()); |
496 EXPECT_EQ(2U, methods->size()); | 504 EXPECT_EQ(2U, methods->size()); |
497 const InputMethodDescriptor* id_to_find = | 505 const InputMethodDescriptor* id_to_find = |
498 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 506 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
499 ImeIdFromEngineId("xkb:us::eng")); | 507 ImeIdFromEngineId("xkb:us::eng")); |
500 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); | 508 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
501 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 509 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
502 ImeIdFromEngineId("xkb:jp::jpn")); | 510 ImeIdFromEngineId("xkb:jp::jpn")); |
503 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); | 511 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
504 } | 512 } |
505 | 513 |
506 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 514 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
507 // For http://crbug.com/19655#c11 - (8), step 6. | 515 // For http://crbug.com/19655#c11 - (8), step 6. |
508 TestObserver observer; | 516 TestObserver observer; |
509 manager_->AddObserver(&observer); | 517 manager_->AddObserver(&observer); |
510 InitComponentExtension(); | 518 InitComponentExtension(); |
511 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 519 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
512 std::vector<std::string> ids; | 520 std::vector<std::string> ids; |
513 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 521 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
514 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 522 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
515 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 523 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
516 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 524 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
517 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 525 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
518 // called. | 526 // called. |
519 EXPECT_EQ(1, observer.input_method_changed_count_); | 527 EXPECT_EQ(1, observer.input_method_changed_count_); |
520 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 528 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 529 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
521 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 530 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
522 // Disable Dvorak. | 531 // Disable Dvorak. |
523 ids.erase(ids.begin()); | 532 ids.erase(ids.begin()); |
524 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 533 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
525 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 534 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
526 EXPECT_EQ(2, observer.input_method_changed_count_); | 535 EXPECT_EQ(2, observer.input_method_changed_count_); |
527 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // colemak | 536 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // colemak |
528 manager_->GetCurrentInputMethod().id()); | 537 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
529 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 538 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
530 manager_->RemoveObserver(&observer); | 539 manager_->RemoveObserver(&observer); |
531 } | 540 } |
532 | 541 |
533 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 542 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
534 // For http://crbug.com/19655#c11 - (9). | 543 // For http://crbug.com/19655#c11 - (9). |
535 TestObserver observer; | 544 TestObserver observer; |
536 manager_->AddObserver(&observer); | 545 manager_->AddObserver(&observer); |
537 InitComponentExtension(); | 546 InitComponentExtension(); |
538 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 547 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
539 std::vector<std::string> ids; | 548 std::vector<std::string> ids; |
540 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 549 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
541 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 550 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
542 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 551 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
543 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 552 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
544 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 553 EXPECT_EQ(3U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
545 EXPECT_EQ(1, observer.input_method_changed_count_); | 554 EXPECT_EQ(1, observer.input_method_changed_count_); |
546 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 555 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 556 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
547 EXPECT_EQ("us", keyboard_->last_layout_); | 557 EXPECT_EQ("us", keyboard_->last_layout_); |
548 // Switch to Dvorak. | 558 // Switch to Dvorak. |
549 manager_->SwitchToNextInputMethod(); | 559 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
550 EXPECT_EQ(2, observer.input_method_changed_count_); | 560 EXPECT_EQ(2, observer.input_method_changed_count_); |
551 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 561 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 562 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
552 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 563 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
553 // Disable Dvorak. | 564 // Disable Dvorak. |
554 ids.erase(ids.begin() + 1); | 565 ids.erase(ids.begin() + 1); |
555 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 566 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
556 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 567 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
557 EXPECT_EQ(3, observer.input_method_changed_count_); | 568 EXPECT_EQ(3, observer.input_method_changed_count_); |
558 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // US Qwerty | 569 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // US Qwerty |
559 manager_->GetCurrentInputMethod().id()); | 570 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
560 EXPECT_EQ("us", keyboard_->last_layout_); | 571 EXPECT_EQ("us", keyboard_->last_layout_); |
561 manager_->RemoveObserver(&observer); | 572 manager_->RemoveObserver(&observer); |
562 } | 573 } |
563 | 574 |
564 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 575 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
565 // For http://crbug.com/19655#c11 - (10). | 576 // For http://crbug.com/19655#c11 - (10). |
566 TestObserver observer; | 577 TestObserver observer; |
567 manager_->AddObserver(&observer); | 578 manager_->AddObserver(&observer); |
568 InitComponentExtension(); | 579 InitComponentExtension(); |
569 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 580 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
570 std::vector<std::string> ids; | 581 std::vector<std::string> ids; |
571 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 582 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
572 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 583 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
573 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 584 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
574 EXPECT_EQ(1, observer.input_method_changed_count_); | 585 EXPECT_EQ(1, observer.input_method_changed_count_); |
575 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 586 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 587 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
576 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 588 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
577 // Switch to Mozc | 589 // Switch to Mozc |
578 manager_->SwitchToNextInputMethod(); | 590 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
579 EXPECT_EQ(2, observer.input_method_changed_count_); | 591 EXPECT_EQ(2, observer.input_method_changed_count_); |
580 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 592 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 593 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
581 EXPECT_EQ("us", keyboard_->last_layout_); | 594 EXPECT_EQ("us", keyboard_->last_layout_); |
582 // Disable Mozc. | 595 // Disable Mozc. |
583 ids.erase(ids.begin() + 1); | 596 ids.erase(ids.begin() + 1); |
584 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 597 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
585 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 598 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
586 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 599 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 600 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
587 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 601 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
588 } | 602 } |
589 | 603 |
590 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 604 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
591 // For http://crbug.com/19655#c11 - (11). | 605 // For http://crbug.com/19655#c11 - (11). |
592 TestObserver observer; | 606 TestObserver observer; |
593 manager_->AddObserver(&observer); | 607 manager_->AddObserver(&observer); |
594 InitComponentExtension(); | 608 InitComponentExtension(); |
595 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 609 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
596 std::vector<std::string> ids; | 610 std::vector<std::string> ids; |
597 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 611 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
598 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 612 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
599 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 613 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
600 EXPECT_EQ(1, observer.input_method_changed_count_); | 614 EXPECT_EQ(1, observer.input_method_changed_count_); |
601 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 615 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 616 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
602 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 617 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
603 | 618 |
604 // Disable Dvorak. | 619 // Disable Dvorak. |
605 ids.erase(ids.begin()); | 620 ids.erase(ids.begin()); |
606 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 621 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
607 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 622 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
608 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // Mozc | 623 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // Mozc |
609 manager_->GetCurrentInputMethod().id()); | 624 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
610 EXPECT_EQ("us", keyboard_->last_layout_); | 625 EXPECT_EQ("us", keyboard_->last_layout_); |
611 manager_->RemoveObserver(&observer); | 626 manager_->RemoveObserver(&observer); |
612 } | 627 } |
613 | 628 |
614 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 629 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
615 TestObserver observer; | 630 TestObserver observer; |
616 manager_->AddObserver(&observer); | 631 manager_->AddObserver(&observer); |
617 InitComponentExtension(); | 632 InitComponentExtension(); |
618 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 633 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
619 std::vector<std::string> ids; | 634 std::vector<std::string> ids; |
620 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); | 635 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); |
621 ids.push_back("mozc-dv"); | 636 ids.push_back("mozc-dv"); |
622 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 637 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
623 EXPECT_EQ(1, observer.input_method_changed_count_); | 638 EXPECT_EQ(1, observer.input_method_changed_count_); |
624 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 639 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 640 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
625 EXPECT_EQ("us", keyboard_->last_layout_); | 641 EXPECT_EQ("us", keyboard_->last_layout_); |
626 manager_->RemoveObserver(&observer); | 642 manager_->RemoveObserver(&observer); |
627 } | 643 } |
628 | 644 |
629 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 645 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
630 TestObserver observer; | 646 TestObserver observer; |
631 manager_->AddObserver(&observer); | 647 manager_->AddObserver(&observer); |
632 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 648 InitComponentExtension(); |
| 649 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
633 std::vector<std::string> ids; | 650 std::vector<std::string> ids; |
634 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 651 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
635 ids.push_back("unknown-super-cool-ime"); | 652 ids.push_back("unknown-super-cool-ime"); |
636 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); | 653 EXPECT_FALSE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
637 | 654 |
638 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this | 655 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this |
639 // case? | 656 // case? |
640 EXPECT_EQ(0, observer.input_method_changed_count_); | 657 EXPECT_EQ(0, observer.input_method_changed_count_); |
641 | 658 |
642 manager_->RemoveObserver(&observer); | 659 manager_->RemoveObserver(&observer); |
643 } | 660 } |
644 | 661 |
645 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { | 662 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { |
646 // For http://crbug.com/19655#c11 - (14). | 663 // For http://crbug.com/19655#c11 - (14). |
647 TestObserver observer; | 664 TestObserver observer; |
648 manager_->AddObserver(&observer); | 665 manager_->AddObserver(&observer); |
649 InitComponentExtension(); | 666 InitComponentExtension(); |
650 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 667 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
651 std::vector<std::string> ids; | 668 std::vector<std::string> ids; |
652 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 669 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
653 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 670 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
654 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 671 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
655 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 672 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
656 EXPECT_EQ(1, observer.input_method_changed_count_); | 673 EXPECT_EQ(1, observer.input_method_changed_count_); |
657 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 674 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 675 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
658 EXPECT_EQ("us", keyboard_->last_layout_); | 676 EXPECT_EQ("us", keyboard_->last_layout_); |
659 | 677 |
660 // Switch to Dvorak. | 678 // Switch to Dvorak. |
661 manager_->SwitchToNextInputMethod(); | 679 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
662 EXPECT_EQ(2, observer.input_method_changed_count_); | 680 EXPECT_EQ(2, observer.input_method_changed_count_); |
663 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 681 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 682 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
664 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 683 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
665 | 684 |
666 // Lock screen | 685 // Lock screen |
667 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 686 manager_->SetUISessionState(InputMethodManager::STATE_LOCK_SCREEN); |
668 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 687 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
669 EXPECT_EQ(ImeIdFromEngineId(ids[1]), // still Dvorak | 688 EXPECT_EQ(ImeIdFromEngineId(ids[1]), // still Dvorak |
670 manager_->GetCurrentInputMethod().id()); | 689 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
671 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 690 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
672 // Switch back to Qwerty. | 691 // Switch back to Qwerty. |
673 manager_->SwitchToNextInputMethod(); | 692 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
674 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 693 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 694 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
675 EXPECT_EQ("us", keyboard_->last_layout_); | 695 EXPECT_EQ("us", keyboard_->last_layout_); |
676 | 696 |
677 // Unlock screen. The original state, Dvorak, is restored. | 697 // Unlock screen. The original state, Dvorak, is restored. |
678 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 698 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
679 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 699 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
680 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 700 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 701 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
681 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 702 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
682 | 703 |
683 manager_->RemoveObserver(&observer); | 704 manager_->RemoveObserver(&observer); |
684 } | 705 } |
685 | 706 |
686 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 707 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
687 // For http://crbug.com/19655#c11 - (15). | 708 // For http://crbug.com/19655#c11 - (15). |
688 TestObserver observer; | 709 TestObserver observer; |
689 manager_->AddObserver(&observer); | 710 manager_->AddObserver(&observer); |
690 InitComponentExtension(); | 711 InitComponentExtension(); |
691 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 712 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
692 std::vector<std::string> ids; | 713 std::vector<std::string> ids; |
693 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 714 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
694 ids.push_back(ImeIdFromEngineId(kExt2Engine2Id)); | 715 ids.push_back(ImeIdFromEngineId(kExt2Engine2Id)); |
695 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); | 716 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); |
696 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 717 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
697 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 718 EXPECT_EQ(3U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
698 EXPECT_EQ(1, observer.input_method_changed_count_); | 719 EXPECT_EQ(1, observer.input_method_changed_count_); |
699 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 720 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 721 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
700 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 722 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
701 | 723 |
702 // Switch to Mozc. | 724 // Switch to Mozc. |
703 manager_->SwitchToNextInputMethod(); | 725 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
704 EXPECT_EQ(2, observer.input_method_changed_count_); | 726 EXPECT_EQ(2, observer.input_method_changed_count_); |
705 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 727 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 728 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
706 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 729 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
707 | 730 |
708 // Lock screen | 731 // Lock screen |
709 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 732 manager_->SetUISessionState(InputMethodManager::STATE_LOCK_SCREEN); |
710 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. | 733 EXPECT_EQ(2U, |
| 734 manager_->GetActiveIMEState() |
| 735 ->GetNumActiveInputMethods()); // Qwerty+Dvorak. |
711 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), | 736 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), |
712 manager_->GetCurrentInputMethod().id()); | 737 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
713 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 738 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
714 manager_->SwitchToNextInputMethod(); | 739 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
715 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), // The hardware keyboard layout. | 740 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), // The hardware keyboard layout. |
716 manager_->GetCurrentInputMethod().id()); | 741 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
717 EXPECT_EQ("us", keyboard_->last_layout_); | 742 EXPECT_EQ("us", keyboard_->last_layout_); |
718 | 743 |
719 // Unlock screen. The original state, pinyin-dv, is restored. | 744 // Unlock screen. The original state, pinyin-dv, is restored. |
720 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 745 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
721 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. | 746 EXPECT_EQ(3U, |
722 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 747 manager_->GetActiveIMEState() |
| 748 ->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. |
| 749 EXPECT_EQ(ImeIdFromEngineId(ids[1]), |
| 750 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
723 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 751 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
724 | 752 |
725 manager_->RemoveObserver(&observer); | 753 manager_->RemoveObserver(&observer); |
726 } | 754 } |
727 | 755 |
728 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 756 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
729 // For http://crbug.com/19655#c11 - (8), step 7-11. | 757 // For http://crbug.com/19655#c11 - (8), step 7-11. |
730 InitComponentExtension(); | 758 InitComponentExtension(); |
731 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 759 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
732 std::vector<std::string> ids; | 760 std::vector<std::string> ids; |
733 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 761 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
734 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 762 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
735 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | 763 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); |
736 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 764 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
737 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 765 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
738 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); | 766 EXPECT_EQ(4U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
739 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); | 767 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); |
740 // See input_methods.txt for an expected XKB layout name. | 768 // See input_methods.txt for an expected XKB layout name. |
741 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 769 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
742 manager_->SwitchToNextInputMethod(); | 770 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
743 EXPECT_EQ(2, keyboard_->set_current_keyboard_layout_by_name_count_); | 771 EXPECT_EQ(2, keyboard_->set_current_keyboard_layout_by_name_count_); |
744 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 772 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
745 manager_->SwitchToNextInputMethod(); | 773 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
746 EXPECT_EQ(3, keyboard_->set_current_keyboard_layout_by_name_count_); | 774 EXPECT_EQ(3, keyboard_->set_current_keyboard_layout_by_name_count_); |
747 EXPECT_EQ("jp", keyboard_->last_layout_); | 775 EXPECT_EQ("jp", keyboard_->last_layout_); |
748 manager_->SwitchToNextInputMethod(); | 776 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
749 EXPECT_EQ(4, keyboard_->set_current_keyboard_layout_by_name_count_); | 777 EXPECT_EQ(4, keyboard_->set_current_keyboard_layout_by_name_count_); |
750 EXPECT_EQ("us", keyboard_->last_layout_); | 778 EXPECT_EQ("us", keyboard_->last_layout_); |
751 manager_->SwitchToNextInputMethod(); | 779 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
752 EXPECT_EQ(5, keyboard_->set_current_keyboard_layout_by_name_count_); | 780 EXPECT_EQ(5, keyboard_->set_current_keyboard_layout_by_name_count_); |
753 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 781 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
754 // Disable Dvorak. | 782 // Disable Dvorak. |
755 ids.erase(ids.begin()); | 783 ids.erase(ids.begin()); |
756 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 784 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
757 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 785 EXPECT_EQ(3U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
758 EXPECT_EQ(6, keyboard_->set_current_keyboard_layout_by_name_count_); | 786 EXPECT_EQ(6, keyboard_->set_current_keyboard_layout_by_name_count_); |
759 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 787 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
760 } | 788 } |
761 | 789 |
762 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) { | 790 TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) { |
763 const std::string kKey = "key"; | 791 const std::string kKey = "key"; |
764 ash::ime::InputMethodMenuItemList menu_list; | 792 ash::ime::InputMethodMenuItemList menu_list; |
765 menu_list.push_back(ash::ime::InputMethodMenuItem( | 793 menu_list.push_back(ash::ime::InputMethodMenuItem( |
766 kKey, "label", false, false)); | 794 kKey, "label", false, false)); |
767 menu_manager_->SetCurrentInputMethodMenuItemList(menu_list); | 795 menu_manager_->SetCurrentInputMethodMenuItemList(menu_list); |
768 | 796 |
769 manager_->ActivateInputMethodMenuItem(kKey); | 797 manager_->ActivateInputMethodMenuItem(kKey); |
770 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 798 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
771 | 799 |
772 // Key2 is not registered, so activated property should not be changed. | 800 // Key2 is not registered, so activated property should not be changed. |
773 manager_->ActivateInputMethodMenuItem("key2"); | 801 manager_->ActivateInputMethodMenuItem("key2"); |
774 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 802 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
775 } | 803 } |
776 | 804 |
777 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { | 805 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
778 InitComponentExtension(); | 806 InitComponentExtension(); |
779 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 807 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
780 | 808 |
781 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 809 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
782 std::vector<std::string> ids; | 810 std::vector<std::string> ids; |
783 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 811 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
784 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 812 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
785 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 813 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
786 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 814 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
787 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 815 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
788 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | 816 manager_->GetActiveIMEState()->ChangeInputMethod( |
| 817 ImeIdFromEngineId(kNaclMozcUsId), false /* show_message */); |
789 | 818 |
790 ash::ime::InputMethodMenuItemList current_property_list; | 819 ash::ime::InputMethodMenuItemList current_property_list; |
791 current_property_list.push_back(ash::ime::InputMethodMenuItem( | 820 current_property_list.push_back(ash::ime::InputMethodMenuItem( |
792 "key", "label", false, false)); | 821 "key", "label", false, false)); |
793 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 822 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
794 | 823 |
795 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 824 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
796 EXPECT_EQ("key", | 825 EXPECT_EQ("key", |
797 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 826 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
798 | 827 |
799 manager_->ChangeInputMethod("xkb:us::eng"); | 828 manager_->GetActiveIMEState()->ChangeInputMethod("xkb:us::eng", |
| 829 false /* show_message */); |
800 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 830 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
801 } | 831 } |
802 | 832 |
803 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { | 833 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
804 InitComponentExtension(); | 834 InitComponentExtension(); |
805 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 835 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
806 | 836 |
807 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 837 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
808 std::vector<std::string> ids; | 838 std::vector<std::string> ids; |
809 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); // Japanese | 839 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); // Japanese |
810 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); // T-Chinese | 840 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); // T-Chinese |
811 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 841 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
812 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 842 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
813 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 843 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
814 | 844 |
815 ash::ime::InputMethodMenuItemList current_property_list; | 845 ash::ime::InputMethodMenuItemList current_property_list; |
816 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", | 846 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", |
817 "label", | 847 "label", |
818 false, | 848 false, |
819 false)); | 849 false)); |
820 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 850 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
821 | 851 |
822 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 852 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
823 EXPECT_EQ("key-mozc", | 853 EXPECT_EQ("key-mozc", |
824 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 854 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
825 | 855 |
826 manager_->ChangeInputMethod(ImeIdFromEngineId(kExt2Engine1Id)); | 856 manager_->GetActiveIMEState()->ChangeInputMethod( |
| 857 ImeIdFromEngineId(kExt2Engine1Id), false /* show_message */); |
827 // Since the IME is changed, the property for mozc Japanese should be hidden. | 858 // Since the IME is changed, the property for mozc Japanese should be hidden. |
828 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 859 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
829 | 860 |
830 // Asynchronous property update signal from mozc-chewing. | 861 // Asynchronous property update signal from mozc-chewing. |
831 current_property_list.clear(); | 862 current_property_list.clear(); |
832 current_property_list.push_back(ash::ime::InputMethodMenuItem( | 863 current_property_list.push_back(ash::ime::InputMethodMenuItem( |
833 "key-chewing", "label", false, false)); | 864 "key-chewing", "label", false, false)); |
834 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 865 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
835 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 866 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
836 EXPECT_EQ("key-chewing", | 867 EXPECT_EQ("key-chewing", |
837 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 868 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
838 } | 869 } |
839 | 870 |
840 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 871 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
841 TestObserver observer; | 872 TestObserver observer; |
842 manager_->AddObserver(&observer); | 873 manager_->AddObserver(&observer); |
843 InitComponentExtension(); | 874 InitComponentExtension(); |
844 std::vector<std::string> keyboard_layouts; | 875 std::vector<std::string> keyboard_layouts; |
845 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 876 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
846 // For http://crbug.com/19655#c11 - (1) | 877 // For http://crbug.com/19655#c11 - (1) |
847 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 878 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
848 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 879 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
849 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 880 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
850 manager_->GetCurrentInputMethod().id()); | 881 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
851 EXPECT_EQ("us", keyboard_->last_layout_); | 882 EXPECT_EQ("us", keyboard_->last_layout_); |
852 manager_->SwitchToNextInputMethod(); | 883 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
853 EXPECT_TRUE(observer.last_show_message_); | 884 EXPECT_TRUE(observer.last_show_message_); |
854 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 885 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
855 manager_->GetCurrentInputMethod().id()); | 886 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
856 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 887 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
857 manager_->SwitchToNextInputMethod(); | 888 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
858 EXPECT_TRUE(observer.last_show_message_); | 889 EXPECT_TRUE(observer.last_show_message_); |
859 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), | 890 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), |
860 manager_->GetCurrentInputMethod().id()); | 891 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
861 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 892 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
862 manager_->SwitchToNextInputMethod(); | 893 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
863 EXPECT_TRUE(observer.last_show_message_); | 894 EXPECT_TRUE(observer.last_show_message_); |
864 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), | 895 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), |
865 manager_->GetCurrentInputMethod().id()); | 896 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
866 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 897 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
867 manager_->SwitchToNextInputMethod(); | 898 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
868 EXPECT_TRUE(observer.last_show_message_); | 899 EXPECT_TRUE(observer.last_show_message_); |
869 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), | 900 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), |
870 manager_->GetCurrentInputMethod().id()); | 901 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
871 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 902 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
872 manager_->SwitchToNextInputMethod(); | 903 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
873 EXPECT_TRUE(observer.last_show_message_); | 904 EXPECT_TRUE(observer.last_show_message_); |
874 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 905 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
875 manager_->GetCurrentInputMethod().id()); | 906 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
876 EXPECT_EQ("us", keyboard_->last_layout_); | 907 EXPECT_EQ("us", keyboard_->last_layout_); |
877 | 908 |
878 manager_->RemoveObserver(&observer); | 909 manager_->RemoveObserver(&observer); |
879 } | 910 } |
880 | 911 |
881 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 912 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
882 TestObserver observer; | 913 TestObserver observer; |
883 manager_->AddObserver(&observer); | 914 manager_->AddObserver(&observer); |
884 InitComponentExtension(); | 915 InitComponentExtension(); |
885 | 916 |
886 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 917 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
887 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 918 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
888 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 919 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
889 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 920 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
890 | 921 |
891 std::vector<std::string> keyboard_layouts; | 922 std::vector<std::string> keyboard_layouts; |
892 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 923 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
893 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 924 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
894 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 925 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
895 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 926 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
896 manager_->GetCurrentInputMethod().id()); | 927 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
897 EXPECT_EQ("us", keyboard_->last_layout_); | 928 EXPECT_EQ("us", keyboard_->last_layout_); |
898 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 929 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToNextInputMethod()); |
899 EXPECT_TRUE(observer.last_show_message_); | 930 EXPECT_TRUE(observer.last_show_message_); |
900 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 931 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
901 manager_->GetCurrentInputMethod().id()); | 932 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
902 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 933 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
903 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 934 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
904 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 935 keydown_accelerator)); |
| 936 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 937 keyup_accelerator)); |
905 EXPECT_TRUE(observer.last_show_message_); | 938 EXPECT_TRUE(observer.last_show_message_); |
906 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 939 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
907 manager_->GetCurrentInputMethod().id()); | 940 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
908 EXPECT_EQ("us", keyboard_->last_layout_); | 941 EXPECT_EQ("us", keyboard_->last_layout_); |
909 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 942 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
910 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 943 keydown_accelerator)); |
| 944 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 945 keyup_accelerator)); |
911 EXPECT_TRUE(observer.last_show_message_); | 946 EXPECT_TRUE(observer.last_show_message_); |
912 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 947 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
913 manager_->GetCurrentInputMethod().id()); | 948 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
914 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 949 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
915 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 950 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
916 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 951 keydown_accelerator)); |
| 952 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 953 keyup_accelerator)); |
917 EXPECT_TRUE(observer.last_show_message_); | 954 EXPECT_TRUE(observer.last_show_message_); |
918 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 955 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
919 manager_->GetCurrentInputMethod().id()); | 956 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
920 EXPECT_EQ("us", keyboard_->last_layout_); | 957 EXPECT_EQ("us", keyboard_->last_layout_); |
921 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 958 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToNextInputMethod()); |
922 EXPECT_TRUE(observer.last_show_message_); | 959 EXPECT_TRUE(observer.last_show_message_); |
923 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 960 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
924 manager_->GetCurrentInputMethod().id()); | 961 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
925 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 962 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
926 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 963 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToNextInputMethod()); |
927 EXPECT_TRUE(observer.last_show_message_); | 964 EXPECT_TRUE(observer.last_show_message_); |
928 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), | 965 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), |
929 manager_->GetCurrentInputMethod().id()); | 966 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
930 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 967 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
931 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 968 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
932 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 969 keydown_accelerator)); |
| 970 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 971 keyup_accelerator)); |
933 EXPECT_TRUE(observer.last_show_message_); | 972 EXPECT_TRUE(observer.last_show_message_); |
934 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 973 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
935 manager_->GetCurrentInputMethod().id()); | 974 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
936 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 975 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
937 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 976 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
938 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 977 keydown_accelerator)); |
| 978 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 979 keyup_accelerator)); |
939 EXPECT_TRUE(observer.last_show_message_); | 980 EXPECT_TRUE(observer.last_show_message_); |
940 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), | 981 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), |
941 manager_->GetCurrentInputMethod().id()); | 982 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
942 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 983 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
943 | 984 |
944 manager_->RemoveObserver(&observer); | 985 manager_->RemoveObserver(&observer); |
945 } | 986 } |
946 | 987 |
947 TEST_F(InputMethodManagerImplTest, | 988 TEST_F(InputMethodManagerImplTest, |
948 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { | 989 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { |
949 TestObserver observer; | 990 TestObserver observer; |
950 manager_->AddObserver(&observer); | 991 manager_->AddObserver(&observer); |
951 InitComponentExtension(); | 992 InitComponentExtension(); |
952 | 993 |
953 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 994 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
954 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 995 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
955 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 996 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
956 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 997 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
957 | 998 |
958 std::vector<std::string> ids; | 999 std::vector<std::string> ids; |
959 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 1000 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
960 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1001 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
961 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1002 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
962 | 1003 |
963 // Ctrl+Space accelerator should not be consumed if there is only one active | 1004 // Ctrl+Space accelerator should not be consumed if there is only one active |
964 // input method. | 1005 // input method. |
965 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 1006 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
966 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 1007 keydown_accelerator)); |
| 1008 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 1009 keyup_accelerator)); |
967 | 1010 |
968 manager_->RemoveObserver(&observer); | 1011 manager_->RemoveObserver(&observer); |
969 } | 1012 } |
970 | 1013 |
971 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 1014 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
972 std::string expect_id = ImeIdFromEngineId("xkb:us::eng"); | 1015 std::string expect_id = ImeIdFromEngineId("xkb:us::eng"); |
973 TestObserver observer; | 1016 TestObserver observer; |
974 manager_->AddObserver(&observer); | 1017 manager_->AddObserver(&observer); |
975 InitComponentExtension(); | 1018 InitComponentExtension(); |
976 std::vector<std::string> keyboard_layouts; | 1019 std::vector<std::string> keyboard_layouts; |
977 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1020 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
978 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 1021 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
979 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 1022 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
980 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 1023 EXPECT_EQ(expect_id, |
| 1024 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
981 EXPECT_EQ("us", keyboard_->last_layout_); | 1025 EXPECT_EQ("us", keyboard_->last_layout_); |
982 | 1026 |
983 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 1027 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
984 // and keyboards are enabled. | 1028 // and keyboards are enabled. |
985 EXPECT_FALSE(manager_->SwitchInputMethod( | 1029 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchInputMethod( |
986 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1030 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
987 EXPECT_FALSE(observer.last_show_message_); | 1031 EXPECT_FALSE(observer.last_show_message_); |
988 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 1032 EXPECT_EQ(expect_id, |
| 1033 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
989 EXPECT_EQ("us", keyboard_->last_layout_); | 1034 EXPECT_EQ("us", keyboard_->last_layout_); |
990 EXPECT_FALSE(manager_->SwitchInputMethod( | 1035 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchInputMethod( |
991 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1036 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
992 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 1037 EXPECT_EQ(expect_id, |
| 1038 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
993 EXPECT_EQ("us", keyboard_->last_layout_); | 1039 EXPECT_EQ("us", keyboard_->last_layout_); |
994 EXPECT_FALSE(manager_->SwitchInputMethod( | 1040 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchInputMethod( |
995 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1041 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
996 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 1042 EXPECT_EQ(expect_id, |
| 1043 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
997 EXPECT_EQ("us", keyboard_->last_layout_); | 1044 EXPECT_EQ("us", keyboard_->last_layout_); |
998 EXPECT_FALSE(manager_->SwitchInputMethod( | 1045 EXPECT_FALSE(manager_->GetActiveIMEState()->SwitchInputMethod( |
999 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1046 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1000 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); | 1047 EXPECT_EQ(expect_id, |
| 1048 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1001 EXPECT_EQ("us", keyboard_->last_layout_); | 1049 EXPECT_EQ("us", keyboard_->last_layout_); |
1002 | 1050 |
1003 manager_->RemoveObserver(&observer); | 1051 manager_->RemoveObserver(&observer); |
1004 } | 1052 } |
1005 | 1053 |
1006 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { | 1054 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
1007 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. | 1055 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. |
1008 InitComponentExtension(); | 1056 InitComponentExtension(); |
1009 | 1057 |
1010 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1058 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1011 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 1059 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
1012 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1060 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1013 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 1061 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
1014 | 1062 |
1015 std::vector<std::string> keyboard_layouts; | 1063 std::vector<std::string> keyboard_layouts; |
1016 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1064 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1017 manager_->EnableLoginLayouts("ja", keyboard_layouts); | 1065 manager_->GetActiveIMEState()->EnableLoginLayouts("ja", keyboard_layouts); |
1018 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1066 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1019 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 1067 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
1020 manager_->GetCurrentInputMethod().id()); | 1068 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1021 EXPECT_EQ("us", keyboard_->last_layout_); | 1069 EXPECT_EQ("us", keyboard_->last_layout_); |
1022 EXPECT_TRUE(manager_->SwitchInputMethod( | 1070 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1023 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1071 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1024 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1072 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1025 manager_->GetCurrentInputMethod().id()); | 1073 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1026 EXPECT_EQ("jp", keyboard_->last_layout_); | 1074 EXPECT_EQ("jp", keyboard_->last_layout_); |
1027 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 1075 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
1028 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 1076 keydown_accelerator)); |
| 1077 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 1078 keyup_accelerator)); |
1029 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 1079 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
1030 manager_->GetCurrentInputMethod().id()); | 1080 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1031 EXPECT_EQ("us", keyboard_->last_layout_); | 1081 EXPECT_EQ("us", keyboard_->last_layout_); |
1032 EXPECT_TRUE(manager_->SwitchInputMethod( | 1082 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1033 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1083 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1034 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1084 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1035 manager_->GetCurrentInputMethod().id()); | 1085 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1036 EXPECT_EQ("jp", keyboard_->last_layout_); | 1086 EXPECT_EQ("jp", keyboard_->last_layout_); |
1037 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 1087 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
1038 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 1088 keydown_accelerator)); |
| 1089 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchToPreviousInputMethod( |
| 1090 keyup_accelerator)); |
1039 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 1091 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
1040 manager_->GetCurrentInputMethod().id()); | 1092 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1041 EXPECT_EQ("us", keyboard_->last_layout_); | 1093 EXPECT_EQ("us", keyboard_->last_layout_); |
1042 EXPECT_TRUE(manager_->SwitchInputMethod( | 1094 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1043 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1095 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1044 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1096 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1045 manager_->GetCurrentInputMethod().id()); | 1097 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1046 EXPECT_EQ("jp", keyboard_->last_layout_); | 1098 EXPECT_EQ("jp", keyboard_->last_layout_); |
1047 } | 1099 } |
1048 | 1100 |
1049 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 1101 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
1050 InitComponentExtension(); | 1102 InitComponentExtension(); |
1051 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1103 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1052 std::vector<std::string> ids; | 1104 std::vector<std::string> ids; |
1053 ids.push_back(ImeIdFromEngineId("xkb:jp::jpn")); | 1105 ids.push_back(ImeIdFromEngineId("xkb:jp::jpn")); |
1054 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | 1106 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); |
1055 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1107 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1056 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1108 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1057 manager_->GetCurrentInputMethod().id()); | 1109 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1058 EXPECT_EQ("jp", keyboard_->last_layout_); | 1110 EXPECT_EQ("jp", keyboard_->last_layout_); |
1059 EXPECT_TRUE(manager_->SwitchInputMethod( | 1111 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1060 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1112 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1061 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1113 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
1062 manager_->GetCurrentInputMethod().id()); | 1114 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1063 EXPECT_EQ("jp", keyboard_->last_layout_); | 1115 EXPECT_EQ("jp", keyboard_->last_layout_); |
1064 EXPECT_TRUE(manager_->SwitchInputMethod( | 1116 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1065 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1117 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
1066 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1118 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1067 manager_->GetCurrentInputMethod().id()); | 1119 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1068 EXPECT_EQ("jp", keyboard_->last_layout_); | 1120 EXPECT_EQ("jp", keyboard_->last_layout_); |
1069 EXPECT_TRUE(manager_->SwitchInputMethod( | 1121 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1070 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1122 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1071 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1123 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
1072 manager_->GetCurrentInputMethod().id()); | 1124 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1073 EXPECT_EQ("jp", keyboard_->last_layout_); | 1125 EXPECT_EQ("jp", keyboard_->last_layout_); |
1074 EXPECT_TRUE(manager_->SwitchInputMethod( | 1126 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1075 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1127 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1076 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1128 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
1077 manager_->GetCurrentInputMethod().id()); | 1129 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1078 EXPECT_EQ("jp", keyboard_->last_layout_); | 1130 EXPECT_EQ("jp", keyboard_->last_layout_); |
1079 EXPECT_TRUE(manager_->SwitchInputMethod( | 1131 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1080 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1132 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1081 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1133 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1082 manager_->GetCurrentInputMethod().id()); | 1134 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1083 EXPECT_EQ("jp", keyboard_->last_layout_); | 1135 EXPECT_EQ("jp", keyboard_->last_layout_); |
1084 EXPECT_TRUE(manager_->SwitchInputMethod( | 1136 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1085 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1137 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1086 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1138 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1087 manager_->GetCurrentInputMethod().id()); | 1139 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1088 EXPECT_EQ("jp", keyboard_->last_layout_); | 1140 EXPECT_EQ("jp", keyboard_->last_layout_); |
1089 | 1141 |
1090 // Add Dvorak. | 1142 // Add Dvorak. |
1091 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 1143 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
1092 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1144 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1093 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1145 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1094 manager_->GetCurrentInputMethod().id()); | 1146 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1095 EXPECT_EQ("jp", keyboard_->last_layout_); | 1147 EXPECT_EQ("jp", keyboard_->last_layout_); |
1096 EXPECT_TRUE(manager_->SwitchInputMethod( | 1148 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1097 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1149 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1098 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1150 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
1099 manager_->GetCurrentInputMethod().id()); | 1151 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1100 EXPECT_EQ("jp", keyboard_->last_layout_); | 1152 EXPECT_EQ("jp", keyboard_->last_layout_); |
1101 EXPECT_TRUE(manager_->SwitchInputMethod( | 1153 EXPECT_TRUE(manager_->GetActiveIMEState()->SwitchInputMethod( |
1102 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1154 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1103 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1155 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
1104 manager_->GetCurrentInputMethod().id()); | 1156 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1105 EXPECT_EQ("jp", keyboard_->last_layout_); | 1157 EXPECT_EQ("jp", keyboard_->last_layout_); |
1106 } | 1158 } |
1107 | 1159 |
1108 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 1160 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
1109 TestObserver observer; | 1161 TestObserver observer; |
1110 manager_->AddObserver(&observer); | 1162 manager_->AddObserver(&observer); |
1111 InitComponentExtension(); | 1163 InitComponentExtension(); |
1112 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1164 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1113 std::vector<std::string> ids; | 1165 std::vector<std::string> ids; |
1114 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 1166 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
1115 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1167 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1116 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1168 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1117 EXPECT_EQ(1, observer.input_method_changed_count_); | 1169 EXPECT_EQ(1, observer.input_method_changed_count_); |
1118 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 1170 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 1171 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1119 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1172 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1120 | 1173 |
1121 // Add two Extension IMEs. | 1174 // Add two Extension IMEs. |
1122 std::vector<std::string> layouts; | 1175 std::vector<std::string> layouts; |
1123 layouts.push_back("us"); | 1176 layouts.push_back("us"); |
1124 std::vector<std::string> languages; | 1177 std::vector<std::string> languages; |
1125 languages.push_back("en-US"); | 1178 languages.push_back("en-US"); |
1126 | 1179 |
1127 const std::string ext1_id = | 1180 const std::string ext1_id = |
1128 extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id"); | 1181 extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id"); |
1129 const InputMethodDescriptor descriptor1(ext1_id, | 1182 const InputMethodDescriptor descriptor1(ext1_id, |
1130 "deadbeef input method", | 1183 "deadbeef input method", |
1131 "DB", | 1184 "DB", |
1132 layouts, | 1185 layouts, |
1133 languages, | 1186 languages, |
1134 false, // is_login_keyboard | 1187 false, // is_login_keyboard |
1135 GURL(), | 1188 GURL(), |
1136 GURL()); | 1189 GURL()); |
1137 MockInputMethodEngine engine; | 1190 MockInputMethodEngine engine; |
1138 InputMethodDescriptors descriptors; | 1191 InputMethodDescriptors descriptors; |
1139 descriptors.push_back(descriptor1); | 1192 descriptors.push_back(descriptor1); |
1140 manager_->AddInputMethodExtension(kExtensionId1, descriptors, &engine); | 1193 manager_->GetActiveIMEState()->AddInputMethodExtension( |
| 1194 kExtensionId1, descriptors, &engine); |
1141 | 1195 |
1142 // Extension IMEs are not enabled by default. | 1196 // Extension IMEs are not enabled by default. |
1143 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1197 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1144 | 1198 |
1145 std::vector<std::string> extension_ime_ids; | 1199 std::vector<std::string> extension_ime_ids; |
1146 extension_ime_ids.push_back(ext1_id); | 1200 extension_ime_ids.push_back(ext1_id); |
1147 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 1201 manager_->GetActiveIMEState()->SetEnabledExtensionImes(&extension_ime_ids); |
1148 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1202 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1149 | 1203 |
1150 { | 1204 { |
1151 scoped_ptr<InputMethodDescriptors> methods( | 1205 scoped_ptr<InputMethodDescriptors> methods( |
1152 manager_->GetActiveInputMethods()); | 1206 manager_->GetActiveIMEState()->GetActiveInputMethods()); |
1153 ASSERT_EQ(2U, methods->size()); | 1207 ASSERT_EQ(2U, methods->size()); |
1154 // Ext IMEs should be at the end of the list. | 1208 // Ext IMEs should be at the end of the list. |
1155 EXPECT_EQ(ext1_id, methods->at(1).id()); | 1209 EXPECT_EQ(ext1_id, methods->at(1).id()); |
1156 } | 1210 } |
1157 | 1211 |
1158 const std::string ext2_id = | 1212 const std::string ext2_id = |
1159 extension_ime_util::GetInputMethodID(kExtensionId2, "engine_id"); | 1213 extension_ime_util::GetInputMethodID(kExtensionId2, "engine_id"); |
1160 const InputMethodDescriptor descriptor2(ext2_id, | 1214 const InputMethodDescriptor descriptor2(ext2_id, |
1161 "cafebabe input method", | 1215 "cafebabe input method", |
1162 "CB", | 1216 "CB", |
1163 layouts, | 1217 layouts, |
1164 languages, | 1218 languages, |
1165 false, // is_login_keyboard | 1219 false, // is_login_keyboard |
1166 GURL(), | 1220 GURL(), |
1167 GURL()); | 1221 GURL()); |
1168 descriptors.clear(); | 1222 descriptors.clear(); |
1169 descriptors.push_back(descriptor2); | 1223 descriptors.push_back(descriptor2); |
1170 MockInputMethodEngine engine2; | 1224 MockInputMethodEngine engine2; |
1171 manager_->AddInputMethodExtension(kExtensionId2, descriptors, &engine2); | 1225 manager_->GetActiveIMEState()->AddInputMethodExtension( |
1172 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1226 kExtensionId2, descriptors, &engine2); |
| 1227 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1173 | 1228 |
1174 extension_ime_ids.push_back(ext2_id); | 1229 extension_ime_ids.push_back(ext2_id); |
1175 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 1230 manager_->GetActiveIMEState()->SetEnabledExtensionImes(&extension_ime_ids); |
1176 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 1231 EXPECT_EQ(3U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1177 { | 1232 { |
1178 scoped_ptr<InputMethodDescriptors> methods( | 1233 scoped_ptr<InputMethodDescriptors> methods( |
1179 manager_->GetActiveInputMethods()); | 1234 manager_->GetActiveIMEState()->GetActiveInputMethods()); |
1180 ASSERT_EQ(3U, methods->size()); | 1235 ASSERT_EQ(3U, methods->size()); |
1181 // Ext IMEs should be at the end of the list. | 1236 // Ext IMEs should be at the end of the list. |
1182 EXPECT_EQ(ext1_id, methods->at(1).id()); | 1237 EXPECT_EQ(ext1_id, methods->at(1).id()); |
1183 EXPECT_EQ(ext2_id, methods->at(2).id()); | 1238 EXPECT_EQ(ext2_id, methods->at(2).id()); |
1184 } | 1239 } |
1185 | 1240 |
1186 // Remove them. | 1241 // Remove them. |
1187 manager_->RemoveInputMethodExtension(kExtensionId1); | 1242 manager_->GetActiveIMEState()->RemoveInputMethodExtension(kExtensionId1); |
1188 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1243 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1189 manager_->RemoveInputMethodExtension(kExtensionId2); | 1244 manager_->GetActiveIMEState()->RemoveInputMethodExtension(kExtensionId2); |
1190 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1245 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1191 } | 1246 } |
1192 | 1247 |
1193 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 1248 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
1194 TestObserver observer; | 1249 TestObserver observer; |
1195 InitComponentExtension(); | 1250 InitComponentExtension(); |
1196 manager_->AddObserver(&observer); | 1251 manager_->AddObserver(&observer); |
1197 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1252 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1198 std::vector<std::string> ids; | 1253 std::vector<std::string> ids; |
1199 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1254 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1200 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1255 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1201 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1256 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1202 EXPECT_EQ(1, observer.input_method_changed_count_); | 1257 EXPECT_EQ(1, observer.input_method_changed_count_); |
1203 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 1258 EXPECT_EQ(ImeIdFromEngineId(ids[0]), |
| 1259 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1204 EXPECT_EQ("us", keyboard_->last_layout_); | 1260 EXPECT_EQ("us", keyboard_->last_layout_); |
1205 | 1261 |
1206 // Add an Extension IME. | 1262 // Add an Extension IME. |
1207 std::vector<std::string> layouts; | 1263 std::vector<std::string> layouts; |
1208 layouts.push_back("us(dvorak)"); | 1264 layouts.push_back("us(dvorak)"); |
1209 std::vector<std::string> languages; | 1265 std::vector<std::string> languages; |
1210 languages.push_back("en-US"); | 1266 languages.push_back("en-US"); |
1211 | 1267 |
1212 const std::string ext_id = | 1268 const std::string ext_id = |
1213 extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id"); | 1269 extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id"); |
1214 const InputMethodDescriptor descriptor(ext_id, | 1270 const InputMethodDescriptor descriptor(ext_id, |
1215 "deadbeef input method", | 1271 "deadbeef input method", |
1216 "DB", | 1272 "DB", |
1217 layouts, | 1273 layouts, |
1218 languages, | 1274 languages, |
1219 false, // is_login_keyboard | 1275 false, // is_login_keyboard |
1220 GURL(), | 1276 GURL(), |
1221 GURL()); | 1277 GURL()); |
1222 MockInputMethodEngine engine; | 1278 MockInputMethodEngine engine; |
1223 InputMethodDescriptors descriptors; | 1279 InputMethodDescriptors descriptors; |
1224 descriptors.push_back(descriptor); | 1280 descriptors.push_back(descriptor); |
1225 manager_->AddInputMethodExtension(kExtensionId1, descriptors, &engine); | 1281 manager_->GetActiveIMEState()->AddInputMethodExtension( |
| 1282 kExtensionId1, descriptors, &engine); |
1226 | 1283 |
1227 // Extension IME is not enabled by default. | 1284 // Extension IME is not enabled by default. |
1228 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1285 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1229 EXPECT_EQ(1, observer.input_method_changed_count_); | 1286 EXPECT_EQ(1, observer.input_method_changed_count_); |
1230 | 1287 |
1231 std::vector<std::string> extension_ime_ids; | 1288 std::vector<std::string> extension_ime_ids; |
1232 extension_ime_ids.push_back(ext_id); | 1289 extension_ime_ids.push_back(ext_id); |
1233 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 1290 manager_->GetActiveIMEState()->SetEnabledExtensionImes(&extension_ime_ids); |
1234 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1291 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1235 | 1292 |
1236 // Switch to the IME. | 1293 // Switch to the IME. |
1237 manager_->SwitchToNextInputMethod(); | 1294 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
1238 EXPECT_EQ(3, observer.input_method_changed_count_); | 1295 EXPECT_EQ(3, observer.input_method_changed_count_); |
1239 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1296 EXPECT_EQ(ext_id, |
| 1297 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1240 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1298 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1241 | 1299 |
1242 // Lock the screen. This is for crosbug.com/27049. | 1300 // Lock the screen. This is for crosbug.com/27049. |
1243 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 1301 manager_->SetUISessionState(InputMethodManager::STATE_LOCK_SCREEN); |
1244 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME | 1302 EXPECT_EQ(1U, |
| 1303 manager_->GetActiveIMEState() |
| 1304 ->GetNumActiveInputMethods()); // Qwerty. No Ext. IME |
1245 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 1305 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
1246 manager_->GetCurrentInputMethod().id()); | 1306 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1247 EXPECT_EQ("us", keyboard_->last_layout_); | 1307 EXPECT_EQ("us", keyboard_->last_layout_); |
1248 | 1308 |
1249 // Unlock the screen. | 1309 // Unlock the screen. |
1250 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1310 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1251 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1311 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1252 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1312 EXPECT_EQ(ext_id, |
| 1313 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1253 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1314 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
1254 { | 1315 { |
1255 // This is for crosbug.com/27052. | 1316 // This is for crosbug.com/27052. |
1256 scoped_ptr<InputMethodDescriptors> methods( | 1317 scoped_ptr<InputMethodDescriptors> methods( |
1257 manager_->GetActiveInputMethods()); | 1318 manager_->GetActiveIMEState()->GetActiveInputMethods()); |
1258 ASSERT_EQ(2U, methods->size()); | 1319 ASSERT_EQ(2U, methods->size()); |
1259 // Ext. IMEs should be at the end of the list. | 1320 // Ext. IMEs should be at the end of the list. |
1260 EXPECT_EQ(ext_id, methods->at(1).id()); | 1321 EXPECT_EQ(ext_id, methods->at(1).id()); |
1261 } | 1322 } |
1262 manager_->RemoveObserver(&observer); | 1323 manager_->RemoveObserver(&observer); |
1263 } | 1324 } |
1264 | 1325 |
1265 TEST_F(InputMethodManagerImplTest, | 1326 TEST_F(InputMethodManagerImplTest, |
1266 ChangeInputMethod_ComponenteExtensionOneIME) { | 1327 ChangeInputMethod_ComponenteExtensionOneIME) { |
1267 InitComponentExtension(); | 1328 InitComponentExtension(); |
1268 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1329 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1269 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1330 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
1270 ime_list_[1].id, | 1331 ime_list_[1].id, |
1271 ime_list_[1].engines[0].engine_id); | 1332 ime_list_[1].engines[0].engine_id); |
1272 std::vector<std::string> ids; | 1333 std::vector<std::string> ids; |
1273 ids.push_back(ext_id); | 1334 ids.push_back(ext_id); |
1274 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1335 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1275 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1336 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1276 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1337 EXPECT_EQ(ext_id, |
| 1338 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1277 } | 1339 } |
1278 | 1340 |
1279 TEST_F(InputMethodManagerImplTest, | 1341 TEST_F(InputMethodManagerImplTest, |
1280 ChangeInputMethod_ComponenteExtensionTwoIME) { | 1342 ChangeInputMethod_ComponenteExtensionTwoIME) { |
1281 InitComponentExtension(); | 1343 InitComponentExtension(); |
1282 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1344 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
1283 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1345 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
1284 ime_list_[1].id, | 1346 ime_list_[1].id, |
1285 ime_list_[1].engines[0].engine_id); | 1347 ime_list_[1].engines[0].engine_id); |
1286 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1348 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
1287 ime_list_[2].id, | 1349 ime_list_[2].id, |
1288 ime_list_[2].engines[0].engine_id); | 1350 ime_list_[2].engines[0].engine_id); |
1289 std::vector<std::string> ids; | 1351 std::vector<std::string> ids; |
1290 ids.push_back(ext_id1); | 1352 ids.push_back(ext_id1); |
1291 ids.push_back(ext_id2); | 1353 ids.push_back(ext_id2); |
1292 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1354 EXPECT_TRUE(manager_->GetActiveIMEState()->ReplaceEnabledInputMethods(ids)); |
1293 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1355 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1294 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1356 EXPECT_EQ(ext_id1, |
1295 manager_->ChangeInputMethod(ext_id2); | 1357 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1296 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1358 manager_->GetActiveIMEState()->ChangeInputMethod(ext_id2, |
| 1359 false /* show_message */); |
| 1360 EXPECT_EQ(ext_id2, |
| 1361 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
1297 } | 1362 } |
1298 | 1363 |
1299 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest) { | 1364 TEST_F(InputMethodManagerImplTest, MigrateInputMethodTest) { |
1300 std::vector<std::string> input_method_ids; | 1365 std::vector<std::string> input_method_ids; |
1301 input_method_ids.push_back("xkb:us::eng"); | 1366 input_method_ids.push_back("xkb:us::eng"); |
1302 input_method_ids.push_back("xkb:fr::fra"); | 1367 input_method_ids.push_back("xkb:fr::fra"); |
1303 input_method_ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1368 input_method_ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1304 input_method_ids.push_back("xkb:fr::fra"); | 1369 input_method_ids.push_back("xkb:fr::fra"); |
1305 input_method_ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1370 input_method_ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1306 input_method_ids.push_back("_comp_ime_asdf_pinyin"); | 1371 input_method_ids.push_back("_comp_ime_asdf_pinyin"); |
1307 input_method_ids.push_back(ImeIdFromEngineId(kPinyinImeId)); | 1372 input_method_ids.push_back(ImeIdFromEngineId(kPinyinImeId)); |
1308 | 1373 |
1309 manager_->MigrateInputMethods(&input_method_ids); | 1374 manager_->MigrateInputMethods(&input_method_ids); |
1310 | 1375 |
1311 ASSERT_EQ(4U, input_method_ids.size()); | 1376 ASSERT_EQ(4U, input_method_ids.size()); |
1312 | 1377 |
1313 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1378 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
1314 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1379 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
1315 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1380 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1316 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1381 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
1317 } | 1382 } |
1318 | 1383 |
1319 } // namespace input_method | 1384 } // namespace input_method |
1320 } // namespace chromeos | 1385 } // namespace chromeos |
OLD | NEW |