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>
This commit is contained in:
parent
8b9b4387e8
commit
1338bfa81c
31
test/touch.c
31
test/touch.c
|
@ -58,9 +58,8 @@ touch_grow_queue(void)
|
||||||
dev.last.touches[i].client_id = i * 2;
|
dev.last.touches[i].client_id = i * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no more space, should've scheduled a workproc */
|
/* no more space, should've reallocated and succeeded */
|
||||||
assert(TouchBeginDDXTouch(&dev, 1234) == NULL);
|
assert(TouchBeginDDXTouch(&dev, 1234) != NULL);
|
||||||
ProcessWorkQueue();
|
|
||||||
|
|
||||||
new_size = size + size / 2 + 1;
|
new_size = size + size / 2 + 1;
|
||||||
assert(dev.last.num_touches == new_size);
|
assert(dev.last.num_touches == new_size);
|
||||||
|
@ -74,8 +73,12 @@ touch_grow_queue(void)
|
||||||
assert(t->client_id == i * 2);
|
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 */
|
/* 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];
|
DDXTouchPointInfoPtr t = &dev.last.touches[i];
|
||||||
|
|
||||||
assert(t->active == FALSE);
|
assert(t->active == FALSE);
|
||||||
|
@ -90,7 +93,7 @@ static void
|
||||||
touch_find_ddxid(void)
|
touch_find_ddxid(void)
|
||||||
{
|
{
|
||||||
DeviceIntRec dev;
|
DeviceIntRec dev;
|
||||||
DDXTouchPointInfoPtr ti;
|
DDXTouchPointInfoPtr ti, ti2;
|
||||||
ValuatorClassRec val;
|
ValuatorClassRec val;
|
||||||
TouchClassRec touch;
|
TouchClassRec touch;
|
||||||
int size = 5;
|
int size = 5;
|
||||||
|
@ -136,22 +139,20 @@ touch_find_ddxid(void)
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
dev.last.touches[i].active = TRUE;
|
dev.last.touches[i].active = TRUE;
|
||||||
|
|
||||||
/* Try to create more, fail */
|
/* Try to create more, succeed */
|
||||||
ti = TouchFindByDDXID(&dev, 30, TRUE);
|
ti = TouchFindByDDXID(&dev, 30, TRUE);
|
||||||
assert(ti == NULL);
|
assert(ti != NULL);
|
||||||
ti = TouchFindByDDXID(&dev, 30, TRUE);
|
ti2 = TouchFindByDDXID(&dev, 30, TRUE);
|
||||||
assert(ti == NULL);
|
assert(ti == ti);
|
||||||
/* make sure we haven't resized, we're in the signal handler */
|
/* make sure we have resized */
|
||||||
assert(dev.last.num_touches == size);
|
assert(dev.last.num_touches == 8); /* EQ grows from 5 to 8 */
|
||||||
|
|
||||||
/* stop one touchpoint, try to create, succeed */
|
/* stop one touchpoint, try to create, succeed */
|
||||||
dev.last.touches[2].active = FALSE;
|
dev.last.touches[2].active = FALSE;
|
||||||
ti = TouchFindByDDXID(&dev, 30, TRUE);
|
ti = TouchFindByDDXID(&dev, 35, TRUE);
|
||||||
assert(ti == &dev.last.touches[2]);
|
assert(ti == &dev.last.touches[2]);
|
||||||
/* but still grow anyway */
|
|
||||||
ProcessWorkQueue();
|
|
||||||
ti = TouchFindByDDXID(&dev, 40, TRUE);
|
ti = TouchFindByDDXID(&dev, 40, TRUE);
|
||||||
assert(ti == &dev.last.touches[size]);
|
assert(ti == &dev.last.touches[size+1]);
|
||||||
|
|
||||||
free(dev.name);
|
free(dev.name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue