Commit graph

12 commits

Author SHA1 Message Date
Peter Hutterer
1014acedfc test: split the tests into one test case each
For debugging it's more important to be able to quickly run a single test
rather than grouping them together, we don't have thousands of tests here
anyway. So let's add a macro to put every test func into its own TCase,
allowing for test selection via the environment variable CK_RUN_CASE.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-11 20:57:42 +10:00
Peter Hutterer
9fe185dd3d Add a code-based name lookup function
Two new function pairs:
	libevdev_event_code_from_code_name()
	libevdev_event_type_from_code_name()

	libevdev_event_code_from_code_name_n()
	libevdev_event_type_from_code_name_n()

These functions look up event codes/types by the name of the event code only,
removing the need to figure out what event type an event code has. So if all
you have is "BTN_TOUCH", you can now look up the type and code for that,
without having to check the prefix yourself to guess at the type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-21 00:55:32 +00:00
Peter Hutterer
1e605f6282 Add libevdev_event_value_get_name() to resolve ABS_MT_TOOL_TYPE values
ABS_MT_TOOL_TYPE values are an enum, not a numerical value like all other
axes. So let's allow converting those values to string.

Fixes https://gitlab.freedesktop.org/libevdev/libevdev/issues/1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-07-09 11:57:57 +10:00
Peter Hutterer
d9cfd143d0 Resolve the names "SW_MAX" and friends
Some of the *_MAX names are duplicates and have a real define. These were not
resolved until now.

Fixes https://gitlab.freedesktop.org/libevdev/libevdev/issues/3

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-07-09 11:57:57 +10:00
Peter Hutterer
83ce8eb5be test: automate test suite handling
Move all tests to a special section, then loop through that section
to fetch all test suite. The result is that new tests only need to add the
source files without having to update everything else as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-15 15:00:24 +10:00
Peter Hutterer
bc5c72571d test: rename some tests for less ambiguity
"key" usually refers to one of KEY_ of EV_KEY in general, but here we're
testing event codes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-15 14:16:29 +10:00
Peter Hutterer
6ff816163e Blacklist SW_MAX so it doesn't shadow SW_PEN_INSERTED
They have the same value, so the _MAX code would shadow the real code, causing
issues in any client that needs to get all event names from libevdev.
Specifically, the loop of:
  for each code in 0 to max-for-type:
      print(name)
would not show up the code (but the _MAX) code instead. This causes issues
with clients that rely on name resolution that works. And the _MAX values are
special values anyway.

Blacklist it in the script here, causing it to resolve from name to code, but
not from code to name (like other duplicated codes).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-02-26 17:12:08 +10:00
Peter Hutterer
8742e1e346 Add libevdev_property_from_name()
12717d79 "Add libevdev_event_type/code_from_name() resolvers" added the
lookup functions for types and codes, this commit adds the missing ones for
input properties.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-20 08:43:15 +10:00
Peter Hutterer
d856a85cda test: drop include of libevdev-int.h
Not needed, and shouldn't be used in a test anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 10:36:08 +10:00
Peter Hutterer
c0248818e6 test: use ck_assert_int_eq() where comparing integers
A simple ck_assert() just fails, a ck_assert_int_eq() also shows the two
values. Makes failures a bit easier to debug.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 10:36:08 +10:00
Peter Hutterer
2aa3d3f1b0 Provide separate lookup functions for zero-terminated strings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-01 08:18:41 +10:00
David Herrmann
523f34b2d9 Add name-resolver unit tests
A bunch of tests for the new name resolver.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31 11:24:26 +10:00