Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 void CandidateWindowClosed(InputMethodManager* manager) override { | 146 void CandidateWindowClosed(InputMethodManager* manager) override { |
| 147 ++candidate_window_closed_count_; | 147 ++candidate_window_closed_count_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 int candidate_window_opened_count_; | 150 int candidate_window_opened_count_; |
| 151 int candidate_window_closed_count_; | 151 int candidate_window_closed_count_; |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); | 154 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); |
| 155 }; | 155 }; |
| 156 | |
| 156 } // namespace | 157 } // namespace |
| 157 | 158 |
| 158 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { | 159 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { |
| 159 public: | 160 public: |
| 160 InputMethodManagerImplTest() | 161 InputMethodManagerImplTest() |
| 161 : delegate_(NULL), | 162 : delegate_(NULL), |
| 162 candidate_window_controller_(NULL), | 163 candidate_window_controller_(NULL), |
| 163 keyboard_(NULL) { | 164 keyboard_(NULL) { |
| 164 } | 165 } |
| 165 ~InputMethodManagerImplTest() override {} | 166 ~InputMethodManagerImplTest() override {} |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 ime_controller.current_ime_id_); | 1639 ime_controller.current_ime_id_); |
| 1639 | 1640 |
| 1640 // Unlock screen. The original state, pinyin-dv, is restored. | 1641 // Unlock screen. The original state, pinyin-dv, is restored. |
| 1641 manager_->SetState(saved_ime_state); | 1642 manager_->SetState(saved_ime_state); |
| 1642 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); | 1643 manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 1643 ime_controller_client.FlushMojoForTesting(); | 1644 ime_controller_client.FlushMojoForTesting(); |
| 1644 ASSERT_EQ(3u, ime_controller.available_imes_.size()); // Dvorak and 2 IMEs. | 1645 ASSERT_EQ(3u, ime_controller.available_imes_.size()); // Dvorak and 2 IMEs. |
| 1645 EXPECT_EQ(ImeIdFromEngineId(ids[1]), ime_controller.current_ime_id_); | 1646 EXPECT_EQ(ImeIdFromEngineId(ids[1]), ime_controller.current_ime_id_); |
| 1646 } | 1647 } |
| 1647 | 1648 |
| 1649 TEST_F(InputMethodManagerImplTest, SetOneFeatureRestrictedState) { | |
| 1650 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
|
James Cook
2017/06/26 17:21:19
nit: EXPECT_EQ here and below (unless the test wil
Azure Wei
2017/06/27 14:27:15
Done.
| |
| 1651 manager_->GetFeaturesRestrictedState()); | |
| 1652 | |
| 1653 // Sets emoji restricted and not restricted | |
| 1654 manager_->SetFeaturesRestrictedState( | |
| 1655 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, true); | |
| 1656 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, | |
| 1657 manager_->GetFeaturesRestrictedState()); | |
| 1658 manager_->SetFeaturesRestrictedState( | |
| 1659 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, false); | |
| 1660 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1661 manager_->GetFeaturesRestrictedState()); | |
| 1662 | |
| 1663 // Sets voice restricted and not restricted | |
| 1664 manager_->SetFeaturesRestrictedState( | |
| 1665 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); | |
| 1666 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, | |
| 1667 manager_->GetFeaturesRestrictedState()); | |
| 1668 manager_->SetFeaturesRestrictedState( | |
| 1669 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, false); | |
| 1670 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1671 manager_->GetFeaturesRestrictedState()); | |
| 1672 | |
| 1673 // Sets handwriting restricted and not restricted | |
| 1674 manager_->SetFeaturesRestrictedState( | |
| 1675 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 1676 true); | |
| 1677 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 1678 manager_->GetFeaturesRestrictedState()); | |
| 1679 manager_->SetFeaturesRestrictedState( | |
| 1680 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 1681 false); | |
| 1682 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1683 manager_->GetFeaturesRestrictedState()); | |
| 1684 } | |
| 1685 | |
| 1686 TEST_F(InputMethodManagerImplTest, SetMoreThanOneFeaturesRestrictedState) { | |
| 1687 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1688 manager_->GetFeaturesRestrictedState()); | |
| 1689 | |
| 1690 // Sets emoji and voice restricted | |
| 1691 manager_->SetFeaturesRestrictedState( | |
| 1692 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, true); | |
| 1693 manager_->SetFeaturesRestrictedState( | |
| 1694 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); | |
| 1695 uint32_t emojiAndVoice = | |
| 1696 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI | | |
| 1697 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE; | |
| 1698 ASSERT_EQ(emojiAndVoice, manager_->GetFeaturesRestrictedState()); | |
| 1699 | |
| 1700 // Sets emoji not restricted | |
| 1701 manager_->SetFeaturesRestrictedState( | |
| 1702 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, false); | |
| 1703 manager_->SetFeaturesRestrictedState( | |
| 1704 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); | |
| 1705 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, | |
| 1706 manager_->GetFeaturesRestrictedState()); | |
| 1707 | |
| 1708 // Sets voice not restricted | |
| 1709 manager_->SetFeaturesRestrictedState( | |
| 1710 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, false); | |
| 1711 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1712 manager_->GetFeaturesRestrictedState()); | |
| 1713 } | |
| 1714 | |
| 1715 TEST_F(InputMethodManagerImplTest, SetAllFeaturesRestrictedState) { | |
| 1716 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1717 manager_->GetFeaturesRestrictedState()); | |
| 1718 | |
| 1719 // Sets all restricted | |
| 1720 manager_->SetFeaturesRestrictedState( | |
| 1721 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, true); | |
| 1722 manager_->SetFeaturesRestrictedState( | |
| 1723 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); | |
| 1724 manager_->SetFeaturesRestrictedState( | |
| 1725 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 1726 true); | |
| 1727 uint32_t allRestricted = | |
| 1728 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI | | |
| 1729 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE | | |
| 1730 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING; | |
| 1731 ASSERT_EQ(allRestricted, manager_->GetFeaturesRestrictedState()); | |
| 1732 | |
| 1733 // Sets all not restricted | |
| 1734 manager_->SetFeaturesRestrictedState( | |
| 1735 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, false); | |
| 1736 manager_->SetFeaturesRestrictedState( | |
| 1737 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, false); | |
| 1738 manager_->SetFeaturesRestrictedState( | |
| 1739 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 1740 false); | |
| 1741 ASSERT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, | |
| 1742 manager_->GetFeaturesRestrictedState()); | |
| 1743 } | |
| 1744 | |
| 1648 } // namespace input_method | 1745 } // namespace input_method |
| 1649 } // namespace chromeos | 1746 } // namespace chromeos |
| OLD | NEW |