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..80d34c15b7ca0a4fdae50781e97376792459bfd3 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 { |
| @@ -299,22 +301,76 @@ 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()); |
| - |
| - chromeos::input_method::InputMethodManager* input_method_manager = |
| + bool show_emoji, show_handwriting, show_voice; |
| + EXPECT_FALSE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| + show_voice)); |
| + EXPECT_FALSE(show_emoji); |
| + EXPECT_FALSE(show_handwriting); |
| + EXPECT_FALSE(show_voice); |
| + |
| + InputMethodManager* input_method_manager = |
| chromeos::input_method::InputMethodManager::Get(); |
|
James Cook
2017/06/26 17:21:19
nit: chromeos::input_method:: not needed (you don'
Azure Wei
2017/06/27 14:27:15
Done.
|
| 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_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, |
| + input_method_manager->GetFeaturesRestrictedState()); |
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| + show_voice)); |
| + EXPECT_TRUE(show_emoji); |
| + EXPECT_TRUE(show_handwriting); |
| + EXPECT_TRUE(show_voice); |
| FocusInInputContext(ui::TEXT_INPUT_TYPE_PASSWORD); |
| - EXPECT_FALSE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); |
| + EXPECT_FALSE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| + show_voice)); |
| + EXPECT_FALSE(show_emoji); |
| + EXPECT_FALSE(show_handwriting); |
| + EXPECT_FALSE(show_voice); |
| +} |
| + |
| +TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) { |
| + FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); |
| + InputMethodManager* input_method_manager = |
| + chromeos::input_method::InputMethodManager::Get(); |
|
James Cook
2017/06/26 17:21:19
ditto
Azure Wei
2017/06/27 14:27:14
Done.
|
| + InputMethodManager::Initialize(new MockInputMethodManager); |
| + input_method_manager = InputMethodManager::Get(); |
| + EXPECT_TRUE(input_method_manager && |
| + input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); |
| + bool show_emoji, show_handwriting, show_voice; |
| + |
| + // Sets emoji restricted. |
| + input_method_manager->SetFeaturesRestrictedState( |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, true); |
| + EXPECT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, |
| + input_method_manager->GetFeaturesRestrictedState()); |
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| + show_voice)); |
| + EXPECT_FALSE(show_emoji); |
| + EXPECT_TRUE(show_handwriting); |
| + EXPECT_TRUE(show_voice); |
| + |
| + // Sets emoji not restriected, but voice and handwriting restricted. |
| + input_method_manager->SetFeaturesRestrictedState( |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, false); |
| + input_method_manager->SetFeaturesRestrictedState( |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); |
| + input_method_manager->SetFeaturesRestrictedState( |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, |
| + true); |
| + uint32_t expected_state = |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE | |
| + InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING; |
| + EXPECT_EQ(expected_state, input_method_manager->GetFeaturesRestrictedState()); |
| + EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| + show_voice)); |
| + EXPECT_TRUE(show_emoji); |
| + EXPECT_FALSE(show_handwriting); |
| + EXPECT_FALSE(show_voice); |
| } |
| } // namespace ash |