test/Makefile.am: Use $(GCC_CFLAGS) from configure.ac

This commit also passes AM_CFLAGS instead of AM_CPPFLAGS to the test
cases CFLAGS.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Make libinput.h safe to be included from C++

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
test: Add include from C++ build test
configure.ac: Always check for C++ compiler

Even though libinput uses no C++, it should be supported to include
libinput.h from C++. Therefore a build test ensuring this possibility
exist. However, since we can not conditionally invoke AC_PROG_CXX
in configure.ac just do it always.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
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>
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>
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>
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>
test: switch the remaining devices to a description-based device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
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>
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>
Structure libinput_seat struct

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
test: fix memleak in touch test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Use log_error instead of fprintf in old touchpad code

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Fix up ARRAY_FOR_EACH macro

Remove compiler warning about signed/unsigned comparison. And while we're at
it, rename i to _i in the macro to avoid name clashes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
tools: add --verbose to event-debug

And redirect the log to stdout. libinput logs to stderr by default, but if
we're running with --verbose we want all msgs on the same stream.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
test: mark the synaptics clickpad as buttonpad

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
test: automatically run the tests against valgrind for leaks

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Add functions to convert back to the base event

A few functions only work on the base event but once we've converted to the
target event we can't go back. Casting works for now but that would expose
internal ABI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
test: add tests for event conversion and back

Looks a bit excessive given how simple the base is but hey, we don't want to
ever break that bit. That'd be embarrassing.

And while we're at it make sure that the 'wrong' event getters return NULL for
each event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>