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/virtual_keyboard_controller.h" | 5 #include "ash/virtual_keyboard_controller.h" |
6 | 6 |
| 7 #include <utility> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
10 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" | 11 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" |
11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
13 #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" |
14 #include "ash_switches.h" | 15 #include "ash_switches.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "ui/events/devices/device_data_manager.h" | 17 #include "ui/events/devices/device_data_manager.h" |
(...skipping 23 matching lines...) Expand all Loading... |
40 void UpdateKeyboardDevices(std::vector<ui::KeyboardDevice> keyboard_devices) { | 41 void UpdateKeyboardDevices(std::vector<ui::KeyboardDevice> keyboard_devices) { |
41 ui::DeviceHotplugEventObserver* manager = | 42 ui::DeviceHotplugEventObserver* manager = |
42 ui::DeviceDataManager::GetInstance(); | 43 ui::DeviceDataManager::GetInstance(); |
43 manager->OnKeyboardDevicesUpdated(keyboard_devices); | 44 manager->OnKeyboardDevicesUpdated(keyboard_devices); |
44 } | 45 } |
45 | 46 |
46 // Sets the event blocker on the maximized window controller. | 47 // Sets the event blocker on the maximized window controller. |
47 void SetEventBlocker( | 48 void SetEventBlocker( |
48 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { | 49 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { |
49 Shell::GetInstance()->maximize_mode_controller()->event_blocker_ = | 50 Shell::GetInstance()->maximize_mode_controller()->event_blocker_ = |
50 blocker.Pass(); | 51 std::move(blocker); |
51 } | 52 } |
52 | 53 |
53 void SetUp() override { | 54 void SetUp() override { |
54 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 55 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
55 keyboard::switches::kDisableSmartVirtualKeyboard); | 56 keyboard::switches::kDisableSmartVirtualKeyboard); |
56 AshTestBase::SetUp(); | 57 AshTestBase::SetUp(); |
57 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); | 58 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
58 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); | 59 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); |
59 } | 60 } |
60 | 61 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 // Tests that reenabling keyboard devices while shutting down does not | 98 // Tests that reenabling keyboard devices while shutting down does not |
98 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. | 99 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. |
99 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { | 100 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { |
100 // Toggle maximized mode on. | 101 // Toggle maximized mode on. |
101 Shell::GetInstance() | 102 Shell::GetInstance() |
102 ->maximize_mode_controller() | 103 ->maximize_mode_controller() |
103 ->EnableMaximizeModeWindowManager(true); | 104 ->EnableMaximizeModeWindowManager(true); |
104 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( | 105 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( |
105 new MockEventBlocker); | 106 new MockEventBlocker); |
106 SetEventBlocker(blocker.Pass()); | 107 SetEventBlocker(std::move(blocker)); |
107 } | 108 } |
108 | 109 |
109 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, | 110 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, |
110 public VirtualKeyboardObserver { | 111 public VirtualKeyboardObserver { |
111 public: | 112 public: |
112 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} | 113 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} |
113 ~VirtualKeyboardControllerAutoTest() override {} | 114 ~VirtualKeyboardControllerAutoTest() override {} |
114 | 115 |
115 void SetUp() override { | 116 void SetUp() override { |
116 AshTestBase::SetUp(); | 117 AshTestBase::SetUp(); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 UpdateTouchscreenDevices(screens); | 340 UpdateTouchscreenDevices(screens); |
340 std::vector<ui::KeyboardDevice> keyboards; | 341 std::vector<ui::KeyboardDevice> keyboards; |
341 keyboards.push_back(ui::KeyboardDevice( | 342 keyboards.push_back(ui::KeyboardDevice( |
342 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 343 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
343 UpdateKeyboardDevices(keyboards); | 344 UpdateKeyboardDevices(keyboards); |
344 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); | 345 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
345 } | 346 } |
346 | 347 |
347 } // namespace test | 348 } // namespace test |
348 } // namespace ash | 349 } // namespace ash |
OLD | NEW |