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.
|
|
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
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
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#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>
|
2015-05-04 09:13:22 +10:00
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#define litest_assert(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
|
|
|
|
#cond, NULL); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_msg(cond, ...) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
|
|
|
|
#cond, __VA_ARGS__); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_abort_msg(...) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
|
|
|
|
"aborting", __VA_ARGS__); \
|
|
|
|
|
|
|
|
|
|
#define litest_assert_notnull(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if ((cond) == NULL) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
2015-05-21 16:40:24 +10:00
|
|
|
#cond, " expected to be not NULL\n"); \
|
2015-05-04 09:13:22 +10:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_comparison_int_(a_, op_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (trunc(_a) != _a || trunc(_b) != _b) \
|
|
|
|
|
litest_abort_msg("litest_assert_int_* used for non-integer value\n"); \
|
|
|
|
|
if (!((_a) op_ (_b))) \
|
|
|
|
|
litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#op_, _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_eq(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, ==, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_ne(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, !=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_lt(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, <, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_le(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, <=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_ge(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, >=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_gt(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, >, b_)
|
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
|
|
|
|
2015-05-08 08:16:39 +10:00
|
|
|
#define litest_assert_comparison_ptr_(a_, op_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!((_a) op_ (_b))) \
|
|
|
|
|
litest_fail_comparison_ptr(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#a_ " " #op_ " " #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_eq(a_, b_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, ==, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_ne(a_, b_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, !=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_null(a_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, ==, NULL)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_notnull(a_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, !=, NULL)
|
|
|
|
|
|
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
|
|
|
enum litest_device_type {
|
|
|
|
|
LITEST_NO_DEVICE = -1,
|
2014-08-04 12:49:59 +10:00
|
|
|
LITEST_SYNAPTICS_CLICKPAD = -2,
|
|
|
|
|
LITEST_SYNAPTICS_TOUCHPAD = -3,
|
|
|
|
|
LITEST_SYNAPTICS_TOPBUTTONPAD = -4,
|
|
|
|
|
LITEST_BCM5974 = -5,
|
|
|
|
|
LITEST_KEYBOARD = -6,
|
|
|
|
|
LITEST_TRACKPOINT = -7,
|
|
|
|
|
LITEST_MOUSE = -8,
|
|
|
|
|
LITEST_WACOM_TOUCH = -9,
|
|
|
|
|
LITEST_ALPS_SEMI_MT = -10,
|
|
|
|
|
LITEST_GENERIC_SINGLETOUCH = -11,
|
2014-11-05 11:20:36 +10:00
|
|
|
LITEST_MS_SURFACE_COVER = -12,
|
2014-10-29 10:59:58 +10:00
|
|
|
LITEST_QEMU_TABLET = -13,
|
2014-10-29 12:08:20 +10:00
|
|
|
LITEST_XEN_VIRTUAL_POINTER = -14,
|
2014-11-06 16:10:15 +10:00
|
|
|
LITEST_VMWARE_VIRTMOUSE = -15,
|
2014-12-11 13:30:33 +10:00
|
|
|
LITEST_SYNAPTICS_HOVER_SEMI_MT = -16,
|
2015-01-28 15:37:21 +10:00
|
|
|
LITEST_SYNAPTICS_TRACKPOINT_BUTTONS = -17,
|
2015-02-25 16:30:06 +10:00
|
|
|
LITEST_PROTOCOL_A_SCREEN = -18,
|
2015-03-04 10:27:22 +10:00
|
|
|
LITEST_WACOM_FINGER = -19,
|
2015-04-08 09:54:33 +10:00
|
|
|
LITEST_KEYBOARD_BLACKWIDOW = -20,
|
2015-04-13 10:23:47 +10:00
|
|
|
LITEST_WHEEL_ONLY = -21,
|
2015-04-17 15:59:36 +10:00
|
|
|
LITEST_MOUSE_ROCCAT = -22,
|
2015-04-28 16:45:35 +10:00
|
|
|
LITEST_LOGITECH_TRACKBALL = -23,
|
2015-05-06 19:41:25 -04:00
|
|
|
LITEST_ATMEL_HOVER = -24,
|
2015-06-16 15:36:40 +10:00
|
|
|
LITEST_ALPS_DUALPOINT = -25,
|
2015-06-26 11:06:05 +10:00
|
|
|
LITEST_MOUSE_LOW_DPI = -26,
|
2015-07-06 17:05:02 +02:00
|
|
|
LITEST_GENERIC_MULTITOUCH_SCREEN = -27,
|
2015-07-06 17:05:03 +02:00
|
|
|
LITEST_NEXUS4_TOUCH_SCREEN = -28,
|
2015-07-10 12:01:15 +10:00
|
|
|
LITEST_MAGIC_TRACKPAD = -29,
|
2015-07-10 14:11:11 +10:00
|
|
|
LITEST_ELANTECH_TOUCHPAD = -30,
|
2015-10-28 09:13:24 +10:00
|
|
|
LITEST_MOUSE_GLADIUS = -31,
|
2015-11-09 10:18:17 +10:00
|
|
|
LITEST_MOUSE_WHEEL_CLICK_ANGLE = -32,
|
2015-12-13 22:27:55 -08:00
|
|
|
LITEST_APPLE_KEYBOARD = -33,
|
2015-12-23 15:15:29 +10:00
|
|
|
LITEST_ANKER_MOUSE_KBD = -34,
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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,
|
2014-10-29 11:05:20 +10:00
|
|
|
LITEST_RELATIVE = 1 << 4,
|
2014-01-21 15:18:09 +10:00
|
|
|
LITEST_WHEEL = 1 << 5,
|
2014-01-22 09:58:43 +10:00
|
|
|
LITEST_TOUCH = 1 << 6,
|
2014-03-24 15:25:32 +10:00
|
|
|
LITEST_SINGLE_TOUCH = 1 << 7,
|
2014-06-05 16:25:37 +10:00
|
|
|
LITEST_APPLE_CLICKPAD = 1 << 8,
|
2014-06-11 08:59:11 +10:00
|
|
|
LITEST_TOPBUTTONPAD = 1 << 9,
|
2014-07-24 13:18:56 +10:00
|
|
|
LITEST_SEMI_MT = 1 << 10,
|
2014-09-18 11:15:27 +02:00
|
|
|
LITEST_POINTINGSTICK = 1 << 11,
|
2014-11-05 11:20:36 +10:00
|
|
|
LITEST_FAKE_MT = 1 << 12,
|
2014-10-29 10:59:58 +10:00
|
|
|
LITEST_ABSOLUTE = 1 << 13,
|
2015-02-25 16:30:06 +10:00
|
|
|
LITEST_PROTOCOL_A = 1 << 14,
|
2015-05-06 19:41:25 -04:00
|
|
|
LITEST_HOVER = 1 << 15,
|
2015-07-06 17:05:02 +02:00
|
|
|
LITEST_ELLIPSE = 1 << 16,
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct litest_device {
|
|
|
|
|
struct libevdev *evdev;
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput *libinput;
|
2014-02-22 15:06:34 +01:00
|
|
|
bool owns_context;
|
2014-01-29 15:38:48 +10:00
|
|
|
struct libinput_device *libinput_device;
|
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
|
|
|
struct litest_device_interface *interface;
|
2014-07-21 12:30:40 +10:00
|
|
|
|
|
|
|
|
int ntouches_down;
|
2014-09-17 10:07:38 +10:00
|
|
|
bool skip_ev_syn;
|
|
|
|
|
|
2014-07-24 13:18:56 +10:00
|
|
|
void *private; /* device-specific data */
|
2015-02-02 10:47:52 +10:00
|
|
|
|
|
|
|
|
char *udev_rule_file;
|
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
|
|
|
};
|
|
|
|
|
|
2015-06-22 12:48:04 +02:00
|
|
|
struct axis_replacement {
|
|
|
|
|
int32_t evcode;
|
|
|
|
|
int32_t value;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-06 08:09:50 +10:00
|
|
|
/* A loop range, resolves to:
|
|
|
|
|
for (i = lower; i < upper; i++)
|
|
|
|
|
*/
|
|
|
|
|
struct range {
|
|
|
|
|
int lower; /* inclusive */
|
|
|
|
|
int upper; /* exclusive */
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
struct libinput *litest_create_context(void);
|
2015-03-13 09:32:37 +10:00
|
|
|
void litest_disable_log_handler(struct libinput *libinput);
|
|
|
|
|
void litest_restore_log_handler(struct libinput *libinput);
|
2014-02-22 15:06:34 +01:00
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
void
|
|
|
|
|
litest_fail_condition(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *condition,
|
|
|
|
|
const char *message,
|
|
|
|
|
...);
|
|
|
|
|
void
|
|
|
|
|
litest_fail_comparison_int(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *operator,
|
|
|
|
|
int a,
|
|
|
|
|
int b,
|
|
|
|
|
const char *astr,
|
|
|
|
|
const char *bstr);
|
2015-05-08 08:16:39 +10:00
|
|
|
void
|
|
|
|
|
litest_fail_comparison_ptr(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *comparison);
|
2015-05-04 09:13:22 +10:00
|
|
|
|
2015-05-20 10:12:39 +10:00
|
|
|
#define litest_add(name_, func_, ...) \
|
|
|
|
|
_litest_add(name_, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_ranged(name_, func_, ...) \
|
|
|
|
|
_litest_add_ranged(name_, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_for_device(name_, func_, ...) \
|
|
|
|
|
_litest_add_for_device(name_, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_ranged_for_device(name_, func_, ...) \
|
|
|
|
|
_litest_add_ranged_for_device(name_, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_no_device(name_, func_) \
|
|
|
|
|
_litest_add_no_device(name_, #func_, func_)
|
|
|
|
|
#define litest_add_ranged_no_device(name_, func_, ...) \
|
|
|
|
|
_litest_add_ranged_no_device(name_, #func_, func_, __VA_ARGS__)
|
|
|
|
|
void _litest_add(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_feature required_feature,
|
|
|
|
|
enum litest_device_feature excluded_feature);
|
|
|
|
|
void _litest_add_ranged(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_feature required,
|
|
|
|
|
enum litest_device_feature excluded,
|
|
|
|
|
const struct range *range);
|
|
|
|
|
void _litest_add_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_type type);
|
|
|
|
|
void _litest_add_ranged_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_type type,
|
|
|
|
|
const struct range *range);
|
|
|
|
|
void _litest_add_no_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func);
|
|
|
|
|
void _litest_add_ranged_no_device(const char *name,
|
|
|
|
|
const char *funcname,
|
2015-05-06 08:09:50 +10:00
|
|
|
void *func,
|
|
|
|
|
const struct range *range);
|
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
|
|
|
|
2015-05-20 09:36:01 +10:00
|
|
|
extern void litest_setup_tests(void);
|
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
|
|
|
struct litest_device * litest_create_device(enum litest_device_type which);
|
2014-08-29 14:08:46 +10:00
|
|
|
struct litest_device * litest_add_device(struct libinput *libinput,
|
|
|
|
|
enum litest_device_type which);
|
2014-03-31 10:00:16 +10:00
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_device_from_description(const char *name,
|
|
|
|
|
const struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
const int *events);
|
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-03-31 14:54:46 +10:00
|
|
|
struct litest_device *
|
|
|
|
|
litest_create_device_with_overrides(enum litest_device_type which,
|
|
|
|
|
const char *name_override,
|
|
|
|
|
struct input_id *id_override,
|
|
|
|
|
const struct input_absinfo *abs_override,
|
|
|
|
|
const int *events_override);
|
2014-02-22 15:06:34 +01:00
|
|
|
struct litest_device *
|
|
|
|
|
litest_add_device_with_overrides(struct libinput *libinput,
|
|
|
|
|
enum litest_device_type which,
|
|
|
|
|
const char *name_override,
|
|
|
|
|
struct input_id *id_override,
|
|
|
|
|
const struct input_absinfo *abs_override,
|
|
|
|
|
const int *events_override);
|
|
|
|
|
|
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
|
|
|
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);
|
2014-07-24 13:18:56 +10:00
|
|
|
int litest_auto_assign_value(struct litest_device *d,
|
|
|
|
|
const struct input_event *ev,
|
2015-05-06 19:41:25 -04:00
|
|
|
int slot, double x, double y,
|
2015-06-22 12:48:04 +02:00
|
|
|
struct axis_replacement *axes,
|
2015-05-06 19:41:25 -04:00
|
|
|
bool touching);
|
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
|
|
|
void litest_touch_up(struct litest_device *d, unsigned int slot);
|
|
|
|
|
void litest_touch_move(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
2014-07-18 16:01:10 +10:00
|
|
|
double x,
|
|
|
|
|
double y);
|
2015-06-22 12:48:04 +02:00
|
|
|
void litest_touch_move_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes);
|
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
|
|
|
void litest_touch_down(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
2014-07-18 16:01:10 +10:00
|
|
|
double x,
|
|
|
|
|
double y);
|
2015-06-22 12:48:04 +02:00
|
|
|
void litest_touch_down_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes);
|
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
|
|
|
void litest_touch_move_to(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
2014-07-18 16:01:10 +10:00
|
|
|
double x_from, double y_from,
|
|
|
|
|
double x_to, double y_to,
|
2014-09-25 13:20:47 +02:00
|
|
|
int steps, int sleep_ms);
|
2015-03-12 20:05:25 +01:00
|
|
|
void litest_touch_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0, double y0,
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
double dx, double dy,
|
|
|
|
|
int steps, int sleep_ms);
|
2015-07-07 11:52:05 +10:00
|
|
|
void litest_touch_move_three_touches(struct litest_device *d,
|
|
|
|
|
double x0, double y0,
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
double x2, double y2,
|
|
|
|
|
double dx, double dy,
|
|
|
|
|
int steps, int sleep_ms);
|
2015-05-06 19:41:25 -04:00
|
|
|
void litest_hover_start(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y);
|
|
|
|
|
void litest_hover_end(struct litest_device *d, unsigned int slot);
|
|
|
|
|
void litest_hover_move(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y);
|
|
|
|
|
void litest_hover_move_to(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x_from, double y_from,
|
|
|
|
|
double x_to, double y_to,
|
|
|
|
|
int steps, int sleep_ms);
|
|
|
|
|
void litest_hover_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0, double y0,
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
double dx, double dy,
|
|
|
|
|
int steps, int sleep_ms);
|
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
|
|
|
void litest_button_click(struct litest_device *d,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
bool is_press);
|
2014-11-06 16:32:53 +01:00
|
|
|
void litest_button_scroll(struct litest_device *d,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
double dx, double dy);
|
2014-04-01 22:24:10 +02:00
|
|
|
void litest_keyboard_key(struct litest_device *d,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
bool is_press);
|
2014-08-20 17:15:50 +10:00
|
|
|
void litest_wait_for_event(struct libinput *li);
|
|
|
|
|
void litest_wait_for_event_of_type(struct libinput *li, ...);
|
2014-01-22 11:20:50 +10:00
|
|
|
void litest_drain_events(struct libinput *li);
|
2014-06-06 10:58:11 +10:00
|
|
|
void litest_assert_empty_queue(struct libinput *li);
|
2015-04-16 10:42:16 +10:00
|
|
|
struct libinput_event_pointer * litest_is_button_event(
|
|
|
|
|
struct libinput_event *event,
|
2015-05-04 09:30:51 +10:00
|
|
|
unsigned int button,
|
2015-04-16 10:42:16 +10:00
|
|
|
enum libinput_button_state state);
|
2015-05-04 13:11:21 +10:00
|
|
|
struct libinput_event_pointer * litest_is_axis_event(
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
enum libinput_pointer_axis_source source);
|
2015-05-04 13:17:27 +10:00
|
|
|
struct libinput_event_pointer * litest_is_motion_event(
|
|
|
|
|
struct libinput_event *event);
|
2015-05-04 13:51:39 +10:00
|
|
|
struct libinput_event_touch * litest_is_touch_event(
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type type);
|
2015-05-05 15:43:08 +10:00
|
|
|
struct libinput_event_keyboard * litest_is_keyboard_event(
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state);
|
2015-07-07 11:52:05 +10:00
|
|
|
struct libinput_event_gesture * litest_is_gesture_event(
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int nfingers);
|
|
|
|
|
|
2014-09-03 10:53:00 +10:00
|
|
|
void litest_assert_button_event(struct libinput *li,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
enum libinput_button_state state);
|
2014-11-06 14:30:21 +10:00
|
|
|
void litest_assert_scroll(struct libinput *li,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
2014-11-10 11:03:46 +10:00
|
|
|
int minimum_movement);
|
2014-12-18 11:29:32 +10:00
|
|
|
void litest_assert_only_typed_events(struct libinput *li,
|
|
|
|
|
enum libinput_event_type type);
|
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
|
|
|
|
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-03-26 20:09:42 +10:00
|
|
|
struct libevdev_uinput * litest_create_uinput_device(const char *name,
|
|
|
|
|
struct input_id *id,
|
|
|
|
|
...);
|
|
|
|
|
struct libevdev_uinput * litest_create_uinput_abs_device(const char *name,
|
|
|
|
|
struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
...);
|
2014-06-11 20:16:04 -04:00
|
|
|
#define litest_assert_double_eq(a_, b_)\
|
|
|
|
|
ck_assert_int_eq((int)(a_ * 256), (int)(b_ * 256))
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_ne(a_, b_)\
|
|
|
|
|
ck_assert_int_ne((int)(a_ * 256), (int)(b_ * 256))
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_lt(a_, b_)\
|
|
|
|
|
ck_assert_int_lt((int)(a_ * 256), (int)(b_ * 256))
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_le(a_, b_)\
|
|
|
|
|
ck_assert_int_le((int)(a_ * 256), (int)(b_ * 256))
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_gt(a_, b_)\
|
|
|
|
|
ck_assert_int_gt((int)(a_ * 256), (int)(b_ * 256))
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_ge(a_, b_)\
|
|
|
|
|
ck_assert_int_ge((int)(a_ * 256), (int)(b_ * 256))
|
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-03-26 20:09:42 +10:00
|
|
|
|
2014-09-16 16:08:29 +10:00
|
|
|
void litest_timeout_tap(void);
|
2015-05-04 08:42:44 +10:00
|
|
|
void litest_timeout_tapndrag(void);
|
2014-09-16 16:08:29 +10:00
|
|
|
void litest_timeout_softbuttons(void);
|
2014-11-06 16:32:53 +01:00
|
|
|
void litest_timeout_buttonscroll(void);
|
2015-03-06 14:36:31 +10:00
|
|
|
void litest_timeout_edgescroll(void);
|
2015-02-16 13:30:24 +01:00
|
|
|
void litest_timeout_finger_switch(void);
|
2015-04-13 16:38:44 +10:00
|
|
|
void litest_timeout_middlebutton(void);
|
2015-05-21 16:58:27 +10:00
|
|
|
void litest_timeout_dwt_short(void);
|
|
|
|
|
void litest_timeout_dwt_long(void);
|
2015-07-07 11:52:05 +10:00
|
|
|
void litest_timeout_gesture(void);
|
2014-09-16 16:08:29 +10:00
|
|
|
|
2014-09-17 10:07:38 +10:00
|
|
|
void litest_push_event_frame(struct litest_device *dev);
|
|
|
|
|
void litest_pop_event_frame(struct litest_device *dev);
|
|
|
|
|
|
2014-12-16 11:28:26 +10:00
|
|
|
/* this is a semi-mt device, so we keep track of the touches that the tests
|
|
|
|
|
* send and modify them so that the first touch is always slot 0 and sends
|
|
|
|
|
* the top-left of the bounding box, the second is always slot 1 and sends
|
|
|
|
|
* the bottom-right of the bounding box.
|
|
|
|
|
* Lifting any of two fingers terminates slot 1
|
|
|
|
|
*/
|
|
|
|
|
struct litest_semi_mt {
|
|
|
|
|
int tracking_id;
|
|
|
|
|
/* The actual touches requested by the test for the two slots
|
|
|
|
|
* in the 0..100 range used by litest */
|
|
|
|
|
struct {
|
|
|
|
|
double x, y;
|
|
|
|
|
} touches[2];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void litest_semi_mt_touch_down(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x, double y);
|
|
|
|
|
void litest_semi_mt_touch_move(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x, double y);
|
|
|
|
|
void litest_semi_mt_touch_up(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot);
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
#ifndef ck_assert_notnull
|
|
|
|
|
#define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-06-17 10:02:17 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_tap(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_tap(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 14:48:12 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_has_2fg_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
return !!(libinput_device_config_scroll_get_methods(device) &
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_2FG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_2fg_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_2FG);
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_edge_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_EDGE);
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_clickfinger(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_click_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_buttonareas(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_click_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_drag_lock(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_lock_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_drag_lock(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_lock_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 12:48:07 +02:00
|
|
|
#define CK_DOUBLE_EQ_EPSILON 1E-3
|
|
|
|
|
#define ck_assert_double_eq(X,Y) \
|
|
|
|
|
do { \
|
|
|
|
|
double _ck_x = X; \
|
|
|
|
|
double _ck_y = Y; \
|
|
|
|
|
ck_assert_msg(fabs(_ck_x - _ck_y) < CK_DOUBLE_EQ_EPSILON, \
|
|
|
|
|
"Assertion '" #X " == " #Y \
|
|
|
|
|
"' failed: "#X"==%f, "#Y"==%f", \
|
|
|
|
|
_ck_x, \
|
|
|
|
|
_ck_y); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define ck_assert_double_ne(X,Y) \
|
|
|
|
|
do { \
|
|
|
|
|
double _ck_x = X; \
|
|
|
|
|
double _ck_y = Y; \
|
|
|
|
|
ck_assert_msg(fabs(_ck_x - _ck_y) > CK_DOUBLE_EQ_EPSILON, \
|
|
|
|
|
"Assertion '" #X " != " #Y \
|
|
|
|
|
"' failed: "#X"==%f, "#Y"==%f", \
|
|
|
|
|
_ck_x, \
|
|
|
|
|
_ck_y); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define _ck_assert_double_eq(X, OP, Y) \
|
|
|
|
|
do { \
|
|
|
|
|
double _ck_x = X; \
|
|
|
|
|
double _ck_y = Y; \
|
|
|
|
|
ck_assert_msg(_ck_x OP _ck_y || \
|
|
|
|
|
fabs(_ck_x - _ck_y) < CK_DOUBLE_EQ_EPSILON, \
|
|
|
|
|
"Assertion '" #X#OP#Y \
|
|
|
|
|
"' failed: "#X"==%f, "#Y"==%f", \
|
|
|
|
|
_ck_x, \
|
|
|
|
|
_ck_y); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define _ck_assert_double_ne(X, OP,Y) \
|
|
|
|
|
do { \
|
|
|
|
|
double _ck_x = X; \
|
|
|
|
|
double _ck_y = Y; \
|
|
|
|
|
ck_assert_msg(_ck_x OP _ck_y && \
|
|
|
|
|
fabs(_ck_x - _ck_y) > CK_DOUBLE_EQ_EPSILON, \
|
|
|
|
|
"Assertion '" #X#OP#Y \
|
|
|
|
|
"' failed: "#X"==%f, "#Y"==%f", \
|
|
|
|
|
_ck_x, \
|
|
|
|
|
_ck_y); \
|
|
|
|
|
} while (0)
|
|
|
|
|
#define ck_assert_double_lt(X, Y) _ck_assert_double_ne(X, <, Y)
|
|
|
|
|
#define ck_assert_double_le(X, Y) _ck_assert_double_eq(X, <=, Y)
|
|
|
|
|
#define ck_assert_double_gt(X, Y) _ck_assert_double_ne(X, >, Y)
|
|
|
|
|
#define ck_assert_double_ge(X, Y) _ck_assert_double_eq(X, >=, Y)
|
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 */
|