summaryrefslogtreecommitdiff
path: root/chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc')
-rw-r--r--chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc b/chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc
new file mode 100644
index 00000000000..02e8fa374de
--- /dev/null
+++ b/chromium/ui/events/ozone/evdev/input_controller_evdev_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/ozone/evdev/input_controller_evdev.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ui {
+
+TEST(InputControllerEvdevTest, AccelerationSuspension) {
+ InputControllerEvdev controller(nullptr, nullptr, nullptr);
+ controller.SetMouseAcceleration(true);
+ controller.SetPointingStickAcceleration(true);
+
+ EXPECT_TRUE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_TRUE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+
+ // Suspending should disable the acceleration temporarily.
+ controller.SuspendMouseAcceleration();
+ EXPECT_FALSE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_FALSE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+
+ // Resuming should enable it again.
+ controller.EndMouseAccelerationSuspension();
+ EXPECT_TRUE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_TRUE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+}
+
+TEST(InputControllerEvdevTest, AccelerationChangeDuringSuspension) {
+ InputControllerEvdev controller(nullptr, nullptr, nullptr);
+ controller.SetMouseAcceleration(true);
+ controller.SetPointingStickAcceleration(true);
+
+ // Suspending should disable the acceleration temporarily.
+ controller.SuspendMouseAcceleration();
+ EXPECT_FALSE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_FALSE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+
+ // Settings changes while suspended should not take effect immediately...
+ controller.SetMouseAcceleration(true);
+ controller.SetPointingStickAcceleration(true);
+ EXPECT_FALSE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_FALSE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+
+ // ...instead being applied when the suspension ends.
+ controller.SetMouseAcceleration(false);
+ controller.SetPointingStickAcceleration(false);
+ controller.EndMouseAccelerationSuspension();
+ EXPECT_FALSE(controller.input_device_settings_.mouse_acceleration_enabled);
+ EXPECT_FALSE(
+ controller.input_device_settings_.pointing_stick_acceleration_enabled);
+}
+
+} // namespace ui