Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 692c7f40 in mainline for uspace/app/nav/test/panel.c


Ignore:
Timestamp:
2021-10-25T00:32:45Z (8 months ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial
Children:
1eb0fafe
Parents:
2fb49522
git-author:
Jiri Svoboda <jiri@…> (2021-10-13 18:40:48)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
Message:

Panel activation

Active panel can be switched using the Tab key. Mouse activation is
not implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/test/panel.c

    r2fb49522 r692c7f40  
    4646        errno_t rc;
    4747
    48         rc = panel_create(NULL, &panel);
     48        rc = panel_create(NULL, true, &panel);
    4949        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5050
     
    7070        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    7171
    72         rc = panel_create(window, &panel);
     72        rc = panel_create(window, true, &panel);
    7373        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    7474
     
    102102        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    103103
    104         rc = panel_create(window, &panel);
     104        rc = panel_create(window, true, &panel);
    105105        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    106106
     
    120120        errno_t rc;
    121121
    122         rc = panel_create(NULL, &panel);
     122        rc = panel_create(NULL, true, &panel);
    123123        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    124124
     
    133133{
    134134        panel_t *panel;
    135         ui_control_t *control;
    136135        ui_evclaim_t claimed;
    137136        kbd_event_t event;
    138137        errno_t rc;
    139138
    140         rc = panel_create(NULL, &panel);
    141         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    142 
    143         control = panel_ctl(panel);
    144         PCUT_ASSERT_NOT_NULL(control);
     139        /* Active panel should claim events */
     140
     141        rc = panel_create(NULL, true, &panel);
     142        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    145143
    146144        event.type = KEY_PRESS;
     
    150148
    151149        claimed = panel_kbd_event(panel, &event);
     150        PCUT_ASSERT_EQUALS(ui_claimed, claimed);
     151
     152        panel_destroy(panel);
     153
     154        /* Inactive panel should not claim events */
     155
     156        rc = panel_create(NULL, false, &panel);
     157        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     158
     159        event.type = KEY_PRESS;
     160        event.key = KC_ENTER;
     161        event.mods = 0;
     162        event.c = '\0';
     163
     164        claimed = panel_kbd_event(panel, &event);
    152165        PCUT_ASSERT_EQUALS(ui_unclaimed, claimed);
    153166
     
    159172{
    160173        panel_t *panel;
    161         ui_control_t *control;
    162174        ui_evclaim_t claimed;
    163175        pos_event_t event;
    164176        errno_t rc;
    165177
    166         rc = panel_create(NULL, &panel);
    167         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    168 
    169         control = panel_ctl(panel);
    170         PCUT_ASSERT_NOT_NULL(control);
     178        rc = panel_create(NULL, true, &panel);
     179        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    171180
    172181        event.pos_id = 0;
     
    186195{
    187196        panel_t *panel;
    188         ui_control_t *control;
    189197        gfx_rect_t rect;
    190198        errno_t rc;
    191199
    192         rc = panel_create(NULL, &panel);
    193         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    194 
    195         control = panel_ctl(panel);
    196         PCUT_ASSERT_NOT_NULL(control);
     200        rc = panel_create(NULL, true, &panel);
     201        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    197202
    198203        rect.p0.x = 1;
     
    214219{
    215220        panel_t *panel;
    216         ui_control_t *control;
    217221        gfx_rect_t rect;
    218222        errno_t rc;
    219223
    220         rc = panel_create(NULL, &panel);
    221         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    222 
    223         control = panel_ctl(panel);
    224         PCUT_ASSERT_NOT_NULL(control);
     224        rc = panel_create(NULL, true, &panel);
     225        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    225226
    226227        rect.p0.x = 10;
     
    237238}
    238239
     240/** panel_is_active() returns panel activity state */
     241PCUT_TEST(is_active)
     242{
     243        panel_t *panel;
     244        errno_t rc;
     245
     246        rc = panel_create(NULL, true, &panel);
     247        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     248        PCUT_ASSERT_TRUE(panel_is_active(panel));
     249        panel_destroy(panel);
     250
     251        rc = panel_create(NULL, false, &panel);
     252        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     253        PCUT_ASSERT_FALSE(panel_is_active(panel));
     254        panel_destroy(panel);
     255}
     256
     257/** panel_activate() activates panel */
     258PCUT_TEST(activate)
     259{
     260        ui_t *ui;
     261        ui_window_t *window;
     262        ui_wnd_params_t params;
     263        panel_t *panel;
     264        errno_t rc;
     265
     266        rc = ui_create_disp(NULL, &ui);
     267        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     268
     269        ui_wnd_params_init(&params);
     270        params.caption = "Test";
     271
     272        rc = ui_window_create(ui, &params, &window);
     273        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     274
     275        rc = panel_create(window, false, &panel);
     276        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     277
     278        PCUT_ASSERT_FALSE(panel_is_active(panel));
     279        panel_activate(panel);
     280        PCUT_ASSERT_TRUE(panel_is_active(panel));
     281
     282        panel_destroy(panel);
     283        ui_window_destroy(window);
     284        ui_destroy(ui);
     285}
     286
     287/** panel_deactivate() deactivates panel */
     288PCUT_TEST(deactivate)
     289{
     290        ui_t *ui;
     291        ui_window_t *window;
     292        ui_wnd_params_t params;
     293        panel_t *panel;
     294        errno_t rc;
     295
     296        rc = ui_create_disp(NULL, &ui);
     297        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     298
     299        ui_wnd_params_init(&params);
     300        params.caption = "Test";
     301
     302        rc = ui_window_create(ui, &params, &window);
     303        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     304
     305        rc = panel_create(window, true, &panel);
     306        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     307
     308        PCUT_ASSERT_TRUE(panel_is_active(panel));
     309        panel_deactivate(panel);
     310        PCUT_ASSERT_FALSE(panel_is_active(panel));
     311
     312        panel_destroy(panel);
     313        ui_window_destroy(window);
     314        ui_destroy(ui);
     315}
     316
    239317/** panel_entry_append() appends new entry */
    240318PCUT_TEST(entry_append)
     
    243321        errno_t rc;
    244322
    245         rc = panel_create(NULL, &panel);
     323        rc = panel_create(NULL, true, &panel);
    246324        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    247325
     
    266344        errno_t rc;
    267345
    268         rc = panel_create(NULL, &panel);
     346        rc = panel_create(NULL, true, &panel);
    269347        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    270348
     
    296374        errno_t rc;
    297375
    298         rc = panel_create(NULL, &panel);
     376        rc = panel_create(NULL, true, &panel);
    299377        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    300378
     
    345423        PCUT_ASSERT_INT_EQUALS(0, rv);
    346424
    347         rc = panel_create(NULL, &panel);
     425        rc = panel_create(NULL, true, &panel);
    348426        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    349427
     
    375453        errno_t rc;
    376454
    377         rc = panel_create(NULL, &panel);
     455        rc = panel_create(NULL, true, &panel);
    378456        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    379457
     
    411489        errno_t rc;
    412490
    413         rc = panel_create(NULL, &panel);
     491        rc = panel_create(NULL, true, &panel);
    414492        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    415493
     
    447525        errno_t rc;
    448526
    449         rc = panel_create(NULL, &panel);
     527        rc = panel_create(NULL, true, &panel);
    450528        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    451529
     
    484562        errno_t rc;
    485563
    486         rc = panel_create(NULL, &panel);
     564        rc = panel_create(NULL, true, &panel);
    487565        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    488566
     
    538616        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    539617
    540         rc = panel_create(window, &panel);
     618        rc = panel_create(window, true, &panel);
    541619        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    542620
     
    619697        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    620698
    621         rc = panel_create(window, &panel);
     699        rc = panel_create(window, true, &panel);
    622700        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    623701
     
    702780        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    703781
    704         rc = panel_create(window, &panel);
     782        rc = panel_create(window, true, &panel);
    705783        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    706784
     
    763841        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    764842
    765         rc = panel_create(window, &panel);
     843        rc = panel_create(window, true, &panel);
    766844        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    767845
     
    825903        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    826904
    827         rc = panel_create(window, &panel);
     905        rc = panel_create(window, true, &panel);
    828906        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    829907
     
    913991        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    914992
    915         rc = panel_create(window, &panel);
     993        rc = panel_create(window, true, &panel);
    916994        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    917995
Note: See TracChangeset for help on using the changeset viewer.