mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-20 02:10:08 +01:00
test: declare the need_frame check as part of the context
Reproducible with something that produces a frame event:
// queues e.g. pointer motion + frame
peck_eis_dispatch_until_stable()
with_server(peck) {
// process the motion only
}
peck_eis_dispatch_until_stable()
The second peck_eis_dispatch_until_stable() triggers an assertion
because we still have the unhandled frame event pending but need_frame
was reset to false.
Keep this as a field in peck so it remembers across invocations.
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/369>
This commit is contained in:
parent
55381623f2
commit
756f74ec73
4 changed files with 30 additions and 33 deletions
|
|
@ -100,6 +100,9 @@ struct peck {
|
|||
|
||||
struct peck_log_capture ei_log_capture;
|
||||
struct peck_log_capture eis_log_capture;
|
||||
|
||||
bool ei_needs_frame;
|
||||
bool eis_needs_frame;
|
||||
};
|
||||
|
||||
static const uint32_t INDENTATION = 4;
|
||||
|
|
@ -160,8 +163,8 @@ peck_destroy(struct peck *peck)
|
|||
|
||||
/* we don't want valgrind to complain about us not handling *all*
|
||||
* events in a test */
|
||||
peck_drain_ei(peck->ei);
|
||||
peck_drain_eis(peck->eis);
|
||||
peck_drain_ei(peck);
|
||||
peck_drain_eis(peck);
|
||||
|
||||
log_debug(peck, "final event processing done\n");
|
||||
|
||||
|
|
@ -1088,7 +1091,6 @@ _peck_dispatch_eis(struct peck *peck, int lineno)
|
|||
{
|
||||
struct eis *eis = peck->eis;
|
||||
bool had_event = false;
|
||||
bool need_frame = false;
|
||||
static uint64_t last_timestamp;
|
||||
|
||||
log_debug(peck, "EIS Dispatch, line %d\n", lineno);
|
||||
|
|
@ -1135,8 +1137,8 @@ _peck_dispatch_eis(struct peck *peck, int lineno)
|
|||
break;
|
||||
case EIS_EVENT_FRAME:
|
||||
/* Ensure we only expect frames when we expect them */
|
||||
munit_assert_true(need_frame);
|
||||
need_frame = false;
|
||||
munit_assert_true(peck->eis_needs_frame);
|
||||
peck->eis_needs_frame = false;
|
||||
if (flag_is_set(peck->eis_behavior, PECK_EIS_BEHAVIOR_HANDLE_FRAME))
|
||||
process_event = tristate_yes;
|
||||
break;
|
||||
|
|
@ -1159,7 +1161,7 @@ _peck_dispatch_eis(struct peck *peck, int lineno)
|
|||
case EIS_EVENT_TOUCH_DOWN:
|
||||
case EIS_EVENT_TOUCH_UP:
|
||||
case EIS_EVENT_TOUCH_MOTION:
|
||||
need_frame = true;
|
||||
peck->eis_needs_frame = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1249,7 +1251,6 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
|
|||
{
|
||||
struct ei *ei = peck->ei;
|
||||
bool had_event = false;
|
||||
bool need_frame = false;
|
||||
|
||||
log_debug(peck, "ei dispatch, line %d\n", lineno);
|
||||
peck_indent(peck);
|
||||
|
|
@ -1299,8 +1300,8 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
|
|||
break;
|
||||
case EI_EVENT_FRAME:
|
||||
/* Ensure we only expect frames when we expect them */
|
||||
munit_assert_true(need_frame);
|
||||
need_frame = false;
|
||||
munit_assert_true(peck->ei_needs_frame);
|
||||
peck->ei_needs_frame = false;
|
||||
|
||||
if (flag_is_set(peck->ei_behavior, PECK_EI_BEHAVIOR_HANDLE_FRAME))
|
||||
process_event = tristate_yes;
|
||||
|
|
@ -1320,7 +1321,7 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
|
|||
case EI_EVENT_TOUCH_DOWN:
|
||||
case EI_EVENT_TOUCH_UP:
|
||||
case EI_EVENT_TOUCH_MOTION:
|
||||
need_frame = true;
|
||||
peck->ei_needs_frame = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1423,8 +1424,10 @@ _peck_dispatch_until_stable(struct peck *peck, const char *func, int lineno)
|
|||
}
|
||||
|
||||
void
|
||||
peck_drain_eis(struct eis *eis)
|
||||
peck_drain_eis(struct peck *peck)
|
||||
{
|
||||
struct eis *eis = peck->eis;
|
||||
|
||||
if (!eis)
|
||||
return;
|
||||
|
||||
|
|
@ -1435,11 +1438,15 @@ peck_drain_eis(struct eis *eis)
|
|||
if (e == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
peck->eis_needs_frame = false;
|
||||
}
|
||||
|
||||
void
|
||||
peck_drain_ei(struct ei *ei)
|
||||
peck_drain_ei(struct peck *peck)
|
||||
{
|
||||
struct ei *ei = peck->ei;
|
||||
|
||||
if (!ei)
|
||||
return;
|
||||
|
||||
|
|
@ -1449,6 +1456,8 @@ peck_drain_ei(struct ei *ei)
|
|||
if (e == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
peck->ei_needs_frame = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -327,13 +327,13 @@ _peck_dispatch_until_stable(struct peck *peck, const char *func, int lineno);
|
|||
* Discard all pending events.
|
||||
*/
|
||||
void
|
||||
peck_drain_eis(struct eis *eis);
|
||||
peck_drain_eis(struct peck *peck);
|
||||
|
||||
/**
|
||||
* Discard all pending events.
|
||||
*/
|
||||
void
|
||||
peck_drain_ei(struct ei *ei);
|
||||
peck_drain_ei(struct peck *peck);
|
||||
|
||||
void
|
||||
_peck_assert_no_eis_events(struct eis *eis, int lineno);
|
||||
|
|
|
|||
|
|
@ -633,9 +633,7 @@ MUNIT_TEST(test_ei_exceed_write_buffer)
|
|||
unsigned int count = 10000; /* Large enough to require several flushes */
|
||||
struct eis_event *events[count];
|
||||
|
||||
with_server(peck) {
|
||||
peck_drain_eis(eis);
|
||||
}
|
||||
peck_drain_eis(peck);
|
||||
|
||||
with_client(peck) {
|
||||
struct ei_device *device = peck_ei_get_default_pointer(peck);
|
||||
|
|
@ -718,9 +716,7 @@ MUNIT_TEST(test_ei_exceed_write_buffer_cleanup)
|
|||
uint64_t toffset = peck_ei_now(peck);
|
||||
unsigned int count = 10000; /* Large enough to require several flushes */
|
||||
|
||||
with_server(peck) {
|
||||
peck_drain_eis(eis);
|
||||
}
|
||||
peck_drain_eis(peck);
|
||||
|
||||
with_client(peck) {
|
||||
struct ei_device *device = peck_ei_get_default_pointer(peck);
|
||||
|
|
@ -843,9 +839,7 @@ MUNIT_TEST(test_ei_ping)
|
|||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
peck_drain_ei(ei);
|
||||
}
|
||||
peck_drain_ei(peck);
|
||||
|
||||
/* Create a ping object without having our own ref, object
|
||||
* is kept alive until the returned pong event is destroyed */
|
||||
|
|
@ -952,7 +946,7 @@ MUNIT_TEST(test_ei_ping_delayed_pong)
|
|||
peck_disable_ei_behavior(peck, PECK_EI_BEHAVIOR_HANDLE_SYNC);
|
||||
|
||||
with_client(peck) {
|
||||
peck_drain_ei(ei);
|
||||
peck_drain_ei(peck);
|
||||
|
||||
/* We send two ping events, one before and one after the frame */
|
||||
struct ei_device *device = peck_ei_get_default_keyboard(peck);
|
||||
|
|
@ -1020,9 +1014,7 @@ MUNIT_TEST(test_ei_ping_within_frame)
|
|||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
peck_drain_ei(ei);
|
||||
}
|
||||
peck_drain_ei(peck);
|
||||
|
||||
/* We send two ping events, one before and one after the frame */
|
||||
with_client(peck) {
|
||||
|
|
|
|||
|
|
@ -557,9 +557,7 @@ MUNIT_TEST(test_eis_ping)
|
|||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
peck_drain_eis(eis);
|
||||
}
|
||||
peck_drain_eis(peck);
|
||||
|
||||
/* Create a ping object without having our own ref, object
|
||||
* is kept alive until the returned pong event is destroyed */
|
||||
|
|
@ -665,9 +663,7 @@ MUNIT_TEST(test_eis_ping_delayed_pong)
|
|||
peck_disable_eis_behavior(peck, PECK_EIS_BEHAVIOR_HANDLE_FRAME);
|
||||
peck_disable_ei_behavior(peck, PECK_EI_BEHAVIOR_HANDLE_SYNC);
|
||||
|
||||
with_server(peck) {
|
||||
peck_drain_eis(eis);
|
||||
}
|
||||
peck_drain_eis(peck);
|
||||
|
||||
with_server(peck) {
|
||||
struct eis_client *client = peck_eis_get_default_client(peck);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue