| 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 495 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
| 496 ImeIdFromEngineId("xkb:jp::jpn")); | 496 ImeIdFromEngineId("xkb:jp::jpn")); |
| 497 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); | 497 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
| 498 } | 498 } |
| 499 | 499 |
| 500 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 500 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
| 501 // For http://crbug.com/19655#c11 - (8), step 6. | 501 // For http://crbug.com/19655#c11 - (8), step 6. |
| 502 TestObserver observer; | 502 TestObserver observer; |
| 503 manager_->AddObserver(&observer); | 503 manager_->AddObserver(&observer); |
| 504 InitComponentExtension(); | 504 InitComponentExtension(); |
| 505 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 505 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 506 std::vector<std::string> ids; | 506 std::vector<std::string> ids; |
| 507 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 507 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 508 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 508 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
| 509 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 509 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 510 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 510 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 511 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 511 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
| 512 // called. | 512 // called. |
| 513 EXPECT_EQ(1, observer.input_method_changed_count_); | 513 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 514 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 514 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 515 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 515 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 516 // Disable Dvorak. | 516 // Disable Dvorak. |
| 517 ids.erase(ids.begin()); | 517 ids.erase(ids.begin()); |
| 518 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 518 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 519 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 519 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 520 EXPECT_EQ(2, observer.input_method_changed_count_); | 520 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 521 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // colemak | 521 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // colemak |
| 522 manager_->GetCurrentInputMethod().id()); | 522 manager_->GetCurrentInputMethod().id()); |
| 523 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 523 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
| 524 manager_->RemoveObserver(&observer); | 524 manager_->RemoveObserver(&observer); |
| 525 } | 525 } |
| 526 | 526 |
| 527 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 527 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
| 528 // For http://crbug.com/19655#c11 - (9). | 528 // For http://crbug.com/19655#c11 - (9). |
| 529 TestObserver observer; | 529 TestObserver observer; |
| 530 manager_->AddObserver(&observer); | 530 manager_->AddObserver(&observer); |
| 531 InitComponentExtension(); | 531 InitComponentExtension(); |
| 532 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 532 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 533 std::vector<std::string> ids; | 533 std::vector<std::string> ids; |
| 534 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 534 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
| 535 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 535 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 536 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 536 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
| 537 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 537 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 538 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 538 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
| 539 EXPECT_EQ(1, observer.input_method_changed_count_); | 539 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 540 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 540 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 541 EXPECT_EQ("us", keyboard_->last_layout_); | 541 EXPECT_EQ("us", keyboard_->last_layout_); |
| 542 // Switch to Dvorak. | 542 // Switch to Dvorak. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 553 manager_->GetCurrentInputMethod().id()); | 553 manager_->GetCurrentInputMethod().id()); |
| 554 EXPECT_EQ("us", keyboard_->last_layout_); | 554 EXPECT_EQ("us", keyboard_->last_layout_); |
| 555 manager_->RemoveObserver(&observer); | 555 manager_->RemoveObserver(&observer); |
| 556 } | 556 } |
| 557 | 557 |
| 558 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 558 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
| 559 // For http://crbug.com/19655#c11 - (10). | 559 // For http://crbug.com/19655#c11 - (10). |
| 560 TestObserver observer; | 560 TestObserver observer; |
| 561 manager_->AddObserver(&observer); | 561 manager_->AddObserver(&observer); |
| 562 InitComponentExtension(); | 562 InitComponentExtension(); |
| 563 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 563 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 564 std::vector<std::string> ids; | 564 std::vector<std::string> ids; |
| 565 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 565 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 566 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 566 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 567 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 567 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 568 EXPECT_EQ(1, observer.input_method_changed_count_); | 568 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 569 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 569 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 570 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 570 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 571 // Switch to Mozc | 571 // Switch to Mozc |
| 572 manager_->SwitchToNextInputMethod(); | 572 manager_->SwitchToNextInputMethod(); |
| 573 EXPECT_EQ(2, observer.input_method_changed_count_); | 573 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 574 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 574 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); |
| 575 EXPECT_EQ("us", keyboard_->last_layout_); | 575 EXPECT_EQ("us", keyboard_->last_layout_); |
| 576 // Disable Mozc. | 576 // Disable Mozc. |
| 577 ids.erase(ids.begin() + 1); | 577 ids.erase(ids.begin() + 1); |
| 578 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 578 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 579 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 579 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 580 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 580 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 581 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 581 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 582 } | 582 } |
| 583 | 583 |
| 584 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 584 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
| 585 // For http://crbug.com/19655#c11 - (11). | 585 // For http://crbug.com/19655#c11 - (11). |
| 586 TestObserver observer; | 586 TestObserver observer; |
| 587 manager_->AddObserver(&observer); | 587 manager_->AddObserver(&observer); |
| 588 InitComponentExtension(); | 588 InitComponentExtension(); |
| 589 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 589 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 590 std::vector<std::string> ids; | 590 std::vector<std::string> ids; |
| 591 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 591 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 592 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 592 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 593 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 593 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 594 EXPECT_EQ(1, observer.input_method_changed_count_); | 594 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 595 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 595 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 596 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 596 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 597 | 597 |
| 598 // Disable Dvorak. | 598 // Disable Dvorak. |
| 599 ids.erase(ids.begin()); | 599 ids.erase(ids.begin()); |
| 600 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 600 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 601 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 601 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 602 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // Mozc | 602 EXPECT_EQ(ImeIdFromEngineId(ids[0]), // Mozc |
| 603 manager_->GetCurrentInputMethod().id()); | 603 manager_->GetCurrentInputMethod().id()); |
| 604 EXPECT_EQ("us", keyboard_->last_layout_); | 604 EXPECT_EQ("us", keyboard_->last_layout_); |
| 605 manager_->RemoveObserver(&observer); | 605 manager_->RemoveObserver(&observer); |
| 606 } | 606 } |
| 607 | 607 |
| 608 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 608 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
| 609 TestObserver observer; | 609 TestObserver observer; |
| 610 manager_->AddObserver(&observer); | 610 manager_->AddObserver(&observer); |
| 611 InitComponentExtension(); | 611 InitComponentExtension(); |
| 612 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 612 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 613 std::vector<std::string> ids; | 613 std::vector<std::string> ids; |
| 614 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); | 614 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); |
| 615 ids.push_back("mozc-dv"); | 615 ids.push_back("mozc-dv"); |
| 616 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 616 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 617 EXPECT_EQ(1, observer.input_method_changed_count_); | 617 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 618 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 618 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 619 EXPECT_EQ("us", keyboard_->last_layout_); | 619 EXPECT_EQ("us", keyboard_->last_layout_); |
| 620 manager_->RemoveObserver(&observer); | 620 manager_->RemoveObserver(&observer); |
| 621 } | 621 } |
| 622 | 622 |
| 623 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 623 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
| 624 TestObserver observer; | 624 TestObserver observer; |
| 625 manager_->AddObserver(&observer); | 625 manager_->AddObserver(&observer); |
| 626 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 626 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 627 std::vector<std::string> ids; | 627 std::vector<std::string> ids; |
| 628 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 628 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
| 629 ids.push_back("unknown-super-cool-ime"); | 629 ids.push_back("unknown-super-cool-ime"); |
| 630 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); | 630 EXPECT_FALSE(manager_->ReplaceEnabledInputMethods(ids)); |
| 631 | 631 |
| 632 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this | 632 // TODO(yusukes): Should we fall back to the hardware keyboard layout in this |
| 633 // case? | 633 // case? |
| 634 EXPECT_EQ(0, observer.input_method_changed_count_); | 634 EXPECT_EQ(0, observer.input_method_changed_count_); |
| 635 | 635 |
| 636 manager_->RemoveObserver(&observer); | 636 manager_->RemoveObserver(&observer); |
| 637 } | 637 } |
| 638 | 638 |
| 639 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { | 639 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { |
| 640 // For http://crbug.com/19655#c11 - (14). | 640 // For http://crbug.com/19655#c11 - (14). |
| 641 TestObserver observer; | 641 TestObserver observer; |
| 642 manager_->AddObserver(&observer); | 642 manager_->AddObserver(&observer); |
| 643 InitComponentExtension(); | 643 InitComponentExtension(); |
| 644 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 644 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 645 std::vector<std::string> ids; | 645 std::vector<std::string> ids; |
| 646 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 646 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
| 647 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 647 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 648 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 648 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 649 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 649 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 650 EXPECT_EQ(1, observer.input_method_changed_count_); | 650 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 651 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 651 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 652 EXPECT_EQ("us", keyboard_->last_layout_); | 652 EXPECT_EQ("us", keyboard_->last_layout_); |
| 653 | 653 |
| 654 // Switch to Dvorak. | 654 // Switch to Dvorak. |
| 655 manager_->SwitchToNextInputMethod(); | 655 manager_->SwitchToNextInputMethod(); |
| 656 EXPECT_EQ(2, observer.input_method_changed_count_); | 656 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 657 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 657 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); |
| 658 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 658 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 659 | 659 |
| 660 // Lock screen | 660 // Lock screen |
| 661 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 661 manager_->SetUIState(InputMethodManager::STATE_LOCK_SCREEN); |
| 662 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 662 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 663 EXPECT_EQ(ImeIdFromEngineId(ids[1]), // still Dvorak | 663 EXPECT_EQ(ImeIdFromEngineId(ids[1]), // still Dvorak |
| 664 manager_->GetCurrentInputMethod().id()); | 664 manager_->GetCurrentInputMethod().id()); |
| 665 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 665 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 666 // Switch back to Qwerty. | 666 // Switch back to Qwerty. |
| 667 manager_->SwitchToNextInputMethod(); | 667 manager_->SwitchToNextInputMethod(); |
| 668 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 668 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 669 EXPECT_EQ("us", keyboard_->last_layout_); | 669 EXPECT_EQ("us", keyboard_->last_layout_); |
| 670 | 670 |
| 671 // Unlock screen. The original state, Dvorak, is restored. | 671 // Unlock screen. The original state, Dvorak, is restored. |
| 672 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 672 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 673 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 673 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 674 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 674 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); |
| 675 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 675 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 676 | 676 |
| 677 manager_->RemoveObserver(&observer); | 677 manager_->RemoveObserver(&observer); |
| 678 } | 678 } |
| 679 | 679 |
| 680 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 680 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
| 681 // For http://crbug.com/19655#c11 - (15). | 681 // For http://crbug.com/19655#c11 - (15). |
| 682 TestObserver observer; | 682 TestObserver observer; |
| 683 manager_->AddObserver(&observer); | 683 manager_->AddObserver(&observer); |
| 684 InitComponentExtension(); | 684 InitComponentExtension(); |
| 685 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 685 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 686 std::vector<std::string> ids; | 686 std::vector<std::string> ids; |
| 687 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 687 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 688 ids.push_back(ImeIdFromEngineId(kExt2Engine2Id)); | 688 ids.push_back(ImeIdFromEngineId(kExt2Engine2Id)); |
| 689 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); | 689 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); |
| 690 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 690 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 691 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 691 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
| 692 EXPECT_EQ(1, observer.input_method_changed_count_); | 692 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 693 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 693 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 694 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 694 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 695 | 695 |
| 696 // Switch to Mozc. | 696 // Switch to Mozc. |
| 697 manager_->SwitchToNextInputMethod(); | 697 manager_->SwitchToNextInputMethod(); |
| 698 EXPECT_EQ(2, observer.input_method_changed_count_); | 698 EXPECT_EQ(2, observer.input_method_changed_count_); |
| 699 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 699 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); |
| 700 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 700 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 701 | 701 |
| 702 // Lock screen | 702 // Lock screen |
| 703 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 703 manager_->SetUIState(InputMethodManager::STATE_LOCK_SCREEN); |
| 704 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. | 704 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. |
| 705 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), | 705 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), |
| 706 manager_->GetCurrentInputMethod().id()); | 706 manager_->GetCurrentInputMethod().id()); |
| 707 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 707 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 708 manager_->SwitchToNextInputMethod(); | 708 manager_->SwitchToNextInputMethod(); |
| 709 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), // The hardware keyboard layout. | 709 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), // The hardware keyboard layout. |
| 710 manager_->GetCurrentInputMethod().id()); | 710 manager_->GetCurrentInputMethod().id()); |
| 711 EXPECT_EQ("us", keyboard_->last_layout_); | 711 EXPECT_EQ("us", keyboard_->last_layout_); |
| 712 | 712 |
| 713 // Unlock screen. The original state, pinyin-dv, is restored. | 713 // Unlock screen. The original state, pinyin-dv, is restored. |
| 714 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 714 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 715 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. | 715 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. |
| 716 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); | 716 EXPECT_EQ(ImeIdFromEngineId(ids[1]), manager_->GetCurrentInputMethod().id()); |
| 717 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 717 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 718 | 718 |
| 719 manager_->RemoveObserver(&observer); | 719 manager_->RemoveObserver(&observer); |
| 720 } | 720 } |
| 721 | 721 |
| 722 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 722 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
| 723 // For http://crbug.com/19655#c11 - (8), step 7-11. | 723 // For http://crbug.com/19655#c11 - (8), step 7-11. |
| 724 InitComponentExtension(); | 724 InitComponentExtension(); |
| 725 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 725 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 726 std::vector<std::string> ids; | 726 std::vector<std::string> ids; |
| 727 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 727 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 728 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); | 728 ids.push_back(ImeIdFromEngineId("xkb:us:colemak:eng")); |
| 729 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | 729 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); |
| 730 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 730 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 731 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 731 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 732 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); | 732 EXPECT_EQ(4U, manager_->GetNumActiveInputMethods()); |
| 733 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); | 733 EXPECT_EQ(1, keyboard_->set_current_keyboard_layout_by_name_count_); |
| 734 // See input_methods.txt for an expected XKB layout name. | 734 // See input_methods.txt for an expected XKB layout name. |
| 735 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 735 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 765 | 765 |
| 766 // Key2 is not registered, so activated property should not be changed. | 766 // Key2 is not registered, so activated property should not be changed. |
| 767 manager_->ActivateInputMethodMenuItem("key2"); | 767 manager_->ActivateInputMethodMenuItem("key2"); |
| 768 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); | 768 EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
| 769 } | 769 } |
| 770 | 770 |
| 771 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { | 771 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
| 772 InitComponentExtension(); | 772 InitComponentExtension(); |
| 773 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 773 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
| 774 | 774 |
| 775 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 775 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 776 std::vector<std::string> ids; | 776 std::vector<std::string> ids; |
| 777 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 777 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
| 778 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 778 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 779 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 779 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 780 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 780 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 781 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 781 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
| 782 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | 782 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); |
| 783 | 783 |
| 784 ash::ime::InputMethodMenuItemList current_property_list; | 784 ash::ime::InputMethodMenuItemList current_property_list; |
| 785 current_property_list.push_back(ash::ime::InputMethodMenuItem( | 785 current_property_list.push_back(ash::ime::InputMethodMenuItem( |
| 786 "key", "label", false, false)); | 786 "key", "label", false, false)); |
| 787 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); | 787 menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
| 788 | 788 |
| 789 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); | 789 ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
| 790 EXPECT_EQ("key", | 790 EXPECT_EQ("key", |
| 791 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); | 791 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
| 792 | 792 |
| 793 manager_->ChangeInputMethod("xkb:us::eng"); | 793 manager_->ChangeInputMethod("xkb:us::eng"); |
| 794 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 794 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
| 795 } | 795 } |
| 796 | 796 |
| 797 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { | 797 TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
| 798 InitComponentExtension(); | 798 InitComponentExtension(); |
| 799 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 799 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
| 800 | 800 |
| 801 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 801 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 802 std::vector<std::string> ids; | 802 std::vector<std::string> ids; |
| 803 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); // Japanese | 803 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); // Japanese |
| 804 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); // T-Chinese | 804 ids.push_back(ImeIdFromEngineId(kExt2Engine1Id)); // T-Chinese |
| 805 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 805 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 806 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 806 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 807 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); | 807 EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
| 808 | 808 |
| 809 ash::ime::InputMethodMenuItemList current_property_list; | 809 ash::ime::InputMethodMenuItemList current_property_list; |
| 810 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", | 810 current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", |
| 811 "label", | 811 "label", |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 EXPECT_EQ("us", keyboard_->last_layout_); | 1035 EXPECT_EQ("us", keyboard_->last_layout_); |
| 1036 EXPECT_TRUE(manager_->SwitchInputMethod( | 1036 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 1037 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1037 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 1038 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1038 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
| 1039 manager_->GetCurrentInputMethod().id()); | 1039 manager_->GetCurrentInputMethod().id()); |
| 1040 EXPECT_EQ("jp", keyboard_->last_layout_); | 1040 EXPECT_EQ("jp", keyboard_->last_layout_); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 1043 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
| 1044 InitComponentExtension(); | 1044 InitComponentExtension(); |
| 1045 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1045 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1046 std::vector<std::string> ids; | 1046 std::vector<std::string> ids; |
| 1047 ids.push_back(ImeIdFromEngineId("xkb:jp::jpn")); | 1047 ids.push_back(ImeIdFromEngineId("xkb:jp::jpn")); |
| 1048 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | 1048 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); |
| 1049 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1049 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1050 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1050 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
| 1051 manager_->GetCurrentInputMethod().id()); | 1051 manager_->GetCurrentInputMethod().id()); |
| 1052 EXPECT_EQ("jp", keyboard_->last_layout_); | 1052 EXPECT_EQ("jp", keyboard_->last_layout_); |
| 1053 EXPECT_TRUE(manager_->SwitchInputMethod( | 1053 EXPECT_TRUE(manager_->SwitchInputMethod( |
| 1054 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1054 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
| 1055 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1055 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1096 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
| 1097 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), | 1097 EXPECT_EQ(ImeIdFromEngineId("xkb:jp::jpn"), |
| 1098 manager_->GetCurrentInputMethod().id()); | 1098 manager_->GetCurrentInputMethod().id()); |
| 1099 EXPECT_EQ("jp", keyboard_->last_layout_); | 1099 EXPECT_EQ("jp", keyboard_->last_layout_); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 1102 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
| 1103 TestObserver observer; | 1103 TestObserver observer; |
| 1104 manager_->AddObserver(&observer); | 1104 manager_->AddObserver(&observer); |
| 1105 InitComponentExtension(); | 1105 InitComponentExtension(); |
| 1106 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1106 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1107 std::vector<std::string> ids; | 1107 std::vector<std::string> ids; |
| 1108 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); | 1108 ids.push_back(ImeIdFromEngineId("xkb:us:dvorak:eng")); |
| 1109 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1109 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1110 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1110 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1111 EXPECT_EQ(1, observer.input_method_changed_count_); | 1111 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 1112 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 1112 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 1113 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1113 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 1114 | 1114 |
| 1115 // Add two Extension IMEs. | 1115 // Add two Extension IMEs. |
| 1116 std::vector<std::string> layouts; | 1116 std::vector<std::string> layouts; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 manager_->RemoveInputMethodExtension(ext1_id); | 1177 manager_->RemoveInputMethodExtension(ext1_id); |
| 1178 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1178 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1179 manager_->RemoveInputMethodExtension(ext2_id); | 1179 manager_->RemoveInputMethodExtension(ext2_id); |
| 1180 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1180 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 1183 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
| 1184 TestObserver observer; | 1184 TestObserver observer; |
| 1185 InitComponentExtension(); | 1185 InitComponentExtension(); |
| 1186 manager_->AddObserver(&observer); | 1186 manager_->AddObserver(&observer); |
| 1187 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1187 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1188 std::vector<std::string> ids; | 1188 std::vector<std::string> ids; |
| 1189 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1189 ids.push_back(ImeIdFromEngineId("xkb:us::eng")); |
| 1190 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1190 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1191 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1191 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1192 EXPECT_EQ(1, observer.input_method_changed_count_); | 1192 EXPECT_EQ(1, observer.input_method_changed_count_); |
| 1193 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); | 1193 EXPECT_EQ(ImeIdFromEngineId(ids[0]), manager_->GetCurrentInputMethod().id()); |
| 1194 EXPECT_EQ("us", keyboard_->last_layout_); | 1194 EXPECT_EQ("us", keyboard_->last_layout_); |
| 1195 | 1195 |
| 1196 // Add an Extension IME. | 1196 // Add an Extension IME. |
| 1197 std::vector<std::string> layouts; | 1197 std::vector<std::string> layouts; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1221 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 1221 manager_->SetEnabledExtensionImes(&extension_ime_ids); |
| 1222 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1222 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1223 | 1223 |
| 1224 // Switch to the IME. | 1224 // Switch to the IME. |
| 1225 manager_->SwitchToNextInputMethod(); | 1225 manager_->SwitchToNextInputMethod(); |
| 1226 EXPECT_EQ(3, observer.input_method_changed_count_); | 1226 EXPECT_EQ(3, observer.input_method_changed_count_); |
| 1227 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1227 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1228 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1228 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 1229 | 1229 |
| 1230 // Lock the screen. This is for crosbug.com/27049. | 1230 // Lock the screen. This is for crosbug.com/27049. |
| 1231 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 1231 manager_->SetUIState(InputMethodManager::STATE_LOCK_SCREEN); |
| 1232 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME | 1232 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME |
| 1233 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 1233 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
| 1234 manager_->GetCurrentInputMethod().id()); | 1234 manager_->GetCurrentInputMethod().id()); |
| 1235 EXPECT_EQ("us", keyboard_->last_layout_); | 1235 EXPECT_EQ("us", keyboard_->last_layout_); |
| 1236 | 1236 |
| 1237 // Unlock the screen. | 1237 // Unlock the screen. |
| 1238 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1238 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1239 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1239 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1240 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1240 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1241 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 1241 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
| 1242 { | 1242 { |
| 1243 // This is for crosbug.com/27052. | 1243 // This is for crosbug.com/27052. |
| 1244 scoped_ptr<InputMethodDescriptors> methods( | 1244 scoped_ptr<InputMethodDescriptors> methods( |
| 1245 manager_->GetActiveInputMethods()); | 1245 manager_->GetActiveInputMethods()); |
| 1246 ASSERT_EQ(2U, methods->size()); | 1246 ASSERT_EQ(2U, methods->size()); |
| 1247 // Ext. IMEs should be at the end of the list. | 1247 // Ext. IMEs should be at the end of the list. |
| 1248 EXPECT_EQ(ext_id, methods->at(1).id()); | 1248 EXPECT_EQ(ext_id, methods->at(1).id()); |
| 1249 } | 1249 } |
| 1250 manager_->RemoveObserver(&observer); | 1250 manager_->RemoveObserver(&observer); |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 TEST_F(InputMethodManagerImplTest, | 1253 TEST_F(InputMethodManagerImplTest, |
| 1254 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { | 1254 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { |
| 1255 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1255 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1256 std::vector<std::string> ids; | 1256 std::vector<std::string> ids; |
| 1257 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 1257 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 1258 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1258 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1259 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1259 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1260 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | 1260 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); |
| 1261 | 1261 |
| 1262 InitComponentExtension(); | 1262 InitComponentExtension(); |
| 1263 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcUsId), | 1263 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcUsId), |
| 1264 manager_->GetCurrentInputMethod().id()); | 1264 manager_->GetCurrentInputMethod().id()); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 TEST_F(InputMethodManagerImplTest, | 1267 TEST_F(InputMethodManagerImplTest, |
| 1268 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { | 1268 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { |
| 1269 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1269 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1270 std::vector<std::string> ids; | 1270 std::vector<std::string> ids; |
| 1271 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | 1271 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); |
| 1272 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | 1272 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); |
| 1273 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1273 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1274 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1274 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1275 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | 1275 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); |
| 1276 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcJpId)); | 1276 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcJpId)); |
| 1277 | 1277 |
| 1278 InitComponentExtension(); | 1278 InitComponentExtension(); |
| 1279 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | 1279 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), |
| 1280 manager_->GetCurrentInputMethod().id()); | 1280 manager_->GetCurrentInputMethod().id()); |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 TEST_F(InputMethodManagerImplTest, | 1283 TEST_F(InputMethodManagerImplTest, |
| 1284 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | 1284 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { |
| 1285 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1285 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1286 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1286 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1287 ime_list_[1].id, | 1287 ime_list_[1].id, |
| 1288 ime_list_[1].engines[0].engine_id); | 1288 ime_list_[1].engines[0].engine_id); |
| 1289 std::vector<std::string> ids; | 1289 std::vector<std::string> ids; |
| 1290 ids.push_back(ext_id); | 1290 ids.push_back(ext_id); |
| 1291 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1291 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1292 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1292 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1293 manager_->ChangeInputMethod(ext_id); | 1293 manager_->ChangeInputMethod(ext_id); |
| 1294 | 1294 |
| 1295 InitComponentExtension(); | 1295 InitComponentExtension(); |
| 1296 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1296 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 TEST_F(InputMethodManagerImplTest, | 1299 TEST_F(InputMethodManagerImplTest, |
| 1300 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { | 1300 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { |
| 1301 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1301 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1302 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1302 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1303 ime_list_[1].id, | 1303 ime_list_[1].id, |
| 1304 ime_list_[1].engines[0].engine_id); | 1304 ime_list_[1].engines[0].engine_id); |
| 1305 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1305 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1306 ime_list_[2].id, | 1306 ime_list_[2].id, |
| 1307 ime_list_[2].engines[0].engine_id); | 1307 ime_list_[2].engines[0].engine_id); |
| 1308 std::vector<std::string> ids; | 1308 std::vector<std::string> ids; |
| 1309 ids.push_back(ext_id1); | 1309 ids.push_back(ext_id1); |
| 1310 ids.push_back(ext_id2); | 1310 ids.push_back(ext_id2); |
| 1311 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1311 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1312 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1312 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1313 manager_->ChangeInputMethod(ext_id1); | 1313 manager_->ChangeInputMethod(ext_id1); |
| 1314 manager_->ChangeInputMethod(ext_id2); | 1314 manager_->ChangeInputMethod(ext_id2); |
| 1315 | 1315 |
| 1316 InitComponentExtension(); | 1316 InitComponentExtension(); |
| 1317 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1317 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 TEST_F(InputMethodManagerImplTest, | 1320 TEST_F(InputMethodManagerImplTest, |
| 1321 ChangeInputMethod_ComponenteExtensionOneIME) { | 1321 ChangeInputMethod_ComponenteExtensionOneIME) { |
| 1322 InitComponentExtension(); | 1322 InitComponentExtension(); |
| 1323 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1323 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1324 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1324 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
| 1325 ime_list_[1].id, | 1325 ime_list_[1].id, |
| 1326 ime_list_[1].engines[0].engine_id); | 1326 ime_list_[1].engines[0].engine_id); |
| 1327 std::vector<std::string> ids; | 1327 std::vector<std::string> ids; |
| 1328 ids.push_back(ext_id); | 1328 ids.push_back(ext_id); |
| 1329 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1329 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| 1330 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1330 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 1331 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1331 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 TEST_F(InputMethodManagerImplTest, | 1334 TEST_F(InputMethodManagerImplTest, |
| 1335 ChangeInputMethod_ComponenteExtensionTwoIME) { | 1335 ChangeInputMethod_ComponenteExtensionTwoIME) { |
| 1336 InitComponentExtension(); | 1336 InitComponentExtension(); |
| 1337 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1337 manager_->SetUIState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1338 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1338 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
| 1339 ime_list_[1].id, | 1339 ime_list_[1].id, |
| 1340 ime_list_[1].engines[0].engine_id); | 1340 ime_list_[1].engines[0].engine_id); |
| 1341 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | 1341 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1342 ime_list_[2].id, | 1342 ime_list_[2].id, |
| 1343 ime_list_[2].engines[0].engine_id); | 1343 ime_list_[2].engines[0].engine_id); |
| 1344 std::vector<std::string> ids; | 1344 std::vector<std::string> ids; |
| 1345 ids.push_back(ext_id1); | 1345 ids.push_back(ext_id1); |
| 1346 ids.push_back(ext_id2); | 1346 ids.push_back(ext_id2); |
| 1347 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1347 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1366 ASSERT_EQ(4U, input_method_ids.size()); | 1366 ASSERT_EQ(4U, input_method_ids.size()); |
| 1367 | 1367 |
| 1368 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1368 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
| 1369 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1369 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
| 1370 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1370 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
| 1371 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1371 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 } // namespace input_method | 1374 } // namespace input_method |
| 1375 } // namespace chromeos | 1375 } // namespace chromeos |
| OLD | NEW |