[PATCH libinput 2/3] test: switch the abs ranged tests over to real ranged tests

Peter Hutterer peter.hutterer at who-t.net
Tue May 5 17:17:07 PDT 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/device.c | 57 +++++++++++++--------------------------------------------
 1 file changed, 13 insertions(+), 44 deletions(-)

diff --git a/test/device.c b/test/device.c
index 1c277ba..b580e00 100644
--- a/test/device.c
+++ b/test/device.c
@@ -831,50 +831,22 @@ assert_device_ignored(struct libinput *li, struct input_absinfo *absinfo)
 	libevdev_uinput_destroy(uinput);
 }
 
-START_TEST(abs_device_no_range_lo)
+START_TEST(abs_device_no_range)
 {
 	struct libinput *li;
-	int code;
+	int code = _i; /* looped test */
 	/* set x/y so libinput doesn't just reject for missing axes */
 	struct input_absinfo absinfo[] = {
 		{ ABS_X, 0, 10, 0, 0, 0 },
 		{ ABS_Y, 0, 10, 0, 0, 0 },
-		{ -1, 0, 0, 0, 0, 0 },
+		{ code, 0, 0, 0, 0, 0 },
 		{ -1, -1, -1, -1, -1, -1 }
 	};
 
 	li = litest_create_context();
 	litest_disable_log_handler(li);
 
-	for (code = 0; code < ABS_MISC/2; code++) {
-		absinfo[2].value = code;
-		assert_device_ignored(li, absinfo);
-	}
-
-	litest_restore_log_handler(li);
-	libinput_unref(li);
-}
-END_TEST
-
-START_TEST(abs_device_no_range_hi)
-{
-	struct libinput *li;
-	int code;
-	/* set x/y so libinput doesn't just reject for missing axes */
-	struct input_absinfo absinfo[] = {
-		{ ABS_X, 0, 10, 0, 0, 0 },
-		{ ABS_Y, 0, 10, 0, 0, 0 },
-		{ -1, 0, 0, 0, 0, 0 },
-		{ -1, -1, -1, -1, -1, -1 }
-	};
-
-	li = litest_create_context();
-	litest_disable_log_handler(li);
-
-	for (code = ABS_MISC/2; code < ABS_MISC; code++) {
-		absinfo[2].value = code;
-		assert_device_ignored(li, absinfo);
-	}
+	assert_device_ignored(li, absinfo);
 
 	litest_restore_log_handler(li);
 	libinput_unref(li);
@@ -884,7 +856,7 @@ END_TEST
 START_TEST(abs_mt_device_no_range)
 {
 	struct libinput *li;
-	int code;
+	int code = _i; /* looped test */
 	/* set x/y so libinput doesn't just reject for missing axes */
 	struct input_absinfo absinfo[] = {
 		{ ABS_X, 0, 10, 0, 0, 0 },
@@ -893,21 +865,16 @@ START_TEST(abs_mt_device_no_range)
 		{ ABS_MT_TRACKING_ID, 0, 255, 0, 0, 0 },
 		{ ABS_MT_POSITION_X, 0, 10, 0, 0, 0 },
 		{ ABS_MT_POSITION_Y, 0, 10, 0, 0, 0 },
-		{ -1, 0, 0, 0, 0, 0 },
+		{ code, 0, 0, 0, 0, 0 },
 		{ -1, -1, -1, -1, -1, -1 }
 	};
 
 	li = litest_create_context();
 	litest_disable_log_handler(li);
 
-	for (code = ABS_MT_SLOT + 1; code < ABS_CNT; code++) {
-		if (code == ABS_MT_TOOL_TYPE ||
-		    code == ABS_MT_TRACKING_ID) /* kernel overrides it */
-			continue;
-
-		absinfo[6].value = code;
+	if (code != ABS_MT_TOOL_TYPE &&
+	    code != ABS_MT_TRACKING_ID) /* kernel overrides it */
 		assert_device_ignored(li, absinfo);
-	}
 
 	litest_restore_log_handler(li);
 	libinput_unref(li);
@@ -978,6 +945,9 @@ END_TEST
 
 int main (int argc, char **argv)
 {
+	struct range abs_range = { 0, ABS_MISC };
+	struct range abs_mt_range = { ABS_MT_SLOT + 1, ABS_CNT };
+
 	litest_add("device:sendevents", device_sendevents_config, LITEST_ANY, LITEST_TOUCHPAD);
 	litest_add("device:sendevents", device_sendevents_config_invalid, LITEST_ANY, LITEST_ANY);
 	litest_add("device:sendevents", device_sendevents_config_touchpad, LITEST_TOUCHPAD, LITEST_ANY);
@@ -1008,9 +978,8 @@ int main (int argc, char **argv)
 	litest_add_no_device("device:invalid devices", abs_device_no_absy);
 	litest_add_no_device("device:invalid devices", abs_mt_device_no_absx);
 	litest_add_no_device("device:invalid devices", abs_mt_device_no_absy);
-	litest_add_no_device("device:invalid devices", abs_device_no_range_hi);
-	litest_add_no_device("device:invalid devices", abs_device_no_range_lo);
-	litest_add_no_device("device:invalid devices", abs_mt_device_no_range);
+	litest_add_ranged_no_device("device:invalid devices", abs_device_no_range, &abs_range);
+	litest_add_ranged_no_device("device:invalid devices", abs_mt_device_no_range, &abs_mt_range);
 	litest_add_no_device("device:invalid devices", abs_device_missing_res);
 	litest_add_no_device("device:invalid devices", abs_mt_device_missing_res);
 
-- 
2.3.5



More information about the wayland-devel mailing list