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>
2013-12-06 15:02:11 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef LITEST_H
|
|
|
|
|
#define LITEST_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <check.h>
|
|
|
|
|
#include <libevdev/libevdev.h>
|
|
|
|
|
#include <libevdev/libevdev-uinput.h>
|
|
|
|
|
#include <libinput.h>
|
|
|
|
|
|
|
|
|
|
enum litest_device_type {
|
|
|
|
|
LITEST_NO_DEVICE = -1,
|
|
|
|
|
LITEST_SYNAPTICS_CLICKPAD,
|
|
|
|
|
LITEST_BCM5974,
|
|
|
|
|
LITEST_KEYBOARD,
|
|
|
|
|
LITEST_TRACKPOINT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum litest_device_feature {
|
|
|
|
|
LITEST_DISABLE_DEVICE = -1,
|
|
|
|
|
LITEST_ANY = 0,
|
|
|
|
|
LITEST_TOUCHPAD = 1 << 0,
|
|
|
|
|
LITEST_CLICKPAD = 1 << 1,
|
|
|
|
|
LITEST_BUTTON = 1 << 2,
|
|
|
|
|
LITEST_KEYS = 1 << 3,
|
|
|
|
|
LITEST_POINTER = 1 << 4,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct litest_device {
|
|
|
|
|
struct libevdev *evdev;
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput *libinput;
|
|
|
|
|
struct litest_device_interface *interface;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void litest_add(const char *name, void *func,
|
|
|
|
|
enum litest_device_feature required_feature,
|
|
|
|
|
enum litest_device_feature excluded_feature);
|
|
|
|
|
void litest_add_no_device(const char *name, void *func);
|
|
|
|
|
|
|
|
|
|
int litest_run(int argc, char **argv);
|
|
|
|
|
struct litest_device * litest_create_device(enum litest_device_type which);
|
|
|
|
|
struct litest_device *litest_current_device(void);
|
|
|
|
|
void litest_delete_device(struct litest_device *d);
|
|
|
|
|
int litest_handle_events(struct litest_device *d);
|
|
|
|
|
|
|
|
|
|
void litest_event(struct litest_device *t,
|
|
|
|
|
unsigned int type,
|
|
|
|
|
unsigned int code,
|
|
|
|
|
int value);
|
|
|
|
|
void litest_touch_up(struct litest_device *d, unsigned int slot);
|
|
|
|
|
void litest_touch_move(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
int x,
|
|
|
|
|
int y);
|
|
|
|
|
void litest_touch_down(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
int x,
|
|
|
|
|
int y);
|
|
|
|
|
void litest_touch_move_to(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
int x_from, int y_from,
|
|
|
|
|
int x_to, int y_to,
|
|
|
|
|
int steps);
|
|
|
|
|
void litest_button_click(struct litest_device *d,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
bool is_press);
|
2014-01-22 11:20:50 +10:00
|
|
|
void litest_drain_events(struct libinput *li);
|
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>
2013-12-06 15:02:11 +10:00
|
|
|
|
|
|
|
|
#endif /* LITEST_H */
|