summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-03-01 15:05:05 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-03-02 11:16:55 +1000
commit1f0cfe5dd48eec52c495c5777d20758563318783 (patch)
tree74657a97f7f6f48f1b3efe2a8a0359c1fc5cdb35 /test
parent82e65fc52d497b57dab4bcd008ee64f9f7f08796 (diff)
test: add basic check that the tool is initialized correctly.
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.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/wacom-tests.c b/test/wacom-tests.c
index 6de4940..1497516 100644
--- a/test/wacom-tests.c
+++ b/test/wacom-tests.c
@@ -134,12 +134,73 @@ test_normalize_pressure(void)
}
}
+/**
+ * After a call to wcmInitialToolSize, the min/max and resolution must be
+ * set up correctly.
+ *
+ * wcmInitialToolSize takes the data from the common rec, so test that the
+ * priv has all the values of the common.
+ */
+static void
+test_initial_size(void)
+{
+ InputInfoRec info = {0};
+ WacomDeviceRec priv = {0};
+ WacomCommonRec common = {0};
+
+ int minx, maxx, miny, maxy, xres, yres;
+
+ info.private = &priv;
+ priv.common = &common;
+
+ /* FIXME: we currently assume min of 0 in the driver. we cannot cope
+ * with non-zero devices */
+ minx = miny = 0;
+
+ common.wcmMaxX = maxx;
+ common.wcmMaxY = maxy;
+ common.wcmResolX = xres;
+ common.wcmResolY = yres;
+
+ wcmInitialToolSize(&info);
+
+ g_assert(priv.topX == minx);
+ g_assert(priv.topY == minx);
+ g_assert(priv.bottomX == maxx);
+ g_assert(priv.bottomY == maxy);
+ g_assert(priv.resolX == xres);
+ g_assert(priv.resolY == yres);
+
+ /* Same thing for a touch-enabled device */
+ memset(&common, 0, sizeof(common));
+
+ priv.flags = TOUCH_ID;
+ g_assert(IsTouch(&priv));
+
+ common.wcmMaxTouchX = maxx;
+ common.wcmMaxTouchY = maxy;
+ common.wcmTouchResolX = xres;
+ common.wcmTouchResolY = yres;
+
+ wcmInitialToolSize(&info);
+
+ g_assert(priv.topX == minx);
+ g_assert(priv.topY == minx);
+ g_assert(priv.bottomX == maxx);
+ g_assert(priv.bottomY == maxy);
+ g_assert(priv.resolX == xres);
+ g_assert(priv.resolY == yres);
+
+}
+
+
int main(int argc, char** argv)
{
g_test_init(&argc, &argv, NULL);
g_test_add_func("/common/refcounting", test_common_ref);
g_test_add_func("/common/rebase_pressure", test_rebase_pressure);
g_test_add_func("/common/normalize_pressure", test_normalize_pressure);
+ g_test_add_func("/xfree86/initial_size", test_initial_size);
return g_test_run();
}