selftests/hid: sync the python tests to hid-tools 0.8

Instead of backporting one by one each commits, let's pull them in bulk
and refer to the hid-tools project for a detailed history.

The short summary is:
- make use of dataclass when possible, to avoid tuples
- wacom: remove unused uhdev parameter
- various small fixes not worth mentioning

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Link: https://patch.msgid.link/20250709-wip-fix-ci-v1-2-b7df4c271cf8@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
This commit is contained in:
Benjamin Tissoires
2025-07-09 11:08:50 +02:00
parent c85a8cb9b8
commit 642f9b2d60
9 changed files with 69 additions and 43 deletions

View File

@@ -40,7 +40,7 @@ import logging
logger = logging.getLogger("hidtools.test.wacom")
KERNEL_MODULE = ("wacom", "wacom")
KERNEL_MODULE = base.KernelModule("wacom", "wacom")
class ProximityState(Enum):
@@ -894,7 +894,7 @@ class TestDTH2452Tablet(test_multitouch.BaseTest.TestMultitouch, TouchTabletTest
"""
return [self.make_contact(id, t) for id in range(0, n)]
def assert_contact(self, uhdev, evdev, contact_ids, t=0):
def assert_contact(self, evdev, contact_ids, t=0):
"""
Assert properties of a contact generated by make_contact.
"""
@@ -916,12 +916,12 @@ class TestDTH2452Tablet(test_multitouch.BaseTest.TestMultitouch, TouchTabletTest
assert evdev.slots[slot_num][libevdev.EV_ABS.ABS_MT_POSITION_X] == x
assert evdev.slots[slot_num][libevdev.EV_ABS.ABS_MT_POSITION_Y] == y
def assert_contacts(self, uhdev, evdev, data, t=0):
def assert_contacts(self, evdev, data, t=0):
"""
Assert properties of a list of contacts generated by make_contacts.
"""
for contact_ids in data:
self.assert_contact(uhdev, evdev, contact_ids, t)
self.assert_contact(evdev, contact_ids, t)
def test_contact_id_0(self):
"""
@@ -998,7 +998,6 @@ class TestDTH2452Tablet(test_multitouch.BaseTest.TestMultitouch, TouchTabletTest
assert libevdev.InputEvent(libevdev.EV_KEY.BTN_TOUCH, 1) in events
self.assert_contacts(
uhdev,
evdev,
[
self.ContactIds(contact_id=0, tracking_id=-1, slot_num=None),
@@ -1032,7 +1031,7 @@ class TestDTH2452Tablet(test_multitouch.BaseTest.TestMultitouch, TouchTabletTest
self.debug_reports(r, uhdev, events)
ids = [x[0] for x in state]
self.assert_contacts(uhdev, evdev, ids, t)
self.assert_contacts(evdev, ids, t)
t += 1