Commit b0722ecf authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: removes ForTesting functions in factor of TestApi

The TestApi class now handles all this, so no reason for the public
virtual ForTesting functions.

BUG=776514
TEST=test only changes

Change-Id: I1e8165fe1747a7b1b0c1ccfc4f2d0f036eb5d3b5
Reviewed-on: https://chromium-review.googlesource.com/830685Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524494}
parent f5a5f376
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/touch/ash_touch_transform_controller.h" #include "ash/touch/ash_touch_transform_controller.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/manager/chromeos/test/touch_device_manager_test_api.h" #include "ui/display/manager/chromeos/test/touch_device_manager_test_api.h"
#include "ui/display/manager/chromeos/test/touch_transform_controller_test_api.h" #include "ui/display/manager/chromeos/test/touch_transform_controller_test_api.h"
...@@ -19,7 +20,6 @@ ...@@ -19,7 +20,6 @@
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/test/display_manager_test_api.h" #include "ui/display/test/display_manager_test_api.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/events/devices/input_device_manager.h"
#include "ui/events/devices/touch_device_transform.h" #include "ui/events/devices/touch_device_transform.h"
#include "ui/events/event_handler.h" #include "ui/events/event_handler.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
...@@ -52,7 +52,7 @@ class TouchCalibratorControllerTest : public AshTestBase { ...@@ -52,7 +52,7 @@ class TouchCalibratorControllerTest : public AshTestBase {
// Reset all touch device and touch association. // Reset all touch device and touch association.
test::TouchDeviceManagerTestApi(touch_device_manager()) test::TouchDeviceManagerTestApi(touch_device_manager())
.ResetTouchDeviceManager(); .ResetTouchDeviceManager();
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting({}); ui::InputDeviceClientTestApi().SetTouchscreenDevices({});
test::TouchTransformControllerTestApi( test::TouchTransformControllerTestApi(
Shell::Get()->touch_transformer_controller()) Shell::Get()->touch_transformer_controller())
.touch_transform_setter() .touch_transform_setter()
...@@ -169,8 +169,7 @@ class TouchCalibratorControllerTest : public AshTestBase { ...@@ -169,8 +169,7 @@ class TouchCalibratorControllerTest : public AshTestBase {
ui::TouchscreenDevice InitTouchDevice( ui::TouchscreenDevice InitTouchDevice(
int64_t display_id, int64_t display_id,
const ui::TouchscreenDevice& touchdevice) { const ui::TouchscreenDevice& touchdevice) {
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting( ui::InputDeviceClientTestApi().SetTouchscreenDevices({touchdevice});
{touchdevice});
std::vector<ui::TouchDeviceTransform> transforms; std::vector<ui::TouchDeviceTransform> transforms;
ui::TouchDeviceTransform touch_device_transform; ui::TouchDeviceTransform touch_device_transform;
...@@ -404,7 +403,7 @@ TEST_F(TouchCalibratorControllerTest, HighDPIMonitorsCalibration) { ...@@ -404,7 +403,7 @@ TEST_F(TouchCalibratorControllerTest, HighDPIMonitorsCalibration) {
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
std::string("external touch device"), gfx::Size(1000, 1000), 1); std::string("external touch device"), gfx::Size(1000, 1000), 1);
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting( ui::InputDeviceClientTestApi().SetTouchscreenDevices(
{internal_touchdevice, external_touchdevice}); {internal_touchdevice, external_touchdevice});
// Associate both touch devices to the internal display. // Associate both touch devices to the internal display.
...@@ -496,7 +495,7 @@ TEST_F(TouchCalibratorControllerTest, RotatedHighDPIMonitorsCalibration) { ...@@ -496,7 +495,7 @@ TEST_F(TouchCalibratorControllerTest, RotatedHighDPIMonitorsCalibration) {
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
std::string("external touch device"), gfx::Size(1000, 1000), 1); std::string("external touch device"), gfx::Size(1000, 1000), 1);
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting( ui::InputDeviceClientTestApi().SetTouchscreenDevices(
{internal_touchdevice, external_touchdevice}); {internal_touchdevice, external_touchdevice});
// Associate both touch devices to the internal display. // Associate both touch devices to the internal display.
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/events/devices/input_device_manager.h" #include "ui/events/devices/input_device_manager.h"
#include "ui/keyboard/keyboard_util.h" #include "ui/keyboard/keyboard_util.h"
...@@ -120,19 +121,21 @@ void TrayIMETest::SuppressKeyboard() { ...@@ -120,19 +121,21 @@ void TrayIMETest::SuppressKeyboard() {
std::vector<ui::TouchscreenDevice> screens; std::vector<ui::TouchscreenDevice> screens;
screens.emplace_back(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, screens.emplace_back(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
"Touchscreen", gfx::Size(1024, 768), 0); "Touchscreen", gfx::Size(1024, 768), 0);
manager->SetTouchscreenDevicesForTesting(screens); ui::InputDeviceClientTestApi input_device_client_test_api;
input_device_client_test_api.SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboards; std::vector<ui::InputDevice> keyboards;
keyboards.push_back(ui::InputDevice( keyboards.push_back(ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
manager->SetKeyboardDevicesForTesting(keyboards); input_device_client_test_api.SetKeyboardDevices(keyboards);
} }
void TrayIMETest::RestoreKeyboard() { void TrayIMETest::RestoreKeyboard() {
DCHECK(keyboard_suppressed_); DCHECK(keyboard_suppressed_);
ui::InputDeviceManager* manager = ui::InputDeviceManager::GetInstance(); ui::InputDeviceClientTestApi().SetTouchscreenDevices(
manager->SetTouchscreenDevicesForTesting(touchscreen_devices_to_restore_); touchscreen_devices_to_restore_);
manager->SetKeyboardDevicesForTesting(keyboard_devices_to_restore_); ui::InputDeviceClientTestApi().SetKeyboardDevices(
keyboard_devices_to_restore_);
} }
void TrayIMETest::SetUp() { void TrayIMETest::SetUp() {
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "ash/wm/tablet_mode/scoped_disable_internal_mouse_and_keyboard.h" #include "ash/wm/tablet_mode/scoped_disable_internal_mouse_and_keyboard.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/events/devices/input_device.h" #include "ui/events/devices/input_device.h"
#include "ui/events/devices/input_device_manager.h"
#include "ui/events/devices/touchscreen_device.h" #include "ui/events/devices/touchscreen_device.h"
#include "ui/keyboard/keyboard_export.h" #include "ui/keyboard/keyboard_export.h"
#include "ui/keyboard/keyboard_switches.h" #include "ui/keyboard/keyboard_switches.h"
...@@ -28,17 +28,6 @@ class VirtualKeyboardControllerTest : public AshTestBase { ...@@ -28,17 +28,6 @@ class VirtualKeyboardControllerTest : public AshTestBase {
VirtualKeyboardControllerTest() = default; VirtualKeyboardControllerTest() = default;
~VirtualKeyboardControllerTest() override = default; ~VirtualKeyboardControllerTest() override = default;
void UpdateTouchscreenDevices(
std::vector<ui::TouchscreenDevice> touchscreen_devices) {
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting(
touchscreen_devices);
}
void UpdateKeyboardDevices(std::vector<ui::InputDevice> keyboard_devices) {
ui::InputDeviceManager::GetInstance()->SetKeyboardDevicesForTesting(
keyboard_devices);
}
// Sets the event blocker on the maximized window controller. // Sets the event blocker on the maximized window controller.
void SetEventBlocker( void SetEventBlocker(
std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) { std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) {
...@@ -47,8 +36,8 @@ class VirtualKeyboardControllerTest : public AshTestBase { ...@@ -47,8 +36,8 @@ class VirtualKeyboardControllerTest : public AshTestBase {
void SetUp() override { void SetUp() override {
AshTestBase::SetUp(); AshTestBase::SetUp();
UpdateKeyboardDevices(std::vector<ui::InputDevice>()); ui::InputDeviceClientTestApi().SetKeyboardDevices({});
UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); ui::InputDeviceClientTestApi().SetTouchscreenDevices({});
} }
private: private:
...@@ -64,8 +53,7 @@ class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard { ...@@ -64,8 +53,7 @@ class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard {
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
ui::InputDeviceManager::GetInstance()->SetKeyboardDevicesForTesting( ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
keyboard_devices);
} }
private: private:
...@@ -92,8 +80,8 @@ class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest, ...@@ -92,8 +80,8 @@ class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest,
AshTestBase::SetUp(); AshTestBase::SetUp();
// Set the current list of devices to empty so that they don't interfere // Set the current list of devices to empty so that they don't interfere
// with the test. // with the test.
UpdateKeyboardDevices(std::vector<ui::InputDevice>()); ui::InputDeviceClientTestApi().SetKeyboardDevices({});
UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); ui::InputDeviceClientTestApi().SetTouchscreenDevices({});
Shell::Get()->system_tray_notifier()->AddVirtualKeyboardObserver(this); Shell::Get()->system_tray_notifier()->AddVirtualKeyboardObserver(this);
} }
...@@ -133,17 +121,17 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { ...@@ -133,17 +121,17 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) {
screens.push_back( screens.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
"Touchscreen", gfx::Size(1024, 768), 0)); "Touchscreen", gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens); ui::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
// Remove the internal keyboard. Virtual keyboard should now show. // Remove the internal keyboard. Virtual keyboard should now show.
UpdateKeyboardDevices(std::vector<ui::InputDevice>()); ui::InputDeviceClientTestApi().SetKeyboardDevices({});
EXPECT_TRUE(keyboard::IsKeyboardEnabled()); EXPECT_TRUE(keyboard::IsKeyboardEnabled());
// Replug in the internal keyboard. Virtual keyboard should hide. // Replug in the internal keyboard. Virtual keyboard should hide.
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
EXPECT_FALSE(keyboard::IsKeyboardEnabled()); EXPECT_FALSE(keyboard::IsKeyboardEnabled());
} }
...@@ -153,10 +141,10 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { ...@@ -153,10 +141,10 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) {
devices.push_back( devices.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
"Touchscreen", gfx::Size(800, 600), 0)); "Touchscreen", gfx::Size(800, 600), 0));
UpdateTouchscreenDevices(devices); ui::InputDeviceClientTestApi().SetTouchscreenDevices(devices);
EXPECT_TRUE(keyboard::IsKeyboardEnabled()); EXPECT_TRUE(keyboard::IsKeyboardEnabled());
// Remove touchscreen. Keyboard should hide. // Remove touchscreen. Keyboard should hide.
UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); ui::InputDeviceClientTestApi().SetTouchscreenDevices({});
EXPECT_FALSE(keyboard::IsKeyboardEnabled()); EXPECT_FALSE(keyboard::IsKeyboardEnabled());
} }
...@@ -165,11 +153,11 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { ...@@ -165,11 +153,11 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) {
screens.push_back(ui::TouchscreenDevice( screens.push_back(ui::TouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Touchscreen", 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Touchscreen",
gfx::Size(1024, 768), 0, false /* has_stylus */)); gfx::Size(1024, 768), 0, false /* has_stylus */));
UpdateTouchscreenDevices(screens); ui::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified()); ASSERT_TRUE(notified());
ASSERT_TRUE(IsVirtualKeyboardSuppressed()); ASSERT_TRUE(IsVirtualKeyboardSuppressed());
...@@ -188,7 +176,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { ...@@ -188,7 +176,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) {
// Remove external keyboard. Should be notified that the keyboard is not // Remove external keyboard. Should be notified that the keyboard is not
// suppressed. // suppressed.
ResetObserver(); ResetObserver();
UpdateKeyboardDevices(std::vector<ui::InputDevice>()); ui::InputDeviceClientTestApi().SetKeyboardDevices({});
ASSERT_TRUE(keyboard::IsKeyboardEnabled()); ASSERT_TRUE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified()); ASSERT_TRUE(notified());
ASSERT_FALSE(IsVirtualKeyboardSuppressed()); ASSERT_FALSE(IsVirtualKeyboardSuppressed());
...@@ -203,7 +191,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) { ...@@ -203,7 +191,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) {
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboards.push_back(ui::InputDevice( keyboards.push_back(ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
UpdateKeyboardDevices(keyboards); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboards);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
} }
...@@ -213,11 +201,11 @@ TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringTabletMode) { ...@@ -213,11 +201,11 @@ TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringTabletMode) {
screens.push_back( screens.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
"Touchscreen", gfx::Size(1024, 768), 0)); "Touchscreen", gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens); ui::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
// Toggle tablet mode on. // Toggle tablet mode on.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
...@@ -233,13 +221,13 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { ...@@ -233,13 +221,13 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
screens.push_back( screens.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
"Touchscreen", gfx::Size(1024, 768), 0)); "Touchscreen", gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens); ui::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard")); 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard"));
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
// Toggle tablet mode on. // Toggle tablet mode on.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
ASSERT_FALSE(keyboard::IsKeyboardEnabled()); ASSERT_FALSE(keyboard::IsKeyboardEnabled());
...@@ -261,7 +249,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) { ...@@ -261,7 +249,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
// suppressed. // suppressed.
ResetObserver(); ResetObserver();
keyboard_devices.pop_back(); keyboard_devices.pop_back();
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_TRUE(keyboard::IsKeyboardEnabled()); ASSERT_TRUE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified()); ASSERT_TRUE(notified());
ASSERT_FALSE(IsVirtualKeyboardSuppressed()); ASSERT_FALSE(IsVirtualKeyboardSuppressed());
...@@ -294,11 +282,11 @@ TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) { ...@@ -294,11 +282,11 @@ TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) {
screens.push_back( screens.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
"Touchscreen", gfx::Size(1024, 768), 0)); "Touchscreen", gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens); ui::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices; std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice( keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
UpdateKeyboardDevices(keyboard_devices); ui::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_TRUE(keyboard::IsKeyboardEnabled()); ASSERT_TRUE(keyboard::IsKeyboardEnabled());
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/extensions/display_info_provider_chromeos.h" #include "chrome/browser/extensions/display_info_provider_chromeos.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "extensions/common/api/system_display.h" #include "extensions/common/api/system_display.h"
#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/display_layout.h" #include "ui/display/display_layout.h"
#include "ui/display/display_switches.h" #include "ui/display/display_switches.h"
...@@ -28,8 +29,8 @@ ...@@ -28,8 +29,8 @@
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/test/display_manager_test_api.h" #include "ui/display/test/display_manager_test_api.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
#include "ui/events/devices/input_device_manager.h"
#include "ui/events/devices/touch_device_transform.h" #include "ui/events/devices/touch_device_transform.h"
#include "ui/events/devices/touchscreen_device.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
namespace extensions { namespace extensions {
...@@ -42,8 +43,7 @@ void InitExternalTouchDevices(int64_t display_id) { ...@@ -42,8 +43,7 @@ void InitExternalTouchDevices(int64_t display_id) {
ui::TouchscreenDevice touchdevice( ui::TouchscreenDevice touchdevice(
123, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, 123, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
std::string("test external touch device"), gfx::Size(1000, 1000), 1); std::string("test external touch device"), gfx::Size(1000, 1000), 1);
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting( ui::InputDeviceClientTestApi().SetTouchscreenDevices({touchdevice});
{touchdevice});
std::vector<ui::TouchDeviceTransform> transforms; std::vector<ui::TouchDeviceTransform> transforms;
ui::TouchDeviceTransform touch_device_transform; ui::TouchDeviceTransform touch_device_transform;
...@@ -1484,7 +1484,7 @@ TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNonTouchDisplay) { ...@@ -1484,7 +1484,7 @@ TEST_F(DisplayInfoProviderChromeosTest, CustomTouchCalibrationNonTouchDisplay) {
? display_id_list[1] ? display_id_list[1]
: display_id_list[0]; : display_id_list[0];
ui::InputDeviceManager::GetInstance()->SetTouchscreenDevicesForTesting({}); ui::InputDeviceClientTestApi().SetTouchscreenDevices({});
std::string id = base::Int64ToString(display_id); std::string id = base::Int64ToString(display_id);
std::string error; std::string error;
......
...@@ -125,16 +125,12 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -125,16 +125,12 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Simulate an external keyboard being connected. We should assume there's a // Simulate an external keyboard being connected. We should assume there's a
// Caps Lock key now. // Caps Lock key now.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{1, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}}); {2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}});
input_device_client_test_api_
.NotifyObserversKeyboardDeviceConfigurationChanged();
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
// Disconnect the external keyboard and check that the key goes away. // Disconnect the external keyboard and check that the key goes away.
input_device_client_test_api_.SetKeyboardDevices({}); input_device_client_test_api_.SetKeyboardDevices({});
input_device_client_test_api_
.NotifyObserversKeyboardDeviceConfigurationChanged();
EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
} }
......
...@@ -61,16 +61,6 @@ void InputDeviceClient::RemoveObserver(ui::InputDeviceEventObserver* observer) { ...@@ -61,16 +61,6 @@ void InputDeviceClient::RemoveObserver(ui::InputDeviceEventObserver* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
void InputDeviceClient::SetKeyboardDevicesForTesting(
const std::vector<InputDevice>& devices) {
OnKeyboardDeviceConfigurationChanged(devices);
}
void InputDeviceClient::SetTouchscreenDevicesForTesting(
const std::vector<TouchscreenDevice>& devices) {
OnTouchscreenDeviceConfigurationChanged(devices, false);
}
InputDeviceClient::InputDeviceClient(bool is_input_device_manager) InputDeviceClient::InputDeviceClient(bool is_input_device_manager)
: binding_(this), is_input_device_manager_(is_input_device_manager) { : binding_(this), is_input_device_manager_(is_input_device_manager) {
if (is_input_device_manager_) if (is_input_device_manager_)
......
...@@ -44,10 +44,6 @@ class InputDeviceClient : public mojom::InputDeviceObserverMojo, ...@@ -44,10 +44,6 @@ class InputDeviceClient : public mojom::InputDeviceObserverMojo,
bool AreTouchscreenTargetDisplaysValid() const override; bool AreTouchscreenTargetDisplaysValid() const override;
void AddObserver(ui::InputDeviceEventObserver* observer) override; void AddObserver(ui::InputDeviceEventObserver* observer) override;
void RemoveObserver(ui::InputDeviceEventObserver* observer) override; void RemoveObserver(ui::InputDeviceEventObserver* observer) override;
void SetKeyboardDevicesForTesting(
const std::vector<InputDevice>& devices) override;
void SetTouchscreenDevicesForTesting(
const std::vector<TouchscreenDevice>& devices) override;
protected: protected:
// Default constructor registers as InputDeviceManager. Can be subclassed in // Default constructor registers as InputDeviceManager. Can be subclassed in
......
...@@ -61,18 +61,21 @@ void InputDeviceClientTestApi::OnDeviceListsComplete() { ...@@ -61,18 +61,21 @@ void InputDeviceClientTestApi::OnDeviceListsComplete() {
void InputDeviceClientTestApi::SetKeyboardDevices( void InputDeviceClientTestApi::SetKeyboardDevices(
const std::vector<InputDevice>& devices) { const std::vector<InputDevice>& devices) {
if (DeviceDataManager::instance_) if (DeviceDataManager::instance_) {
DeviceDataManager::instance_->keyboard_devices_ = devices; DeviceDataManager::instance_->OnKeyboardDevicesUpdated(devices);
else } else {
GetInputDeviceClient()->keyboard_devices_ = devices; GetInputDeviceClient()->OnKeyboardDeviceConfigurationChanged(devices);
}
} }
void InputDeviceClientTestApi::SetTouchscreenDevices( void InputDeviceClientTestApi::SetTouchscreenDevices(
const std::vector<TouchscreenDevice>& devices) { const std::vector<TouchscreenDevice>& devices) {
if (DeviceDataManager::instance_) if (DeviceDataManager::instance_) {
DeviceDataManager::instance_->touchscreen_devices_ = devices; DeviceDataManager::instance_->OnTouchscreenDevicesUpdated(devices);
else } else {
GetInputDeviceClient()->touchscreen_devices_ = devices; GetInputDeviceClient()->OnTouchscreenDeviceConfigurationChanged(devices,
false);
}
} }
InputDeviceClient* InputDeviceClientTestApi::GetInputDeviceClient() { InputDeviceClient* InputDeviceClientTestApi::GetInputDeviceClient() {
......
...@@ -253,16 +253,6 @@ void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { ...@@ -253,16 +253,6 @@ void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
void DeviceDataManager::SetKeyboardDevicesForTesting(
const std::vector<InputDevice>& devices) {
OnKeyboardDevicesUpdated(devices);
}
void DeviceDataManager::SetTouchscreenDevicesForTesting(
const std::vector<TouchscreenDevice>& devices) {
OnTouchscreenDevicesUpdated(devices);
}
void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { void DeviceDataManager::SetTouchscreensEnabled(bool enabled) {
touch_screens_enabled_ = enabled; touch_screens_enabled_ = enabled;
} }
......
...@@ -62,10 +62,6 @@ class EVENTS_DEVICES_EXPORT DeviceDataManager ...@@ -62,10 +62,6 @@ class EVENTS_DEVICES_EXPORT DeviceDataManager
bool AreTouchscreenTargetDisplaysValid() const override; bool AreTouchscreenTargetDisplaysValid() const override;
void AddObserver(InputDeviceEventObserver* observer) override; void AddObserver(InputDeviceEventObserver* observer) override;
void RemoveObserver(InputDeviceEventObserver* observer) override; void RemoveObserver(InputDeviceEventObserver* observer) override;
void SetKeyboardDevicesForTesting(
const std::vector<InputDevice>& devices) override;
void SetTouchscreenDevicesForTesting(
const std::vector<TouchscreenDevice>& devices) override;
protected: protected:
DeviceDataManager(); DeviceDataManager();
......
...@@ -42,11 +42,6 @@ class EVENTS_DEVICES_EXPORT InputDeviceManager { ...@@ -42,11 +42,6 @@ class EVENTS_DEVICES_EXPORT InputDeviceManager {
virtual void AddObserver(InputDeviceEventObserver* observer) = 0; virtual void AddObserver(InputDeviceEventObserver* observer) = 0;
virtual void RemoveObserver(InputDeviceEventObserver* observer) = 0; virtual void RemoveObserver(InputDeviceEventObserver* observer) = 0;
virtual void SetKeyboardDevicesForTesting(
const std::vector<InputDevice>& devices) = 0;
virtual void SetTouchscreenDevicesForTesting(
const std::vector<TouchscreenDevice>& devices) = 0;
protected: protected:
// Sets the instance. This should only be set once per thread. // Sets the instance. This should only be set once per thread.
static void SetInstance(InputDeviceManager* instance); static void SetInstance(InputDeviceManager* instance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment