summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2020-12-19 03:12:36 +0200
committerPovilas Kanapickas <povilas@radix.lt>2020-12-19 03:12:36 +0200
commit628d5cc2e015381a3efcf6dbb188a029c9f114a7 (patch)
tree4dbefea0aa1215af38fec5fb43c59e0e1c6e76fd
parent8422eb358677eaf60254393070d37f8dda2faed1 (diff)
tests: Rewrite general input tests to use inputtest driver
The current tests for input drivers are unreliable and effectively unfixable, because of the race condition introduced by separate input thread. The inputtest driver has the required synchronization capabilities.
-rw-r--r--tests/server/input.cpp849
1 files changed, 345 insertions, 504 deletions
diff --git a/tests/server/input.cpp b/tests/server/input.cpp
index f13bff3..0ad48fe 100644
--- a/tests/server/input.cpp
+++ b/tests/server/input.cpp
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <xorg/gtest/xorg-gtest.h>
+#include <xorg/gtest/inputtest/xorg-gtest-device.h>
#include <X11/Xatom.h>
#include <X11/extensions/XInput2.h>
@@ -40,66 +41,106 @@
#include "xit-event.h"
#include "xit-property.h"
#include "device-interface.h"
+#include "device-inputtest-interface.h"
#include "helpers.h"
using namespace xorg::testing;
class PointerMotionTest : public XITServerInputTest,
- public DeviceInterface {
+ public DeviceInputTestInterface {
public:
/**
* Initializes a standard mouse device.
*/
virtual void SetUp() {
- SetDevice("mice/PIXART-USB-OPTICAL-MOUSE-HWHEEL.desc");
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
XITServerInputTest::SetUp();
}
+ virtual void SetUpConfigAndLog() {
+ config.AddDefaultScreenWithDriver();
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"CorePointer\" \"on\"\n" +
+ Dev(0).GetOptions());
+ // add default keyboard device
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions());
+ config.WriteConfig();
+ }
+
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
+};
+
+class PointerMotionAbsoluteTest : public XITServerInputTest,
+ public DeviceInputTestInterface {
+public:
/**
- * Sets up an xorg.conf for a single evdev CoreKeyboard device based on
- * the evemu device. The input from GetParam() is used as XkbLayout.
+ * Initializes a standard mouse device.
*/
+ virtual void SetUp() {
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER_ABSOLUTE);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
+ XITServerInputTest::SetUp();
+ }
+
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--device--",
- "Option \"Emulate3Buttons\" \"off\"\n"
- "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
- /* add default keyboard device to avoid server adding our device again */
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"CorePointer\" \"on\"\n" +
+ Dev(0).GetOptions());
+ // add default keyboard device
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions());
config.WriteConfig();
}
+
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
};
-class TabletMotionTest : public PointerMotionTest
-{
+class PointerMotionPressureTest : public XITServerInputTest,
+ public DeviceInputTestInterface {
virtual void SetUp() {
- SetDevice("tablets/Wacom-Intuos4-6x9.desc");
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER_ABSOLUTE);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
XITServerInputTest::SetUp();
}
+ virtual void RequireXI2(int major, int minor, int *major_return, int *minor_return) {
+ // don't require XI2
+ }
+
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- /* need the wacom driver for this */
- config.AddInputSection("wacom", "--device--",
- "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Type\" \"stylus\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
- /* add default keyboard device to avoid server adding our device again */
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"PointerHasPressure\" \"on\"\n"+
+ Dev(0).GetOptions());
+ // add default keyboard device
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions());
config.WriteConfig();
}
+
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
};
-TEST_F(TabletMotionTest, MissingValuator1InEvent)
+TEST_F(PointerMotionPressureTest, MissingValuator1InEvent)
{
- XORG_TESTCASE("Create tablet device\n"
+ XORG_TESTCASE("Create pointer device\n"
"Register for XI 1.x motion events\n"
- "Move tablet's x and pressure axis, leave y umodified\n"
+ "Move pointer position x, leave y umodified\n"
"Ensure that valuator 1 is set correctly in XI event\n");
::Display *dpy = Display();
@@ -107,35 +148,32 @@ TEST_F(TabletMotionTest, MissingValuator1InEvent)
int deviceid;
ASSERT_EQ(FindInputDeviceByName(dpy, "--device--", &deviceid), 1);
- dev->PlayOne(EV_ABS, ABS_X, 1000);
- dev->PlayOne(EV_ABS, ABS_Y, 1000);
- dev->PlayOne(EV_ABS, ABS_PRESSURE, 56);
- dev->PlayOne(EV_ABS, ABS_DISTANCE, 0);
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 1, true);
+ const int pressure_axis = 4;
+
+ xorg::testing::inputtest::Valuators valuators;
+ valuators.Set(pressure_axis, 56);
+ Dev(0).AbsMotion(1000, 1000, valuators);
XDevice *xdev = XOpenDevice(dpy, deviceid);
ASSERT_TRUE(xdev);
- XSetDeviceMode(dpy, xdev, Relative);
-
int motion_type;
XEventClass evclass;
DeviceMotionNotify(xdev, motion_type, evclass);
XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &evclass, 1);
- dev->PlayOne(EV_ABS, ABS_X, 5000);
- dev->PlayOne(EV_ABS, ABS_Y, 1000);
- dev->PlayOne(EV_ABS, ABS_PRESSURE, 200);
- dev->PlayOne(EV_ABS, ABS_DISTANCE, 0);
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 1, true);
+ valuators.Set(pressure_axis, 200);
+ Dev(0).AbsMotion(5000, 1000, valuators);
ASSERT_EVENT(XEvent, motion, dpy, motion_type);
XDeviceMotionEvent *m = reinterpret_cast<XDeviceMotionEvent*>(motion);
ASSERT_EQ(m->first_axis, 0);
- ASSERT_EQ(m->axes_count, 6);
- ASSERT_GT(m->axis_data[0], 1000);
+ ASSERT_EQ(m->axes_count, 5);
+ ASSERT_EQ(m->axis_data[0], 5000);
ASSERT_EQ(m->axis_data[1], 1000);
- ASSERT_GT(m->axis_data[2], 56);
+ ASSERT_EQ(m->axis_data[2], 0);
+ ASSERT_EQ(m->axis_data[3], 0);
+ ASSERT_EQ(m->axis_data[4], 200);
XCloseDevice(dpy, xdev);
}
@@ -150,6 +188,9 @@ enum scoll_direction {
class SmoothScrollingTest : public PointerMotionTest,
public ::testing::WithParamInterface<enum scoll_direction> {
public:
+ static constexpr int SCROLL_AXIS_HORIZ = 2;
+ static constexpr int SCROLL_AXIS_VERT = 3;
+
virtual int GetScrollIncrement(::Display *dpy, int deviceid, int type) {
int increment = 0;
int ndevices;
@@ -204,33 +245,28 @@ TEST_P(SmoothScrollingTest, SmoothScrolling)
int button;
int axis;
- int direction;
- int increment;
+ int scroll_amount;
switch(which) {
case VSCROLL_UP:
button = 4;
- axis = REL_WHEEL;
- direction = 1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
+ axis = SCROLL_AXIS_VERT;
+ scroll_amount = -GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
break;
case VSCROLL_DOWN:
button = 5;
- axis = REL_WHEEL;
- direction = -1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
+ axis = SCROLL_AXIS_VERT;
+ scroll_amount = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
break;
case HSCROLL_LEFT:
button = 6;
- axis = REL_HWHEEL;
- direction = -1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
+ axis = SCROLL_AXIS_HORIZ;
+ scroll_amount = -GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
break;
case HSCROLL_RIGHT:
button = 7;
- axis = REL_HWHEEL;
- direction = 1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
+ axis = SCROLL_AXIS_HORIZ;
+ scroll_amount = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
break;
default:
FAIL();
@@ -239,8 +275,10 @@ TEST_P(SmoothScrollingTest, SmoothScrolling)
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_ButtonPress, XI_ButtonRelease, XI_Motion, -1);
- dev->PlayOne(EV_REL, axis, direction, true);
- dev->PlayOne(EV_REL, axis, direction, true);
+ xorg::testing::inputtest::Valuators valuators;
+ valuators.Set(axis, scroll_amount);
+ Dev(0).RelMotion(0, 0, valuators);
+ Dev(0).RelMotion(0, 0, valuators);
ASSERT_EVENT(XIDeviceEvent, motion1, dpy, GenericEvent, xi2_opcode, XI_Motion);
CheckMotionEvent(motion1);
@@ -250,27 +288,11 @@ TEST_P(SmoothScrollingTest, SmoothScrolling)
CheckMotionEvent(motion2);
AssertEmulatedButtonEvent(dpy, button);
-
/* expect x/y to be unset */
- if (button <= 5) {
- ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, 3));
- ASSERT_TRUE(XIMaskIsSet(motion2->valuators.mask, 3));
- } else {
- ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, 2));
- ASSERT_TRUE(XIMaskIsSet(motion2->valuators.mask, 2));
- }
+ ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, axis));
+ ASSERT_TRUE(XIMaskIsSet(motion2->valuators.mask, axis));
- int delta = motion2->valuators.values[0] - motion1->valuators.values[0];
- switch(which) {
- case VSCROLL_UP:
- case HSCROLL_LEFT:
- ASSERT_EQ(delta, -increment);
- break;
- case VSCROLL_DOWN:
- case HSCROLL_RIGHT:
- ASSERT_EQ(delta, increment);
- break;
- }
+ ASSERT_EQ(motion2->valuators.values[0] - motion1->valuators.values[0], scroll_amount);
}
TEST_P(SmoothScrollingTest, SmoothScrollingButtonInverted)
@@ -302,33 +324,28 @@ TEST_P(SmoothScrollingTest, SmoothScrollingButtonInverted)
int button;
int axis;
- int direction;
- int increment;
+ int scroll_amount;
switch(which) {
case VSCROLL_UP:
button = 5;
- axis = REL_WHEEL;
- direction = 1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
+ axis = SCROLL_AXIS_VERT;
+ scroll_amount = -GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
break;
case VSCROLL_DOWN:
button = 4;
- axis = REL_WHEEL;
- direction = -1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
+ axis = SCROLL_AXIS_VERT;
+ scroll_amount = GetScrollIncrement(dpy, deviceid, XIScrollTypeVertical);
break;
case HSCROLL_LEFT:
button = 7;
- axis = REL_HWHEEL;
- direction = -1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
+ axis = SCROLL_AXIS_HORIZ;
+ scroll_amount = -GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
break;
case HSCROLL_RIGHT:
button = 6;
- axis = REL_HWHEEL;
- direction = 1;
- increment = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
+ axis = SCROLL_AXIS_HORIZ;
+ scroll_amount = GetScrollIncrement(dpy, deviceid, XIScrollTypeHorizontal);
break;
default:
FAIL();
@@ -337,8 +354,10 @@ TEST_P(SmoothScrollingTest, SmoothScrollingButtonInverted)
SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
XI_ButtonPress, XI_ButtonRelease, XI_Motion, -1);
- dev->PlayOne(EV_REL, axis, direction, true);
- dev->PlayOne(EV_REL, axis, direction, true);
+ xorg::testing::inputtest::Valuators valuators;
+ valuators.Set(axis, scroll_amount);
+ Dev(0).RelMotion(0, 0, valuators);
+ Dev(0).RelMotion(0, 0, valuators);
ASSERT_EVENT(XIDeviceEvent, motion1, dpy, GenericEvent, xi2_opcode, XI_Motion);
CheckMotionEvent(motion1);
@@ -348,239 +367,65 @@ TEST_P(SmoothScrollingTest, SmoothScrollingButtonInverted)
CheckMotionEvent(motion2);
AssertEmulatedButtonEvent(dpy, button);
-
/* expect x/y to be unset */
- if (button <= 5)
- ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, 3));
- else
- ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, 2));
+ ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, axis));
+ ASSERT_TRUE(XIMaskIsSet(motion1->valuators.mask, axis));
- if (button <= 5)
- ASSERT_TRUE(XIMaskIsSet(motion2->valuators.mask, 3));
- else
- ASSERT_TRUE(XIMaskIsSet(motion2->valuators.mask, 2));
-
- int delta = motion2->valuators.values[0] - motion1->valuators.values[0];
- switch(which) {
- case VSCROLL_UP:
- case HSCROLL_LEFT:
- ASSERT_EQ(delta, -increment);
- break;
- case VSCROLL_DOWN:
- case HSCROLL_RIGHT:
- ASSERT_EQ(delta, increment);
- break;
- }
+ ASSERT_EQ(motion2->valuators.values[0] - motion1->valuators.values[0], scroll_amount);
}
INSTANTIATE_TEST_CASE_P(, SmoothScrollingTest,
::testing::Values(VSCROLL_UP, VSCROLL_DOWN, HSCROLL_LEFT, HSCROLL_RIGHT));
-
-enum device_type {
- MOUSE, TABLET, TOUCHPAD, KEYBOARD
-};
-
-class PointerAccelerationTest : public XITServerInputTest,
- public DeviceInterface,
- public ::testing::WithParamInterface<enum device_type>
+TEST_F(PointerMotionTest, PointerAccelerationIdenticalMovementVerticalHorizontal)
{
-public:
- virtual void SetUpMouse() {
- SetDevice("mice/PIXART-USB-OPTICAL-MOUSE-HWHEEL.desc");
-
- driver = "evdev";
- config_section = "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"";
- }
-
- virtual void SetResolution(const std::string &file, int code, int resolution) {
- int fd, rc;
- struct input_absinfo abs;
-
- fd = open(file.c_str(), O_RDWR);
- ASSERT_NE(fd, -1);
-
- rc = ioctl(fd, EVIOCGABS(code), &abs);
- ASSERT_NE(rc, -1) << strerror(errno);
-
- abs.resolution = resolution;
- rc = ioctl(fd, EVIOCSABS(code), &abs);
- ASSERT_NE(rc, -1) << strerror(errno);
-
- close(fd);
- }
-
- virtual void SetUpTablet() {
- xres = 10000;
- yres = 10000;
-
- SetDevice("tablets/Wacom-Intuos4-6x9.desc");
-
- driver = "wacom";
- config_section = "Option \"device\" \"" + dev->GetDeviceNode() + "\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Type\" \"stylus\"\n"
- "Option \"CorePointer\" \"on\"\n"
- "Option \"Mode\" \"relative\"\n";
- }
-
- virtual void SetUpTouchpad() {
- xres = 75;
- yres = 129;
-
- SetDevice("touchpads/SynPS2-Synaptics-TouchPad.desc");
-
- driver = "synaptics";
- config_section = "Option \"device\" \"" + dev->GetDeviceNode() + "\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"CorePointer\" \"on\"\n";
- }
-
- virtual void SetUp() {
-
- switch(GetParam()) {
- case MOUSE: SetUpMouse(); break;
- case TABLET: SetUpTablet(); break;
- case TOUCHPAD: SetUpTouchpad(); break;
- default:
- FAIL() << "Unsupported device type";
- break;
- }
-
- /* FIXME: evemu should do this */
- if (xres != 0)
- SetResolution(dev->GetDeviceNode(), ABS_X, xres);
- if (yres != 0)
- SetResolution(dev->GetDeviceNode(), ABS_Y, yres);
-
- XITServerInputTest::SetUp();
- }
-
- virtual void SetUpConfigAndLog() {
- config.AddDefaultScreenWithDriver();
- config.SetAutoAddDevices(false);
- config.AddInputSection(driver, "device", config_section);
- config.WriteConfig();
- }
+ XORG_TESTCASE("Start server with devices in mode relative\n"
+ "Move the pointer diagonally down\n"
+ "Verify x and y relative movement are the same\n"
+ "https://bugs.freedesktop.org/show_bug.cgi?id=31636");
- virtual void InitPosition(enum device_type type) {
- switch(type) {
- case MOUSE: break;
- case TABLET:
- dev->PlayOne(EV_ABS, ABS_X, 1000);
- dev->PlayOne(EV_ABS, ABS_Y, 1000);
- dev->PlayOne(EV_ABS, ABS_DISTANCE, 0);
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 1, true);
- break;
- case TOUCHPAD:
- dev->PlayOne(EV_ABS, ABS_X, 1500);
- dev->PlayOne(EV_ABS, ABS_Y, 2000);
- dev->PlayOne(EV_ABS, ABS_PRESSURE, 34);
- dev->PlayOne(EV_KEY, BTN_TOOL_FINGER, 1, true);
- break;
- default:
- FAIL() << "Unsupported device type";
- break;
- }
- }
+ ::Display *dpy = Display();
- virtual void Move(enum device_type type) {
- int x, y;
- int minx, maxx, miny, maxy;
+ double x1, y1;
+ QueryPointerPosition(dpy, &x1, &y1);
- switch(type) {
- case MOUSE:
- for (int i = 0; i < 20; i++)
- dev->PlayOne(EV_REL, REL_X, 1, true);
+ for (int i = 0; i < 20; i++)
+ Dev(0).RelMotion(1, 1);
- for (int i = 0; i < 20; i++)
- dev->PlayOne(EV_REL, REL_Y, 1, true);
- break;
- case TABLET:
- dev->GetAbsData(ABS_X, &minx, &maxx);
- dev->GetAbsData(ABS_Y, &miny, &maxy);
- x = 1000;
- y = 1000;
-
- while (x < 10000)
- {
- x += 10 * xres/100.0;
- y += 10 * yres/100.0;
- dev->PlayOne(EV_ABS, ABS_X, x);
- dev->PlayOne(EV_ABS, ABS_Y, y);
-
- dev->PlayOne(EV_ABS, ABS_DISTANCE, 0);
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 1, true);
- }
-
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 0, true);
- break;
- case TOUCHPAD:
- dev->GetAbsData(ABS_X, &minx, &maxx);
- dev->GetAbsData(ABS_Y, &miny, &maxy);
- x = 1500;
- y = 2000;
-
- while (x < 3000)
- {
- x += 10 * xres;
- y += 10 * yres;
- dev->PlayOne(EV_ABS, ABS_X, x);
- dev->PlayOne(EV_ABS, ABS_Y, y);
-
- dev->PlayOne(EV_ABS, ABS_PRESSURE, 40);
- dev->PlayOne(EV_ABS, ABS_TOOL_WIDTH, 10);
- dev->PlayOne(EV_KEY, BTN_TOUCH, 1, true);
- dev->PlayOne(EV_KEY, BTN_TOOL_FINGER, 1, true);
- }
-
- dev->PlayOne(EV_KEY, BTN_TOOL_FINGER, 0, true);
- break;
- default:
- FAIL() << "Unsupported device type";
- break;
- }
- }
+ double x2, y2;
+ QueryPointerPosition(dpy, &x2, &y2);
-private:
- std::string config_section;
- std::string driver;
+ /* have we moved at all? */
+ ASSERT_NE(x1, x2);
+ ASSERT_NE(y1, y2);
- int xres;
- int yres;
-};
+ /* we moved diagonally, expect same accel in both directions */
+ ASSERT_EQ(x2 - x1, y2 - y1);
+}
-TEST_P(PointerAccelerationTest, IdenticalMovementVerticalHorizontal)
+TEST_F(PointerMotionAbsoluteTest, PointerAccelerationIdenticalMovementVerticalHorizontal)
{
- enum device_type device_type = GetParam();
- std::string devtype;
- switch(device_type) {
- case MOUSE: devtype = "mouse"; break;
- case TABLET: devtype = "tablet"; break;
- case TOUCHPAD: devtype = "touchpad"; break;
- default:
- FAIL() << "Unsupported device type";
- break;
- }
-
- XORG_TESTCASE("Start server with devices in mode relative\n"
+ XORG_TESTCASE("Start server with devices in mode absolute\n"
"Move the pointer diagonally down\n"
"Verify x and y relative movement are the same\n"
"https://bugs.freedesktop.org/show_bug.cgi?id=31636");
- SCOPED_TRACE("Device type is " + devtype);
::Display *dpy = Display();
- ASSERT_EQ(FindInputDeviceByName(dpy, "device"), 1);
+ int x = 1000;
+ int y = 1000;
- InitPosition(device_type);
+ Dev(0).AbsMotion(x, y);
double x1, y1;
QueryPointerPosition(dpy, &x1, &y1);
- Move(device_type);
+ while (x < 10000)
+ {
+ x += 250;
+ y += 250;
+ Dev(0).AbsMotion(x, y);
+ }
double x2, y2;
QueryPointerPosition(dpy, &x2, &y2);
@@ -589,12 +434,15 @@ TEST_P(PointerAccelerationTest, IdenticalMovementVerticalHorizontal)
ASSERT_NE(x1, x2);
ASSERT_NE(y1, y2);
- /* we moved diagonally, expect same accel in both directions */
- ASSERT_EQ(x2 - x1, y2 - y1);
+ /* we moved diagonally, expect same accel in both directions.
+ Note that the inputtest driver uses the same resolution for both X and Y directions which
+ may not match the screen resolution
+ */
+ auto diff = (x2 - x1) - (y2 - y1) * DisplayWidth(dpy, DefaultScreen(dpy)) /
+ DisplayHeight(dpy, DefaultScreen(dpy));
+ ASSERT_LE(std::abs(diff), 1);
}
-INSTANTIATE_TEST_CASE_P(, PointerAccelerationTest, ::testing::Values(MOUSE, TABLET, TOUCHPAD));
-
class PointerButtonMotionMaskTest : public PointerMotionTest,
public ::testing::WithParamInterface<int>
{
@@ -613,21 +461,13 @@ TEST_P(PointerButtonMotionMaskTest, ButtonXMotionMask)
XSelectInput(dpy, DefaultRootWindow(dpy), Button1MotionMask << (button - 1));
XSync(dpy, False);
- dev->PlayOne(EV_REL, REL_X, 10, true);
+ Dev(0).RelMotion(10, 0);
XSync(dpy, False);
ASSERT_EQ(XPending(dpy), 0);
- int devbutton;
- switch(button) {
- case 1: devbutton = BTN_LEFT; break;
- case 2: devbutton = BTN_MIDDLE; break;
- case 3: devbutton = BTN_RIGHT; break;
- default: FAIL();
- }
-
- dev->PlayOne(EV_KEY, devbutton, 1, true);
- dev->PlayOne(EV_REL, REL_X, 10, true);
- dev->PlayOne(EV_KEY, devbutton, 0, true);
+ Dev(0).ButtonDown(button);
+ Dev(0).RelMotion(10, 0);
+ Dev(0).ButtonUp(button);
ASSERT_EVENT(XEvent, motion, dpy, MotionNotify);
ASSERT_TRUE(motion->xmotion.state & (Button1Mask << (button -1)));
@@ -638,29 +478,40 @@ TEST_P(PointerButtonMotionMaskTest, ButtonXMotionMask)
INSTANTIATE_TEST_CASE_P(, PointerButtonMotionMaskTest, ::testing::Range(1, 4));
-class DISABLED_PointerSubpixelTest : public PointerMotionTest {
+class PointerSubpixelTest : public XITServerInputTest, public DeviceInputTestInterface {
+public:
/**
- * Sets up an xorg.conf for a single evdev CoreKeyboard device based on
- * the evemu device. The input from GetParam() is used as XkbLayout.
+ * Initializes a standard mouse device.
*/
+ virtual void SetUp() {
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
+ XITServerInputTest::SetUp();
+ }
+
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--device--",
- "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"ConstantDeceleration\" \"20\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
- /* add default keyboard device to avoid server adding our device again */
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"ConstantDeceleration\" \"20\"\n" +
+ Dev(0).GetOptions());
+ // add default keyboard device
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions());
config.WriteConfig();
}
+
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
};
-TEST_F(DISABLED_PointerSubpixelTest, NoSubpixelCoreEvents)
+TEST_F(PointerSubpixelTest, SubpixelCoreEvents_Incorrect)
{
XORG_TESTCASE("Move pointer by less than a pixels\n"
- "Ensure no core motion event is received\n"
+ "Ensure core motion events are received"
+ "(we should not get such events, but this has not yet been implemented)\n"
"Ensure XI2 motion events are received\n");
::Display *dpy = Display();
@@ -673,12 +524,12 @@ TEST_F(DISABLED_PointerSubpixelTest, NoSubpixelCoreEvents)
XSelectInput(dpy, DefaultRootWindow(dpy), PointerMotionMask);
XSync(dpy, False);
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
- ASSERT_FALSE(XServer::WaitForEvent(Display(), 500));
+ ASSERT_TRUE(XServer::WaitForEventOfType(dpy, MotionNotify));
XSelectInput(dpy, DefaultRootWindow(dpy), NoEventMask);
XSync(dpy, False);
@@ -694,10 +545,10 @@ TEST_F(DISABLED_PointerSubpixelTest, NoSubpixelCoreEvents)
delete[] mask.mask;
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
- dev->PlayOne(EV_REL, REL_X, 1, true);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
+ Dev(0).RelMotion(0.1, 0);
ASSERT_TRUE(XServer::WaitForEventOfType(dpy2, GenericEvent, xi2_opcode, XI_Motion));
@@ -735,8 +586,7 @@ public:
double x, y;
QueryPointerPosition(dpy, &x, &y);
- dev->PlayOne(EV_REL, REL_X, dx);
- dev->PlayOne(EV_REL, REL_Y, dy, true);
+ Dev(0).RelMotion(dx, dy);
ASSERT_EVENT(XIDeviceEvent, motion, dpy, GenericEvent, xi2_opcode, XI_Motion);
ASSERT_EQ(motion->root_x, x + dx);
ASSERT_EQ(motion->root_y, y + dy);
@@ -765,7 +615,7 @@ TEST_F(PointerRelativeTransformationMatrixTest, IgnoreTranslationComponent)
DisablePtrAccel(dpy, deviceid);
- struct pixman_f_transform m;
+ pixman_f_transform m;
pixman_f_transform_init_translate(&m, 10, 0);
SetDeviceMatrix(dpy, deviceid, &m);
@@ -830,9 +680,7 @@ TEST_P(PointerRelativeRotationMatrixTest, RotationTest)
double x, y;
QueryPointerPosition(dpy, &x, &y);
- /* Move pointer */
- dev->PlayOne(EV_REL, REL_X, dx);
- dev->PlayOne(EV_REL, REL_Y, dy, true);
+ Dev(0).RelMotion(dx, dy);
/* Compare to two decimal places */
ASSERT_EVENT(XIDeviceEvent, motion, dpy, GenericEvent, xi2_opcode, XI_Motion);
@@ -845,18 +693,18 @@ TEST_P(PointerRelativeRotationMatrixTest, RotationTest)
INSTANTIATE_TEST_CASE_P(, PointerRelativeRotationMatrixTest, ::testing::Range(0, 360, 15));
-class DeviceChangedTest : public XITServerInputTest {
+class DeviceChangedTest : public XITServerInputTest, public DeviceInputTestInterface {
public:
+
+ xorg::testing::inputtest::Device& TouchDev() { return Dev(0); }
+ xorg::testing::inputtest::Device& MouseDev() { return Dev(1); }
+ xorg::testing::inputtest::Device& KeyboardDev() { return Dev(2); }
+
virtual void SetUp() {
- mouse = std::unique_ptr<xorg::testing::evemu::Device>(
- new xorg::testing::evemu::Device(
- RECORDINGS_DIR "/mice/PIXART-USB-OPTICAL-MOUSE.desc")
- );
-
- touchpad = std::unique_ptr<xorg::testing::evemu::Device>(
- new xorg::testing::evemu::Device(
- RECORDINGS_DIR "/touchpads/SynPS2-Synaptics-TouchPad.desc")
- );
+ AddDevice(xorg::testing::inputtest::DeviceType::TOUCH);
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
+
xi2_major_minimum = 2;
xi2_minor_minimum = 2;
XITServerInputTest::SetUp();
@@ -864,22 +712,23 @@ public:
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--mouse--",
- "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + mouse->GetDeviceNode() + "\"");
- config.AddInputSection("synaptics", "--touchpad--",
- "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + touchpad->GetDeviceNode() + "\"");
- /* add default keyboard device to avoid server adding our device again */
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"CorePointer\" \"on\"\n" +
+ Dev(0).GetOptions());
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-mouse--",
+ "Option \"CorePointer\" \"on\"\n" +
+ Dev(1).GetOptions());
+ /* add default keyboard device */
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(2).GetOptions());
config.WriteConfig();
}
- std::unique_ptr<xorg::testing::evemu::Device> mouse;
- std::unique_ptr<xorg::testing::evemu::Device> touchpad;
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
};
@@ -902,7 +751,7 @@ TEST_F(DeviceChangedTest, DeviceChangedEvent)
int deviceid = -1;
for (int i = 0; deviceid == -1 && i < ndevices; i++) {
- if (strcmp(info[i].name, "--touchpad--"))
+ if (strcmp(info[i].name, "--device--"))
continue;
deviceid = info[i].deviceid;
@@ -930,16 +779,16 @@ TEST_F(DeviceChangedTest, DeviceChangedEvent)
XISetMask(mask.mask, XI_DeviceChanged);
XISelectEvents(dpy, DefaultRootWindow(dpy), &mask, 1);
- touchpad->Play(RECORDINGS_DIR "touchpads/SynPS2-Synaptics-TouchPad-two-finger-scroll-down.events");
-
- XSync(dpy, False);
- while(XPending(dpy) > 1) {
- XEvent ev;
- XNextEvent(dpy, &ev);
- XSync(dpy, False);
- }
+ xorg::testing::inputtest::Valuators event_valuators;
+ event_valuators.Set(2, 0);
+ event_valuators.Set(3, 10);
+ TouchDev().TouchBegin(100, 100, 0, event_valuators);
+ TouchDev().TouchUpdate(120, 120, 0);
+ TouchDev().TouchEnd(120, 120, 0);
+ ASSERT_EVENT(XIDeviceChangedEvent, dce1, dpy, GenericEvent, xi2_opcode, XI_DeviceChanged);
ASSERT_EVENT(XIDeviceEvent, motion, dpy, GenericEvent, xi2_opcode, XI_Motion);
+ ASSERT_EVENT(XIDeviceEvent, motion2, dpy, GenericEvent, xi2_opcode, XI_Motion);
ASSERT_GT(motion->valuators.mask_len, 0);
ASSERT_TRUE(XIMaskIsSet(motion->valuators.mask, vscroll_axis));
@@ -954,23 +803,26 @@ TEST_F(DeviceChangedTest, DeviceChangedEvent)
last_value = *valuators;
ASSERT_GT(last_value, 0);
- mouse->PlayOne(EV_REL, REL_X, 1, true);
+ MouseDev().RelMotion(1, 0);
- XSync(dpy, True); /* discard DCE from mouse */
+ ASSERT_EVENT(XIDeviceChangedEvent, dce2, dpy, GenericEvent, xi2_opcode, XI_DeviceChanged);
+ ASSERT_EVENT(XIDeviceEvent, motion3, dpy, GenericEvent, xi2_opcode, XI_Motion);
- touchpad->Play(RECORDINGS_DIR "touchpads/SynPS2-Synaptics-TouchPad-two-finger-scroll-down.events");
+ TouchDev().TouchBegin(100, 100, 0, event_valuators);
+ TouchDev().TouchUpdate(120, 120, 0);
+ TouchDev().TouchEnd(120, 120, 0);
- ASSERT_EVENT(XIDeviceChangedEvent, dce, dpy, GenericEvent, xi2_opcode, XI_DeviceChanged);
- ASSERT_EQ(dce->sourceid, deviceid);
- ASSERT_EQ(dce->reason, XISlaveSwitch);
+ ASSERT_EVENT(XIDeviceChangedEvent, dce_final, dpy, GenericEvent, xi2_opcode, XI_DeviceChanged);
+ ASSERT_EQ(dce_final->sourceid, deviceid);
+ ASSERT_EQ(dce_final->reason, XISlaveSwitch);
- ASSERT_GT(dce->num_classes, 1);
+ ASSERT_GT(dce_final->num_classes, 1);
- for (int i = 0; i < dce->num_classes; i++) {
- if (dce->classes[i]->type != XIValuatorClass)
+ for (int i = 0; i < dce_final->num_classes; i++) {
+ if (dce_final->classes[i]->type != XIValuatorClass)
continue;
- XIValuatorClassInfo *v = reinterpret_cast<XIValuatorClassInfo*>(dce->classes[i]);
+ XIValuatorClassInfo *v = reinterpret_cast<XIValuatorClassInfo*>(dce_final->classes[i]);
if (v->number != vscroll_axis)
continue;
ASSERT_EQ(v->value, last_value);
@@ -987,19 +839,24 @@ enum MatrixType {
};
class PointerAbsoluteTransformationMatrixTest : public XITServerInputTest,
- public DeviceInterface,
+ public DeviceInputTestInterface,
public ::testing::WithParamInterface<std::tuple<enum ::MatrixType, int> > {
public:
virtual void SetUp() {
- SetDevice("tablets/Wacom-Intuos4-6x9.desc");
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER_ABSOLUTE);
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
XITServerInputTest::SetUp();
}
- virtual std::string EvdevOptions(enum MatrixType which) {
+ virtual void SetUpConfigAndLog() {
+ std::tuple<enum MatrixType, int> t = GetParam();
+ MatrixType matrix_type = std::get<0>(t);
+ int nscreens = std::get<1>(t);
+
std::string matrix;
- switch(which) {
+ switch(matrix_type) {
case LEFT_HALF:
- matrix = "0.5 0 0 0 1 0 0 0 1";
+ matrix = "0.5 0 0 0 1 0 0 0 1";
break;
case RIGHT_HALF:
matrix = "0.5 0 0.5 0 1 0 0 0 1";
@@ -1009,70 +866,62 @@ public:
break;
}
- return "Option \"CorePointer\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"TransformationMatrix\" \"" + matrix +"\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"";
- }
-
- virtual void SetUpConfigAndLog() {
- std::tuple<enum MatrixType, int> t = GetParam();
- enum MatrixType mtype = std::get<0>(t);
- int nscreens = std::get<1>(t);
-
- std::string opts = EvdevOptions(mtype);
-
+ bool reference_from_layout = false;
switch(nscreens) {
- case 1: SetUpSingleScreen(opts); break;
- case 2: SetupDualHead(opts); break;
+ case 1:
+ config.AddDefaultScreenWithDriver();
+ reference_from_layout = true;
+ break;
+ case 2:
+ config.SetAutoAddDevices(true);
+ config.AppendRawConfig(std::string() +
+ "Section \"ServerLayout\"\n"
+ " Identifier \"X.org Configured\"\n"
+ " Screen 0 \"Screen0\"\n"
+ " Screen 1 \"Screen1\" RightOf \"Screen0\"\n"
+ " Option \"Xinerama\" \"off\"\n"
+ " Option \"AutoAddDevices\" \"off\"\n"
+ "EndSection\n"
+ "\n"
+ "Section \"Device\"\n"
+ " Identifier \"Card0\"\n"
+ " Driver \"dummy\"\n"
+ "EndSection\n"
+ "\n"
+ "Section \"Device\"\n"
+ " Identifier \"Card1\"\n"
+ " Driver \"dummy\"\n"
+ "EndSection\n"
+ "\n"
+ "Section \"Screen\"\n"
+ " Identifier \"Screen0\"\n"
+ " Device \"Card0\"\n"
+ "EndSection\n"
+ "\n"
+ "Section \"Screen\"\n"
+ " Identifier \"Screen1\"\n"
+ " Device \"Card1\"\n"
+ "EndSection");
+ reference_from_layout = false;
+ break;
default:
FAIL();
}
- }
-
- virtual void SetUpSingleScreen(std::string &evdev_options) {
- config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--device--", evdev_options);
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"CorePointer\" \"on\"\n"
+ "Option \"TransformationMatrix\" \"" + matrix +"\"\n" +
+ Dev(0).GetOptions(),
+ reference_from_layout);
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "kbd-device",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions(),
+ reference_from_layout);
config.WriteConfig();
}
- virtual void SetupDualHead(std::string &evdev_options) {
- config.SetAutoAddDevices(true);
- config.AppendRawConfig(std::string() +
- "Section \"ServerLayout\"\n"
- " Identifier \"X.org Configured\"\n"
- " Screen 0 \"Screen0\"\n"
- " Screen 1 \"Screen1\" RightOf \"Screen0\"\n"
- " Option \"Xinerama\" \"off\"\n"
- " Option \"AutoAddDevices\" \"off\"\n"
- "EndSection\n"
- "\n"
- "Section \"Device\"\n"
- " Identifier \"Card0\"\n"
- " Driver \"dummy\"\n"
- "EndSection\n"
- "\n"
- "Section \"Device\"\n"
- " Identifier \"Card1\"\n"
- " Driver \"dummy\"\n"
- "EndSection\n"
- "\n"
- "Section \"Screen\"\n"
- " Identifier \"Screen0\"\n"
- " Device \"Card0\"\n"
- "EndSection\n"
- "\n"
- "Section \"Screen\"\n"
- " Identifier \"Screen1\"\n"
- " Device \"Card1\"\n"
- "EndSection");
- config.AddInputSection("evdev", "--device--", evdev_options, false);
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n",
- false);
- config.WriteConfig();
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
}
};
@@ -1122,18 +971,15 @@ TEST_P(PointerAbsoluteTransformationMatrixTest, XI2ValuatorData)
int w = DisplayWidth(dpy, 0);
- int minx, maxx;
- dev->GetAbsData(ABS_X, &minx, &maxx);
+ // these are hardcoded into inputtest driver. TODO: expose in header
+ double minx = 0, maxx = 0xffff;
- dev->PlayOne(EV_ABS, ABS_X, 1000);
- dev->PlayOne(EV_ABS, ABS_Y, 1000);
- dev->PlayOne(EV_ABS, ABS_DISTANCE, 0);
- dev->PlayOne(EV_KEY, BTN_TOOL_PEN, 1, true);
+ Dev(0).AbsMotion(1000, 1000);
/* drop first event */
ASSERT_EVENT(XIDeviceEvent, m, dpy, GenericEvent, xi2_opcode, XI_Motion);
- dev->PlayOne(EV_ABS, ABS_X, minx, true);
+ Dev(0).AbsMotion(minx, 1000);
double expected_minx = minx,
expected_maxx = maxx;
@@ -1147,10 +993,10 @@ TEST_P(PointerAbsoluteTransformationMatrixTest, XI2ValuatorData)
setup. dual-screen is per-device range*/
case LEFT_HALF:
if (nscreens == 1)
- expected_maxx = maxx/2;
+ expected_maxx = maxx / 2;
break;
/* right half we expect the device to go from something smaller than
- max/2 to max. the device has ~46 units per pixel, if we map to
+ max/2 to max. the device has 64 units per pixel, if we map to
512 on the screen that's not maxx/2, it's something less than
that (see the scaling formula) */
case RIGHT_HALF:
@@ -1190,7 +1036,7 @@ TEST_P(PointerAbsoluteTransformationMatrixTest, XI2ValuatorData)
/* y will be scaled in some weird way (depending on proportion of
screen:tablet), so we ignore it here */
- dev->PlayOne(EV_ABS, ABS_X, maxx, true);
+ Dev(0).AbsMotion(maxx, 1000);
ASSERT_EVENT(XIDeviceEvent, m2, dpy, GenericEvent, xi2_opcode, XI_Motion);
ASSERT_EQ(m1->deviceid, deviceid);
@@ -1202,14 +1048,15 @@ INSTANTIATE_TEST_CASE_P(, PointerAbsoluteTransformationMatrixTest,
::testing::Combine(::testing::Values(IDENTITY, LEFT_HALF, RIGHT_HALF),
::testing::Values(1, 2)));
+
class KeyboardTest : public XITServerInputTest,
- public DeviceInterface {
+ public DeviceInputTestInterface {
public:
/**
* Initializes a standard mouse device.
*/
virtual void SetUp() {
- SetDevice("keyboards/AT-Translated-Set-2-Keyboard.desc");
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
XITServerInputTest::SetUp();
}
@@ -1219,12 +1066,16 @@ public:
*/
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--device--",
- "Option \"CoreKeyboard\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device-kbd--",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(0).GetOptions());
config.WriteConfig();
}
+
+ void StartServer() override {
+ XITServerInputTest::StartServer();
+ WaitForDevices();
+ }
};
TEST_F(KeyboardTest, FocusTestAttachedSlave)
@@ -1238,15 +1089,15 @@ TEST_F(KeyboardTest, FocusTestAttachedSlave)
::Display *dpy = Display();
int deviceid;
- ASSERT_TRUE(FindInputDeviceByName(dpy, "--device--", &deviceid));
+ ASSERT_TRUE(FindInputDeviceByName(dpy, "--device-kbd--", &deviceid));
Window win = CreateWindow(dpy, None, 0, 0, 10, 10);
XISetFocus(dpy, VIRTUAL_CORE_KEYBOARD_ID, win, CurrentTime);
SelectXI2Events(dpy, VIRTUAL_CORE_KEYBOARD_ID, win,
XI_KeyPress, XI_KeyRelease, -1);
- dev->PlayOne(EV_KEY, KEY_A, 1, true);
- dev->PlayOne(EV_KEY, KEY_A, 0, true);
+ Dev(0).KeyDown(KEY_A);
+ Dev(0).KeyUp(KEY_A);
ASSERT_EVENT(XIDeviceEvent, press, dpy, GenericEvent, xi2_opcode, XI_KeyPress);
ASSERT_EQ(press->event, win);
@@ -1258,6 +1109,7 @@ TEST_F(KeyboardTest, FocusTestAttachedSlave)
ASSERT_EQ(release->sourceid, deviceid);
}
+
TEST_F(KeyboardTest, FocusTestAttachedSlaveSeparateFocus)
{
XORG_TESTCASE("Create window\n"
@@ -1269,20 +1121,20 @@ TEST_F(KeyboardTest, FocusTestAttachedSlaveSeparateFocus)
::Display *dpy = Display();
int deviceid;
- ASSERT_TRUE(FindInputDeviceByName(dpy, "--device--", &deviceid));
+ ASSERT_TRUE(FindInputDeviceByName(dpy, "--device-kbd--", &deviceid));
Window win = CreateWindow(dpy, None, 0, 0, 10, 10);
SelectXI2Events(dpy, deviceid, win,
XI_KeyPress, XI_KeyRelease, -1);
- dev->PlayOne(EV_KEY, KEY_A, 1, true);
- dev->PlayOne(EV_KEY, KEY_A, 0, true);
+ Dev(0).KeyDown(KEY_A);
+ Dev(0).KeyUp(KEY_A);
ASSERT_TRUE(NoEventPending(dpy));
XISetFocus(dpy, deviceid, win, CurrentTime);
- dev->PlayOne(EV_KEY, KEY_A, 1, true);
- dev->PlayOne(EV_KEY, KEY_A, 0, true);
+ Dev(0).KeyDown(KEY_A);
+ Dev(0).KeyUp(KEY_A);
ASSERT_EVENT(XIDeviceEvent, press, dpy, GenericEvent, xi2_opcode, XI_KeyPress);
ASSERT_EQ(press->event, win);
@@ -1307,7 +1159,7 @@ TEST_F(KeyboardTest, FocusTestFloatingSlave)
::Display *dpy = Display();
int deviceid;
- ASSERT_TRUE(FindInputDeviceByName(dpy, "--device--", &deviceid));
+ ASSERT_TRUE(FindInputDeviceByName(dpy, "--device-kbd--", &deviceid));
XIAnyHierarchyChangeInfo float_slave;
float_slave.detach.type = XIDetachSlave;
@@ -1319,16 +1171,16 @@ TEST_F(KeyboardTest, FocusTestFloatingSlave)
SelectXI2Events(dpy, deviceid, win,
XI_KeyPress, XI_KeyRelease, -1);
- dev->PlayOne(EV_KEY, KEY_A, 1, true);
- dev->PlayOne(EV_KEY, KEY_A, 0, true);
+ Dev(0).KeyDown(KEY_A);
+ Dev(0).KeyUp(KEY_A);
ASSERT_TRUE(NoEventPending(dpy));
XISetFocus(dpy, VIRTUAL_CORE_KEYBOARD_ID, DefaultRootWindow(dpy), CurrentTime);
XISetFocus(dpy, deviceid, win, CurrentTime);
- dev->PlayOne(EV_KEY, KEY_A, 1, true);
- dev->PlayOne(EV_KEY, KEY_A, 0, true);
+ Dev(0).KeyDown(KEY_A);
+ Dev(0).KeyUp(KEY_A);
ASSERT_EVENT(XIDeviceEvent, press, dpy, GenericEvent, xi2_opcode, XI_KeyPress);
ASSERT_EQ(press->event, win);
@@ -1338,7 +1190,6 @@ TEST_F(KeyboardTest, FocusTestFloatingSlave)
ASSERT_EQ(release->deviceid, deviceid);
}
-
class XIQueryVersionTest : public XITServerTest,
public ::testing::WithParamInterface<int>
{
@@ -1420,39 +1271,27 @@ TEST_F(XIQueryVersionTest, NoBadLengthOnXIAllowEvents)
}
class FloatingSlaveTest : public XITServerInputTest,
- public DeviceInterface,
- public ::testing::WithParamInterface<enum device_type>
+ public DeviceInputTestInterface,
+ public ::testing::WithParamInterface<xorg::testing::inputtest::DeviceType>
{
- virtual void SetUpMouse() {
- SetDevice("mice/PIXART-USB-OPTICAL-MOUSE-HWHEEL.desc");
- }
-
- virtual void SetUpKeyboard() {
- SetDevice("keyboards/AT-Translated-Set-2-Keyboard.desc");
- }
-
virtual void SetUp() {
-
- switch(GetParam()) {
- case MOUSE: SetUpMouse(); break;
- case KEYBOARD: SetUpKeyboard(); break;
- default:
- FAIL() << "Unsupported device type";
- break;
- }
+ AddDevice(GetParam());
+ AddDevice(xorg::testing::inputtest::DeviceType::KEYBOARD);
+ AddDevice(xorg::testing::inputtest::DeviceType::POINTER);
XITServerInputTest::SetUp();
}
virtual void SetUpConfigAndLog() {
config.AddDefaultScreenWithDriver();
- config.AddInputSection("evdev", "--device--",
- "Option \"Floating\" \"on\"\n"
- "Option \"GrabDevice\" \"on\"\n"
- "Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
- config.AddInputSection("kbd", "kbd-device",
- "Option \"CoreKeyboard\" \"on\"\n");
- config.AddInputSection("mouse", "mouse-device",
- "Option \"CorePointer\" \"on\"\n");
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "--device--",
+ "Option \"Floating\" \"on\"\n" +
+ Dev(0).GetOptions());
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "kbd-device",
+ "Option \"CoreKeyboard\" \"on\"\n" +
+ Dev(1).GetOptions());
+ config.AddInputSection(XORG_INPUTTEST_DRIVER, "mouse-device",
+ "Option \"CorePointer\" \"on\"\n" +
+ Dev(2).GetOptions());
config.WriteConfig();
}
};
@@ -1487,4 +1326,6 @@ TEST_P(FloatingSlaveTest, DisableEnableDevice)
XSync(dpy, False);
}
-INSTANTIATE_TEST_CASE_P(, FloatingSlaveTest, ::testing::Values(MOUSE, KEYBOARD));
+INSTANTIATE_TEST_CASE_P(, FloatingSlaveTest, ::testing::Values(
+ xorg::testing::inputtest::DeviceType::POINTER,
+ xorg::testing::inputtest::DeviceType::KEYBOARD));