Changes in uspace/lib/ui/test/control.c [c6f00b40:7481ee19] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/test/control.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/control.c
rc6f00b40 r7481ee19 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 29 29 #include <errno.h> 30 30 #include <mem.h> 31 #include <io/kbd_event.h> 31 32 #include <io/pos_event.h> 32 33 #include <pcut/pcut.h> … … 41 42 static void test_ctl_destroy(void *); 42 43 static errno_t test_ctl_paint(void *); 44 static ui_evclaim_t test_ctl_kbd_event(void *, kbd_event_t *); 43 45 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 46 static void test_ctl_unfocus(void *); 44 47 45 48 static ui_control_ops_t test_ctl_ops = { 46 49 .destroy = test_ctl_destroy, 47 50 .paint = test_ctl_paint, 48 .pos_event = test_ctl_pos_event 51 .kbd_event = test_ctl_kbd_event, 52 .pos_event = test_ctl_pos_event, 53 .unfocus = test_ctl_unfocus 49 54 }; 50 55 … … 62 67 bool paint; 63 68 69 /** @c true iff kbd_event was called */ 70 bool kbd; 71 /** Keyboard event that was sent */ 72 kbd_event_t kevent; 73 64 74 /** @c true iff pos_event was called */ 65 75 bool pos; 66 76 /** Position event that was sent */ 67 77 pos_event_t pevent; 78 79 /** @c true iff unfocus was called */ 80 bool unfocus; 68 81 } test_resp_t; 69 82 … … 129 142 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 130 143 PCUT_ASSERT_TRUE(resp.paint); 144 145 ui_control_delete(control); 146 } 147 148 /** Test sending keyboard event to control */ 149 PCUT_TEST(kbd_event) 150 { 151 ui_control_t *control = NULL; 152 test_resp_t resp; 153 kbd_event_t event; 154 ui_evclaim_t claim; 155 errno_t rc; 156 157 rc = ui_control_new(&test_ctl_ops, &resp, &control); 158 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 159 PCUT_ASSERT_NOT_NULL(control); 160 161 resp.claim = ui_claimed; 162 resp.kbd = false; 163 event.type = KEY_PRESS; 164 event.key = KC_2; 165 event.mods = KM_LSHIFT; 166 event.c = '@'; 167 168 claim = ui_control_kbd_event(control, &event); 169 PCUT_ASSERT_EQUALS(resp.claim, claim); 170 PCUT_ASSERT_TRUE(resp.kbd); 171 PCUT_ASSERT_EQUALS(resp.kevent.type, event.type); 172 PCUT_ASSERT_INT_EQUALS(resp.kevent.key, event.key); 173 PCUT_ASSERT_INT_EQUALS(resp.kevent.mods, event.mods); 174 PCUT_ASSERT_INT_EQUALS(resp.kevent.c, event.c); 131 175 132 176 ui_control_delete(control); … … 166 210 } 167 211 212 /** Test sending unfocus to control */ 213 PCUT_TEST(unfocus) 214 { 215 ui_control_t *control = NULL; 216 test_resp_t resp; 217 errno_t rc; 218 219 rc = ui_control_new(&test_ctl_ops, &resp, &control); 220 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 221 PCUT_ASSERT_NOT_NULL(control); 222 223 resp.unfocus = false; 224 225 ui_control_unfocus(control); 226 PCUT_ASSERT_TRUE(resp.unfocus); 227 228 ui_control_delete(control); 229 } 230 168 231 static void test_ctl_destroy(void *arg) 169 232 { … … 181 244 } 182 245 246 static ui_evclaim_t test_ctl_kbd_event(void *arg, kbd_event_t *event) 247 { 248 test_resp_t *resp = (test_resp_t *) arg; 249 250 resp->kbd = true; 251 resp->kevent = *event; 252 253 return resp->claim; 254 } 255 183 256 static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event) 184 257 { … … 191 264 } 192 265 266 static void test_ctl_unfocus(void *arg) 267 { 268 test_resp_t *resp = (test_resp_t *) arg; 269 270 resp->unfocus = true; 271 } 272 193 273 PCUT_EXPORT(control);
Note:
See TracChangeset
for help on using the changeset viewer.
