[PATCH libinput 1/3] test: widen litest to use doubles for scaled variables

Peter Hutterer peter.hutterer at who-t.net
Fri Jul 18 00:01:02 PDT 2014


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 at who-t.net>
---
 test/litest-int.h |  2 +-
 test/litest.c     | 15 +++++++++------
 test/litest.h     | 12 ++++++------
 test/touchpad.c   |  4 ++--
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/test/litest-int.h b/test/litest-int.h
index 19e6e68..581930b 100644
--- a/test/litest-int.h
+++ b/test/litest-int.h
@@ -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
diff --git a/test/litest.c b/test/litest.c
index adcbf3e..452cb77 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -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);
diff --git a/test/litest.h b/test/litest.h
index 3e75dd5..2363c7f 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -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,
diff --git a/test/touchpad.c b/test/touchpad.c
index b7b31d6..5a19e05 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -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, 100);
 	litest_assert_empty_queue(li);
 }
 END_TEST
-- 
1.9.3



More information about the wayland-devel mailing list