Skip to content

Commit 2b22d89

Browse files
Update test_keyboard.c
1 parent e8e1383 commit 2b22d89

File tree

1 file changed

+58
-11
lines changed

1 file changed

+58
-11
lines changed

code/tests/cases/test_keyboard.c

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
// * * * * * * * * * * * * * * * * * * * * * * * *
2424

2525
// Define the test suite and add test cases
26-
FOSSIL_TEST_SUITE(c_keyboard_suite);
26+
FOSSIL_TEST_SUITE(c_device_suite);
2727

28-
// Setup function for the test suite
29-
FOSSIL_SETUP(c_keyboard_suite) {
30-
// Setup code here
28+
FOSSIL_SETUP(c_device_suite) {
29+
fossil_io_mouse_init();
30+
fossil_io_touch_init();
3131
}
3232

33-
// Teardown function for the test suite
34-
FOSSIL_TEARDOWN(c_keyboard_suite) {
35-
// Teardown code here
33+
FOSSIL_TEARDOWN(c_device_suite) {
34+
fossil_io_mouse_shutdown();
35+
fossil_io_touch_shutdown();
3636
}
3737

3838
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -73,15 +73,62 @@ FOSSIL_TEST_CASE(c_test_keyboard_poll_events) {
7373
fossil_io_keyboard_unregister_binding(event);
7474
}
7575

76+
FOSSIL_TEST_CASE(c_test_mouse_register_unregister_binding) {
77+
fossil_io_mouse_event_t event = { .x = 10, .y = 20, .button = 0, .shift = 0, .ctrl = 0, .alt = 0 };
78+
fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)1;
79+
80+
fossil_io_mouse_register_binding(event, callback);
81+
ASSUME_NOT_CNULL(callback);
82+
83+
fossil_io_mouse_unregister_binding(event);
84+
ASSUME_NOT_CNULL(callback);
85+
}
86+
87+
FOSSIL_TEST_CASE(c_test_mouse_clear_bindings) {
88+
fossil_io_mouse_event_t event = { .x = 10, .y = 20, .button = 0, .shift = 0, .ctrl = 0, .alt = 0 };
89+
fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)1;
90+
91+
fossil_io_mouse_register_binding(event, callback);
92+
fossil_io_mouse_clear_bindings();
93+
ASSUME_NOT_CNULL(callback);
94+
}
95+
96+
FOSSIL_TEST_CASE(c_test_touch_register_unregister_binding) {
97+
fossil_io_touch_event_t event = { .x = 100, .y = 200, .touch_id = 1, .action = 0, .shift = 0, .ctrl = 0, .alt = 0 };
98+
fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)1;
99+
100+
fossil_io_touch_register_binding(event, callback);
101+
ASSUME_NOT_CNULL(callback);
102+
103+
fossil_io_touch_unregister_binding(event);
104+
ASSUME_NOT_CNULL(callback);
105+
}
106+
107+
FOSSIL_TEST_CASE(c_test_touch_clear_bindings) {
108+
fossil_io_touch_event_t event = { .x = 100, .y = 200, .touch_id = 1, .action = 0, .shift = 0, .ctrl = 0, .alt = 0 };
109+
fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)1;
110+
111+
fossil_io_touch_register_binding(event, callback);
112+
fossil_io_touch_clear_bindings();
113+
ASSUME_NOT_CNULL(callback);
114+
}
76115

77116
// * * * * * * * * * * * * * * * * * * * * * * * *
78117
// * Fossil Logic Test Pool
79118
// * * * * * * * * * * * * * * * * * * * * * * * *
80119

81120
FOSSIL_TEST_GROUP(c_keyboard_tests) {
82-
FOSSIL_TEST_ADD(c_keyboard_suite, c_test_keyboard_register_unregister_binding);
83-
FOSSIL_TEST_ADD(c_keyboard_suite, c_test_keyboard_clear_bindings);
84-
FOSSIL_TEST_ADD(c_keyboard_suite, c_test_keyboard_poll_events);
121+
FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_register_unregister_binding);
122+
FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_clear_bindings);
123+
FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_poll_events);
124+
125+
// Mouse tests
126+
FOSSIL_TEST_ADD(c_device_suite, c_test_mouse_register_unregister_binding);
127+
FOSSIL_TEST_ADD(c_device_suite, c_test_mouse_clear_bindings);
128+
129+
// Touch tests
130+
FOSSIL_TEST_ADD(c_device_suite, c_test_touch_register_unregister_binding);
131+
FOSSIL_TEST_ADD(c_device_suite, c_test_touch_clear_bindings);
85132

86-
FOSSIL_TEST_REGISTER(c_keyboard_suite);
133+
FOSSIL_TEST_REGISTER(c_device_suite);
87134
}

0 commit comments

Comments
 (0)