Changes in uspace/lib/ui/test/window.c [0576df9:db3895d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/window.c
r0576df9 rdb3895d 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 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 … … 175 178 } 176 179 180 /** ui_window_get_active */ 181 PCUT_TEST(get_active) 182 { 183 errno_t rc; 184 ui_t *ui = NULL; 185 ui_wnd_params_t params; 186 ui_window_t *window1 = NULL; 187 ui_window_t *window2 = NULL; 188 ui_window_t *awnd; 189 190 rc = ui_create_cons(NULL, &ui); 191 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 192 193 awnd = ui_window_get_active(ui); 194 PCUT_ASSERT_NULL(awnd); 195 196 ui_wnd_params_init(¶ms); 197 params.caption = "Hello"; 198 199 rc = ui_window_create(ui, ¶ms, &window1); 200 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 201 PCUT_ASSERT_NOT_NULL(window1); 202 203 awnd = ui_window_get_active(ui); 204 PCUT_ASSERT_EQUALS(window1, awnd); 205 206 rc = ui_window_create(ui, ¶ms, &window2); 207 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 208 PCUT_ASSERT_NOT_NULL(window2); 209 210 awnd = ui_window_get_active(ui); 211 PCUT_ASSERT_EQUALS(window2, awnd); 212 213 ui_window_destroy(window2); 214 215 awnd = ui_window_get_active(ui); 216 PCUT_ASSERT_EQUALS(window1, awnd); 217 218 ui_window_destroy(window1); 219 220 awnd = ui_window_get_active(ui); 221 PCUT_ASSERT_NULL(awnd); 222 223 ui_destroy(ui); 224 } 225 177 226 /** ui_window_resize */ 178 227 PCUT_TEST(resize) … … 242 291 } 243 292 293 /** ui_window_set_ctl_cursor() */ 294 PCUT_TEST(set_ctl_cursor) 295 { 296 errno_t rc; 297 ui_t *ui = NULL; 298 ui_wnd_params_t params; 299 ui_window_t *window = NULL; 300 301 rc = ui_create_disp(NULL, &ui); 302 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 303 304 ui_wnd_params_init(¶ms); 305 params.caption = "Hello"; 306 307 rc = ui_window_create(ui, ¶ms, &window); 308 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 309 PCUT_ASSERT_NOT_NULL(window); 310 311 ui_window_set_ctl_cursor(window, ui_curs_ibeam); 312 313 ui_window_destroy(window); 314 ui_destroy(ui); 315 } 316 244 317 /** ui_window_get_app_gc() return valid GC */ 245 318 PCUT_TEST(get_app_gc) … … 258 331 params.rect.p0.x = 0; 259 332 params.rect.p0.y = 0; 260 params.rect.p0.x = 10 ;261 params.rect.p0.y = 10 ;333 params.rect.p0.x = 100; 334 params.rect.p0.y = 100; 262 335 263 336 rc = ui_window_create(ui, ¶ms, &window); … … 388 461 PCUT_ASSERT_INT_EQUALS(event.hpos, resp.pos_event.hpos); 389 462 PCUT_ASSERT_INT_EQUALS(event.vpos, resp.pos_event.vpos); 463 464 /* Need to remove first because we didn't implement the destructor */ 465 ui_window_remove(window, control); 466 467 ui_window_destroy(window); 468 ui_destroy(ui); 469 } 470 471 /** ui_window_def_unfocus() delivers unfocus event to control in window */ 472 PCUT_TEST(def_unfocus) 473 { 474 errno_t rc; 475 ui_t *ui = NULL; 476 ui_wnd_params_t params; 477 ui_window_t *window = NULL; 478 ui_control_t *control = NULL; 479 test_ctl_resp_t resp; 480 481 rc = ui_create_disp(NULL, &ui); 482 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 483 484 ui_wnd_params_init(¶ms); 485 params.caption = "Hello"; 486 487 rc = ui_window_create(ui, ¶ms, &window); 488 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 489 490 rc = ui_control_new(&test_ctl_ops, &resp, &control); 491 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 492 493 ui_window_add(window, control); 494 495 resp.unfocus = false; 496 497 ui_window_def_unfocus(window); 498 PCUT_ASSERT_TRUE(resp.unfocus); 390 499 391 500 /* Need to remove first because we didn't implement the destructor */ … … 701 810 } 702 811 812 static void test_ctl_unfocus(void *arg) 813 { 814 test_ctl_resp_t *resp = (test_ctl_resp_t *) arg; 815 816 resp->unfocus = true; 817 } 818 703 819 PCUT_EXPORT(window);
Note:
See TracChangeset
for help on using the changeset viewer.