| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/tray_ime_chromeos.h" | 5 #include "ash/system/ime/tray_ime_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/accessibility_types.h" | 8 #include "ash/accessibility_types.h" |
| 9 #include "ash/public/cpp/config.h" | 9 #include "ash/public/cpp/config.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/system/ime/ime_util.h" |
| 11 #include "ash/system/ime_menu/ime_list_view.h" | 12 #include "ash/system/ime_menu/ime_list_view.h" |
| 12 #include "ash/system/tray/system_tray_notifier.h" | 13 #include "ash/system/tray/system_tray_notifier.h" |
| 13 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "ui/events/devices/device_data_manager.h" | 16 #include "ui/events/devices/device_data_manager.h" |
| 16 #include "ui/keyboard/keyboard_util.h" | 17 #include "ui/keyboard/keyboard_util.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 class TrayIMETest : public test::AshTestBase { | 21 class TrayIMETest : public test::AshTestBase { |
| 21 public: | 22 public: |
| 22 TrayIMETest() {} | 23 TrayIMETest() |
| 24 : scoped_current_ime_(¤t_ime_), |
| 25 scoped_available_ime_list_(&available_ime_list_) {} |
| 23 ~TrayIMETest() override {} | 26 ~TrayIMETest() override {} |
| 24 | 27 |
| 25 views::View* default_view() const { return default_view_.get(); } | 28 views::View* default_view() const { return default_view_.get(); } |
| 26 | 29 |
| 27 views::View* detailed_view() const { return detailed_view_.get(); } | 30 views::View* detailed_view() const { return detailed_view_.get(); } |
| 28 | 31 |
| 29 // Mocks enabling the a11y virtual keyboard since the actual a11y manager | 32 // Mocks enabling the a11y virtual keyboard since the actual a11y manager |
| 30 // is not created in ash tests. | 33 // is not created in ash tests. |
| 31 void SetAccessibilityKeyboardEnabled(bool enabled); | 34 void SetAccessibilityKeyboardEnabled(bool enabled); |
| 32 | 35 |
| 33 // Sets the current number of active IMEs. | 36 // Sets the current number of active IMEs. |
| 34 void SetIMELength(int length); | 37 void SetIMELength(int length); |
| 35 | 38 |
| 36 // Returns the view responsible for toggling virtual keyboard. | 39 // Returns the view responsible for toggling virtual keyboard. |
| 37 views::View* GetToggleView() const; | 40 views::View* GetToggleView() const; |
| 38 | 41 |
| 39 // Sets the managed IMEs tooltip message (and thus also if IMEs are managed = | 42 // Sets the managed IMEs tooltip message (and thus also if IMEs are managed = |
| 40 // non-empty or not = empty) | 43 // non-empty or not = empty) |
| 41 void SetManagedMessage(base::string16 managed_message); | 44 void SetManagedMessage(base::string16 managed_message); |
| 42 | 45 |
| 43 void SuppressKeyboard(); | 46 void SuppressKeyboard(); |
| 44 void RestoreKeyboard(); | 47 void RestoreKeyboard(); |
| 45 | 48 |
| 46 // test::AshTestBase: | 49 // test::AshTestBase: |
| 47 void SetUp() override; | 50 void SetUp() override; |
| 48 void TearDown() override; | 51 void TearDown() override; |
| 49 | 52 |
| 50 private: | 53 private: |
| 54 IMEInfo current_ime_; |
| 55 ime_util::ScopedCurrentImeForTesting scoped_current_ime_; |
| 56 |
| 57 std::vector<IMEInfo> available_ime_list_; |
| 58 ime_util::ScopedAvailableImeListForTesting scoped_available_ime_list_; |
| 59 |
| 51 std::unique_ptr<TrayIME> tray_; | 60 std::unique_ptr<TrayIME> tray_; |
| 52 std::unique_ptr<views::View> default_view_; | 61 std::unique_ptr<views::View> default_view_; |
| 53 std::unique_ptr<views::View> detailed_view_; | 62 std::unique_ptr<views::View> detailed_view_; |
| 54 | 63 |
| 55 bool keyboard_suppressed_ = false; | 64 bool keyboard_suppressed_ = false; |
| 56 std::vector<ui::TouchscreenDevice> touchscreen_devices_to_restore_; | 65 std::vector<ui::TouchscreenDevice> touchscreen_devices_to_restore_; |
| 57 std::vector<ui::InputDevice> keyboard_devices_to_restore_; | 66 std::vector<ui::InputDevice> keyboard_devices_to_restore_; |
| 58 | 67 |
| 59 DISALLOW_COPY_AND_ASSIGN(TrayIMETest); | 68 DISALLOW_COPY_AND_ASSIGN(TrayIMETest); |
| 60 }; | 69 }; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Clicking again should disable the keyboard. | 205 // Clicking again should disable the keyboard. |
| 197 toggle = GetToggleView(); | 206 toggle = GetToggleView(); |
| 198 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(), | 207 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(), |
| 199 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 208 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 200 toggle->OnGestureEvent(&tap); | 209 toggle->OnGestureEvent(&tap); |
| 201 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 210 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 202 EXPECT_TRUE(default_view()->visible()); | 211 EXPECT_TRUE(default_view()->visible()); |
| 203 } | 212 } |
| 204 | 213 |
| 205 } // namespace ash | 214 } // namespace ash |
| OLD | NEW |