mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-03 20:40:28 +01:00
test: add tests for multiple regions
Adds the test for
commit 0f81114544 ("Fix region check for devices with multiple regions")
This commit is contained in:
parent
e411b85a33
commit
9f82bbf344
1 changed files with 202 additions and 0 deletions
|
|
@ -591,6 +591,208 @@ MUNIT_TEST(test_ei_device_regions)
|
|||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
/* Same test as test_ei_device_regions_touch but for absmotion */
|
||||
MUNIT_TEST(test_ei_device_regions_absmotion)
|
||||
{
|
||||
_unref_(peck) *peck = peck_new();
|
||||
|
||||
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
|
||||
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
|
||||
|
||||
/* nothing cares about the actual values, so we're just
|
||||
* checking for correct passthrough here */
|
||||
_unref_(eis_region) *r1 = eis_device_new_region(device);
|
||||
eis_region_set_size(r1, 100, 200);
|
||||
eis_region_set_offset(r1, 300, 400);
|
||||
eis_region_add(r1);
|
||||
|
||||
_unref_(eis_region) *r2 = eis_device_new_region(device);
|
||||
eis_region_set_size(r2, 500, 600);
|
||||
eis_region_set_offset(r2, 700, 800);
|
||||
eis_region_add(r2);
|
||||
|
||||
_unref_(eis_region) *r3 = eis_device_new_region(device);
|
||||
eis_region_set_size(r3, 900, 1000);
|
||||
eis_region_set_offset(r3, 1100, 1200);
|
||||
eis_region_add(r3);
|
||||
|
||||
eis_device_add(device);
|
||||
eis_device_resume(device);
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
struct ei_device *device = peck_ei_get_default_pointer_absolute(peck);
|
||||
ei_device_start_emulating(device, 0);
|
||||
/* valid */
|
||||
ei_device_pointer_motion_absolute(device, 301, 401);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
ei_device_pointer_motion_absolute(device, 401, 401);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* valid */
|
||||
ei_device_pointer_motion_absolute(device, 701, 801);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
ei_device_pointer_motion_absolute(device, 1201, 801);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* valid */
|
||||
ei_device_pointer_motion_absolute(device, 1101, 1201);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
ei_device_pointer_motion_absolute(device, 2000, 1201);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
_unref_(eis_event) *e1 = peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_x(e1), 301, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_y(e1), 401, 2 /* precision */);
|
||||
|
||||
_unref_(eis_event) *e2 = peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_x(e2), 701, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_y(e2), 801, 2 /* precision */);
|
||||
|
||||
_unref_(eis_event) *e3 = peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_x(e3), 1101, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_pointer_get_absolute_y(e3), 1201, 2 /* precision */);
|
||||
|
||||
peck_assert_no_eis_events(eis);
|
||||
}
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
/* Same test as test_ei_device_regions_absmotion but for touch */
|
||||
MUNIT_TEST(test_ei_device_regions_touch)
|
||||
{
|
||||
_unref_(peck) *peck = peck_new();
|
||||
|
||||
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
|
||||
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_TOUCH);
|
||||
|
||||
/* nothing cares about the actual values, so we're just
|
||||
* checking for correct passthrough here */
|
||||
_unref_(eis_region) *r1 = eis_device_new_region(device);
|
||||
eis_region_set_size(r1, 100, 200);
|
||||
eis_region_set_offset(r1, 300, 400);
|
||||
eis_region_add(r1);
|
||||
|
||||
_unref_(eis_region) *r2 = eis_device_new_region(device);
|
||||
eis_region_set_size(r2, 500, 600);
|
||||
eis_region_set_offset(r2, 700, 800);
|
||||
eis_region_add(r2);
|
||||
|
||||
_unref_(eis_region) *r3 = eis_device_new_region(device);
|
||||
eis_region_set_size(r3, 900, 1000);
|
||||
eis_region_set_offset(r3, 1100, 1200);
|
||||
eis_region_add(r3);
|
||||
|
||||
eis_device_add(device);
|
||||
eis_device_resume(device);
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
struct ei_device *device = peck_ei_get_default_touch(peck);
|
||||
ei_device_start_emulating(device, 0);
|
||||
|
||||
/* valid */
|
||||
_unref_(ei_touch) *t1 = ei_device_touch_new(device);
|
||||
ei_touch_down(t1, 301, 401);
|
||||
ei_touch_up(t1);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
_unref_(ei_touch) *t2 = ei_device_touch_new(device);
|
||||
peck_ei_disable_fatal_bug(peck);
|
||||
ei_touch_down(t2, 401, 401);
|
||||
ei_touch_up(t2);
|
||||
peck_ei_enable_fatal_bug(peck);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* valid */
|
||||
_unref_(ei_touch) *t3 = ei_device_touch_new(device);
|
||||
ei_touch_down(t3, 701, 801);
|
||||
ei_touch_up(t3);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
_unref_(ei_touch) *t4 = ei_device_touch_new(device);
|
||||
peck_ei_disable_fatal_bug(peck);
|
||||
ei_touch_down(t4, 1201, 801);
|
||||
ei_touch_up(t4);
|
||||
peck_ei_enable_fatal_bug(peck);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* valid */
|
||||
_unref_(ei_touch) *t5 = ei_device_touch_new(device);
|
||||
ei_touch_down(t5, 1101, 1201);
|
||||
ei_touch_up(t5);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
|
||||
/* ignored */
|
||||
_unref_(ei_touch) *t6 = ei_device_touch_new(device);
|
||||
peck_ei_disable_fatal_bug(peck);
|
||||
ei_touch_down(t6, 2000, 1201);
|
||||
ei_touch_up(t6);
|
||||
peck_ei_enable_fatal_bug(peck);
|
||||
ei_device_frame(device, peck_ei_now(peck));
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
_unref_(eis_event) *t1d = peck_eis_next_event(eis, EIS_EVENT_TOUCH_DOWN);
|
||||
munit_assert_double_equal(eis_event_touch_get_x(t1d), 301, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_touch_get_y(t1d), 401, 2 /* precision */);
|
||||
|
||||
_unref_(eis_event) *t1u = peck_eis_next_event(eis, EIS_EVENT_TOUCH_UP);
|
||||
munit_assert_ptr_not_null(t1u);
|
||||
|
||||
_unref_(eis_event) *t2d = peck_eis_next_event(eis, EIS_EVENT_TOUCH_DOWN);
|
||||
munit_assert_double_equal(eis_event_touch_get_x(t2d), 701, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_touch_get_y(t2d), 801, 2 /* precision */);
|
||||
|
||||
_unref_(eis_event) *t2u = peck_eis_next_event(eis, EIS_EVENT_TOUCH_UP);
|
||||
munit_assert_ptr_not_null(t2u);
|
||||
|
||||
_unref_(eis_event) *t3d = peck_eis_next_event(eis, EIS_EVENT_TOUCH_DOWN);
|
||||
munit_assert_double_equal(eis_event_touch_get_x(t3d), 1101, 2 /* precision */);
|
||||
munit_assert_double_equal(eis_event_touch_get_y(t3d), 1201, 2 /* precision */);
|
||||
|
||||
_unref_(eis_event) *t3u = peck_eis_next_event(eis, EIS_EVENT_TOUCH_UP);
|
||||
munit_assert_ptr_not_null(t3u);
|
||||
|
||||
peck_assert_no_eis_events(eis);
|
||||
}
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
MUNIT_TEST(test_ei_device_regions_ref_unref)
|
||||
{
|
||||
_unref_(peck) *peck = peck_new();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue