test: auto-assign the tool type for tablet tests
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 10 Sep 2020 22:43:58 +0000 (08:43 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 22 Sep 2020 07:35:41 +0000 (17:35 +1000)
The current tool type test merely sends BTN_TOOL_RUBBER (and others) manually
and expects libinput to do the right thing. This only tests the perfect
sequence but not test weird devices that behave differently on a tool type
switch.

So let's fix this by setting the tool type as property on the libinput test
device itself, and then emulate the tool switch through litest.
For special devices this will need extra callbacks, this is just the initial
framework to handle those buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
17 files changed:
test/litest-device-elan-tablet.c
test/litest-device-huion-pentablet.c
test/litest-device-wacom-bamboo-16fg-pen.c
test/litest-device-wacom-bamboo-2fg-pen.c
test/litest-device-wacom-cintiq-12wx-pen.c
test/litest-device-wacom-cintiq-13hdt-pen.c
test/litest-device-wacom-cintiq-24hd-pen.c
test/litest-device-wacom-cintiq-pro-16-pen.c
test/litest-device-wacom-hid4800-pen.c
test/litest-device-wacom-intuos5-pen.c
test/litest-device-wacom-isdv4-4200-pen.c
test/litest-device-wacom-isdv4-e6-pen.c
test/litest-device-waltop-tablet.c
test/litest-int.h
test/litest.c
test/litest.h
test/test-tablet.c

index 7b8e702272742ecd02055029e0460f385f94958e..433a03c2ef21cfaf50dd7c245f0d779fac514209 100644 (file)
@@ -30,13 +30,13 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
 
 static struct input_event proximity_out[] = {
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 976d6708949d9c303efd5c821792df103c333415..8e81bc1572068bc8b137471248d88e25c660f124 100644 (file)
@@ -30,7 +30,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 2427fc72810ce7d72f47862d7fc1e69af5f17270..cc65afeae2790fffd0d490bf684f1e5fe14e8a1a 100644 (file)
@@ -31,7 +31,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -40,7 +40,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_X, .value = 0 },
        { .type = EV_ABS, .code = ABS_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index aa1e3c249c3f02ecd2ab334126913080d7203283..6889ff3ff4607293dd14dc3b6a1a33eab1699180 100644 (file)
@@ -31,7 +31,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -40,7 +40,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_X, .value = 0 },
        { .type = EV_ABS, .code = ABS_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index ca33137c9de6217cf9b5bf53bb372d0a16671071..e9c4f684fa4868308517035d32bcbeb6d929ab2b 100644 (file)
@@ -35,7 +35,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -48,7 +48,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 5975510738b2ba0b37632ad90d31541aac6d3c18..4adf0efd51020f7653f77243efbdbb2b85936646 100644 (file)
@@ -35,7 +35,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -48,7 +48,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 2e47df9be99eeee1a56dcda005064022e9935ae5..f8b9a57a41c75f8a5f61243ce5dbaa43ca20b6e0 100644 (file)
@@ -35,7 +35,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -48,7 +48,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 35997ae2fb84d6c9e445197b3bd201de65865079..3b9dc1a437f406cd9e2cef3d135846832e7a34b3 100644 (file)
@@ -37,7 +37,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -52,7 +52,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 3f424851afccc95e18c79ed4750eaf3946ccbc08..85f091bee9e8f2eb07780a2bf9cef6a6c392bb3e 100644 (file)
@@ -30,7 +30,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
@@ -40,7 +40,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_X, .value = 0 },
        { .type = EV_ABS, .code = ABS_Y, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index ae8439c0706196bfd50dce5ef1242e4baa1397b0..4970909337c1039edba3a1df7ff8bbe71c07af97 100644 (file)
@@ -35,7 +35,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_MISC, .value = 1050626 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -48,7 +48,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
        { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 2627138fc2829fa6ed5955cc65a8ed348b04f852..59bf8662c26fe3b063ad39f34d9ffb42f1bdcc87 100644 (file)
@@ -30,13 +30,13 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
 
 static struct input_event proximity_out[] = {
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 07c250a2b1d0b3a19c0aa0148d0abfbd53e18832..d1e291cfa1be8ca3d4cfa6b395f4a8ea42eb2283 100644 (file)
@@ -30,13 +30,13 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
 
 static struct input_event proximity_out[] = {
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index 195228663e861817ad38467efce135c76455af0a..62561e1504c9144d2bfa2f33cb00849d6457258a 100644 (file)
@@ -32,7 +32,7 @@ static struct input_event proximity_in[] = {
        { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
        { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
@@ -42,7 +42,7 @@ static struct input_event proximity_out[] = {
        { .type = EV_ABS, .code = ABS_Y, .value = 0 },
        { .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
        { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
-       { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+       { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
        { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
        { .type = -1, .code = -1 },
 };
index c5b05e68864346bb7809aa8e512d622205a5c45b..5bc62d9cb9e38bd422e424408e55c9abb9cb05fe 100644 (file)
@@ -31,6 +31,9 @@
 /* Use as designater for litest to change the value */
 #define LITEST_AUTO_ASSIGN INT_MIN
 
+/* Special event code to auto-assign the BTN_TOOL_PEN and friends */
+#define LITEST_BTN_TOOL_AUTO (KEY_MAX << 1)
+
 struct litest_test_device {
        struct list node; /* global test device list */
 
@@ -129,6 +132,8 @@ struct litest_device_interface {
 
        int min[2]; /* x/y axis minimum */
        int max[2]; /* x/y axis maximum */
+
+       unsigned int tool_type;
 };
 
 struct path {
index a10d50db5b99506a9ba1b5b2261cc61196f9f81f..401112388bbb383170da3af985e66ab3163fd0a6 100644 (file)
@@ -65,6 +65,8 @@
 
 #include <linux/kd.h>
 
+#define evbit(t, c) ((t) << 16U | (c & 0xffff))
+
 #define UDEV_RULES_D "/run/udev/rules.d"
 #define UDEV_FUZZ_OVERRIDE_RULE_FILE UDEV_RULES_D \
        "/91-litest-fuzz-override-REMOVEME-XXXXXX.rules"
@@ -1812,6 +1814,7 @@ litest_add_device_with_overrides(struct libinput *libinput,
                        d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, code);
                        d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, code);
                }
+               d->interface->tool_type = BTN_TOOL_PEN;
        }
        return d;
 }
@@ -2443,6 +2446,33 @@ tablet_ignore_event(const struct input_event *ev, int value)
        return value == -1 && (ev->code == ABS_PRESSURE || ev->code == ABS_DISTANCE);
 }
 
+void
+litest_tablet_set_tool_type(struct litest_device *d, unsigned int code)
+{
+       switch (code) {
+       case BTN_TOOL_PEN:
+       case BTN_TOOL_RUBBER:
+       case BTN_TOOL_BRUSH:
+       case BTN_TOOL_PENCIL:
+       case BTN_TOOL_AIRBRUSH:
+       case BTN_TOOL_MOUSE:
+       case BTN_TOOL_LENS:
+               break;
+       default:
+               abort();
+       }
+
+       d->interface->tool_type = code;
+}
+
+static void
+litest_tool_event(struct litest_device *d, int value)
+{
+       unsigned int tool = d->interface->tool_type;
+
+       litest_event(d, EV_KEY, tool, value);
+}
+
 void
 litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes)
 {
@@ -2450,9 +2480,17 @@ litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_re
 
        ev = d->interface->tablet_proximity_in_events;
        while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
-               int value = auto_assign_tablet_value(d, ev, x, y, axes);
-               if (!tablet_ignore_event(ev, value))
-                       litest_event(d, ev->type, ev->code, value);
+               int value;
+
+               switch (evbit(ev->type, ev->code)) {
+               case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO):
+                       litest_tool_event(d, ev->value);
+                       break;
+               default:
+                       value = auto_assign_tablet_value(d, ev, x, y, axes);
+                       if (!tablet_ignore_event(ev, value))
+                               litest_event(d, ev->type, ev->code, value);
+               }
                ev++;
        }
 }
@@ -2464,9 +2502,18 @@ litest_tablet_proximity_out(struct litest_device *d)
 
        ev = d->interface->tablet_proximity_out_events;
        while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
-               int value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
-               if (!tablet_ignore_event(ev, value))
-                       litest_event(d, ev->type, ev->code, value);
+               int value;
+
+               switch (evbit(ev->type, ev->code)) {
+               case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO):
+                       litest_tool_event(d, ev->value);
+                       break;
+               default:
+                       value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
+                       if (!tablet_ignore_event(ev, value))
+                               litest_event(d, ev->type, ev->code, value);
+                       break;
+               }
                ev++;
        }
 }
index 1f4e609d7e2015165e920e2fc21a14c84da0641d..dcbb47bc7b62605011810812bc97cfc0288df7f4 100644 (file)
@@ -603,6 +603,10 @@ litest_touch_move_three_touches(struct litest_device *d,
                                double dx, double dy,
                                int steps);
 
+void
+litest_tablet_set_tool_type(struct litest_device *d,
+                           unsigned int code);
+
 void
 litest_tablet_proximity_in(struct litest_device *d,
                           int x, int y,
index bfc25737dfbe1cd0afd0ed5c6f99de19f2540a68..d0b728ec5e223261eff9fd4a0aa9a93e74bc348f 100644 (file)
@@ -2820,12 +2820,8 @@ START_TEST(tool_type)
                    !tablet_has_mouse(dev))
                        continue;
 
-               litest_push_event_frame(dev);
-               litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN);
+               litest_tablet_set_tool_type(dev, tt->code);
                litest_tablet_proximity_in(dev, 50, 50, axes);
-               litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN);
-               litest_event(dev, EV_KEY, tt->code, 1);
-               litest_pop_event_frame(dev);
                libinput_dispatch(li);
 
                event = libinput_get_event(li);
@@ -2839,12 +2835,7 @@ START_TEST(tool_type)
                libinput_event_destroy(event);
                litest_assert_empty_queue(li);
 
-               litest_push_event_frame(dev);
-               litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN);
                litest_tablet_proximity_out(dev);
-               litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN);
-               litest_event(dev, EV_KEY, tt->code, 0);
-               litest_pop_event_frame(dev);
                litest_drain_events(li);
        }
 }