Changeset 966a27d3 in mainline for uspace/app/nav/test/panel.c


Ignore:
Timestamp:
2021-10-22T07:45:13Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Children:
8922b76
Parents:
2651dc5
git-author:
Jiri Svoboda <jiri@…> (2021-10-21 17:44:55)
git-committer:
Jiri Svoboda <jiri@…> (2021-10-22 07:45:13)
Message:

Activating panel using the mouse

File:
1 edited

Legend:

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

    r2651dc5 r966a27d3  
    4040PCUT_TEST_SUITE(panel);
    4141
     42/** Test response */
     43typedef struct {
     44        bool activate_req;
     45        panel_t *activate_req_panel;
     46} test_resp_t;
     47
     48static void test_panel_activate_req(void *, panel_t *);
     49
     50static panel_cb_t test_cb = {
     51        .activate_req = test_panel_activate_req
     52};
     53
    4254/** Create and destroy panel. */
    4355PCUT_TEST(create_destroy)
     
    4860        rc = panel_create(NULL, true, &panel);
    4961        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     62
     63        panel_destroy(panel);
     64}
     65
     66/** panel_set_cb() sets callback */
     67PCUT_TEST(set_cb)
     68{
     69        panel_t *panel;
     70        errno_t rc;
     71        test_resp_t resp;
     72
     73        rc = panel_create(NULL, true, &panel);
     74        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     75
     76        panel_set_cb(panel, &test_cb, &resp);
     77        PCUT_ASSERT_EQUALS(&test_cb, panel->cb);
     78        PCUT_ASSERT_EQUALS(&resp, panel->cb_arg);
    5079
    5180        panel_destroy(panel);
     
    14261455}
    14271456
     1457/** panel_activate_req() sends activation request */
     1458PCUT_TEST(activate_req)
     1459{
     1460        panel_t *panel;
     1461        errno_t rc;
     1462        test_resp_t resp;
     1463
     1464        rc = panel_create(NULL, true, &panel);
     1465        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1466
     1467        panel_set_cb(panel, &test_cb, &resp);
     1468
     1469        resp.activate_req = false;
     1470        resp.activate_req_panel = NULL;
     1471
     1472        panel_activate_req(panel);
     1473        PCUT_ASSERT_TRUE(resp.activate_req);
     1474        PCUT_ASSERT_EQUALS(panel, resp.activate_req_panel);
     1475
     1476        panel_destroy(panel);
     1477}
     1478
     1479static void test_panel_activate_req(void *arg, panel_t *panel)
     1480{
     1481        test_resp_t *resp = (test_resp_t *)arg;
     1482
     1483        resp->activate_req = true;
     1484        resp->activate_req_panel = panel;
     1485}
     1486
    14281487PCUT_EXPORT(panel);
Note: See TracChangeset for help on using the changeset viewer.