mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 13:50:15 +01:00
test: widen litest to use doubles for scaled variables
Using a 0-100% range is useful but in some cases we need events with finer than 1% granularity. And fix up the two-finger test that now fails. This was a bug in the test anyway, the dx/dy supplied here was 1% of the touchpad width. Confined to integers this meant we only ever had the touch down, then the single move by 1%. That caused two events - not enough to satisfy tp_estimate_delta, so we always had a delta of 0/0 regardless of the size of the move. Now with doubles this fails, so drop it to 0.1% instead, which is small enough on all touchpads we currently have. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
8665e3678a
commit
489630f58b
4 changed files with 18 additions and 15 deletions
|
|
@ -93,7 +93,7 @@ struct litest_device_interface {
|
|||
};
|
||||
|
||||
void litest_set_current_device(struct litest_device *device);
|
||||
int litest_scale(const struct litest_device *d, unsigned int axis, int val);
|
||||
int litest_scale(const struct litest_device *d, unsigned int axis, double val);
|
||||
void litest_generic_device_teardown(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ litest_event(struct litest_device *d, unsigned int type,
|
|||
static int
|
||||
auto_assign_value(struct litest_device *d,
|
||||
const struct input_event *ev,
|
||||
int slot, int x, int y)
|
||||
int slot, double x, double y)
|
||||
{
|
||||
static int tracking_id;
|
||||
int value = ev->value;
|
||||
|
|
@ -625,7 +625,8 @@ auto_assign_value(struct litest_device *d,
|
|||
|
||||
|
||||
void
|
||||
litest_touch_down(struct litest_device *d, unsigned int slot, int x, int y)
|
||||
litest_touch_down(struct litest_device *d, unsigned int slot,
|
||||
double x, double y)
|
||||
{
|
||||
struct input_event *ev;
|
||||
|
||||
|
|
@ -669,7 +670,8 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
|
|||
}
|
||||
|
||||
void
|
||||
litest_touch_move(struct litest_device *d, unsigned int slot, int x, int y)
|
||||
litest_touch_move(struct litest_device *d, unsigned int slot,
|
||||
double x, double y)
|
||||
{
|
||||
struct input_event *ev;
|
||||
|
||||
|
|
@ -689,8 +691,8 @@ litest_touch_move(struct litest_device *d, unsigned int slot, int x, int y)
|
|||
void
|
||||
litest_touch_move_to(struct litest_device *d,
|
||||
unsigned int slot,
|
||||
int x_from, int y_from,
|
||||
int x_to, int y_to,
|
||||
double x_from, double y_from,
|
||||
double x_to, double y_to,
|
||||
int steps)
|
||||
{
|
||||
for (int i = 0; i < steps - 1; i++)
|
||||
|
|
@ -720,7 +722,8 @@ litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
|
|||
litest_button_click(d, key, is_press);
|
||||
}
|
||||
|
||||
int litest_scale(const struct litest_device *d, unsigned int axis, int val)
|
||||
int
|
||||
litest_scale(const struct litest_device *d, unsigned int axis, double val)
|
||||
{
|
||||
int min, max;
|
||||
ck_assert_int_ge(val, 0);
|
||||
|
|
|
|||
|
|
@ -108,16 +108,16 @@ void litest_event(struct litest_device *t,
|
|||
void litest_touch_up(struct litest_device *d, unsigned int slot);
|
||||
void litest_touch_move(struct litest_device *d,
|
||||
unsigned int slot,
|
||||
int x,
|
||||
int y);
|
||||
double x,
|
||||
double y);
|
||||
void litest_touch_down(struct litest_device *d,
|
||||
unsigned int slot,
|
||||
int x,
|
||||
int y);
|
||||
double x,
|
||||
double y);
|
||||
void litest_touch_move_to(struct litest_device *d,
|
||||
unsigned int slot,
|
||||
int x_from, int y_from,
|
||||
int x_to, int y_to,
|
||||
double x_from, double y_from,
|
||||
double x_to, double y_to,
|
||||
int steps);
|
||||
void litest_button_click(struct litest_device *d,
|
||||
unsigned int button,
|
||||
|
|
|
|||
|
|
@ -1127,7 +1127,7 @@ START_TEST(clickpad_topsoftbuttons_move_out_ignore)
|
|||
END_TEST
|
||||
|
||||
static void
|
||||
test_2fg_scroll(struct litest_device *dev, int dx, int dy, int sleep)
|
||||
test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep)
|
||||
{
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
|
|
@ -1210,7 +1210,7 @@ START_TEST(touchpad_2fg_scroll)
|
|||
check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
|
||||
|
||||
/* 2fg scroll smaller than the threshold should not generate events */
|
||||
test_2fg_scroll(dev, 1, 1, 200);
|
||||
test_2fg_scroll(dev, 0.1, 0.1, 200);
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue