Changeset 62223ec in mainline for uspace/lib/ui/test
- Timestamp:
- 2021-04-09T22:41:22Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f251883
- Parents:
- 0262f16c
- git-author:
- Jiri Svoboda <jiri@…> (2021-04-01 21:04:11)
- git-committer:
- jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
- Location:
- uspace/lib/ui/test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/control.c
r0262f16c r62223ec 42 42 static errno_t test_ctl_paint(void *); 43 43 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 44 static void test_ctl_unfocus(void *); 44 45 45 46 static ui_control_ops_t test_ctl_ops = { 46 47 .destroy = test_ctl_destroy, 47 48 .paint = test_ctl_paint, 48 .pos_event = test_ctl_pos_event 49 .pos_event = test_ctl_pos_event, 50 .unfocus = test_ctl_unfocus 49 51 }; 50 52 … … 66 68 /** Position event that was sent */ 67 69 pos_event_t pevent; 70 71 /** @c true iff unfocus was called */ 72 bool unfocus; 68 73 } test_resp_t; 69 74 … … 166 171 } 167 172 173 /** Test sending unfocus to control */ 174 PCUT_TEST(unfocus) 175 { 176 ui_control_t *control = NULL; 177 test_resp_t resp; 178 errno_t rc; 179 180 rc = ui_control_new(&test_ctl_ops, &resp, &control); 181 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 182 PCUT_ASSERT_NOT_NULL(control); 183 184 resp.unfocus = false; 185 186 ui_control_unfocus(control); 187 PCUT_ASSERT_TRUE(resp.unfocus); 188 189 ui_control_delete(control); 190 } 191 168 192 static void test_ctl_destroy(void *arg) 169 193 { … … 191 215 } 192 216 217 static void test_ctl_unfocus(void *arg) 218 { 219 test_resp_t *resp = (test_resp_t *) arg; 220 221 resp->unfocus = true; 222 } 223 193 224 PCUT_EXPORT(control); -
uspace/lib/ui/test/fixed.c
r0262f16c r62223ec 41 41 static errno_t test_ctl_paint(void *); 42 42 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 43 static void test_ctl_unfocus(void *); 43 44 44 45 static ui_control_ops_t test_ctl_ops = { 45 46 .destroy = test_ctl_destroy, 46 47 .paint = test_ctl_paint, 47 .pos_event = test_ctl_pos_event 48 .pos_event = test_ctl_pos_event, 49 .unfocus = test_ctl_unfocus 48 50 }; 49 51 … … 62 64 /** Position event that was sent */ 63 65 pos_event_t pevent; 66 /** @c true iff unfocus was called */ 67 bool unfocus; 64 68 } test_resp_t; 65 69 … … 230 234 } 231 235 236 /** ui_fixed_unfocus() delivers unfocus notification to control */ 237 PCUT_TEST(unfocus) 238 { 239 ui_fixed_t *fixed = NULL; 240 ui_control_t *control; 241 test_resp_t resp; 242 errno_t rc; 243 244 rc = ui_fixed_create(&fixed); 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 246 247 rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control); 248 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 249 250 rc = ui_fixed_add(fixed, control); 251 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 252 253 resp.unfocus = false; 254 255 ui_fixed_unfocus(fixed); 256 PCUT_ASSERT_TRUE(resp.unfocus); 257 258 ui_fixed_destroy(fixed); 259 } 260 232 261 static void test_ctl_destroy(void *arg) 233 262 { … … 255 284 } 256 285 286 static void test_ctl_unfocus(void *arg) 287 { 288 test_resp_t *resp = (test_resp_t *) arg; 289 290 resp->unfocus = true; 291 } 292 257 293 PCUT_EXPORT(fixed); -
uspace/lib/ui/test/window.c
r0262f16c r62223ec 66 66 static errno_t test_ctl_paint(void *); 67 67 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 68 static void test_ctl_unfocus(void *); 68 69 69 70 static ui_control_ops_t test_ctl_ops = { 70 71 .paint = test_ctl_paint, 71 .pos_event = test_ctl_pos_event 72 .pos_event = test_ctl_pos_event, 73 .unfocus = test_ctl_unfocus 72 74 }; 73 75 … … 90 92 bool pos; 91 93 pos_event_t pos_event; 94 bool unfocus; 92 95 } test_ctl_resp_t; 93 96 … … 388 391 PCUT_ASSERT_INT_EQUALS(event.hpos, resp.pos_event.hpos); 389 392 PCUT_ASSERT_INT_EQUALS(event.vpos, resp.pos_event.vpos); 393 394 /* Need to remove first because we didn't implement the destructor */ 395 ui_window_remove(window, control); 396 397 ui_window_destroy(window); 398 ui_destroy(ui); 399 } 400 401 /** ui_window_def_unfocus() delivers unfocus event to control in window */ 402 PCUT_TEST(def_unfocus) 403 { 404 errno_t rc; 405 ui_t *ui = NULL; 406 ui_wnd_params_t params; 407 ui_window_t *window = NULL; 408 ui_control_t *control = NULL; 409 test_ctl_resp_t resp; 410 411 rc = ui_create_disp(NULL, &ui); 412 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 413 414 ui_wnd_params_init(¶ms); 415 params.caption = "Hello"; 416 417 rc = ui_window_create(ui, ¶ms, &window); 418 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 419 420 rc = ui_control_new(&test_ctl_ops, &resp, &control); 421 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 422 423 ui_window_add(window, control); 424 425 resp.unfocus = false; 426 427 ui_window_def_unfocus(window); 428 PCUT_ASSERT_TRUE(resp.unfocus); 390 429 391 430 /* Need to remove first because we didn't implement the destructor */ … … 701 740 } 702 741 742 static void test_ctl_unfocus(void *arg) 743 { 744 test_ctl_resp_t *resp = (test_ctl_resp_t *) arg; 745 746 resp->unfocus = true; 747 } 748 703 749 PCUT_EXPORT(window);
Note:
See TracChangeset
for help on using the changeset viewer.