bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/virtual_keyboard_controller.h" |
| 6 | |
dcheng | 2272495 | 2015-12-31 03:17:54 | [diff] [blame] | 7 | #include <utility> |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 10 | #include "ash/shell.h" |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 11 | #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 12 | #include "ash/test/ash_test_base.h" |
| 13 | #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 14 | #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" |
rsadam | f478ba76 | 2015-01-16 01:08:11 | [diff] [blame] | 15 | #include "ash_switches.h" |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 16 | #include "base/command_line.h" |
dnicoara | 78a73470 | 2014-11-04 19:54:38 | [diff] [blame] | 17 | #include "ui/events/devices/device_data_manager.h" |
| 18 | #include "ui/events/devices/device_hotplug_event_observer.h" |
| 19 | #include "ui/events/devices/input_device.h" |
| 20 | #include "ui/events/devices/keyboard_device.h" |
| 21 | #include "ui/events/devices/touchscreen_device.h" |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 22 | #include "ui/keyboard/keyboard_export.h" |
| 23 | #include "ui/keyboard/keyboard_switches.h" |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 24 | #include "ui/keyboard/keyboard_util.h" |
| 25 | |
| 26 | namespace ash { |
| 27 | namespace test { |
| 28 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 29 | class VirtualKeyboardControllerTest : public AshTestBase { |
| 30 | public: |
| 31 | VirtualKeyboardControllerTest() {} |
dcheng | 222b9c7 | 2015-01-16 00:48:01 | [diff] [blame] | 32 | ~VirtualKeyboardControllerTest() override {} |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 33 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 34 | void UpdateTouchscreenDevices( |
| 35 | std::vector<ui::TouchscreenDevice> touchscreen_devices) { |
| 36 | ui::DeviceHotplugEventObserver* manager = |
| 37 | ui::DeviceDataManager::GetInstance(); |
| 38 | manager->OnTouchscreenDevicesUpdated(touchscreen_devices); |
| 39 | } |
| 40 | |
| 41 | void UpdateKeyboardDevices(std::vector<ui::KeyboardDevice> keyboard_devices) { |
| 42 | ui::DeviceHotplugEventObserver* manager = |
| 43 | ui::DeviceDataManager::GetInstance(); |
| 44 | manager->OnKeyboardDevicesUpdated(keyboard_devices); |
| 45 | } |
| 46 | |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 47 | // Sets the event blocker on the maximized window controller. |
| 48 | void SetEventBlocker( |
| 49 | scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 50 | Shell::GetInstance()->maximize_mode_controller()->event_blocker_ = |
dcheng | 2272495 | 2015-12-31 03:17:54 | [diff] [blame] | 51 | std::move(blocker); |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 52 | } |
| 53 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 54 | void SetUp() override { |
flackr | 512a103 | 2015-12-07 15:43:05 | [diff] [blame] | 55 | base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 56 | keyboard::switches::kDisableSmartVirtualKeyboard); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 57 | AshTestBase::SetUp(); |
| 58 | UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
| 59 | UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerTest); |
| 64 | }; |
| 65 | |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 66 | TEST_F(VirtualKeyboardControllerTest, EnabledDuringMaximizeMode) { |
| 67 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 68 | // Toggle maximized mode on. |
| 69 | Shell::GetInstance() |
| 70 | ->maximize_mode_controller() |
| 71 | ->EnableMaximizeModeWindowManager(true); |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 72 | EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 73 | // Toggle maximized mode off. |
| 74 | Shell::GetInstance() |
| 75 | ->maximize_mode_controller() |
| 76 | ->EnableMaximizeModeWindowManager(false); |
| 77 | EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 78 | } |
| 79 | |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 80 | // Mock event blocker that enables the internal keyboard when it's destructor |
| 81 | // is called. |
| 82 | class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard { |
| 83 | public: |
| 84 | MockEventBlocker() {} |
| 85 | ~MockEventBlocker() override { |
| 86 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 87 | keyboards.push_back(ui::KeyboardDevice( |
| 88 | 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 89 | ui::DeviceHotplugEventObserver* manager = |
| 90 | ui::DeviceDataManager::GetInstance(); |
| 91 | manager->OnKeyboardDevicesUpdated(keyboards); |
| 92 | } |
| 93 | |
| 94 | private: |
| 95 | DISALLOW_COPY_AND_ASSIGN(MockEventBlocker); |
| 96 | }; |
| 97 | |
| 98 | // Tests that reenabling keyboard devices while shutting down does not |
| 99 | // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. |
| 100 | TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { |
| 101 | // Toggle maximized mode on. |
| 102 | Shell::GetInstance() |
| 103 | ->maximize_mode_controller() |
| 104 | ->EnableMaximizeModeWindowManager(true); |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 105 | scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( |
| 106 | new MockEventBlocker); |
dcheng | 2272495 | 2015-12-31 03:17:54 | [diff] [blame] | 107 | SetEventBlocker(std::move(blocker)); |
rsadam | bbaf2c8 | 2015-01-07 17:54:13 | [diff] [blame] | 108 | } |
| 109 | |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 110 | class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, |
| 111 | public VirtualKeyboardObserver { |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 112 | public: |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 113 | VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} |
| 114 | ~VirtualKeyboardControllerAutoTest() override {} |
| 115 | |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 116 | void SetUp() override { |
rsadam | 47e23d2 | 2014-12-15 18:11:37 | [diff] [blame] | 117 | AshTestBase::SetUp(); |
| 118 | // Set the current list of devices to empty so that they don't interfere |
| 119 | // with the test. |
| 120 | UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
| 121 | UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 122 | Shell::GetInstance()->system_tray_notifier()->AddVirtualKeyboardObserver( |
| 123 | this); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 124 | } |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 125 | |
| 126 | void TearDown() override { |
| 127 | Shell::GetInstance()->system_tray_notifier()->RemoveVirtualKeyboardObserver( |
| 128 | this); |
| 129 | AshTestBase::TearDown(); |
| 130 | } |
| 131 | |
| 132 | void OnKeyboardSuppressionChanged(bool suppressed) override { |
| 133 | notified_ = true; |
| 134 | suppressed_ = suppressed; |
| 135 | } |
| 136 | |
| 137 | void ResetObserver() { |
| 138 | suppressed_ = false; |
| 139 | notified_ = false; |
| 140 | } |
| 141 | |
| 142 | bool IsVirtualKeyboardSuppressed() { return suppressed_; } |
| 143 | |
| 144 | bool notified() { return notified_; } |
| 145 | |
| 146 | private: |
| 147 | // Whether the observer method was called. |
| 148 | bool notified_; |
| 149 | |
| 150 | // Whether the keeyboard is suppressed. |
| 151 | bool suppressed_; |
| 152 | |
| 153 | DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | // Tests that the onscreen keyboard is disabled if an internal keyboard is |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 157 | // present and maximized mode is disabled. |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 158 | TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { |
| 159 | std::vector<ui::TouchscreenDevice> screens; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 160 | screens.push_back( |
| 161 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
| 162 | "Touchscreen", gfx::Size(1024, 768), 0)); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 163 | UpdateTouchscreenDevices(screens); |
| 164 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 165 | keyboards.push_back(ui::KeyboardDevice( |
| 166 | 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 167 | UpdateKeyboardDevices(keyboards); |
| 168 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 169 | // Remove the internal keyboard. Virtual keyboard should now show. |
| 170 | UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
| 171 | EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 172 | // Replug in the internal keyboard. Virtual keyboard should hide. |
| 173 | UpdateKeyboardDevices(keyboards); |
| 174 | EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 175 | } |
| 176 | |
| 177 | TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { |
| 178 | std::vector<ui::TouchscreenDevice> devices; |
| 179 | // Add a touchscreen. Keyboard should deploy. |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 180 | devices.push_back( |
| 181 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, |
| 182 | "Touchscreen", gfx::Size(800, 600), 0)); |
rsadam | 9172bc8a | 2014-10-29 23:37:38 | [diff] [blame] | 183 | UpdateTouchscreenDevices(devices); |
| 184 | EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 185 | // Remove touchscreen. Keyboard should hide. |
| 186 | UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 187 | EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 188 | } |
| 189 | |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 190 | TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { |
| 191 | std::vector<ui::TouchscreenDevice> screens; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 192 | screens.push_back( |
| 193 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
| 194 | "Touchscreen", gfx::Size(1024, 768), 0)); |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 195 | UpdateTouchscreenDevices(screens); |
| 196 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 197 | keyboards.push_back(ui::KeyboardDevice( |
| 198 | 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
rsadam | c727b6a | 2014-10-31 18:59:33 | [diff] [blame] | 199 | UpdateKeyboardDevices(keyboards); |
| 200 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 201 | ASSERT_TRUE(notified()); |
| 202 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 203 | // Toggle show keyboard. Keyboard should be visible. |
| 204 | ResetObserver(); |
| 205 | Shell::GetInstance() |
| 206 | ->virtual_keyboard_controller() |
| 207 | ->ToggleIgnoreExternalKeyboard(); |
| 208 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 209 | ASSERT_TRUE(notified()); |
| 210 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 211 | // Toggle show keyboard. Keyboard should be hidden. |
| 212 | ResetObserver(); |
| 213 | Shell::GetInstance() |
| 214 | ->virtual_keyboard_controller() |
| 215 | ->ToggleIgnoreExternalKeyboard(); |
| 216 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 217 | ASSERT_TRUE(notified()); |
| 218 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 219 | // Remove external keyboard. Should be notified that the keyboard is not |
| 220 | // suppressed. |
| 221 | ResetObserver(); |
| 222 | UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
| 223 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 224 | ASSERT_TRUE(notified()); |
| 225 | ASSERT_FALSE(IsVirtualKeyboardSuppressed()); |
| 226 | } |
| 227 | |
rsadam | f971997 | 2014-11-05 02:57:59 | [diff] [blame] | 228 | // Tests handling multiple keyboards. Catches crbug.com/430252 |
| 229 | TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) { |
| 230 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 231 | keyboards.push_back(ui::KeyboardDevice( |
| 232 | 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); |
| 233 | keyboards.push_back(ui::KeyboardDevice( |
| 234 | 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
| 235 | keyboards.push_back(ui::KeyboardDevice( |
| 236 | 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
rsadam | f971997 | 2014-11-05 02:57:59 | [diff] [blame] | 237 | UpdateKeyboardDevices(keyboards); |
| 238 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 239 | } |
| 240 | |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 241 | // Tests maximized mode interaction without disabling the internal keyboard. |
| 242 | TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) { |
| 243 | std::vector<ui::TouchscreenDevice> screens; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 244 | screens.push_back( |
| 245 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
| 246 | "Touchscreen", gfx::Size(1024, 768), 0)); |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 247 | UpdateTouchscreenDevices(screens); |
| 248 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 249 | keyboards.push_back(ui::KeyboardDevice( |
| 250 | 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 251 | UpdateKeyboardDevices(keyboards); |
| 252 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 253 | // Toggle maximized mode on. |
| 254 | Shell::GetInstance() |
| 255 | ->maximize_mode_controller() |
| 256 | ->EnableMaximizeModeWindowManager(true); |
| 257 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 258 | // Toggle maximized mode off. |
| 259 | Shell::GetInstance() |
| 260 | ->maximize_mode_controller() |
| 261 | ->EnableMaximizeModeWindowManager(false); |
| 262 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 263 | } |
| 264 | |
| 265 | // Tests that keyboard gets suppressed in maximized mode. |
| 266 | TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { |
| 267 | std::vector<ui::TouchscreenDevice> screens; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 268 | screens.push_back( |
| 269 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
| 270 | "Touchscreen", gfx::Size(1024, 768), 0)); |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 271 | UpdateTouchscreenDevices(screens); |
| 272 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 273 | keyboards.push_back(ui::KeyboardDevice( |
| 274 | 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); |
| 275 | keyboards.push_back(ui::KeyboardDevice( |
| 276 | 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard")); |
rsadam | d4f6a0b | 2015-03-02 23:50:08 | [diff] [blame] | 277 | UpdateKeyboardDevices(keyboards); |
| 278 | // Toggle maximized mode on. |
| 279 | Shell::GetInstance() |
| 280 | ->maximize_mode_controller() |
| 281 | ->EnableMaximizeModeWindowManager(true); |
| 282 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 283 | ASSERT_TRUE(notified()); |
| 284 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 285 | // Toggle show keyboard. Keyboard should be visible. |
| 286 | ResetObserver(); |
| 287 | Shell::GetInstance() |
| 288 | ->virtual_keyboard_controller() |
| 289 | ->ToggleIgnoreExternalKeyboard(); |
| 290 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 291 | ASSERT_TRUE(notified()); |
| 292 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 293 | // Toggle show keyboard. Keyboard should be hidden. |
| 294 | ResetObserver(); |
| 295 | Shell::GetInstance() |
| 296 | ->virtual_keyboard_controller() |
| 297 | ->ToggleIgnoreExternalKeyboard(); |
| 298 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 299 | ASSERT_TRUE(notified()); |
| 300 | ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
| 301 | // Remove external keyboard. Should be notified that the keyboard is not |
| 302 | // suppressed. |
| 303 | ResetObserver(); |
| 304 | keyboards.pop_back(); |
| 305 | UpdateKeyboardDevices(keyboards); |
| 306 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 307 | ASSERT_TRUE(notified()); |
| 308 | ASSERT_FALSE(IsVirtualKeyboardSuppressed()); |
| 309 | // Toggle maximized mode oFF. |
| 310 | Shell::GetInstance() |
| 311 | ->maximize_mode_controller() |
| 312 | ->EnableMaximizeModeWindowManager(false); |
| 313 | ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 314 | } |
| 315 | |
rsadam | f478ba76 | 2015-01-16 01:08:11 | [diff] [blame] | 316 | class VirtualKeyboardControllerAlwaysEnabledTest |
| 317 | : public VirtualKeyboardControllerAutoTest { |
| 318 | public: |
| 319 | VirtualKeyboardControllerAlwaysEnabledTest() |
| 320 | : VirtualKeyboardControllerAutoTest() {} |
| 321 | ~VirtualKeyboardControllerAlwaysEnabledTest() override {} |
| 322 | |
| 323 | void SetUp() override { |
| 324 | base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 325 | keyboard::switches::kEnableVirtualKeyboard); |
| 326 | VirtualKeyboardControllerAutoTest::SetUp(); |
| 327 | } |
| 328 | |
| 329 | private: |
| 330 | DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAlwaysEnabledTest); |
| 331 | }; |
| 332 | |
| 333 | // Tests that the controller cannot suppress the keyboard if the virtual |
| 334 | // keyboard always enabled flag is active. |
| 335 | TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) { |
| 336 | std::vector<ui::TouchscreenDevice> screens; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 337 | screens.push_back( |
| 338 | ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
| 339 | "Touchscreen", gfx::Size(1024, 768), 0)); |
rsadam | f478ba76 | 2015-01-16 01:08:11 | [diff] [blame] | 340 | UpdateTouchscreenDevices(screens); |
| 341 | std::vector<ui::KeyboardDevice> keyboards; |
kpschoedel | 16ce3d88 | 2015-04-27 16:59:00 | [diff] [blame] | 342 | keyboards.push_back(ui::KeyboardDevice( |
| 343 | 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
rsadam | f478ba76 | 2015-01-16 01:08:11 | [diff] [blame] | 344 | UpdateKeyboardDevices(keyboards); |
| 345 | ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 346 | } |
| 347 | |
bshe | eaae09a | 2014-09-22 23:16:52 | [diff] [blame] | 348 | } // namespace test |
| 349 | } // namespace ash |