diff options
author | kpschoedel <kpschoedel@chromium.org> | 2015-04-27 09:59:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-27 16:59:27 +0000 |
commit | 16ce3d88cfcb6ab69af3dc8ba445da47d80c1d9b (patch) | |
tree | 9eec97eb407800f830564d1d4cccaa2fc6955c1f /ash | |
parent | aea81ada3a7947aae790d8c3c84f8b1e4257eee1 (diff) | |
download | chromium_src-16ce3d88cfcb6ab69af3dc8ba445da47d80c1d9b.zip chromium_src-16ce3d88cfcb6ab69af3dc8ba445da47d80c1d9b.tar.gz chromium_src-16ce3d88cfcb6ab69af3dc8ba445da47d80c1d9b.tar.bz2 |
Ozone support for device special cases in keyboard event rewriting.
Keyboard event rewriting has some special cases keyed on the device
name (Apple keyboards) or USB VID/PID (Hotrod remote), which had been
handled by special-case device inspection under X11, and not handled
at all under Ozone. This moves the properties to ui::DeviceDataManager
and makes the use in chromeos::EventRewriter platform-independent.
BUG=471753
Committed: https://crrev.com/711f2fc883c05bb10466fb65fdaf9bc10c909b23
Cr-Commit-Position: refs/heads/master@{#325660}
Review URL: https://codereview.chromium.org/1073573002
Cr-Commit-Position: refs/heads/master@{#327060}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/test/virtual_keyboard_test_helper.cc | 9 | ||||
-rw-r--r-- | ash/touch/touch_transformer_controller_unittest.cc | 2 | ||||
-rw-r--r-- | ash/touch/touchscreen_util_unittest.cc | 45 | ||||
-rw-r--r-- | ash/virtual_keyboard_controller_unittest.cc | 79 |
4 files changed, 75 insertions, 60 deletions
diff --git a/ash/test/virtual_keyboard_test_helper.cc b/ash/test/virtual_keyboard_test_helper.cc index 5cb39db..c920213 100644 --- a/ash/test/virtual_keyboard_test_helper.cc +++ b/ash/test/virtual_keyboard_test_helper.cc @@ -17,13 +17,14 @@ void VirtualKeyboardTestHelper::SuppressKeyboard() { ui::DeviceHotplugEventObserver* manager = ui::DeviceDataManager::GetInstance(); std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); manager->OnTouchscreenDevicesUpdated(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); manager->OnKeyboardDevicesUpdated(keyboards); } diff --git a/ash/touch/touch_transformer_controller_unittest.cc b/ash/touch/touch_transformer_controller_unittest.cc index 2a5131a..7662346 100644 --- a/ash/touch/touch_transformer_controller_unittest.cc +++ b/ash/touch/touch_transformer_controller_unittest.cc @@ -33,7 +33,7 @@ DisplayInfo CreateDisplayInfo(int64 id, ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id, const gfx::Size& size) { return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, - size, 0); + std::string(), size, 0); } } // namespace diff --git a/ash/touch/touchscreen_util_unittest.cc b/ash/touch/touchscreen_util_unittest.cc index ea88753..ce14702 100644 --- a/ash/touch/touchscreen_util_unittest.cc +++ b/ash/touch/touchscreen_util_unittest.cc @@ -76,10 +76,12 @@ TEST_F(TouchscreenUtilTest, NoTouchscreens) { TEST_F(TouchscreenUtilTest, OneToOneMapping) { std::vector<ui::TouchscreenDevice> devices; - devices.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600), 0)); - devices.push_back(ui::TouchscreenDevice( - 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); + devices.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(800, 600), 0)); + devices.push_back( + ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(1024, 768), 0)); AssociateTouchscreens(&displays_, devices); @@ -91,8 +93,9 @@ TEST_F(TouchscreenUtilTest, OneToOneMapping) { TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { std::vector<ui::TouchscreenDevice> devices; - devices.push_back(ui::TouchscreenDevice( - 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); + devices.push_back( + ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(1024, 768), 0)); AssociateTouchscreens(&displays_, devices); @@ -104,10 +107,12 @@ TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { std::vector<ui::TouchscreenDevice> devices; - devices.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(801, 600), 0)); - devices.push_back(ui::TouchscreenDevice( - 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1023, 768), 0)); + devices.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(801, 600), 0)); + devices.push_back( + ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(1023, 768), 0)); AssociateTouchscreens(&displays_, devices); @@ -119,10 +124,12 @@ TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { std::vector<ui::TouchscreenDevice> devices; - devices.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1022, 768), 0)); - devices.push_back(ui::TouchscreenDevice( - 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(802, 600), 0)); + devices.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(1022, 768), 0)); + devices.push_back( + ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(802, 600), 0)); AssociateTouchscreens(&displays_, devices); @@ -134,10 +141,12 @@ TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { std::vector<ui::TouchscreenDevice> devices; - devices.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080), 0)); - devices.push_back(ui::TouchscreenDevice( - 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888), 0)); + devices.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", + gfx::Size(1920, 1080), 0)); + devices.push_back( + ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "", + gfx::Size(9999, 888), 0)); AssociateTouchscreens(&displays_, devices); diff --git a/ash/virtual_keyboard_controller_unittest.cc b/ash/virtual_keyboard_controller_unittest.cc index 7ca7a2a..f7a59ef 100644 --- a/ash/virtual_keyboard_controller_unittest.cc +++ b/ash/virtual_keyboard_controller_unittest.cc @@ -46,9 +46,8 @@ class VirtualKeyboardControllerTest : public AshTestBase { // Sets the event blocker on the maximized window controller. void SetEventBlocker( scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { - Shell::GetInstance() - ->maximize_mode_controller() - ->event_blocker_ = blocker.Pass(); + Shell::GetInstance()->maximize_mode_controller()->event_blocker_ = + blocker.Pass(); } void SetUp() override { @@ -84,8 +83,8 @@ class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard { MockEventBlocker() {} ~MockEventBlocker() override { std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); ui::DeviceHotplugEventObserver* manager = ui::DeviceDataManager::GetInstance(); manager->OnKeyboardDevicesUpdated(keyboards); @@ -102,8 +101,8 @@ TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { Shell::GetInstance() ->maximize_mode_controller() ->EnableMaximizeModeWindowManager(true); - scoped_ptr<ScopedDisableInternalMouseAndKeyboard> - blocker(new MockEventBlocker); + scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker( + new MockEventBlocker); SetEventBlocker(blocker.Pass()); } @@ -157,12 +156,13 @@ class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, // present and maximized mode is disabled. TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); UpdateTouchscreenDevices(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); UpdateKeyboardDevices(keyboards); ASSERT_FALSE(keyboard::IsKeyboardEnabled()); // Remove the internal keyboard. Virtual keyboard should now show. @@ -176,8 +176,9 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { std::vector<ui::TouchscreenDevice> devices; // Add a touchscreen. Keyboard should deploy. - devices.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600), 0)); + devices.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, + "Touchscreen", gfx::Size(800, 600), 0)); UpdateTouchscreenDevices(devices); EXPECT_TRUE(keyboard::IsKeyboardEnabled()); // Remove touchscreen. Keyboard should hide. @@ -187,12 +188,13 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); UpdateTouchscreenDevices(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); UpdateKeyboardDevices(keyboards); ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_TRUE(notified()); @@ -225,12 +227,12 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { // Tests handling multiple keyboards. Catches crbug.com/430252 TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) { std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); - keyboards.push_back( - ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); - keyboards.push_back( - ui::KeyboardDevice(3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); + keyboards.push_back(ui::KeyboardDevice( + 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); + keyboards.push_back(ui::KeyboardDevice( + 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); UpdateKeyboardDevices(keyboards); ASSERT_FALSE(keyboard::IsKeyboardEnabled()); } @@ -238,12 +240,13 @@ TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) { // Tests maximized mode interaction without disabling the internal keyboard. TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) { std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); UpdateTouchscreenDevices(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); UpdateKeyboardDevices(keyboards); ASSERT_FALSE(keyboard::IsKeyboardEnabled()); // Toggle maximized mode on. @@ -261,14 +264,15 @@ TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) { // Tests that keyboard gets suppressed in maximized mode. TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); UpdateTouchscreenDevices(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); - keyboards.push_back( - ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); + keyboards.push_back(ui::KeyboardDevice( + 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard")); UpdateKeyboardDevices(keyboards); // Toggle maximized mode on. Shell::GetInstance() @@ -329,12 +333,13 @@ class VirtualKeyboardControllerAlwaysEnabledTest // keyboard always enabled flag is active. TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) { std::vector<ui::TouchscreenDevice> screens; - screens.push_back(ui::TouchscreenDevice( - 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); + screens.push_back( + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, + "Touchscreen", gfx::Size(1024, 768), 0)); UpdateTouchscreenDevices(screens); std::vector<ui::KeyboardDevice> keyboards; - keyboards.push_back( - ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); + keyboards.push_back(ui::KeyboardDevice( + 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); UpdateKeyboardDevices(keyboards); ASSERT_TRUE(keyboard::IsKeyboardEnabled()); } |