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