| 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/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/status_area_widget.h" | 9 #include "ash/system/status_area_widget.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/status_area_widget_test_helper.h" | 12 #include "ash/test/status_area_widget_test_helper.h" |
| 13 #include "ash/test/virtual_keyboard_test_helper.h" | 13 #include "ash/test/virtual_keyboard_test_helper.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "ui/keyboard/keyboard_switches.h" | 15 #include "ui/keyboard/keyboard_switches.h" |
| 16 #include "ui/keyboard/keyboard_util.h" | 16 #include "ui/keyboard/keyboard_util.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 class TrayIMETest : public test::AshTestBase { | 20 class TrayIMETest : public test::AshTestBase { |
| 21 public: | 21 public: |
| 22 TrayIMETest() {} | 22 TrayIMETest() {} |
| 23 virtual ~TrayIMETest() {} | 23 ~TrayIMETest() override {} |
| 24 | 24 |
| 25 TrayIME* tray() { return tray_.get(); } | 25 TrayIME* tray() { return tray_.get(); } |
| 26 | 26 |
| 27 views::View* default_view() { return default_view_.get(); } | 27 views::View* default_view() { return default_view_.get(); } |
| 28 | 28 |
| 29 views::View* detailed_view() { return detailed_view_.get(); } | 29 views::View* detailed_view() { return detailed_view_.get(); } |
| 30 | 30 |
| 31 // Sets up a TrayIME and its default view. | 31 // Sets up a TrayIME and its default view. |
| 32 void SetUpForStatusAreaWidget(StatusAreaWidget* status_area_widget); | 32 void SetUpForStatusAreaWidget(StatusAreaWidget* status_area_widget); |
| 33 | 33 |
| 34 // Mocks enabling the a11y virtual keyboard since the actual a11y manager | 34 // Mocks enabling the a11y virtual keyboard since the actual a11y manager |
| 35 // is not created in ash tests. | 35 // is not created in ash tests. |
| 36 void SetAccessibilityKeyboardEnabled(bool enabled); | 36 void SetAccessibilityKeyboardEnabled(bool enabled); |
| 37 | 37 |
| 38 // Resets |tray_| and |default_view_| so that all components of | 38 // Resets |tray_| and |default_view_| so that all components of |
| 39 // TrayIME have been cleared. Tests may then call | 39 // TrayIME have been cleared. Tests may then call |
| 40 // SetUpForStatusAreaWidget in order to initialize the components. | 40 // SetUpForStatusAreaWidget in order to initialize the components. |
| 41 void TearDownViews(); | 41 void TearDownViews(); |
| 42 | 42 |
| 43 // Sets the current number of active IMEs. | 43 // Sets the current number of active IMEs. |
| 44 void SetIMELength(int length); | 44 void SetIMELength(int length); |
| 45 | 45 |
| 46 // Returns the view in the detailed views scroll content at the provided | 46 // Returns the view in the detailed views scroll content at the provided |
| 47 // index. | 47 // index. |
| 48 views::View* GetScrollChildView(int index); | 48 views::View* GetScrollChildView(int index); |
| 49 | 49 |
| 50 // test::AshTestBase: | 50 // test::AshTestBase: |
| 51 virtual void SetUp() override; | 51 void SetUp() override; |
| 52 virtual void TearDown() override; | 52 void TearDown() override; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 scoped_ptr<TrayIME> tray_; | 55 scoped_ptr<TrayIME> tray_; |
| 56 scoped_ptr<views::View> default_view_; | 56 scoped_ptr<views::View> default_view_; |
| 57 scoped_ptr<views::View> detailed_view_; | 57 scoped_ptr<views::View> detailed_view_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 void TrayIMETest::SetUpForStatusAreaWidget( | 60 void TrayIMETest::SetUpForStatusAreaWidget( |
| 61 StatusAreaWidget* status_area_widget) { | 61 StatusAreaWidget* status_area_widget) { |
| 62 tray_.reset(new TrayIME(status_area_widget->system_tray())); | 62 tray_.reset(new TrayIME(status_area_widget->system_tray())); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 toggle = GetScrollChildView(0); | 155 toggle = GetScrollChildView(0); |
| 156 // Clicking again should disable the keyboard. | 156 // Clicking again should disable the keyboard. |
| 157 tap = ui::GestureEvent(0, 0, 0, base::TimeDelta(), | 157 tap = ui::GestureEvent(0, 0, 0, base::TimeDelta(), |
| 158 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 158 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 159 toggle->OnGestureEvent(&tap); | 159 toggle->OnGestureEvent(&tap); |
| 160 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 160 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 161 EXPECT_TRUE(default_view()->visible()); | 161 EXPECT_TRUE(default_view()->visible()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace ash | 164 } // namespace ash |
| OLD | NEW |