HelenOS sources
This source file includes following definitions.
- test_ds_dcev_pending
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
#include <disp_srv.h>
#include <errno.h>
#include <pcut/pcut.h>
#include <str.h>
#include "../display.h"
#include "../cfgclient.h"
PCUT_INIT;
PCUT_TEST_SUITE(cfgclient);
static void test_ds_dcev_pending(void *);
static ds_cfgclient_cb_t test_ds_cfgclient_cb = {
.ev_pending = test_ds_dcev_pending
};
static void test_ds_dcev_pending(void *arg)
{
bool *called_cb = (bool *) arg;
*called_cb = true;
}
PCUT_TEST(create_destroy)
{
ds_display_t *disp;
ds_cfgclient_t *cfgclient;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_cfgclient_create(disp, &test_ds_cfgclient_cb, NULL, &cfgclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ds_cfgclient_destroy(cfgclient);
ds_display_destroy(disp);
}
PCUT_TEST(client_get_post_seat_added_event)
{
ds_display_t *disp;
ds_cfgclient_t *cfgclient;
dispcfg_ev_t revent;
bool called_cb = NULL;
sysarg_t seat_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_cfgclient_create(disp, &test_ds_cfgclient_cb, &called_cb,
&cfgclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
called_cb = false;
seat_id = 42;
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
rc = ds_cfgclient_post_seat_added_event(cfgclient, seat_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(called_cb);
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_EQUALS(seat_id, revent.seat_id);
PCUT_ASSERT_EQUALS(dcev_seat_added, revent.etype);
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_cfgclient_destroy(cfgclient);
ds_display_destroy(disp);
}
PCUT_TEST(client_get_post_seat_removed_event)
{
ds_display_t *disp;
ds_cfgclient_t *cfgclient;
dispcfg_ev_t revent;
bool called_cb = NULL;
sysarg_t seat_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_cfgclient_create(disp, &test_ds_cfgclient_cb, &called_cb,
&cfgclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
called_cb = false;
seat_id = 42;
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
rc = ds_cfgclient_post_seat_removed_event(cfgclient, seat_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(called_cb);
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_EQUALS(seat_id, revent.seat_id);
PCUT_ASSERT_EQUALS(dcev_seat_removed, revent.etype);
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_cfgclient_destroy(cfgclient);
ds_display_destroy(disp);
}
PCUT_TEST(purge_events)
{
ds_display_t *disp;
ds_cfgclient_t *cfgclient;
dispcfg_ev_t revent;
bool called_cb = NULL;
sysarg_t seat_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_cfgclient_create(disp, &test_ds_cfgclient_cb, &called_cb,
&cfgclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
seat_id = 42;
rc = ds_cfgclient_post_seat_added_event(cfgclient, seat_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ds_cfgclient_purge_events(cfgclient);
rc = ds_cfgclient_get_event(cfgclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_cfgclient_destroy(cfgclient);
ds_display_destroy(disp);
}
PCUT_EXPORT(cfgclient);
HelenOS homepage, sources at GitHub