summaryrefslogtreecommitdiff
path: root/test/touch.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-27 01:56:39 -0700
committerKeith Packard <keithp@keithp.com>2016-05-29 18:35:29 -0700
commit1338bfa81c6eddc66f07c15225c3feff062182ce (patch)
tree4335579f8a41babfdfad9b0e2fb904e0ff1e7873 /test/touch.c
parent8b9b4387e8473810f6174519ee76818fcaae725d (diff)
test: Make touch test reflect new ability to realloc touch array [v2]
Threaded input allows the input code to call malloc while processing events. In this case, that's in the middle of processing touch events and needing to resize the touch buffer. This test was expecting the old behaviour where touch points would get dropped if the buffer was full. The fix is to check for the new behaviour instead. [v2] * make sure two finding two equivalent touches return the same touch object * check to make sure the queue resizes by the expected amount Changes provided by Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/touch.c')
-rw-r--r--test/touch.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/test/touch.c b/test/touch.c
index 981c694b6..1364d615c 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -58,9 +58,8 @@ touch_grow_queue(void)
dev.last.touches[i].client_id = i * 2;
}
- /* no more space, should've scheduled a workproc */
- assert(TouchBeginDDXTouch(&dev, 1234) == NULL);
- ProcessWorkQueue();
+ /* no more space, should've reallocated and succeeded */
+ assert(TouchBeginDDXTouch(&dev, 1234) != NULL);
new_size = size + size / 2 + 1;
assert(dev.last.num_touches == new_size);
@@ -74,8 +73,12 @@ touch_grow_queue(void)
assert(t->client_id == i * 2);
}
+ assert(dev.last.touches[size].active == TRUE);
+ assert(dev.last.touches[size].ddx_id == 1234);
+ assert(dev.last.touches[size].client_id == 1);
+
/* make sure those are zero-initialized */
- for (i = size; i < new_size; i++) {
+ for (i = size + 1; i < new_size; i++) {
DDXTouchPointInfoPtr t = &dev.last.touches[i];
assert(t->active == FALSE);
@@ -90,7 +93,7 @@ static void
touch_find_ddxid(void)
{
DeviceIntRec dev;
- DDXTouchPointInfoPtr ti;
+ DDXTouchPointInfoPtr ti, ti2;
ValuatorClassRec val;
TouchClassRec touch;
int size = 5;
@@ -136,22 +139,20 @@ touch_find_ddxid(void)
for (i = 0; i < size; i++)
dev.last.touches[i].active = TRUE;
- /* Try to create more, fail */
- ti = TouchFindByDDXID(&dev, 30, TRUE);
- assert(ti == NULL);
+ /* Try to create more, succeed */
ti = TouchFindByDDXID(&dev, 30, TRUE);
- assert(ti == NULL);
- /* make sure we haven't resized, we're in the signal handler */
- assert(dev.last.num_touches == size);
+ assert(ti != NULL);
+ ti2 = TouchFindByDDXID(&dev, 30, TRUE);
+ assert(ti == ti);
+ /* make sure we have resized */
+ assert(dev.last.num_touches == 8); /* EQ grows from 5 to 8 */
/* stop one touchpoint, try to create, succeed */
dev.last.touches[2].active = FALSE;
- ti = TouchFindByDDXID(&dev, 30, TRUE);
+ ti = TouchFindByDDXID(&dev, 35, TRUE);
assert(ti == &dev.last.touches[2]);
- /* but still grow anyway */
- ProcessWorkQueue();
ti = TouchFindByDDXID(&dev, 40, TRUE);
- assert(ti == &dev.last.touches[size]);
+ assert(ti == &dev.last.touches[size+1]);
free(dev.name);
}