fix: repair Wayland key lifecycle
This commit is contained in:
@@ -5,9 +5,9 @@ LIBS = -lthread -lbio
|
||||
|
||||
PROG = unit_test
|
||||
TESTSRC = unit_test.c test_util.c str_test.c hash_test.c trie_test.c \
|
||||
ko_test.c vi_test.c engine_test.c dict_test.c ipc_test.c
|
||||
ko_test.c vi_test.c engine_test.c dict_test.c ipc_test.c wayland_test.c
|
||||
TESTOBJ = $(TESTSRC:.c=.o)
|
||||
PARENTSRC = str.c hash.c trie.c dict.c ko.c vi.c ipc.c
|
||||
PARENTSRC = str.c hash.c trie.c dict.c ko.c vi.c ipc.c wayland_state.c
|
||||
PARENTOBJ = $(PARENTSRC:%.c=unit_%.o)
|
||||
OBJS = $(TESTOBJ) $(PARENTOBJ)
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ void hmap_long_utf8_keys(struct ct*);
|
||||
void hmap_binary_keys_and_invalid_lengths(struct ct*);
|
||||
void trie_exact_prefix_and_duplicate(struct ct*);
|
||||
void trie_optional_outputs_and_invalid_lengths(struct ct*);
|
||||
void wayland_press_release_state(struct ct*);
|
||||
void wayland_repeat_state(struct ct*);
|
||||
void wayland_repeat_cancellation(struct ct*);
|
||||
void production_maps_load(struct ct*);
|
||||
void transmap_states(struct ct*);
|
||||
void korean_sequences(struct ct*);
|
||||
|
||||
@@ -72,6 +72,9 @@ static const struct ct_test tests[] = {
|
||||
{ "hmap/binary-invalid-lengths", hmap_binary_keys_and_invalid_lengths },
|
||||
{ "trie/exact-prefix-duplicate", trie_exact_prefix_and_duplicate },
|
||||
{ "trie/optional-invalid-lengths", trie_optional_outputs_and_invalid_lengths },
|
||||
{ "wayland/press-release", wayland_press_release_state },
|
||||
{ "wayland/repeat", wayland_repeat_state },
|
||||
{ "wayland/repeat-cancellation", wayland_repeat_cancellation },
|
||||
{ "map/production-lifecycle", production_maps_load },
|
||||
{ "transmap/states", transmap_states },
|
||||
{ "hangul/sequences", korean_sequences },
|
||||
|
||||
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