summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-03-03 14:01:21 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-03-07 13:10:58 +1000
commitaa96977dc7ff0b44b7d1dcb5bf524c339d4820e5 (patch)
treee9d0f5c642788dbddf3a07d5948164b8aa605106 /test
parent1982daf6b13685cc6568a53b85d62089405963a9 (diff)
test: add tests for wcmCheckSuppress.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Ping Cheng <pinglinux@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/wacom-tests.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/wacom-tests.c b/test/wacom-tests.c
index b8ad63c..23bfba6 100644
--- a/test/wacom-tests.c
+++ b/test/wacom-tests.c
@@ -228,6 +228,92 @@ test_suppress(void)
rc = wcmCheckSuppress(&common, &old, &new);
g_assert(rc == SUPPRESS_ALL);
+
+ /* proximity, buttons and strip send for any change */
+
+#define test_any_suppress(field) \
+ old.field = 1; \
+ rc = wcmCheckSuppress(&common, &old, &new); \
+ g_assert(rc == SUPPRESS_NONE); \
+ new.field = old.field;
+
+ test_any_suppress(proximity);
+ test_any_suppress(buttons);
+ test_any_suppress(stripx);
+ test_any_suppress(stripy);
+
+#undef test_any_suppress
+
+ /* pressure, capacity, throttle, rotation, abswheel only when
+ * difference is above suppress */
+
+ /* test negative and positive transition */
+#define test_above_suppress(field) \
+ old.field = common.wcmSuppress; \
+ rc = wcmCheckSuppress(&common, &old, &new); \
+ g_assert(rc == SUPPRESS_ALL); \
+ old.field = common.wcmSuppress + 1; \
+ rc = wcmCheckSuppress(&common, &old, &new); \
+ g_assert(rc == SUPPRESS_NONE); \
+ old.field = -common.wcmSuppress; \
+ rc = wcmCheckSuppress(&common, &old, &new); \
+ g_assert(rc == SUPPRESS_ALL); \
+ old.field = -common.wcmSuppress - 1; \
+ rc = wcmCheckSuppress(&common, &old, &new); \
+ g_assert(rc == SUPPRESS_NONE); \
+ new.field = old.field;
+
+ test_above_suppress(pressure);
+ test_above_suppress(capacity);
+ test_above_suppress(throttle);
+ test_above_suppress(rotation);
+ test_above_suppress(abswheel);
+
+#undef test_above_suppress
+
+ /* any movement on relwheel counts */
+ new.relwheel = 1;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_NONE);
+ new.relwheel = 0;
+
+ /* x axis movement */
+
+ /* not enough movement */
+ new.x = common.wcmSuppress;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_ALL);
+ g_assert(old.x == new.x);
+ g_assert(old.y == new.y);
+
+ /* only x axis above thresh */
+ new.x = common.wcmSuppress + 1;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_NON_MOTION);
+
+ /* x and other field above thres */
+ new.pressure = ~old.pressure;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_NONE);
+
+ new.pressure = old.pressure;
+ new.x = old.x;
+
+ /* y axis movement */
+ new.y = common.wcmSuppress;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_ALL);
+ g_assert(old.x == new.x);
+ g_assert(old.y == new.y);
+
+ new.y = common.wcmSuppress + 1;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_NON_MOTION);
+
+ new.pressure = ~old.pressure;
+ rc = wcmCheckSuppress(&common, &old, &new);
+ g_assert(rc == SUPPRESS_NONE);
+ new.pressure = old.pressure;
}
int main(int argc, char** argv)