Commit graph

272 commits

Author SHA1 Message Date
Peter Hutterer
56ae994efa test: add --verbose flag to litests
Sometimes it's handy to see what libinput prints out while running a test.
This breaks test-log if run with --verbose. Checking that the default log
priority hasn't changed obviously doesn't work if we change it on demand.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-10 20:55:04 +10:00
Peter Hutterer
51d28f215e test: fix compiler warning for is_debugger_attached
litest.c:207:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-10 20:54:38 +10:00
Peter Hutterer
4982b46010 Add our own version of linux/input.h
Avoids having to #define any values we're trying to use.

Header file is from Linux 3.15-rc8.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-06-04 09:40:39 +10:00
Jonas Ådahl
3f349026cf test: Test seat wide button and key count helpers
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-23 00:07:40 +02:00
Jonas Ådahl
6207216702 test: Add ability to add test devices to existing libinput context
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-04-23 00:07:40 +02:00
Jonas Ådahl
dbbc091123 test: Fix test device type validity check
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-23 00:07:40 +02:00
Jonas Ådahl
d9bfaeb59e test: Fix name of litest_button_click() definition
In litest.h it was called litest_button_click() while in litest.c
litest_click(); update the definition to be the same as the declaration.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-04-09 20:51:46 +02:00
Jonas Ådahl
3bee64a845 test: Use generic test device API in touch_abs_transform test
Instead of having a test device which only purpose is to test absolute
coordinate transformation, use the litest_create_device_with_overrides()
API to create a specially crafted wacom touch device with high
resolution.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-08 23:07:49 +02:00
Peter Hutterer
a9a24c33e7 test: allow partial overriding the test devices
For specific tests we need something that e.g. looks like a touchpad, but has
a different name, a different number of slots, etc. In this case, the
following code will do exactly that:

struct input_absinfo overrides[] = {
 { .value = ABS_MT_SLOT, .minimum = 0, .maximum = 100 },
 { .value = -1 },
};

litest_create_device_with_overrides(LITEST_SYNAPTICS_CLICKPAD,
				    NULL, NULL, &overrides, NULL);

For general event codes, overrides can only add to the set of events, they
can't remove.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-08 15:07:02 +10:00
Peter Hutterer
a242d68989 test: allow for description-based test devices
Most of the test devices now are static descriptions anyway, make them fully
static now, including for touch events.

Switch the synaptics device now as example, the rest comes later for easier
patch review.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-08 15:07:02 +10:00
Peter Hutterer
258ba1c375 test: if no teardown func is set, use the default
Reduces the amount of boilerplate code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-08 15:07:02 +10:00
Peter Hutterer
04d52d718f test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.

The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.

Both functions abort on failure, so the caller does not need to check the
return value.

Example code for creating a rel device:

struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
                                     EV_REL, REL_X,
                                     EV_REL, REL_Y,
                                     EV_KEY, BTN_LEFT,
                                     INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
                                     -1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-08 15:07:02 +10:00
Peter Hutterer
d1ba8a8fcc test: add framework for a single-touch synaptics device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 11:06:09 +10:00
Jonas Ådahl
ad24bc07f8 test: Add scale li_fixed overflow test
Add a test case and test device that checks if the scale transform can
handle high resolution devices and output monitor resolutions.

The test case is created in a way that it will fail if the coordinate
transform expression will overflow if only 32 bit integer data
containers are used.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-20 11:30:08 +10:00
Peter Hutterer
606249f91c path: add libinput_path_create_context instead of libinput_create_from_path
Creates an empty context that is not hooked up to a device. Callers can then
add and remove devices to this context using libinput_path_add_device() and
libinput_path_remove_device().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Jonas Ådahl
1f1304041c Replace output screen size callback with transform helpers
Instead of automatically transforming absolute coordinates of touch and
pointer events to screen coordinates, the user now uses the corresponding
transform helper function. This means the coordinates returned by
libinput_event_pointer_get_absolute_x(),
libinput_event_pointer_get_absolute_y(), libinput_touch_get_x() and
libinput_touch_get_y() has changed from being in output screen coordinate
space to being in device specific coordinate space.

For example, where one before would call libinput_event_touch_get_x(event),
one now calls libinput_event_touch_get_x_transformed(event, output_width).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-03 23:39:58 +01:00
Peter Hutterer
6f1e422a5e test: add a wacom touch devices (absolute touchscreen)
This means we do have to provide the get_current_screen_dimensions() call in
litest now, just hardcode it to 1024x768.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 11:23:00 +10:00
Peter Hutterer
404a0ea14e test: Add a basic mouse test device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 11:23:00 +10:00
Peter Hutterer
4ec24b2037 test: Add a common helper function to drain all current events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 11:23:00 +10:00
Jonas Ådahl
ec717caad1 test: Remove short option and fail on invalid options
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-15 23:24:21 +01:00
Jonas Ådahl
a9a6a6099d test: Fix optstring in getopt_long call
Was missing the "l".

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-15 21:11:51 +01:00
Peter Hutterer
3a344169bb Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.

The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.

Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.

For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.

check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.

litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);

adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
   "foo:bar", "trackpoint"
   "foo:bar", "clickpad"
   ...

Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).

The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-15 11:59:27 +10:00