fix: make popup rendering deterministic
This commit is contained in:
@@ -5,9 +5,11 @@ 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 wayland_test.c
|
||||
ko_test.c vi_test.c engine_test.c dict_test.c ipc_test.c wayland_test.c \
|
||||
popup_test.c
|
||||
TESTOBJ = $(TESTSRC:.c=.o)
|
||||
PARENTSRC = str.c hash.c trie.c dict.c ko.c vi.c ipc.c wayland_state.c
|
||||
PARENTSRC = str.c hash.c trie.c dict.c ko.c vi.c ipc.c wayland_state.c \
|
||||
popup_layout.c
|
||||
PARENTOBJ = $(PARENTSRC:%.c=unit_%.o)
|
||||
OBJS = $(TESTOBJ) $(PARENTOBJ)
|
||||
|
||||
|
||||
28
tests/popup_test.c
Normal file
28
tests/popup_test.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "test.h"
|
||||
#include "../popup_layout.h"
|
||||
|
||||
void
|
||||
popup_layout(struct ct *t)
|
||||
{
|
||||
Rune heart[] = { 0x2764, 0xfe0f };
|
||||
Caret caret;
|
||||
int x, y;
|
||||
|
||||
CT_EQ_INT(t, 1, popupcells(heart, nelem(heart)));
|
||||
memset(&caret, 0, sizeof caret);
|
||||
popupposition(&caret, 40, 50, 800, 600, 100, 60, &x, &y);
|
||||
CT_EQ_INT(t, 50, x);
|
||||
CT_EQ_INT(t, 60, y);
|
||||
caret.valid = 1;
|
||||
caret.x = 70;
|
||||
caret.y = 80;
|
||||
caret.h = 20;
|
||||
popupposition(&caret, 40, 50, 800, 600, 100, 60, &x, &y);
|
||||
CT_EQ_INT(t, 70, x);
|
||||
CT_EQ_INT(t, 100, y);
|
||||
caret.x = 790;
|
||||
caret.y = 590;
|
||||
popupposition(&caret, 0, 0, 800, 600, 100, 60, &x, &y);
|
||||
CT_EQ_INT(t, 700, x);
|
||||
CT_EQ_INT(t, 540, y);
|
||||
}
|
||||
@@ -26,6 +26,7 @@ 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 popup_layout(struct ct*);
|
||||
void production_maps_load(struct ct*);
|
||||
void transmap_states(struct ct*);
|
||||
void korean_sequences(struct ct*);
|
||||
|
||||
@@ -75,6 +75,7 @@ static const struct ct_test tests[] = {
|
||||
{ "wayland/press-release", wayland_press_release_state },
|
||||
{ "wayland/repeat", wayland_repeat_state },
|
||||
{ "wayland/repeat-cancellation", wayland_repeat_cancellation },
|
||||
{ "popup/layout", popup_layout },
|
||||
{ "map/production-lifecycle", production_maps_load },
|
||||
{ "transmap/states", transmap_states },
|
||||
{ "hangul/sequences", korean_sequences },
|
||||
|
||||
Reference in New Issue
Block a user