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

Side by Side Diff: ash/virtual_keyboard_controller_unittest.cc

Issue 2909763002: Revert of Rename MaximizeMode to TabletMode (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « ash/virtual_keyboard_controller.cc ('k') | ash/wm/lock_state_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/virtual_keyboard/virtual_keyboard_observer.h" 12 #include "ash/system/virtual_keyboard/virtual_keyboard_observer.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/wm/tablet_mode/scoped_disable_internal_mouse_and_keyboard.h" 14 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
15 #include "ash/wm/tablet_mode/tablet_mode_controller.h" 15 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.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/touchscreen_device.h" 20 #include "ui/events/devices/touchscreen_device.h"
21 #include "ui/keyboard/keyboard_export.h" 21 #include "ui/keyboard/keyboard_export.h"
22 #include "ui/keyboard/keyboard_switches.h" 22 #include "ui/keyboard/keyboard_switches.h"
23 #include "ui/keyboard/keyboard_util.h" 23 #include "ui/keyboard/keyboard_util.h"
24 24
25 namespace ash { 25 namespace ash {
(...skipping 13 matching lines...) Expand all
39 39
40 void UpdateKeyboardDevices(std::vector<ui::InputDevice> keyboard_devices) { 40 void UpdateKeyboardDevices(std::vector<ui::InputDevice> keyboard_devices) {
41 ui::DeviceHotplugEventObserver* manager = 41 ui::DeviceHotplugEventObserver* manager =
42 ui::DeviceDataManager::GetInstance(); 42 ui::DeviceDataManager::GetInstance();
43 manager->OnKeyboardDevicesUpdated(keyboard_devices); 43 manager->OnKeyboardDevicesUpdated(keyboard_devices);
44 } 44 }
45 45
46 // Sets the event blocker on the maximized window controller. 46 // Sets the event blocker on the maximized window controller.
47 void SetEventBlocker( 47 void SetEventBlocker(
48 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { 48 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) {
49 Shell::Get()->tablet_mode_controller()->event_blocker_ = std::move(blocker); 49 Shell::Get()->maximize_mode_controller()->event_blocker_ =
50 std::move(blocker);
50 } 51 }
51 52
52 void SetUp() override { 53 void SetUp() override {
53 AshTestBase::SetUp(); 54 AshTestBase::SetUp();
54 UpdateKeyboardDevices(std::vector<ui::InputDevice>()); 55 UpdateKeyboardDevices(std::vector<ui::InputDevice>());
55 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); 56 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>());
56 } 57 }
57 58
58 private: 59 private:
59 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerTest); 60 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerTest);
(...skipping 13 matching lines...) Expand all
73 manager->OnKeyboardDevicesUpdated(keyboard_devices); 74 manager->OnKeyboardDevicesUpdated(keyboard_devices);
74 } 75 }
75 76
76 private: 77 private:
77 DISALLOW_COPY_AND_ASSIGN(MockEventBlocker); 78 DISALLOW_COPY_AND_ASSIGN(MockEventBlocker);
78 }; 79 };
79 80
80 // Tests that reenabling keyboard devices while shutting down does not 81 // Tests that reenabling keyboard devices while shutting down does not
81 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. 82 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204.
82 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { 83 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) {
83 // Toggle tablet mode on. 84 // Toggle maximized mode on.
84 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 85 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
86 true);
85 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( 87 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker(
86 new MockEventBlocker); 88 new MockEventBlocker);
87 SetEventBlocker(std::move(blocker)); 89 SetEventBlocker(std::move(blocker));
88 } 90 }
89 91
90 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, 92 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest,
91 public VirtualKeyboardObserver { 93 public VirtualKeyboardObserver {
92 public: 94 public:
93 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} 95 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {}
94 ~VirtualKeyboardControllerAutoTest() override {} 96 ~VirtualKeyboardControllerAutoTest() override {}
(...skipping 30 matching lines...) Expand all
125 // Whether the observer method was called. 127 // Whether the observer method was called.
126 bool notified_; 128 bool notified_;
127 129
128 // Whether the keeyboard is suppressed. 130 // Whether the keeyboard is suppressed.
129 bool suppressed_; 131 bool suppressed_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest); 133 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest);
132 }; 134 };
133 135
134 // Tests that the onscreen keyboard is disabled if an internal keyboard is 136 // Tests that the onscreen keyboard is disabled if an internal keyboard is
135 // present and tablet mode is disabled. 137 // present and maximized mode is disabled.
136 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { 138 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) {
137 std::vector<ui::TouchscreenDevice> screens; 139 std::vector<ui::TouchscreenDevice> screens;
138 screens.push_back( 140 screens.push_back(
139 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 141 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
140 "Touchscreen", gfx::Size(1024, 768), 0)); 142 "Touchscreen", gfx::Size(1024, 768), 0));
141 UpdateTouchscreenDevices(screens); 143 UpdateTouchscreenDevices(screens);
142 std::vector<ui::InputDevice> keyboard_devices; 144 std::vector<ui::InputDevice> keyboard_devices;
143 keyboard_devices.push_back(ui::InputDevice( 145 keyboard_devices.push_back(ui::InputDevice(
144 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 146 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
145 UpdateKeyboardDevices(keyboard_devices); 147 UpdateKeyboardDevices(keyboard_devices);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 keyboards.push_back(ui::InputDevice( 207 keyboards.push_back(ui::InputDevice(
206 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 208 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
207 keyboards.push_back(ui::InputDevice( 209 keyboards.push_back(ui::InputDevice(
208 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 210 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
209 keyboards.push_back(ui::InputDevice( 211 keyboards.push_back(ui::InputDevice(
210 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 212 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
211 UpdateKeyboardDevices(keyboards); 213 UpdateKeyboardDevices(keyboards);
212 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 214 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
213 } 215 }
214 216
215 // Tests tablet mode interaction without disabling the internal keyboard. 217 // Tests maximized mode interaction without disabling the internal keyboard.
216 TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringTabletMode) { 218 TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) {
217 std::vector<ui::TouchscreenDevice> screens; 219 std::vector<ui::TouchscreenDevice> screens;
218 screens.push_back( 220 screens.push_back(
219 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 221 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
220 "Touchscreen", gfx::Size(1024, 768), 0)); 222 "Touchscreen", gfx::Size(1024, 768), 0));
221 UpdateTouchscreenDevices(screens); 223 UpdateTouchscreenDevices(screens);
222 std::vector<ui::InputDevice> keyboard_devices; 224 std::vector<ui::InputDevice> keyboard_devices;
223 keyboard_devices.push_back(ui::InputDevice( 225 keyboard_devices.push_back(ui::InputDevice(
224 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 226 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
225 UpdateKeyboardDevices(keyboard_devices); 227 UpdateKeyboardDevices(keyboard_devices);
226 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 228 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
227 // Toggle tablet mode on. 229 // Toggle maximized mode on.
228 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 230 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
231 true);
229 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 232 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
230 // Toggle tablet mode off. 233 // Toggle maximized mode off.
231 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 234 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
235 false);
232 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 236 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
233 } 237 }
234 238
235 // Tests that keyboard gets suppressed in tablet mode. 239 // Tests that keyboard gets suppressed in maximized mode.
236 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { 240 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
237 std::vector<ui::TouchscreenDevice> screens; 241 std::vector<ui::TouchscreenDevice> screens;
238 screens.push_back( 242 screens.push_back(
239 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, 243 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
240 "Touchscreen", gfx::Size(1024, 768), 0)); 244 "Touchscreen", gfx::Size(1024, 768), 0));
241 UpdateTouchscreenDevices(screens); 245 UpdateTouchscreenDevices(screens);
242 std::vector<ui::InputDevice> keyboard_devices; 246 std::vector<ui::InputDevice> keyboard_devices;
243 keyboard_devices.push_back(ui::InputDevice( 247 keyboard_devices.push_back(ui::InputDevice(
244 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 248 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
245 keyboard_devices.push_back(ui::InputDevice( 249 keyboard_devices.push_back(ui::InputDevice(
246 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard")); 250 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard"));
247 UpdateKeyboardDevices(keyboard_devices); 251 UpdateKeyboardDevices(keyboard_devices);
248 // Toggle tablet mode on. 252 // Toggle maximized mode on.
249 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 253 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
254 true);
250 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 255 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
251 ASSERT_TRUE(notified()); 256 ASSERT_TRUE(notified());
252 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 257 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
253 // Toggle show keyboard. Keyboard should be visible. 258 // Toggle show keyboard. Keyboard should be visible.
254 ResetObserver(); 259 ResetObserver();
255 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard(); 260 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard();
256 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 261 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
257 ASSERT_TRUE(notified()); 262 ASSERT_TRUE(notified());
258 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 263 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
259 // Toggle show keyboard. Keyboard should be hidden. 264 // Toggle show keyboard. Keyboard should be hidden.
260 ResetObserver(); 265 ResetObserver();
261 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard(); 266 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard();
262 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 267 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
263 ASSERT_TRUE(notified()); 268 ASSERT_TRUE(notified());
264 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); 269 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
265 // Remove external keyboard. Should be notified that the keyboard is not 270 // Remove external keyboard. Should be notified that the keyboard is not
266 // suppressed. 271 // suppressed.
267 ResetObserver(); 272 ResetObserver();
268 keyboard_devices.pop_back(); 273 keyboard_devices.pop_back();
269 UpdateKeyboardDevices(keyboard_devices); 274 UpdateKeyboardDevices(keyboard_devices);
270 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 275 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
271 ASSERT_TRUE(notified()); 276 ASSERT_TRUE(notified());
272 ASSERT_FALSE(IsVirtualKeyboardSuppressed()); 277 ASSERT_FALSE(IsVirtualKeyboardSuppressed());
273 // Toggle tablet mode oFF. 278 // Toggle maximized mode oFF.
274 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 279 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
280 false);
275 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 281 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
276 } 282 }
277 283
278 class VirtualKeyboardControllerAlwaysEnabledTest 284 class VirtualKeyboardControllerAlwaysEnabledTest
279 : public VirtualKeyboardControllerAutoTest { 285 : public VirtualKeyboardControllerAutoTest {
280 public: 286 public:
281 VirtualKeyboardControllerAlwaysEnabledTest() 287 VirtualKeyboardControllerAlwaysEnabledTest()
282 : VirtualKeyboardControllerAutoTest() {} 288 : VirtualKeyboardControllerAutoTest() {}
283 ~VirtualKeyboardControllerAlwaysEnabledTest() override {} 289 ~VirtualKeyboardControllerAlwaysEnabledTest() override {}
284 290
(...skipping 17 matching lines...) Expand all
302 UpdateTouchscreenDevices(screens); 308 UpdateTouchscreenDevices(screens);
303 std::vector<ui::InputDevice> keyboard_devices; 309 std::vector<ui::InputDevice> keyboard_devices;
304 keyboard_devices.push_back(ui::InputDevice( 310 keyboard_devices.push_back(ui::InputDevice(
305 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 311 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
306 UpdateKeyboardDevices(keyboard_devices); 312 UpdateKeyboardDevices(keyboard_devices);
307 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 313 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
308 } 314 }
309 315
310 } // namespace test 316 } // namespace test
311 } // namespace ash 317 } // namespace ash
OLDNEW
« no previous file with comments | « ash/virtual_keyboard_controller.cc ('k') | ash/wm/lock_state_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698