fix: repair Wayland key lifecycle
This commit is contained in:
67
tests/wayland_test.c
Normal file
67
tests/wayland_test.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "test.h"
|
||||
#include "../wayland_state.h"
|
||||
|
||||
void
|
||||
wayland_press_release_state(struct ct *t)
|
||||
{
|
||||
Wlstate s;
|
||||
|
||||
wlstateinit(&s);
|
||||
CT_CHECK(t, wlstatepress(&s, 30, 1, 0, 0));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 30));
|
||||
CT_CHECK(t, wlstaterelease(&s, 30));
|
||||
CT_CHECK(t, wlstatepress(&s, 31, 0, 0, 0));
|
||||
CT_CHECK(t, wlstaterelease(&s, 31));
|
||||
CT_CHECK(t, !wlstatepress(&s, Wlkeymax, 1, 0, 0));
|
||||
CT_CHECK(t, wlstaterelease(&s, Wlkeymax));
|
||||
}
|
||||
|
||||
void
|
||||
wayland_repeat_state(struct ct *t)
|
||||
{
|
||||
Wlstate s;
|
||||
u32int key;
|
||||
|
||||
wlstateinit(&s);
|
||||
wlstaterepeatinfo(&s, 25, 400);
|
||||
CT_CHECK(t, wlstatepress(&s, 14, 1, 1, 100));
|
||||
CT_EQ_INT(t, 400, wlstatetimeout(&s, 100));
|
||||
CT_CHECK(t, !wlstaterepeat(&s, 499, &key));
|
||||
CT_CHECK(t, wlstaterepeat(&s, 500, &key));
|
||||
CT_EQ_UINT(t, 14, key);
|
||||
CT_EQ_INT(t, 40, wlstatetimeout(&s, 500));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 14));
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 500));
|
||||
|
||||
CT_CHECK(t, wlstatepress(&s, 15, 1, 0, 600));
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 600));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 15));
|
||||
CT_CHECK(t, wlstatepress(&s, 16, 0, 1, 600));
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 600));
|
||||
CT_CHECK(t, wlstaterelease(&s, 16));
|
||||
}
|
||||
|
||||
void
|
||||
wayland_repeat_cancellation(struct ct *t)
|
||||
{
|
||||
Wlstate s;
|
||||
|
||||
wlstateinit(&s);
|
||||
wlstaterepeatinfo(&s, 20, 300);
|
||||
CT_CHECK(t, wlstatepress(&s, 20, 1, 1, 0));
|
||||
CT_CHECK(t, wlstatepress(&s, 19, 0, 0, 10));
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 10));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 20));
|
||||
CT_CHECK(t, wlstaterelease(&s, 19));
|
||||
CT_CHECK(t, wlstatepress(&s, 20, 1, 1, 0));
|
||||
wlstaterepeatinfo(&s, 30, 200);
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 0));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 20));
|
||||
CT_CHECK(t, wlstatepress(&s, 21, 1, 1, 0));
|
||||
wlstatecancelrepeat(&s);
|
||||
CT_EQ_INT(t, -1, wlstatetimeout(&s, 0));
|
||||
CT_CHECK(t, !wlstaterelease(&s, 21));
|
||||
CT_CHECK(t, wlstatepress(&s, 22, 1, 1, 0));
|
||||
wlstateclear(&s);
|
||||
CT_CHECK(t, wlstaterelease(&s, 22));
|
||||
}
|
||||
Reference in New Issue
Block a user