Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/system/ime_menu/ime_menu_tray.h" | 5 #include "ash/system/ime_menu/ime_menu_tray.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/ime/ime_controller.h" | 9 #include "ash/ime/ime_controller.h" |
| 10 #include "ash/public/interfaces/ime_info.mojom.h" | 10 #include "ash/public/interfaces/ime_info.mojom.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/system/ime_menu/ime_list_view.h" | 12 #include "ash/system/ime_menu/ime_list_view.h" |
| 13 #include "ash/system/status_area_widget.h" | 13 #include "ash/system/status_area_widget.h" |
| 14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/test/status_area_widget_test_helper.h" | 15 #include "ash/test/status_area_widget_test_helper.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "ui/accessibility/ax_node_data.h" | 18 #include "ui/accessibility/ax_node_data.h" |
| 19 #include "ui/base/ime/chromeos/input_method_manager.h" | 19 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 20 #include "ui/base/ime/chromeos/mock_input_method_manager.h" | 20 #include "ui/base/ime/chromeos/mock_input_method_manager.h" |
| 21 #include "ui/base/ime/ime_bridge.h" | 21 #include "ui/base/ime/ime_bridge.h" |
| 22 #include "ui/base/ime/text_input_flags.h" | 22 #include "ui/base/ime/text_input_flags.h" |
| 23 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| 24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 25 | 25 |
| 26 using base::UTF8ToUTF16; | 26 using base::UTF8ToUTF16; |
| 27 using chromeos::input_method::InputMethodManager; | |
| 28 using chromeos::input_method::MockInputMethodManager; | |
| 27 | 29 |
| 28 namespace ash { | 30 namespace ash { |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 ImeMenuTray* GetTray() { | 33 ImeMenuTray* GetTray() { |
| 32 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()->ime_menu_tray(); | 34 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()->ime_menu_tray(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 void SetCurrentIme(const std::string& current_ime_id, | 37 void SetCurrentIme(const std::string& current_ime_id, |
| 36 const std::vector<mojom::ImeInfo>& available_imes) { | 38 const std::vector<mojom::ImeInfo>& available_imes) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 // The virtual keyboard should be enabled. | 294 // The virtual keyboard should be enabled. |
| 293 EXPECT_TRUE(accessibility_delegate->IsVirtualKeyboardEnabled()); | 295 EXPECT_TRUE(accessibility_delegate->IsVirtualKeyboardEnabled()); |
| 294 | 296 |
| 295 // Hides the keyboard. | 297 // Hides the keyboard. |
| 296 GetTray()->OnKeyboardHidden(); | 298 GetTray()->OnKeyboardHidden(); |
| 297 // The keyboard should still be disabled, which is a posted task. | 299 // The keyboard should still be disabled, which is a posted task. |
| 298 base::RunLoop().RunUntilIdle(); | 300 base::RunLoop().RunUntilIdle(); |
| 299 EXPECT_FALSE(accessibility_delegate->IsVirtualKeyboardEnabled()); | 301 EXPECT_FALSE(accessibility_delegate->IsVirtualKeyboardEnabled()); |
| 300 } | 302 } |
| 301 | 303 |
| 302 TEST_F(ImeMenuTrayTest, ShowEmojiHandwritingVoiceButtons) { | 304 TEST_F(ImeMenuTrayTest, ShouldShowBottomButtons) { |
| 303 FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); | 305 FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); |
| 304 EXPECT_FALSE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); | 306 bool show_emoji, show_handwriting, show_voice; |
| 307 EXPECT_FALSE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, | |
| 308 show_voice)); | |
| 309 EXPECT_FALSE(show_emoji); | |
| 310 EXPECT_FALSE(show_handwriting); | |
| 311 EXPECT_FALSE(show_voice); | |
| 305 | 312 |
| 306 chromeos::input_method::InputMethodManager* input_method_manager = | 313 InputMethodManager* input_method_manager = |
| 307 chromeos::input_method::InputMethodManager::Get(); | 314 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.
| |
| 308 EXPECT_FALSE(input_method_manager); | 315 EXPECT_FALSE(input_method_manager); |
| 309 chromeos::input_method::InputMethodManager::Initialize( | 316 InputMethodManager::Initialize(new MockInputMethodManager); |
| 310 new chromeos::input_method::MockInputMethodManager); | 317 input_method_manager = InputMethodManager::Get(); |
| 311 input_method_manager = chromeos::input_method::InputMethodManager::Get(); | |
| 312 EXPECT_TRUE(input_method_manager && | 318 EXPECT_TRUE(input_method_manager && |
| 313 input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); | 319 input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); |
| 314 EXPECT_TRUE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); | 320 EXPECT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_NONE, |
| 321 input_method_manager->GetFeaturesRestrictedState()); | |
| 322 EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, | |
| 323 show_voice)); | |
| 324 EXPECT_TRUE(show_emoji); | |
| 325 EXPECT_TRUE(show_handwriting); | |
| 326 EXPECT_TRUE(show_voice); | |
| 315 | 327 |
| 316 FocusInInputContext(ui::TEXT_INPUT_TYPE_PASSWORD); | 328 FocusInInputContext(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 317 EXPECT_FALSE(GetTray()->ShouldShowEmojiHandwritingVoiceButtons()); | 329 EXPECT_FALSE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, |
| 330 show_voice)); | |
| 331 EXPECT_FALSE(show_emoji); | |
| 332 EXPECT_FALSE(show_handwriting); | |
| 333 EXPECT_FALSE(show_voice); | |
| 334 } | |
| 335 | |
| 336 TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) { | |
| 337 FocusInInputContext(ui::TEXT_INPUT_TYPE_TEXT); | |
| 338 InputMethodManager* input_method_manager = | |
| 339 chromeos::input_method::InputMethodManager::Get(); | |
|
James Cook
2017/06/26 17:21:19
ditto
Azure Wei
2017/06/27 14:27:14
Done.
| |
| 340 InputMethodManager::Initialize(new MockInputMethodManager); | |
| 341 input_method_manager = InputMethodManager::Get(); | |
| 342 EXPECT_TRUE(input_method_manager && | |
| 343 input_method_manager->IsEmojiHandwritingVoiceOnImeMenuEnabled()); | |
| 344 bool show_emoji, show_handwriting, show_voice; | |
| 345 | |
| 346 // Sets emoji restricted. | |
| 347 input_method_manager->SetFeaturesRestrictedState( | |
| 348 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, true); | |
| 349 EXPECT_EQ(InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, | |
| 350 input_method_manager->GetFeaturesRestrictedState()); | |
| 351 EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, | |
| 352 show_voice)); | |
| 353 EXPECT_FALSE(show_emoji); | |
| 354 EXPECT_TRUE(show_handwriting); | |
| 355 EXPECT_TRUE(show_voice); | |
| 356 | |
| 357 // Sets emoji not restriected, but voice and handwriting restricted. | |
| 358 input_method_manager->SetFeaturesRestrictedState( | |
| 359 InputMethodManager::FeaturesRestrictedState::RESTRICTED_EMOJI, false); | |
| 360 input_method_manager->SetFeaturesRestrictedState( | |
| 361 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE, true); | |
| 362 input_method_manager->SetFeaturesRestrictedState( | |
| 363 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING, | |
| 364 true); | |
| 365 uint32_t expected_state = | |
| 366 InputMethodManager::FeaturesRestrictedState::RESTRICTED_VOICE | | |
| 367 InputMethodManager::FeaturesRestrictedState::RESTRICTED_HANDWRITING; | |
| 368 EXPECT_EQ(expected_state, input_method_manager->GetFeaturesRestrictedState()); | |
| 369 EXPECT_TRUE(GetTray()->ShouldShowBottomButtons(show_emoji, show_handwriting, | |
| 370 show_voice)); | |
| 371 EXPECT_TRUE(show_emoji); | |
| 372 EXPECT_FALSE(show_handwriting); | |
| 373 EXPECT_FALSE(show_voice); | |
| 318 } | 374 } |
| 319 | 375 |
| 320 } // namespace ash | 376 } // namespace ash |
| OLD | NEW |