Changeset 35cffea in mainline for uspace/lib/ui/test/window.c
- Timestamp:
- 2022-05-19T08:02:31Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ad698f4
- Parents:
- fd05ea6
- git-author:
- Jiri Svoboda <jiri@…> (2022-05-18 17:02:12)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-05-19 08:02:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/window.c
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 45 45 PCUT_TEST_SUITE(window); 46 46 47 static void test_window_maximize(ui_window_t *, void *); 48 static void test_window_unmaximize(ui_window_t *, void *); 47 49 static void test_window_close(ui_window_t *, void *); 48 50 static void test_window_focus(ui_window_t *, void *); … … 53 55 54 56 static ui_window_cb_t test_window_cb = { 57 .maximize = test_window_maximize, 58 .unmaximize = test_window_unmaximize, 55 59 .close = test_window_close, 56 60 .focus = test_window_focus, … … 76 80 typedef struct { 77 81 errno_t rc; 82 bool maximize; 83 bool unmaximize; 78 84 bool close; 79 85 bool focus; … … 526 532 /* Need to remove first because we didn't implement the destructor */ 527 533 ui_window_remove(window, control); 534 535 ui_window_destroy(window); 536 ui_destroy(ui); 537 } 538 539 /** ui_window_send_maximize() calls maximize callback set via ui_window_set_cb() */ 540 PCUT_TEST(send_maximize) 541 { 542 errno_t rc; 543 ui_t *ui = NULL; 544 ui_wnd_params_t params; 545 ui_window_t *window = NULL; 546 test_cb_resp_t resp; 547 548 rc = ui_create_disp(NULL, &ui); 549 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 550 551 ui_wnd_params_init(¶ms); 552 params.caption = "Hello"; 553 554 rc = ui_window_create(ui, ¶ms, &window); 555 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 556 PCUT_ASSERT_NOT_NULL(window); 557 558 /* Maximize callback with no callbacks set */ 559 ui_window_send_maximize(window); 560 561 /* Maximize callback with maximize callback not implemented */ 562 ui_window_set_cb(window, &dummy_window_cb, NULL); 563 ui_window_send_maximize(window); 564 565 /* Maximize callback with real callback set */ 566 resp.maximize = false; 567 ui_window_set_cb(window, &test_window_cb, &resp); 568 ui_window_send_maximize(window); 569 PCUT_ASSERT_TRUE(resp.maximize); 570 571 ui_window_destroy(window); 572 ui_destroy(ui); 573 } 574 575 /** ui_window_send_unmaximize() calls unmaximize callback set via ui_window_set_cb() */ 576 PCUT_TEST(send_unmaximize) 577 { 578 errno_t rc; 579 ui_t *ui = NULL; 580 ui_wnd_params_t params; 581 ui_window_t *window = NULL; 582 test_cb_resp_t resp; 583 584 rc = ui_create_disp(NULL, &ui); 585 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 586 587 ui_wnd_params_init(¶ms); 588 params.caption = "Hello"; 589 590 rc = ui_window_create(ui, ¶ms, &window); 591 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 592 PCUT_ASSERT_NOT_NULL(window); 593 594 /* Unmaximize callback with no callbacks set */ 595 ui_window_send_unmaximize(window); 596 597 /* Unmaximize callback with unmaximize callback not implemented */ 598 ui_window_set_cb(window, &dummy_window_cb, NULL); 599 ui_window_send_unmaximize(window); 600 601 /* Unmaximize callback with real callback set */ 602 resp.unmaximize = false; 603 ui_window_set_cb(window, &test_window_cb, &resp); 604 ui_window_send_unmaximize(window); 605 PCUT_ASSERT_TRUE(resp.unmaximize); 528 606 529 607 ui_window_destroy(window); … … 771 849 } 772 850 851 static void test_window_maximize(ui_window_t *window, void *arg) 852 { 853 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 854 855 resp->maximize = true; 856 } 857 858 static void test_window_unmaximize(ui_window_t *window, void *arg) 859 { 860 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 861 862 resp->unmaximize = true; 863 } 864 773 865 static void test_window_close(ui_window_t *window, void *arg) 774 866 {
Note:
See TracChangeset
for help on using the changeset viewer.