Commit 164a6a81 authored by Peter Hutterer's avatar Peter Hutterer

test: fix an intermitted failing test

The touchpad_2fg_scroll_initially_diagonal test would semi-reliably fail under
valgrind but succeed otherwise. Cause was that on some devices, the initial
diagonal movement wasn't diagonal enough and closer to a horizontal movement.
This was fine on normal runs, but under valgrind we'd hit the "active
threshold" time limit and lock to horizontal scrolling, ditching the remaining
events and failing the test.

Fix this by calculating the scroll vector based on the device's width/height
ratio and go "more diagonal" on the initial vector.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 383a60ab
......@@ -173,10 +173,15 @@ START_TEST(touchpad_2fg_scroll_initially_diagonal)
struct libinput_event_pointer *ptrev;
int i;
int expected_nevents;
double w, h;
double ratio;
double ydelta;
if (!litest_has_2fg_scroll(dev))
return;
ck_assert_int_eq(libinput_device_get_size(dev->libinput_device, &w, &h), 0);
ratio = w/h;
litest_enable_2fg_scroll(dev);
litest_drain_events(li);
......@@ -184,7 +189,8 @@ START_TEST(touchpad_2fg_scroll_initially_diagonal)
litest_touch_down(dev, 1, 55, 30);
/* start diagonally */
litest_touch_move_two_touches(dev, 45, 30, 55, 30, 10, 10, 10);
ydelta = 15 * ratio;
litest_touch_move_two_touches(dev, 45, 30, 55, 30, 15, ydelta, 10);
libinput_dispatch(li);
litest_wait_for_event_of_type(li,
LIBINPUT_EVENT_POINTER_AXIS,
......@@ -193,13 +199,13 @@ START_TEST(touchpad_2fg_scroll_initially_diagonal)
/* get rid of any touch history still adding x deltas sideways */
for (i = 0; i < 5; i++)
litest_touch_move(dev, 0, 55, 41 + i);
litest_touch_move(dev, 0, 60, 30 + ydelta + (i * ratio));
litest_drain_events(li);
/* scroll vertical only and make sure the horiz axis is never set */
expected_nevents = 0;
for (i = 6; i < 10; i++) {
litest_touch_move(dev, 0, 55, 41 + i);
for (i = 6; i < 15; i++) {
litest_touch_move(dev, 0, 60, 30 + ydelta + i * ratio);
expected_nevents++;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment