Changeset 35cffea in mainline for uspace/lib/ui/test/window.c


Ignore:
Timestamp:
2022-05-19T08:02:31Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Maximizing/unmaximizing a window

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/test/window.c

    rfd05ea6 r35cffea  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4545PCUT_TEST_SUITE(window);
    4646
     47static void test_window_maximize(ui_window_t *, void *);
     48static void test_window_unmaximize(ui_window_t *, void *);
    4749static void test_window_close(ui_window_t *, void *);
    4850static void test_window_focus(ui_window_t *, void *);
     
    5355
    5456static ui_window_cb_t test_window_cb = {
     57        .maximize = test_window_maximize,
     58        .unmaximize = test_window_unmaximize,
    5559        .close = test_window_close,
    5660        .focus = test_window_focus,
     
    7680typedef struct {
    7781        errno_t rc;
     82        bool maximize;
     83        bool unmaximize;
    7884        bool close;
    7985        bool focus;
     
    526532        /* Need to remove first because we didn't implement the destructor */
    527533        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() */
     540PCUT_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(&params);
     552        params.caption = "Hello";
     553
     554        rc = ui_window_create(ui, &params, &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() */
     576PCUT_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(&params);
     588        params.caption = "Hello";
     589
     590        rc = ui_window_create(ui, &params, &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);
    528606
    529607        ui_window_destroy(window);
     
    771849}
    772850
     851static 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
     858static 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
    773865static void test_window_close(ui_window_t *window, void *arg)
    774866{
Note: See TracChangeset for help on using the changeset viewer.