| 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/common/system/ime/tray_ime_chromeos.h" | 5 #include "ash/common/system/ime/tray_ime_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/accessibility_types.h" | 8 #include "ash/common/accessibility_types.h" |
| 9 #include "ash/common/system/tray/system_tray_notifier.h" | 9 #include "ash/common/system/tray/system_tray_notifier.h" |
| 10 #include "ash/common/system/tray/tray_details_view.h" | 10 #include "ash/common/system/tray/tray_details_view.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 SetAccessibilityKeyboardEnabled(false); | 126 SetAccessibilityKeyboardEnabled(false); |
| 127 tray_.reset(); | 127 tray_.reset(); |
| 128 default_view_.reset(); | 128 default_view_.reset(); |
| 129 detailed_view_.reset(); | 129 detailed_view_.reset(); |
| 130 test::AshTestBase::TearDown(); | 130 test::AshTestBase::TearDown(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Tests that if the keyboard is not suppressed the default view is hidden | 133 // Tests that if the keyboard is not suppressed the default view is hidden |
| 134 // if less than 2 IMEs are present. | 134 // if less than 2 IMEs are present. |
| 135 TEST_F(TrayIMETest, HiddenWithNoIMEs) { | 135 TEST_F(TrayIMETest, HiddenWithNoIMEs) { |
| 136 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 137 return; |
| 138 |
| 136 SetIMELength(0); | 139 SetIMELength(0); |
| 137 EXPECT_FALSE(default_view()->visible()); | 140 EXPECT_FALSE(default_view()->visible()); |
| 138 SetIMELength(1); | 141 SetIMELength(1); |
| 139 EXPECT_FALSE(default_view()->visible()); | 142 EXPECT_FALSE(default_view()->visible()); |
| 140 SetIMELength(2); | 143 SetIMELength(2); |
| 141 EXPECT_TRUE(default_view()->visible()); | 144 EXPECT_TRUE(default_view()->visible()); |
| 142 } | 145 } |
| 143 | 146 |
| 144 // Tests that if no IMEs are present the default view is hidden when a11y is | 147 // Tests that if no IMEs are present the default view is hidden when a11y is |
| 145 // enabled. | 148 // enabled. |
| 146 TEST_F(TrayIMETest, HidesOnA11yEnabled) { | 149 TEST_F(TrayIMETest, HidesOnA11yEnabled) { |
| 150 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 151 return; |
| 152 |
| 147 SetIMELength(0); | 153 SetIMELength(0); |
| 148 SuppressKeyboard(); | 154 SuppressKeyboard(); |
| 149 EXPECT_TRUE(default_view()->visible()); | 155 EXPECT_TRUE(default_view()->visible()); |
| 150 // Enable a11y keyboard. | 156 // Enable a11y keyboard. |
| 151 SetAccessibilityKeyboardEnabled(true); | 157 SetAccessibilityKeyboardEnabled(true); |
| 152 EXPECT_FALSE(default_view()->visible()); | 158 EXPECT_FALSE(default_view()->visible()); |
| 153 // Disable the a11y keyboard. | 159 // Disable the a11y keyboard. |
| 154 SetAccessibilityKeyboardEnabled(false); | 160 SetAccessibilityKeyboardEnabled(false); |
| 155 EXPECT_TRUE(default_view()->visible()); | 161 EXPECT_TRUE(default_view()->visible()); |
| 156 } | 162 } |
| 157 | 163 |
| 158 // Tests that clicking on the keyboard toggle causes the virtual keyboard | 164 // Tests that clicking on the keyboard toggle causes the virtual keyboard |
| 159 // to toggle between enabled and disabled. | 165 // to toggle between enabled and disabled. |
| 160 TEST_F(TrayIMETest, PerformActionOnDetailedView) { | 166 TEST_F(TrayIMETest, PerformActionOnDetailedView) { |
| 167 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 168 return; |
| 169 |
| 161 SetIMELength(0); | 170 SetIMELength(0); |
| 162 SuppressKeyboard(); | 171 SuppressKeyboard(); |
| 163 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 172 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 164 views::View* toggle = GetScrollChildView(0); | 173 views::View* toggle = GetScrollChildView(0); |
| 165 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 174 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 166 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 175 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 167 // Enable the keyboard. | 176 // Enable the keyboard. |
| 168 toggle->OnGestureEvent(&tap); | 177 toggle->OnGestureEvent(&tap); |
| 169 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 178 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 170 EXPECT_TRUE(default_view()->visible()); | 179 EXPECT_TRUE(default_view()->visible()); |
| 171 // With no IMEs the toggle should be the first child. | 180 // With no IMEs the toggle should be the first child. |
| 172 toggle = GetScrollChildView(0); | 181 toggle = GetScrollChildView(0); |
| 173 // Clicking again should disable the keyboard. | 182 // Clicking again should disable the keyboard. |
| 174 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(), | 183 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(), |
| 175 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 184 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 176 toggle->OnGestureEvent(&tap); | 185 toggle->OnGestureEvent(&tap); |
| 177 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 186 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 178 EXPECT_TRUE(default_view()->visible()); | 187 EXPECT_TRUE(default_view()->visible()); |
| 179 } | 188 } |
| 180 | 189 |
| 181 } // namespace ash | 190 } // namespace ash |
| OLD | NEW |