mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-07 10:00:14 +01:00
test: add tip down/up helper functions
Add two helper functions that set/unset BTN_TOUCH together with the specified axes and switch all tests over. Devices can override the tip down/up sequence. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
35c5ef4e30
commit
878d00b0e9
4 changed files with 78 additions and 111 deletions
|
|
@ -119,6 +119,12 @@ struct litest_device_interface {
|
|||
double x, double y,
|
||||
struct axis_replacement *axes);
|
||||
bool (*tablet_proximity_out)(struct litest_device *d, unsigned int tool_type);
|
||||
bool (*tablet_tip_down)(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes);
|
||||
bool (*tablet_tip_up)(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes);
|
||||
|
||||
/**
|
||||
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
||||
|
|
|
|||
|
|
@ -2541,6 +2541,36 @@ litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacem
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
litest_tablet_tip_down(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes)
|
||||
{
|
||||
/* If the test device overrides tip_down and says it didn't
|
||||
* handle the event, let's continue normally */
|
||||
if (d->interface->tablet_tip_down &&
|
||||
d->interface->tablet_tip_down(d, x, y, axes))
|
||||
return;
|
||||
|
||||
litest_event(d, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_tablet_motion(d, x, y, axes);
|
||||
}
|
||||
|
||||
void
|
||||
litest_tablet_tip_up(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes)
|
||||
{
|
||||
/* If the test device overrides tip_down and says it didn't
|
||||
* handle the event, let's continue normally */
|
||||
if (d->interface->tablet_tip_up &&
|
||||
d->interface->tablet_tip_up(d, x, y, axes))
|
||||
return;
|
||||
|
||||
litest_event(d, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_tablet_motion(d, x, y, axes);
|
||||
}
|
||||
|
||||
void
|
||||
litest_touch_move_two_touches(struct litest_device *d,
|
||||
double x0, double y0,
|
||||
|
|
|
|||
|
|
@ -629,6 +629,16 @@ litest_tablet_proximity_in(struct litest_device *d,
|
|||
void
|
||||
litest_tablet_proximity_out(struct litest_device *d);
|
||||
|
||||
void
|
||||
litest_tablet_tip_down(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes);
|
||||
|
||||
void
|
||||
litest_tablet_tip_up(struct litest_device *d,
|
||||
int x, int y,
|
||||
struct axis_replacement *axes);
|
||||
|
||||
void
|
||||
litest_tablet_motion(struct litest_device *d,
|
||||
int x, int y,
|
||||
|
|
|
|||
|
|
@ -223,10 +223,7 @@ START_TEST(tip_down_up)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
|
|
@ -240,10 +237,7 @@ START_TEST(tip_down_up)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 10);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 10, 10, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -274,8 +268,7 @@ START_TEST(tip_down_prox_in)
|
|||
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_proximity_in(dev, 10, 10, axes);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
|
@ -311,15 +304,13 @@ START_TEST(tip_up_prox_out)
|
|||
};
|
||||
|
||||
litest_tablet_proximity_in(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 30);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_tablet_tip_up(dev, 10, 10, axes);
|
||||
litest_tablet_proximity_out(dev);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
|
|
@ -357,19 +348,15 @@ START_TEST(tip_up_btn_change)
|
|||
{ -1, -1 }
|
||||
};
|
||||
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_proximity_in(dev, 10, 10, axes);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 30);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 20, axes);
|
||||
litest_tablet_tip_up(dev, 10, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_STYLUS, 1);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
|
@ -394,18 +381,14 @@ START_TEST(tip_up_btn_change)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
/* same thing with a release at tip-up */
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 30);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_tablet_tip_up(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_STYLUS, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
|
|
@ -449,9 +432,8 @@ START_TEST(tip_down_btn_change)
|
|||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 20, axes);
|
||||
litest_tablet_tip_down(dev, 10, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_STYLUS, 1);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
|
@ -477,18 +459,14 @@ START_TEST(tip_down_btn_change)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 30);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 10, 20, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
/* same thing with a release at tip-down */
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_tablet_tip_down(dev, 10, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_STYLUS, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
|
|
@ -542,11 +520,7 @@ START_TEST(tip_down_motion)
|
|||
/* move x/y on tip down, make sure x/y changed */
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 20);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -583,11 +557,7 @@ START_TEST(tip_up_motion)
|
|||
litest_drain_events(li);
|
||||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 20);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -599,10 +569,7 @@ START_TEST(tip_up_motion)
|
|||
|
||||
/* move x/y on tip up, make sure x/y changed */
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 40, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 40, 40, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -656,11 +623,7 @@ START_TEST(tip_up_motion_one_axis)
|
|||
litest_tablet_proximity_in(dev, start_x, start_y, axes);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 20);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, start_x, start_y, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, start_x, start_y, axes);
|
||||
|
||||
switch (axis) {
|
||||
case ABS_X:
|
||||
|
|
@ -685,17 +648,14 @@ START_TEST(tip_up_motion_one_axis)
|
|||
|
||||
/* move x on tip up, make sure x/y changed */
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
switch (axis) {
|
||||
case ABS_X:
|
||||
litest_tablet_motion(dev, 40, 20, axes);
|
||||
litest_tablet_tip_up(dev, 40, 20, axes);
|
||||
break;
|
||||
case ABS_Y:
|
||||
litest_tablet_motion(dev, 20, 40, axes);
|
||||
litest_tablet_tip_up(dev, 20, 40, axes);
|
||||
break;
|
||||
}
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -753,17 +713,11 @@ START_TEST(tip_state_proximity)
|
|||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 10);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 10, 10, axes);
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
|
|
@ -809,10 +763,7 @@ START_TEST(tip_state_axis)
|
|||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 40, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 40, 40, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_tablet_motion(dev, 30, 30, axes);
|
||||
|
|
@ -827,10 +778,7 @@ START_TEST(tip_state_axis)
|
|||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 10);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 40, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 40, 40, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_tablet_motion(dev, 40, 80, axes);
|
||||
|
|
@ -875,10 +823,7 @@ START_TEST(tip_state_button)
|
|||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 40, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 40, 40, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_button_click(dev, button, false);
|
||||
|
|
@ -893,10 +838,7 @@ START_TEST(tip_state_button)
|
|||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 10);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 40, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 40, 40, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_button_click(dev, button, true);
|
||||
|
|
@ -940,10 +882,7 @@ START_TEST(tip_up_on_delete)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 10, 10, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 10, 10, axes);
|
||||
|
||||
litest_drain_events(li);
|
||||
litest_delete_device(dev);
|
||||
|
|
@ -3834,10 +3773,7 @@ START_TEST(tablet_pressure_offset)
|
|||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 25);
|
||||
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
libinput_dispatch(li);
|
||||
litest_drain_events(li);
|
||||
|
||||
|
|
@ -3928,10 +3864,7 @@ START_TEST(tablet_pressure_offset_decrease)
|
|||
|
||||
/* trigger the pressure threshold */
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 15);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
libinput_dispatch(li);
|
||||
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -3972,10 +3905,7 @@ START_TEST(tablet_pressure_offset_increase)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 31);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
libinput_dispatch(li);
|
||||
litest_drain_events(li);
|
||||
|
||||
|
|
@ -4162,7 +4092,7 @@ START_TEST(tablet_pressure_offset_none_for_zero_distance)
|
|||
* offset the pressure here */
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_proximity_in(dev, 5, 100, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_tablet_tip_down(dev, 5, 100, axes);
|
||||
litest_pop_event_frame(dev);
|
||||
libinput_dispatch(li);
|
||||
|
||||
|
|
@ -4197,10 +4127,7 @@ START_TEST(tablet_pressure_offset_none_for_small_distance)
|
|||
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 21);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 70, 70, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 70, 70, axes);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 20);
|
||||
|
|
@ -4626,10 +4553,7 @@ START_TEST(relative_no_delta_on_tip)
|
|||
/* tip down */
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 0);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 30);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 30, 20, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_down(dev, 30, 20, axes);
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
|
|
@ -4658,10 +4582,7 @@ START_TEST(relative_no_delta_on_tip)
|
|||
/* tip up */
|
||||
litest_axis_set_value(axes, ABS_DISTANCE, 10);
|
||||
litest_axis_set_value(axes, ABS_PRESSURE, 0);
|
||||
litest_push_event_frame(dev);
|
||||
litest_tablet_motion(dev, 50, 40, axes);
|
||||
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
|
||||
litest_pop_event_frame(dev);
|
||||
litest_tablet_tip_up(dev, 50, 40, axes);
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
tev = litest_is_tablet_event(event,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue