Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: ash/virtual_keyboard_controller_unittest.cc

Issue 2019413002: Remove KeyboardDevice class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/virtual_keyboard_controller.h" 5 #include "ash/virtual_keyboard_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" 11 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
14 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" 14 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h"
15 #include "ash_switches.h" 15 #include "ash_switches.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "ui/events/devices/device_data_manager.h" 17 #include "ui/events/devices/device_data_manager.h"
18 #include "ui/events/devices/device_hotplug_event_observer.h" 18 #include "ui/events/devices/device_hotplug_event_observer.h"
19 #include "ui/events/devices/input_device.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" 20 #include "ui/events/devices/touchscreen_device.h"
22 #include "ui/keyboard/keyboard_export.h" 21 #include "ui/keyboard/keyboard_export.h"
23 #include "ui/keyboard/keyboard_switches.h" 22 #include "ui/keyboard/keyboard_switches.h"
24 #include "ui/keyboard/keyboard_util.h" 23 #include "ui/keyboard/keyboard_util.h"
25 24
26 namespace ash { 25 namespace ash {
27 namespace test { 26 namespace test {
28 27
29 class VirtualKeyboardControllerTest : public AshTestBase { 28 class VirtualKeyboardControllerTest : public AshTestBase {
30 public: 29 public:
31 VirtualKeyboardControllerTest() {} 30 VirtualKeyboardControllerTest() {}
32 ~VirtualKeyboardControllerTest() override {} 31 ~VirtualKeyboardControllerTest() override {}
33 32
34 void UpdateTouchscreenDevices( 33 void UpdateTouchscreenDevices(
35 std::vector<ui::TouchscreenDevice> touchscreen_devices) { 34 std::vector<ui::TouchscreenDevice> touchscreen_devices) {
36 ui::DeviceHotplugEventObserver* manager = 35 ui::DeviceHotplugEventObserver* manager =
37 ui::DeviceDataManager::GetInstance(); 36 ui::DeviceDataManager::GetInstance();
38 manager->OnTouchscreenDevicesUpdated(touchscreen_devices); 37 manager->OnTouchscreenDevicesUpdated(touchscreen_devices);
39 } 38 }
40 39
41 void UpdateKeyboardDevices(std::vector<ui::KeyboardDevice> keyboard_devices) { 40 void UpdateKeyboardDevices(std::vector<ui::InputDevice> keyboard_devices) {
42 ui::DeviceHotplugEventObserver* manager = 41 ui::DeviceHotplugEventObserver* manager =
43 ui::DeviceDataManager::GetInstance(); 42 ui::DeviceDataManager::GetInstance();
44 manager->OnKeyboardDevicesUpdated(keyboard_devices); 43 manager->OnKeyboardDevicesUpdated(keyboard_devices);
45 } 44 }
46 45
47 // Sets the event blocker on the maximized window controller. 46 // Sets the event blocker on the maximized window controller.
48 void SetEventBlocker( 47 void SetEventBlocker(
49 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { 48 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) {
50 Shell::GetInstance()->maximize_mode_controller()->event_blocker_ = 49 Shell::GetInstance()->maximize_mode_controller()->event_blocker_ =
51 std::move(blocker); 50 std::move(blocker);
52 } 51 }
53 52
54 void SetUp() override { 53 void SetUp() override {
55 base::CommandLine::ForCurrentProcess()->AppendSwitch( 54 base::CommandLine::ForCurrentProcess()->AppendSwitch(
56 keyboard::switches::kDisableSmartVirtualKeyboard); 55 keyboard::switches::kDisableSmartVirtualKeyboard);
57 AshTestBase::SetUp(); 56 AshTestBase::SetUp();
58 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); 57 UpdateKeyboardDevices(std::vector<ui::InputDevice>());
59 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); 58 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>());
60 } 59 }
61 60
62 private: 61 private:
63 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerTest); 62 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerTest);
64 }; 63 };
65 64
66 TEST_F(VirtualKeyboardControllerTest, EnabledDuringMaximizeMode) { 65 TEST_F(VirtualKeyboardControllerTest, EnabledDuringMaximizeMode) {
67 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 66 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
68 // Toggle maximized mode on. 67 // Toggle maximized mode on.
69 Shell::GetInstance() 68 Shell::GetInstance()
70 ->maximize_mode_controller() 69 ->maximize_mode_controller()
71 ->EnableMaximizeModeWindowManager(true); 70 ->EnableMaximizeModeWindowManager(true);
72 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 71 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
73 // Toggle maximized mode off. 72 // Toggle maximized mode off.
74 Shell::GetInstance() 73 Shell::GetInstance()
75 ->maximize_mode_controller() 74 ->maximize_mode_controller()
76 ->EnableMaximizeModeWindowManager(false); 75 ->EnableMaximizeModeWindowManager(false);
77 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 76 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
78 } 77 }
79 78
80 // Mock event blocker that enables the internal keyboard when it's destructor 79 // Mock event blocker that enables the internal keyboard when it's destructor
81 // is called. 80 // is called.
82 class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard { 81 class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard {
83 public: 82 public:
84 MockEventBlocker() {} 83 MockEventBlocker() {}
85 ~MockEventBlocker() override { 84 ~MockEventBlocker() override {
86 std::vector<ui::KeyboardDevice> keyboards; 85 std::vector<ui::InputDevice> keyboard_devices;
87 keyboards.push_back(ui::KeyboardDevice( 86 keyboard_devices.push_back(ui::InputDevice(
88 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 87 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
89 ui::DeviceHotplugEventObserver* manager = 88 ui::DeviceHotplugEventObserver* manager =
90 ui::DeviceDataManager::GetInstance(); 89 ui::DeviceDataManager::GetInstance();
91 manager->OnKeyboardDevicesUpdated(keyboards); 90 manager->OnKeyboardDevicesUpdated(keyboard_devices);
92 } 91 }
93 92
94 private: 93 private:
95 DISALLOW_COPY_AND_ASSIGN(MockEventBlocker); 94 DISALLOW_COPY_AND_ASSIGN(MockEventBlocker);
96 }; 95 };
97 96
98 // Tests that reenabling keyboard devices while shutting down does not 97 // Tests that reenabling keyboard devices while shutting down does not
99 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. 98 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204.
100 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { 99 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) {
101 // Toggle maximized mode on. 100 // Toggle maximized mode on.
102 Shell::GetInstance() 101 Shell::GetInstance()
103 ->maximize_mode_controller() 102 ->maximize_mode_controller()
104 ->EnableMaximizeModeWindowManager(true); 103 ->EnableMaximizeModeWindowManager(true);
105 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( 104 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker(
106 new MockEventBlocker); 105 new MockEventBlocker);
107 SetEventBlocker(std::move(blocker)); 106 SetEventBlocker(std::move(blocker));
108 } 107 }
109 108
110 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, 109 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest,
111 public VirtualKeyboardObserver { 110 public VirtualKeyboardObserver {
112 public: 111 public:
113 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} 112 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {}
114 ~VirtualKeyboardControllerAutoTest() override {} 113 ~VirtualKeyboardControllerAutoTest() override {}
115 114
116 void SetUp() override { 115 void SetUp() override {
117 AshTestBase::SetUp(); 116 AshTestBase::SetUp();
118 // Set the current list of devices to empty so that they don't interfere 117 // Set the current list of devices to empty so that they don't interfere
119 // with the test. 118 // with the test.
120 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); 119 UpdateKeyboardDevices(std::vector<ui::InputDevice>());
121 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); 120 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>());
122 Shell::GetInstance()->system_tray_notifier()->AddVirtualKeyboardObserver( 121 Shell::GetInstance()->system_tray_notifier()->AddVirtualKeyboardObserver(
123 this); 122 this);
124 } 123 }
125 124
126 void TearDown() override { 125 void TearDown() override {
127 Shell::GetInstance()->system_tray_notifier()->RemoveVirtualKeyboardObserver( 126 Shell::GetInstance()->system_tray_notifier()->RemoveVirtualKeyboardObserver(
128 this); 127 this);
129 AshTestBase::TearDown(); 128 AshTestBase::TearDown();
130 } 129 }
(...skipping 23 matching lines...) Expand all
154 }; 153 };
155 154
156 // Tests that the onscreen keyboard is disabled if an internal keyboard is 155 // Tests that the onscreen keyboard is disabled if an internal keyboard is
157 // present and maximized mode is disabled. 156 // present and maximized mode is disabled.
158 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { 157 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) {
159 std::vector<ui::TouchscreenDevice> screens; 158 std::vector<ui::TouchscreenDevice> screens;
160 screens.push_back( 159 screens.push_back(
161 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 160 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
162 "Touchscreen", gfx::Size(1024, 768), 0)); 161 "Touchscreen", gfx::Size(1024, 768), 0));
163 UpdateTouchscreenDevices(screens); 162 UpdateTouchscreenDevices(screens);
164 std::vector<ui::KeyboardDevice> keyboards; 163 std::vector<ui::InputDevice> keyboard_devices;
165 keyboards.push_back(ui::KeyboardDevice( 164 keyboard_devices.push_back(ui::InputDevice(
166 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 165 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
167 UpdateKeyboardDevices(keyboards); 166 UpdateKeyboardDevices(keyboard_devices);
168 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 167 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
169 // Remove the internal keyboard. Virtual keyboard should now show. 168 // Remove the internal keyboard. Virtual keyboard should now show.
170 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); 169 UpdateKeyboardDevices(std::vector<ui::InputDevice>());
171 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 170 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
172 // Replug in the internal keyboard. Virtual keyboard should hide. 171 // Replug in the internal keyboard. Virtual keyboard should hide.
173 UpdateKeyboardDevices(keyboards); 172 UpdateKeyboardDevices(keyboard_devices);
174 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 173 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
175 } 174 }
176 175
177 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { 176 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) {
178 std::vector<ui::TouchscreenDevice> devices; 177 std::vector<ui::TouchscreenDevice> devices;
179 // Add a touchscreen. Keyboard should deploy. 178 // Add a touchscreen. Keyboard should deploy.
180 devices.push_back( 179 devices.push_back(
181 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, 180 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
182 "Touchscreen", gfx::Size(800, 600), 0)); 181 "Touchscreen", gfx::Size(800, 600), 0));
183 UpdateTouchscreenDevices(devices); 182 UpdateTouchscreenDevices(devices);
184 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 183 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
185 // Remove touchscreen. Keyboard should hide. 184 // Remove touchscreen. Keyboard should hide.
186 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); 185 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>());
187 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 186 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
188 } 187 }
189 188
190 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { 189 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) {
191 std::vector<ui::TouchscreenDevice> screens; 190 std::vector<ui::TouchscreenDevice> screens;
192 screens.push_back( 191 screens.push_back(
193 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 192 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
194 "Touchscreen", gfx::Size(1024, 768), 0)); 193 "Touchscreen", gfx::Size(1024, 768), 0));
195 UpdateTouchscreenDevices(screens); 194 UpdateTouchscreenDevices(screens);
196 std::vector<ui::KeyboardDevice> keyboards; 195 std::vector<ui::InputDevice> keyboard_devices;
197 keyboards.push_back(ui::KeyboardDevice( 196 keyboard_devices.push_back(ui::InputDevice(
198 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 197 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
199 UpdateKeyboardDevices(keyboards); 198 UpdateKeyboardDevices(keyboard_devices);
200 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 199 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
201 ASSERT_TRUE(notified()); 200 ASSERT_TRUE(notified());
202 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 201 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
203 // Toggle show keyboard. Keyboard should be visible. 202 // Toggle show keyboard. Keyboard should be visible.
204 ResetObserver(); 203 ResetObserver();
205 Shell::GetInstance() 204 Shell::GetInstance()
206 ->virtual_keyboard_controller() 205 ->virtual_keyboard_controller()
207 ->ToggleIgnoreExternalKeyboard(); 206 ->ToggleIgnoreExternalKeyboard();
208 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 207 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
209 ASSERT_TRUE(notified()); 208 ASSERT_TRUE(notified());
210 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 209 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
211 // Toggle show keyboard. Keyboard should be hidden. 210 // Toggle show keyboard. Keyboard should be hidden.
212 ResetObserver(); 211 ResetObserver();
213 Shell::GetInstance() 212 Shell::GetInstance()
214 ->virtual_keyboard_controller() 213 ->virtual_keyboard_controller()
215 ->ToggleIgnoreExternalKeyboard(); 214 ->ToggleIgnoreExternalKeyboard();
216 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 215 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
217 ASSERT_TRUE(notified()); 216 ASSERT_TRUE(notified());
218 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 217 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
219 // Remove external keyboard. Should be notified that the keyboard is not 218 // Remove external keyboard. Should be notified that the keyboard is not
220 // suppressed. 219 // suppressed.
221 ResetObserver(); 220 ResetObserver();
222 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); 221 UpdateKeyboardDevices(std::vector<ui::InputDevice>());
223 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 222 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
224 ASSERT_TRUE(notified()); 223 ASSERT_TRUE(notified());
225 ASSERT_FALSE(IsVirtualKeyboardSuppressed()); 224 ASSERT_FALSE(IsVirtualKeyboardSuppressed());
226 } 225 }
227 226
228 // Tests handling multiple keyboards. Catches crbug.com/430252 227 // Tests handling multiple keyboards. Catches crbug.com/430252
229 TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) { 228 TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) {
230 std::vector<ui::KeyboardDevice> keyboards; 229 std::vector<ui::InputDevice> keyboards;
231 keyboards.push_back(ui::KeyboardDevice( 230 keyboards.push_back(ui::InputDevice(
232 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 231 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
233 keyboards.push_back(ui::KeyboardDevice( 232 keyboards.push_back(ui::InputDevice(
234 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 233 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
235 keyboards.push_back(ui::KeyboardDevice( 234 keyboards.push_back(ui::InputDevice(
236 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 235 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
237 UpdateKeyboardDevices(keyboards); 236 UpdateKeyboardDevices(keyboards);
238 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 237 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
239 } 238 }
240 239
241 // Tests maximized mode interaction without disabling the internal keyboard. 240 // Tests maximized mode interaction without disabling the internal keyboard.
242 TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) { 241 TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) {
243 std::vector<ui::TouchscreenDevice> screens; 242 std::vector<ui::TouchscreenDevice> screens;
244 screens.push_back( 243 screens.push_back(
245 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 244 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
246 "Touchscreen", gfx::Size(1024, 768), 0)); 245 "Touchscreen", gfx::Size(1024, 768), 0));
247 UpdateTouchscreenDevices(screens); 246 UpdateTouchscreenDevices(screens);
248 std::vector<ui::KeyboardDevice> keyboards; 247 std::vector<ui::InputDevice> keyboard_devices;
249 keyboards.push_back(ui::KeyboardDevice( 248 keyboard_devices.push_back(ui::InputDevice(
250 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 249 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
251 UpdateKeyboardDevices(keyboards); 250 UpdateKeyboardDevices(keyboard_devices);
252 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 251 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
253 // Toggle maximized mode on. 252 // Toggle maximized mode on.
254 Shell::GetInstance() 253 Shell::GetInstance()
255 ->maximize_mode_controller() 254 ->maximize_mode_controller()
256 ->EnableMaximizeModeWindowManager(true); 255 ->EnableMaximizeModeWindowManager(true);
257 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 256 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
258 // Toggle maximized mode off. 257 // Toggle maximized mode off.
259 Shell::GetInstance() 258 Shell::GetInstance()
260 ->maximize_mode_controller() 259 ->maximize_mode_controller()
261 ->EnableMaximizeModeWindowManager(false); 260 ->EnableMaximizeModeWindowManager(false);
262 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 261 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
263 } 262 }
264 263
265 // Tests that keyboard gets suppressed in maximized mode. 264 // Tests that keyboard gets suppressed in maximized mode.
266 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { 265 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
267 std::vector<ui::TouchscreenDevice> screens; 266 std::vector<ui::TouchscreenDevice> screens;
268 screens.push_back( 267 screens.push_back(
269 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 268 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
270 "Touchscreen", gfx::Size(1024, 768), 0)); 269 "Touchscreen", gfx::Size(1024, 768), 0));
271 UpdateTouchscreenDevices(screens); 270 UpdateTouchscreenDevices(screens);
272 std::vector<ui::KeyboardDevice> keyboards; 271 std::vector<ui::InputDevice> keyboard_devices;
273 keyboards.push_back(ui::KeyboardDevice( 272 keyboard_devices.push_back(ui::InputDevice(
274 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 273 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
275 keyboards.push_back(ui::KeyboardDevice( 274 keyboard_devices.push_back(ui::InputDevice(
276 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard")); 275 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard"));
277 UpdateKeyboardDevices(keyboards); 276 UpdateKeyboardDevices(keyboard_devices);
278 // Toggle maximized mode on. 277 // Toggle maximized mode on.
279 Shell::GetInstance() 278 Shell::GetInstance()
280 ->maximize_mode_controller() 279 ->maximize_mode_controller()
281 ->EnableMaximizeModeWindowManager(true); 280 ->EnableMaximizeModeWindowManager(true);
282 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 281 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
283 ASSERT_TRUE(notified()); 282 ASSERT_TRUE(notified());
284 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 283 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
285 // Toggle show keyboard. Keyboard should be visible. 284 // Toggle show keyboard. Keyboard should be visible.
286 ResetObserver(); 285 ResetObserver();
287 Shell::GetInstance() 286 Shell::GetInstance()
288 ->virtual_keyboard_controller() 287 ->virtual_keyboard_controller()
289 ->ToggleIgnoreExternalKeyboard(); 288 ->ToggleIgnoreExternalKeyboard();
290 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 289 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
291 ASSERT_TRUE(notified()); 290 ASSERT_TRUE(notified());
292 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 291 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
293 // Toggle show keyboard. Keyboard should be hidden. 292 // Toggle show keyboard. Keyboard should be hidden.
294 ResetObserver(); 293 ResetObserver();
295 Shell::GetInstance() 294 Shell::GetInstance()
296 ->virtual_keyboard_controller() 295 ->virtual_keyboard_controller()
297 ->ToggleIgnoreExternalKeyboard(); 296 ->ToggleIgnoreExternalKeyboard();
298 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 297 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
299 ASSERT_TRUE(notified()); 298 ASSERT_TRUE(notified());
300 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 299 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
301 // Remove external keyboard. Should be notified that the keyboard is not 300 // Remove external keyboard. Should be notified that the keyboard is not
302 // suppressed. 301 // suppressed.
303 ResetObserver(); 302 ResetObserver();
304 keyboards.pop_back(); 303 keyboard_devices.pop_back();
305 UpdateKeyboardDevices(keyboards); 304 UpdateKeyboardDevices(keyboard_devices);
306 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 305 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
307 ASSERT_TRUE(notified()); 306 ASSERT_TRUE(notified());
308 ASSERT_FALSE(IsVirtualKeyboardSuppressed()); 307 ASSERT_FALSE(IsVirtualKeyboardSuppressed());
309 // Toggle maximized mode oFF. 308 // Toggle maximized mode oFF.
310 Shell::GetInstance() 309 Shell::GetInstance()
311 ->maximize_mode_controller() 310 ->maximize_mode_controller()
312 ->EnableMaximizeModeWindowManager(false); 311 ->EnableMaximizeModeWindowManager(false);
313 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 312 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
314 } 313 }
315 314
(...skipping 15 matching lines...) Expand all
331 }; 330 };
332 331
333 // Tests that the controller cannot suppress the keyboard if the virtual 332 // Tests that the controller cannot suppress the keyboard if the virtual
334 // keyboard always enabled flag is active. 333 // keyboard always enabled flag is active.
335 TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) { 334 TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) {
336 std::vector<ui::TouchscreenDevice> screens; 335 std::vector<ui::TouchscreenDevice> screens;
337 screens.push_back( 336 screens.push_back(
338 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 337 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
339 "Touchscreen", gfx::Size(1024, 768), 0)); 338 "Touchscreen", gfx::Size(1024, 768), 0));
340 UpdateTouchscreenDevices(screens); 339 UpdateTouchscreenDevices(screens);
341 std::vector<ui::KeyboardDevice> keyboards; 340 std::vector<ui::InputDevice> keyboard_devices;
342 keyboards.push_back(ui::KeyboardDevice( 341 keyboard_devices.push_back(ui::InputDevice(
343 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 342 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
344 UpdateKeyboardDevices(keyboards); 343 UpdateKeyboardDevices(keyboard_devices);
345 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 344 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
346 } 345 }
347 346
348 } // namespace test 347 } // namespace test
349 } // namespace ash 348 } // namespace ash
OLDNEW
« no previous file with comments | « ash/virtual_keyboard_controller.cc ('k') | ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698