Chromium Code Reviews| 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 <vector> | |
| 8 | |
| 7 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 8 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" | 10 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" |
| 9 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" | |
| 11 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 12 #include "ui/events/devices/device_data_manager.h" | 15 #include "ui/events/devices/device_data_manager.h" |
| 13 #include "ui/events/devices/device_hotplug_event_observer.h" | 16 #include "ui/events/devices/device_hotplug_event_observer.h" |
| 14 #include "ui/events/devices/input_device.h" | 17 #include "ui/events/devices/input_device.h" |
| 15 #include "ui/events/devices/keyboard_device.h" | 18 #include "ui/events/devices/keyboard_device.h" |
| 16 #include "ui/events/devices/touchscreen_device.h" | 19 #include "ui/events/devices/touchscreen_device.h" |
| 17 #include "ui/keyboard/keyboard_export.h" | 20 #include "ui/keyboard/keyboard_export.h" |
| 18 #include "ui/keyboard/keyboard_switches.h" | 21 #include "ui/keyboard/keyboard_switches.h" |
| 19 #include "ui/keyboard/keyboard_util.h" | 22 #include "ui/keyboard/keyboard_util.h" |
| 20 | 23 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 ->maximize_mode_controller() | 61 ->maximize_mode_controller() |
| 59 ->EnableMaximizeModeWindowManager(true); | 62 ->EnableMaximizeModeWindowManager(true); |
| 60 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 63 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 61 // Toggle maximized mode off. | 64 // Toggle maximized mode off. |
| 62 Shell::GetInstance() | 65 Shell::GetInstance() |
| 63 ->maximize_mode_controller() | 66 ->maximize_mode_controller() |
| 64 ->EnableMaximizeModeWindowManager(false); | 67 ->EnableMaximizeModeWindowManager(false); |
| 65 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 68 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 66 } | 69 } |
| 67 | 70 |
| 71 // Mock event blocker that enables the internal keyboard when it's destructor | |
| 72 // is called. | |
| 73 class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard { | |
| 74 public: | |
| 75 MockEventBlocker() {} | |
| 76 ~MockEventBlocker() { | |
|
sky
2015/01/06 22:34:04
override
rsadam
2015/01/06 23:18:41
Done.
| |
| 77 std::vector<ui::KeyboardDevice> keyboards; | |
| 78 keyboards.push_back(ui::KeyboardDevice( | |
| 79 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); | |
| 80 ui::DeviceHotplugEventObserver* manager = | |
| 81 ui::DeviceDataManager::GetInstance(); | |
| 82 manager->OnKeyboardDevicesUpdated(keyboards); | |
| 83 } | |
| 84 | |
| 85 private: | |
| 86 DISALLOW_COPY_AND_ASSIGN(MockEventBlocker); | |
| 87 }; | |
| 88 | |
| 89 // Tests that reenabling keyboard devices while shutting down does not | |
| 90 // cause the Virtual Keyboard Controller to crash. See crbug.com/446204. | |
| 91 TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { | |
| 92 // Toggle maximized mode on. | |
| 93 Shell::GetInstance() | |
| 94 ->maximize_mode_controller() | |
| 95 ->EnableMaximizeModeWindowManager(true); | |
| 96 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> | |
| 97 blocker(new MockEventBlocker); | |
| 98 // Install event blocker. | |
| 99 Shell::GetInstance() | |
| 100 ->maximize_mode_controller() | |
| 101 ->InstallEventBlockerForTest(blocker.Pass()); | |
| 102 } | |
| 103 | |
| 68 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, | 104 class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, |
| 69 public VirtualKeyboardObserver { | 105 public VirtualKeyboardObserver { |
| 70 public: | 106 public: |
| 71 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} | 107 VirtualKeyboardControllerAutoTest() : notified_(false), suppressed_(false) {} |
| 72 ~VirtualKeyboardControllerAutoTest() override {} | 108 ~VirtualKeyboardControllerAutoTest() override {} |
| 73 | 109 |
| 74 void SetUp() override { | 110 void SetUp() override { |
| 75 AshTestBase::SetUp(); | 111 AshTestBase::SetUp(); |
| 76 // Set the current list of devices to empty so that they don't interfere | 112 // Set the current list of devices to empty so that they don't interfere |
| 77 // with the test. | 113 // with the test. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 keyboards.push_back(ui::KeyboardDevice( | 233 keyboards.push_back(ui::KeyboardDevice( |
| 198 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 234 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
| 199 keyboards.push_back(ui::KeyboardDevice( | 235 keyboards.push_back(ui::KeyboardDevice( |
| 200 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 236 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
| 201 UpdateKeyboardDevices(keyboards); | 237 UpdateKeyboardDevices(keyboards); |
| 202 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); | 238 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
| 203 } | 239 } |
| 204 | 240 |
| 205 } // namespace test | 241 } // namespace test |
| 206 } // namespace ash | 242 } // namespace ash |
| OLD | NEW |