Chromium Code Reviews| Index: ash/system/ime_menu/ime_menu_tray_unittest.cc |
| diff --git a/ash/system/ime_menu/ime_menu_tray_unittest.cc b/ash/system/ime_menu/ime_menu_tray_unittest.cc |
| index a73eb1031559162eb444be3b8a02b9b018def656..68b46ae6a60a2f4a4d444b8b8997cbfca4a89267 100644 |
| --- a/ash/system/ime_menu/ime_menu_tray_unittest.cc |
| +++ b/ash/system/ime_menu/ime_menu_tray_unittest.cc |
| @@ -24,6 +24,8 @@ |
| #include "ui/views/controls/label.h" |
| using base::UTF8ToUTF16; |
| +using chromeos::input_method::InputMethodManager; |
| +using chromeos::input_method::MockInputMethodManager; |
| namespace ash { |
| namespace { |
| @@ -62,6 +64,15 @@ class ImeMenuTrayTest : public test::AshTestBase { |
| // Returns true if the IME menu bubble has been shown. |
| bool IsBubbleShown() { return GetTray()->IsImeMenuBubbleShown(); } |
| + // Returns true if emoji palatte is enabled for the current keyboard. |
| + bool IsEmojiEnabled() { return GetTray()->emoji_enabled_; } |
| + |
| + // Returns true if handwirting input is enabled for the current keyboard. |
| + bool IsHandwritingEnabled() { return GetTray()->handwriting_enabled_; } |
| + |
| + // Returns true if voice input is enabled for the current keyboard. |
| + bool IsVoiceEnabled() { return GetTray()->voice_enabled_; } |
| + |
| // Verifies the IME menu list has been updated with the right IME list. |
| void ExpectValidImeList(const std::vector<mojom::ImeInfo>& expected_imes, |
| const mojom::ImeInfo& expected_current_ime) { |
| @@ -299,22 +310,68 @@ TEST_F(ImeMenuTrayTest, ForceToShowEmojiKeyset) { |
| EXPECT_FALSE(accessibility_delegate->IsVirtualKeyboardEnabled()); |
| } |
| -TEST_F(ImeMenuTrayTest, ShowEmojiHandwritingVoiceButtons) { |
| +TEST_F(ImeMenuTrayTest, ShouldShowBottomButtons) { |
| FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); |
| - EXPECT_FALSE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); |
| + EXPECT_FALSE(GetTray()->ShouldShowBottomButtons()); |
| + EXPECT_FALSE(IsEmojiEnabled()); |
| + EXPECT_FALSE(IsHandwritingEnabled()); |
| + EXPECT_FALSE(IsVoiceEnabled()); |
| - chromeos::input_method::InputMethodManager* input_method_manager = |
| - chromeos::input_method::InputMethodManager::Get(); |
| + InputMethodManager* input_method_manager = InputMethodManager::Get(); |
| EXPECT_FALSE(input_method_manager); |
| - chromeos::input_method::InputMethodManager::Initialize( |
| - new chromeos::input_method::MockInputMethodManager); |
| - input_method_manager = chromeos::input_method::InputMethodManager::Get(); |
| + InputMethodManager::Initialize(new MockInputMethodManager); |
| + input_method_manager = InputMethodManager::Get(); |
| EXPECT_TRUE(input_method_manager && |
| input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); |
| - EXPECT_TRUE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); |
| + EXPECT_TRUE(input_method_manager->GetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::NONE)); |
|
James Cook
2017/06/27 16:31:11
nit: No "::FeaturesRestricted::" for plain enums.
Azure Wei
2017/06/29 16:37:02
Done.
|
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons()); |
| + EXPECT_TRUE(IsEmojiEnabled()); |
| + EXPECT_TRUE(IsHandwritingEnabled()); |
| + EXPECT_TRUE(IsVoiceEnabled()); |
| FocusInInputContext(ui::TEXT_INPUT_TYPE_PASSWORD); |
| - EXPECT_FALSE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); |
| + EXPECT_FALSE(GetTray()->ShouldShowBottomButtons()); |
| + EXPECT_FALSE(IsEmojiEnabled()); |
| + EXPECT_FALSE(IsHandwritingEnabled()); |
| + EXPECT_FALSE(IsVoiceEnabled()); |
| +} |
| + |
| +TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) { |
| + FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); |
| + InputMethodManager* input_method_manager = InputMethodManager::Get(); |
| + InputMethodManager::Initialize(new MockInputMethodManager); |
| + input_method_manager = InputMethodManager::Get(); |
| + EXPECT_TRUE(input_method_manager && |
| + input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); |
| + |
| + // Sets emoji restricted. |
| + input_method_manager->SetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::EMOJI, true); |
| + EXPECT_TRUE(input_method_manager->GetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::EMOJI)); |
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons()); |
| + EXPECT_FALSE(IsEmojiEnabled()); |
| + EXPECT_TRUE(IsHandwritingEnabled()); |
| + EXPECT_TRUE(IsVoiceEnabled()); |
| + |
| + // Sets emoji not restriected, but voice and handwriting restricted. |
| + input_method_manager->SetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::EMOJI, false); |
| + input_method_manager->SetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::VOICE, true); |
| + input_method_manager->SetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::HANDWRITING, true); |
| + EXPECT_FALSE(input_method_manager->GetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::EMOJI)); |
| + EXPECT_TRUE(input_method_manager->GetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::VOICE)); |
| + EXPECT_TRUE(input_method_manager->GetFeaturesRestricted( |
| + InputMethodManager::FeaturesRestricted::HANDWRITING)); |
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons()); |
| + EXPECT_TRUE(IsEmojiEnabled()); |
| + EXPECT_FALSE(IsHandwritingEnabled()); |
| + EXPECT_FALSE(IsVoiceEnabled()); |
| } |
| } // namespace ash |