mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 04:40:05 +01:00
test: add optional value names to parametrized tests
Only implemented for i32 values so far, used for enums and enum-like constants, replaces a runtime lookup from stringly-typed parameters. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1141>
This commit is contained in:
parent
bf3a67de6c
commit
3a60c47e33
12 changed files with 147 additions and 194 deletions
|
|
@ -39,6 +39,7 @@ struct multivalue {
|
|||
uint32_t u;
|
||||
int32_t i;
|
||||
} value;
|
||||
char name[64];
|
||||
};
|
||||
|
||||
static inline void
|
||||
|
|
@ -73,10 +74,7 @@ multivalue_extract_typed(const struct multivalue *v, char type, void *ptr)
|
|||
static inline struct multivalue
|
||||
multivalue_copy(const struct multivalue *v)
|
||||
{
|
||||
struct multivalue copy = {
|
||||
copy.type = v->type,
|
||||
copy.value = v->value,
|
||||
};
|
||||
struct multivalue copy = *v;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
@ -143,11 +141,25 @@ multivalue_new_bool(bool b)
|
|||
return v;
|
||||
}
|
||||
|
||||
static inline struct multivalue
|
||||
multivalue_new_named_i32(int32_t value, const char *name)
|
||||
{
|
||||
struct multivalue v = multivalue_new_i32(value);
|
||||
|
||||
assert(strlen(name) < sizeof(v.name));
|
||||
|
||||
snprintf(v.name, sizeof(v.name), "%s", name);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
multivalue_as_str(const struct multivalue *v)
|
||||
{
|
||||
char *str;
|
||||
|
||||
if (v->name[0])
|
||||
return safe_strdup(v->name);
|
||||
|
||||
switch (v->type) {
|
||||
case 'd':
|
||||
xasprintf(&str, "%f", v->value.d);
|
||||
|
|
|
|||
|
|
@ -666,7 +666,7 @@ _litest_test_param_fetch(const struct litest_test_parameters *params, ...)
|
|||
void **ptr = va_arg(args, void *);
|
||||
list_for_each(p, ¶ms->test_params, link) {
|
||||
if (streq(p->name, name)) {
|
||||
if (p->value.type != type)
|
||||
if (tolower(p->value.type) != tolower(type))
|
||||
litest_abort_msg("Paramter type mismatch: parameter '%s' is of type %c", p->name, p->value.type);
|
||||
found = true;
|
||||
multivalue_extract(&p->value, ptr);
|
||||
|
|
|
|||
|
|
@ -385,6 +385,16 @@ litest_parameter_add_double(struct litest_parameter *p, double d)
|
|||
list_append(&p->values, &pv->link);
|
||||
}
|
||||
|
||||
static inline void
|
||||
litest_parameter_add_named_i32(struct litest_parameter *p, const struct litest_named_i32 i)
|
||||
{
|
||||
assert(p->type == 'I');
|
||||
|
||||
struct litest_parameter_value *pv = litest_parameter_value_new();
|
||||
pv->value = multivalue_new_named_i32(i.value, i.name);
|
||||
list_append(&p->values, &pv->link);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static struct litest_parameter_value *
|
||||
litest_parameter_value_ref(struct litest_parameter_value *pv) {
|
||||
|
|
@ -417,6 +427,7 @@ litest_parameter_new(const char *name, char type)
|
|||
case 'c':
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'I':
|
||||
case 's':
|
||||
case 'u':
|
||||
break;
|
||||
|
|
@ -515,6 +526,11 @@ _litest_parameters_new(const char *name, ...) {
|
|||
litest_parameter_add_string(param, s);
|
||||
break;
|
||||
}
|
||||
case 'I': {
|
||||
struct litest_named_i32 p = va_arg(args, struct litest_named_i32);
|
||||
litest_parameter_add_named_i32(param, p);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -615,6 +615,19 @@ _litest_parameters_new(const char *name, ...);
|
|||
params_; \
|
||||
params_ = litest_parameters_unref(params_))
|
||||
|
||||
#define _LITEST_NAMED_I32(v_, n_, ...) (struct litest_named_i32){ .value = v_, .name = n_ }
|
||||
/* Helper to default second argument to stringification of first argument.
|
||||
* This allows for two uses of this macro:
|
||||
* - litest_named_i32(0) expands to { 0, "0" }
|
||||
* - litest_named_i32(0, "zero") expands to (effectively) { 0, "zero" }
|
||||
*/
|
||||
#define litest_named_i32(...) _LITEST_NAMED_I32(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
struct litest_named_i32 {
|
||||
int32_t value;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct litest_parameters_permutation_value {
|
||||
struct list link;
|
||||
char name[128];
|
||||
|
|
|
|||
|
|
@ -172,10 +172,7 @@ START_TEST(log_axisrange_warning)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
const struct input_absinfo *abs;
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
int axis = libevdev_event_code_from_code_name(axisname);
|
||||
litest_assert_int_ne(axis, -1);
|
||||
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
litest_touch_down(dev, 0, 90, 100);
|
||||
litest_drain_events(li);
|
||||
|
|
@ -210,7 +207,7 @@ TEST_COLLECTION(log)
|
|||
litest_add_deviceless(log_handler_NULL);
|
||||
litest_add_no_device(log_priority);
|
||||
|
||||
litest_with_parameters(params, "axis", 's', 2, "ABS_X", "ABS_Y") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
||||
/* mtdev clips to axis ranges */
|
||||
litest_add_parametrized(log_axisrange_warning, LITEST_TOUCH, LITEST_PROTOCOL_A, params);
|
||||
litest_add_parametrized(log_axisrange_warning, LITEST_TOUCHPAD, LITEST_ANY, params);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
#include "libinput-util.h"
|
||||
#include "litest.h"
|
||||
|
||||
enum cardinal {
|
||||
N, NE, E, SE, S, SW, W, NW
|
||||
};
|
||||
|
||||
static void
|
||||
test_relative_event(struct litest_device *dev, double dx, double dy)
|
||||
{
|
||||
|
|
@ -184,27 +188,36 @@ START_TEST(pointer_motion_relative_min_decel)
|
|||
double evx, evy;
|
||||
int dx, dy;
|
||||
double len;
|
||||
enum cardinal direction = litest_test_param_get_i32(test_env->params, "direction");
|
||||
|
||||
const char *direction = litest_test_param_get_string(test_env->params, "direction");
|
||||
|
||||
if (streq(direction, "N")) {
|
||||
switch(direction) {
|
||||
case N:
|
||||
dx = 0; dy = 1;
|
||||
} else if (streq(direction, "NE")) {
|
||||
break;
|
||||
case NE:
|
||||
dx = 1; dy = 1;
|
||||
} else if (streq(direction, "E")) {
|
||||
break;
|
||||
case E:
|
||||
dx = 1; dy = 0;
|
||||
} else if (streq(direction, "SE")) {
|
||||
break;
|
||||
case SE:
|
||||
dx = 1; dy = -1;
|
||||
} else if (streq(direction, "S")) {
|
||||
break;
|
||||
case S:
|
||||
dx = 0; dy = -1;
|
||||
} else if (streq(direction, "SW")) {
|
||||
break;
|
||||
case SW:
|
||||
dx = -1; dy = -1;
|
||||
} else if (streq(direction, "W")) {
|
||||
break;
|
||||
case W:
|
||||
dx = -1; dy = 0;
|
||||
} else if (streq(direction, "NW")) {
|
||||
dx = -1, dy = 1;
|
||||
} else
|
||||
litest_abort_msg("Invalid direction %s", direction);
|
||||
break;
|
||||
case NW:
|
||||
dx = -1; dy = 1;
|
||||
break;
|
||||
default:
|
||||
litest_abort_msg("Invalid direction %d", direction);
|
||||
}
|
||||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
|
|
@ -273,10 +286,7 @@ START_TEST(pointer_absolute_initial_state)
|
|||
struct libinput *libinput1, *libinput2;
|
||||
struct libinput_event *ev1, *ev2;
|
||||
struct libinput_event_pointer *p1, *p2;
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
int axis = libevdev_event_code_from_code_name(axisname);
|
||||
litest_assert_int_ne(axis, -1);
|
||||
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
libinput1 = dev->libinput;
|
||||
litest_touch_down(dev, 0, 40, 60);
|
||||
|
|
@ -777,19 +787,21 @@ START_TEST(pointer_scroll_wheel_hires_send_only_lores)
|
|||
struct libinput *li = dev->libinput;
|
||||
unsigned int lores_code, hires_code;
|
||||
int direction;
|
||||
enum libinput_pointer_axis axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
|
||||
if (streq(axisname, "vertical")) {
|
||||
switch (axis) {
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
||||
lores_code = REL_WHEEL;
|
||||
hires_code = REL_WHEEL_HI_RES;
|
||||
direction = -1;
|
||||
} else if (streq(axisname, "horizontal")) {
|
||||
break;
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
||||
lores_code = REL_HWHEEL;
|
||||
hires_code = REL_HWHEEL_HI_RES;
|
||||
direction = 1;
|
||||
} else {
|
||||
litest_abort_msg("Invalid test axis '%s'", axisname);
|
||||
break;
|
||||
default:
|
||||
litest_abort_msg("Invalid test axis '%d'", axis);
|
||||
}
|
||||
|
||||
if (!libevdev_has_event_code(dev->evdev, EV_REL, lores_code) &&
|
||||
|
|
@ -3758,7 +3770,10 @@ TEST_COLLECTION(pointer)
|
|||
litest_add(pointer_motion_relative, LITEST_RELATIVE, LITEST_POINTINGSTICK);
|
||||
litest_add_for_device(pointer_motion_relative_zero, LITEST_MOUSE);
|
||||
litest_with_parameters(params,
|
||||
"direction", 's', 8, "N", "E", "S", "W", "NE", "SE", "SW", "NW") {
|
||||
"direction", 'I', 8, litest_named_i32(N), litest_named_i32(NE),
|
||||
litest_named_i32(E), litest_named_i32(SE),
|
||||
litest_named_i32(S), litest_named_i32(SW),
|
||||
litest_named_i32(W), litest_named_i32(NW)) {
|
||||
litest_add_parametrized(pointer_motion_relative_min_decel, LITEST_RELATIVE, LITEST_POINTINGSTICK, params);
|
||||
}
|
||||
litest_add(pointer_motion_absolute, LITEST_ABSOLUTE, LITEST_ANY);
|
||||
|
|
@ -3770,7 +3785,8 @@ TEST_COLLECTION(pointer)
|
|||
litest_add(pointer_recover_from_lost_button_count, LITEST_BUTTON, LITEST_CLICKPAD);
|
||||
litest_add(pointer_scroll_wheel, LITEST_WHEEL, LITEST_TABLET);
|
||||
litest_add(pointer_scroll_wheel_hires, LITEST_WHEEL, LITEST_TABLET);
|
||||
litest_with_parameters(params, "axis", 's', 2, "vertical", "horizontal") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, "vertical"),
|
||||
litest_named_i32(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, "horizontal")) {
|
||||
litest_add_parametrized(pointer_scroll_wheel_hires_send_only_lores, LITEST_WHEEL, LITEST_TABLET, params);
|
||||
}
|
||||
litest_add(pointer_scroll_wheel_inhibit_small_deltas, LITEST_WHEEL, LITEST_TABLET);
|
||||
|
|
@ -3840,7 +3856,7 @@ TEST_COLLECTION(pointer)
|
|||
litest_add(middlebutton_device_remove_while_down, LITEST_BUTTON, LITEST_CLICKPAD);
|
||||
litest_add(middlebutton_device_remove_while_one_is_down, LITEST_BUTTON, LITEST_CLICKPAD);
|
||||
|
||||
litest_with_parameters(params, "axis", 's', 2, "ABS_X", "ABS_Y") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
||||
litest_add_parametrized(pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, params);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,25 +104,12 @@ START_TEST(switch_has_tablet_mode_switch)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static enum libinput_switch
|
||||
switch_param_lookup(const char *sw)
|
||||
{
|
||||
if (streq(sw, "lid"))
|
||||
return LIBINPUT_SWITCH_LID;
|
||||
if (streq(sw, "tablet_mode"))
|
||||
return LIBINPUT_SWITCH_TABLET_MODE;
|
||||
|
||||
litest_abort_msg("Invalid switch parameter: %s", sw);
|
||||
}
|
||||
|
||||
START_TEST(switch_toggle)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
struct libinput_event *event;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch sw = switch_param_lookup(str);
|
||||
enum libinput_switch sw = litest_test_param_get_i32(test_env->params, "switch");
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
|
|
@ -157,9 +144,7 @@ START_TEST(switch_toggle_double)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
struct libinput_event *event;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch sw = switch_param_lookup(str);
|
||||
enum libinput_switch sw = litest_test_param_get_i32(test_env->params, "switch");
|
||||
|
||||
if (libinput_device_switch_has_switch(dev->libinput_device, sw) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -205,9 +190,7 @@ START_TEST(switch_down_on_init)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li;
|
||||
struct libinput_event *event;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch sw = switch_param_lookup(str);
|
||||
enum libinput_switch sw = litest_test_param_get_i32(test_env->params, "switch");
|
||||
|
||||
if (libinput_device_switch_has_switch(dev->libinput_device, sw) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -295,10 +278,7 @@ START_TEST(switch_disable_touchpad)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -337,9 +317,7 @@ START_TEST(switch_disable_touchpad_during_touch)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -370,10 +348,7 @@ START_TEST(switch_disable_touchpad_edge_scroll)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -412,10 +387,7 @@ START_TEST(switch_disable_touchpad_edge_scroll_interrupt)
|
|||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
struct libinput_event *event;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -454,10 +426,7 @@ START_TEST(switch_disable_touchpad_already_open)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -491,10 +460,7 @@ START_TEST(switch_dont_resume_disabled_touchpad)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -534,10 +500,7 @@ START_TEST(switch_dont_resume_disabled_touchpad_external_mouse)
|
|||
struct litest_device *sw = litest_current_device();
|
||||
struct litest_device *touchpad, *mouse;
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
if (libinput_device_switch_has_switch(sw->libinput_device, which) <= 0)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
||||
|
|
@ -668,10 +631,7 @@ START_TEST(switch_suspend_with_keyboard)
|
|||
struct libinput *li;
|
||||
struct litest_device *keyboard;
|
||||
struct litest_device *sw;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
li = litest_create_context();
|
||||
|
||||
switch(which) {
|
||||
|
|
@ -711,10 +671,7 @@ START_TEST(switch_suspend_with_touchpad)
|
|||
{
|
||||
struct libinput *li;
|
||||
struct litest_device *touchpad, *sw;
|
||||
|
||||
const char *str = litest_test_param_get_string(test_env->params, "switch");
|
||||
enum libinput_switch which = switch_param_lookup(str);
|
||||
|
||||
enum libinput_switch which = litest_test_param_get_i32(test_env->params, "switch");
|
||||
li = litest_create_context();
|
||||
|
||||
switch(which) {
|
||||
|
|
@ -1431,7 +1388,8 @@ TEST_COLLECTION(switch)
|
|||
litest_add(switch_has_tablet_mode_switch, LITEST_SWITCH, LITEST_ANY);
|
||||
litest_add(switch_not_down_on_init, LITEST_SWITCH, LITEST_ANY);
|
||||
|
||||
litest_with_parameters(params, "switch", 's', 2, "lid", "tablet_mode") {
|
||||
litest_with_parameters(params, "switch", 'I', 2, litest_named_i32(LIBINPUT_SWITCH_LID, "lid"),
|
||||
litest_named_i32(LIBINPUT_SWITCH_TABLET_MODE, "tablet_mode")) {
|
||||
litest_add_parametrized(switch_toggle, LITEST_SWITCH, LITEST_ANY, params);
|
||||
litest_add_parametrized(switch_toggle_double, LITEST_SWITCH, LITEST_ANY, params);
|
||||
litest_add_parametrized(switch_down_on_init, LITEST_SWITCH, LITEST_ANY, params);
|
||||
|
|
|
|||
|
|
@ -669,10 +669,7 @@ START_TEST(tip_up_motion_one_axis)
|
|||
double x, y, last_x, last_y;
|
||||
double start_x = 20,
|
||||
start_y = 20;
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
int axis = libevdev_event_code_from_code_name(axisname);
|
||||
litest_assert_int_ne(axis, -1);
|
||||
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
switch (axis) {
|
||||
case ABS_X:
|
||||
|
|
@ -5321,10 +5318,6 @@ START_TEST(tilt_fixed_points)
|
|||
{ ABS_PRESSURE, 0 },
|
||||
{ -1, -1 }
|
||||
};
|
||||
int axis_value;
|
||||
double expected;
|
||||
|
||||
const char *testcase = litest_test_param_get_string(test_env->params, "tilt");
|
||||
|
||||
/* On devices with a range of [-N, M], make sure we calculate the hw zero position
|
||||
* as zero and that the respective min/max resolve to our (hardcoded) min/max degree
|
||||
|
|
@ -5341,17 +5334,24 @@ START_TEST(tilt_fixed_points)
|
|||
/* see tablet_fix_tilt() */
|
||||
bool is_adjusted = (int)absinfo_range(abs) % 2 == 0;
|
||||
|
||||
if (streq(testcase, "minimum")) {
|
||||
int axis_value;
|
||||
double expected;
|
||||
int testcase = litest_test_param_get_i32(test_env->params, "tilt");
|
||||
switch (testcase) {
|
||||
case TILT_MINIMUM:
|
||||
axis_value = abs->minimum;
|
||||
expected = -64.0;
|
||||
} else if (streq(testcase, "center")) {
|
||||
break;
|
||||
case TILT_CENTER:
|
||||
axis_value = 0;
|
||||
expected = 0.0;
|
||||
} else if (streq(testcase, "maximum")) {
|
||||
break;
|
||||
case TILT_MAXIMUM:
|
||||
axis_value = abs->maximum;
|
||||
expected = 64.0;
|
||||
} else {
|
||||
abort();
|
||||
break;
|
||||
default:
|
||||
litest_abort_msg("Invalid tilt testcase '%d'", testcase);
|
||||
}
|
||||
|
||||
litest_drain_events(li);
|
||||
|
|
@ -7099,7 +7099,7 @@ TEST_COLLECTION(tablet)
|
|||
litest_add(tip_down_motion, LITEST_TABLET|LITEST_HOVER, LITEST_ANY);
|
||||
litest_add(tip_up_motion, LITEST_TABLET|LITEST_HOVER, LITEST_ANY);
|
||||
litest_add(tip_down_up_eraser, LITEST_TABLET|LITEST_HOVER, LITEST_ANY);
|
||||
litest_with_parameters(params, "axis", 's', 2, "ABS_X", "ABS_Y") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
||||
litest_add_parametrized(tip_up_motion_one_axis, LITEST_TABLET|LITEST_HOVER, LITEST_ANY, params);
|
||||
}
|
||||
litest_add(tip_state_proximity, LITEST_TABLET|LITEST_HOVER, LITEST_ANY);
|
||||
|
|
@ -7113,7 +7113,9 @@ TEST_COLLECTION(tablet)
|
|||
litest_add(tilt_not_available, LITEST_TABLET, LITEST_TILT);
|
||||
litest_add(tilt_x, LITEST_TABLET|LITEST_TILT, LITEST_ANY);
|
||||
litest_add(tilt_y, LITEST_TABLET|LITEST_TILT, LITEST_ANY);
|
||||
litest_with_parameters(params, "tilt", 's', 3, "minimum", "maximum", "center") {
|
||||
litest_with_parameters(params, "tilt", 'I', 3, litest_named_i32(TILT_MINIMUM, "minimum"),
|
||||
litest_named_i32(TILT_CENTER, "center"),
|
||||
litest_named_i32(TILT_MAXIMUM, "maximum")) {
|
||||
litest_add_parametrized(tilt_fixed_points, LITEST_TABLET|LITEST_TILT, LITEST_ANY, params);
|
||||
}
|
||||
litest_add(pad_buttons_ignored, LITEST_TABLET, LITEST_TOTEM);
|
||||
|
|
|
|||
|
|
@ -815,10 +815,7 @@ START_TEST(touch_initial_state)
|
|||
struct libinput_event *ev2 = NULL;
|
||||
struct libinput_event_touch *t1, *t2;
|
||||
struct libinput_device *device1, *device2;
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
int axis = libevdev_event_code_from_code_name(axisname);
|
||||
litest_assert_int_ne(axis, -1);
|
||||
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
dev = litest_current_device();
|
||||
device1 = dev->libinput_device;
|
||||
|
|
@ -1365,7 +1362,7 @@ TEST_COLLECTION(touch)
|
|||
litest_add(touch_protocol_a_touch, LITEST_PROTOCOL_A, LITEST_ANY);
|
||||
litest_add(touch_protocol_a_2fg_touch, LITEST_PROTOCOL_A, LITEST_ANY);
|
||||
|
||||
litest_with_parameters(params, "axis", 's', 2, "ABS_X", "ABS_Y") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
||||
litest_add_parametrized(touch_initial_state, LITEST_TOUCH, LITEST_PROTOCOL_A, params);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -254,25 +254,12 @@ START_TEST(touchpad_1fg_clickfinger_no_touch_phantomclicks)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static enum libinput_config_clickfinger_button_map
|
||||
map_param_lookup(const char *arg)
|
||||
{
|
||||
if (streq(arg, "LMR"))
|
||||
return LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR;
|
||||
if (streq(arg, "LRM"))
|
||||
return LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM;
|
||||
|
||||
litest_abort_msg("Invalid map parameter: %s", arg);
|
||||
}
|
||||
|
||||
START_TEST(touchpad_2fg_clickfinger)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
litest_enable_clickfinger(dev);
|
||||
litest_set_clickfinger_map(dev, map);
|
||||
|
|
@ -314,8 +301,7 @@ START_TEST(touchpad_3fg_clickfinger)
|
|||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) < 3)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -363,9 +349,7 @@ START_TEST(touchpad_3fg_clickfinger_btntool)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) >= 3 ||
|
||||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
|
||||
|
|
@ -519,9 +503,7 @@ START_TEST(touchpad_2fg_clickfinger_distance)
|
|||
double w, h;
|
||||
bool small_touchpad = false;
|
||||
unsigned int expected_button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (libinput_device_get_size(dev->libinput_device, &w, &h) == 0 &&
|
||||
h < 50.0)
|
||||
|
|
@ -587,9 +569,7 @@ START_TEST(touchpad_3fg_clickfinger_distance)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) < 3)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -636,9 +616,7 @@ START_TEST(touchpad_3fg_clickfinger_distance_btntool)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_clickfinger_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_clickfinger_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) > 2)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -2271,7 +2249,8 @@ TEST_COLLECTION(touchpad_buttons)
|
|||
litest_add(touchpad_1fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
|
||||
litest_add(touchpad_1fg_clickfinger_no_touch, LITEST_CLICKPAD, LITEST_ANY);
|
||||
|
||||
litest_with_parameters(params, "map", 's', 2, "LRM", "LMR") {
|
||||
litest_with_parameters(params, "map", 'I', 2, litest_named_i32(LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM, "LRM"),
|
||||
litest_named_i32(LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR, "LMR")) {
|
||||
litest_add_parametrized(touchpad_2fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY, params);
|
||||
litest_add_parametrized(touchpad_3fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY, params);
|
||||
litest_add_parametrized(touchpad_3fg_clickfinger_btntool, LITEST_CLICKPAD, LITEST_ANY, params);
|
||||
|
|
|
|||
|
|
@ -2276,17 +2276,6 @@ START_TEST(touchpad_tap_n_drag_draglock_3fg_swipe)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static enum libinput_config_tap_button_map
|
||||
map_param_lookup(const char *arg)
|
||||
{
|
||||
if (streq(arg, "LMR"))
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LMR;
|
||||
if (streq(arg, "LRM"))
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
|
||||
litest_abort_msg("Invalid map parameter: %s", arg);
|
||||
}
|
||||
|
||||
START_TEST(touchpad_2fg_tap)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
|
|
@ -2296,8 +2285,7 @@ START_TEST(touchpad_2fg_tap)
|
|||
struct libinput_event_pointer *ptrev;
|
||||
uint64_t ptime, rtime;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
litest_enable_tap(dev->libinput_device);
|
||||
litest_set_tap_map(dev->libinput_device, map);
|
||||
|
|
@ -2353,8 +2341,7 @@ START_TEST(touchpad_2fg_tap_inverted)
|
|||
struct libinput_event_pointer *ptrev;
|
||||
uint64_t ptime, rtime;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
litest_enable_tap(dev->libinput_device);
|
||||
litest_set_tap_map(dev->libinput_device, map);
|
||||
|
|
@ -2884,8 +2871,7 @@ START_TEST(touchpad_3fg_tap)
|
|||
unsigned int button = 0;
|
||||
int i;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) < 3)
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -3158,8 +3144,7 @@ START_TEST(touchpad_3fg_tap_btntool)
|
|||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) >= 3 ||
|
||||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
|
||||
|
|
@ -3211,8 +3196,7 @@ START_TEST(touchpad_3fg_tap_btntool_inverted)
|
|||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) > 3 ||
|
||||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
|
||||
|
|
@ -3264,8 +3248,7 @@ START_TEST(touchpad_3fg_tap_btntool_pointerjump)
|
|||
struct libinput *li = dev->libinput;
|
||||
unsigned int button = 0;
|
||||
|
||||
const char *mapstr = litest_test_param_get_string(test_env->params, "map");
|
||||
enum libinput_config_tap_button_map map = map_param_lookup(mapstr);
|
||||
enum libinput_config_tap_button_map map = litest_test_param_get_i32(test_env->params, "map");
|
||||
|
||||
if (litest_slot_count(dev) > 3 ||
|
||||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
|
||||
|
|
@ -5743,7 +5726,8 @@ TEST_COLLECTION(touchpad_tap)
|
|||
litest_add(touchpad_5fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
|
||||
litest_add(touchpad_5fg_tap_quickrelease, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
|
||||
|
||||
litest_with_parameters(params, "map", 's', 2, "LRM", "LMR") {
|
||||
litest_with_parameters(params, "map", 'I', 2, litest_named_i32(LIBINPUT_CONFIG_TAP_MAP_LRM, "LRM"),
|
||||
litest_named_i32(LIBINPUT_CONFIG_TAP_MAP_LMR, "LMR")) {
|
||||
litest_add_parametrized(touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT, params);
|
||||
litest_add_parametrized(touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params);
|
||||
litest_add_parametrized(touchpad_3fg_tap_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params);
|
||||
|
|
|
|||
|
|
@ -3617,10 +3617,7 @@ START_TEST(touchpad_initial_state)
|
|||
struct litest_device *dev;
|
||||
struct libinput *libinput1, *libinput2;
|
||||
int x = 40, y = 60;
|
||||
|
||||
const char *axisname = litest_test_param_get_string(test_env->params, "axis");
|
||||
int axis = libevdev_event_code_from_code_name(axisname);
|
||||
litest_assert_int_ne(axis, -1);
|
||||
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
||||
|
||||
dev = litest_current_device();
|
||||
libinput1 = dev->libinput;
|
||||
|
|
@ -6921,29 +6918,12 @@ assert_touchpad_does_not_move(struct litest_device *tp)
|
|||
litest_assert_empty_queue(li);
|
||||
}
|
||||
|
||||
static enum suspend
|
||||
mode_param_lookup(const char *mode)
|
||||
{
|
||||
if (streq(mode, "external_mouse"))
|
||||
return SUSPEND_EXT_MOUSE;
|
||||
else if (streq(mode, "sendevents"))
|
||||
return SUSPEND_SENDEVENTS;
|
||||
else if (streq(mode, "lid"))
|
||||
return SUSPEND_LID;
|
||||
else if (streq(mode, "tabletmode"))
|
||||
return SUSPEND_TABLETMODE;
|
||||
|
||||
litest_abort_msg("Invalid mode parameter: %s", mode);
|
||||
}
|
||||
|
||||
START_TEST(touchpad_suspend_abba)
|
||||
{
|
||||
struct litest_device *tp = litest_current_device();
|
||||
struct litest_device *lid, *tabletmode, *extmouse;
|
||||
struct libinput *li = tp->libinput;
|
||||
|
||||
const char *mode = litest_test_param_get_string(test_env->params, "mode");
|
||||
enum suspend first = mode_param_lookup(mode);
|
||||
enum suspend first = litest_test_param_get_i32(test_env->params, "mode");
|
||||
|
||||
if (first == SUSPEND_EXT_MOUSE && litest_touchpad_is_external(tp))
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -7082,9 +7062,7 @@ START_TEST(touchpad_suspend_abab)
|
|||
struct litest_device *tp = litest_current_device();
|
||||
struct litest_device *lid, *tabletmode, *extmouse;
|
||||
struct libinput *li = tp->libinput;
|
||||
|
||||
const char *mode = litest_test_param_get_string(test_env->params, "mode");
|
||||
enum suspend first = mode_param_lookup(mode);
|
||||
enum suspend first = litest_test_param_get_i32(test_env->params, "mode");
|
||||
|
||||
if (first == SUSPEND_EXT_MOUSE && litest_touchpad_is_external(tp))
|
||||
return LITEST_NOT_APPLICABLE;
|
||||
|
|
@ -7356,7 +7334,7 @@ TEST_COLLECTION(touchpad)
|
|||
litest_add_for_device(touchpad_trackpoint_buttons_2fg_scroll, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
|
||||
litest_add_for_device(touchpad_trackpoint_no_trackpoint, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
|
||||
|
||||
litest_with_parameters(params, "axis", 's', 2, "ABS_X", "ABS_Y") {
|
||||
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
||||
litest_add_parametrized(touchpad_initial_state, LITEST_TOUCHPAD, LITEST_ANY, params);
|
||||
}
|
||||
|
||||
|
|
@ -7402,9 +7380,10 @@ TEST_COLLECTION(touchpad)
|
|||
litest_add(touchpad_speed_ignore_finger_edgescroll, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
|
||||
litest_add_for_device(touchpad_speed_ignore_hovering_finger, LITEST_BCM5974);
|
||||
|
||||
litest_with_parameters(params, "mode", 's', 4,
|
||||
"external_mouse", "sendevents",
|
||||
"lid", "tabletmode") {
|
||||
litest_with_parameters(params, "mode", 'I', 4, litest_named_i32(SUSPEND_EXT_MOUSE, "external_mouse"),
|
||||
litest_named_i32(SUSPEND_SENDEVENTS, "sendevents"),
|
||||
litest_named_i32(SUSPEND_LID, "lid"),
|
||||
litest_named_i32(SUSPEND_TABLETMODE, "tabletmode")) {
|
||||
litest_add_parametrized(touchpad_suspend_abba, LITEST_TOUCHPAD, LITEST_ANY, params);
|
||||
litest_add_parametrized(touchpad_suspend_abab, LITEST_TOUCHPAD, LITEST_ANY, params);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue