HelenOS sources
This source file includes following definitions.
- test_ds_wmev_pending
- PCUT_TEST
- 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 "../wmclient.h"
PCUT_INIT;
PCUT_TEST_SUITE(wmclient);
static void test_ds_wmev_pending(void *);
static ds_wmclient_cb_t test_ds_wmclient_cb = {
.ev_pending = test_ds_wmev_pending
};
static void test_ds_wmev_pending(void *arg)
{
bool *called_cb = (bool *) arg;
*called_cb = true;
}
PCUT_TEST(create_destroy)
{
ds_display_t *disp;
ds_wmclient_t *wmclient;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, NULL, &wmclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ds_wmclient_destroy(wmclient);
ds_display_destroy(disp);
}
PCUT_TEST(client_get_post_wnd_added_event)
{
ds_display_t *disp;
ds_wmclient_t *wmclient;
wndmgt_ev_t revent;
bool called_cb = NULL;
sysarg_t wnd_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, &called_cb,
&wmclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
called_cb = false;
wnd_id = 42;
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
rc = ds_wmclient_post_wnd_added_event(wmclient, wnd_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(called_cb);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_EQUALS(wnd_id, revent.wnd_id);
PCUT_ASSERT_EQUALS(wmev_window_added, revent.etype);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_wmclient_destroy(wmclient);
ds_display_destroy(disp);
}
PCUT_TEST(client_get_post_wnd_removed_event)
{
ds_display_t *disp;
ds_wmclient_t *wmclient;
wndmgt_ev_t revent;
bool called_cb = NULL;
sysarg_t wnd_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, &called_cb,
&wmclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
called_cb = false;
wnd_id = 42;
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
rc = ds_wmclient_post_wnd_removed_event(wmclient, wnd_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(called_cb);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_EQUALS(wnd_id, revent.wnd_id);
PCUT_ASSERT_EQUALS(wmev_window_removed, revent.etype);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_wmclient_destroy(wmclient);
ds_display_destroy(disp);
}
PCUT_TEST(client_get_post_wnd_changed_event)
{
ds_display_t *disp;
ds_wmclient_t *wmclient;
wndmgt_ev_t revent;
bool called_cb = NULL;
sysarg_t wnd_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, &called_cb,
&wmclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
called_cb = false;
wnd_id = 42;
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
rc = ds_wmclient_post_wnd_changed_event(wmclient, wnd_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(called_cb);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_EQUALS(wnd_id, revent.wnd_id);
PCUT_ASSERT_EQUALS(wmev_window_changed, revent.etype);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_wmclient_destroy(wmclient);
ds_display_destroy(disp);
}
PCUT_TEST(purge_events)
{
ds_display_t *disp;
ds_wmclient_t *wmclient;
wndmgt_ev_t revent;
bool called_cb = NULL;
sysarg_t wnd_id;
errno_t rc;
rc = ds_display_create(NULL, df_none, &disp);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, &called_cb,
&wmclient);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
wnd_id = 42;
rc = ds_wmclient_post_wnd_added_event(wmclient, wnd_id);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ds_wmclient_purge_events(wmclient);
rc = ds_wmclient_get_event(wmclient, &revent);
PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
ds_wmclient_destroy(wmclient);
ds_display_destroy(disp);
}
PCUT_EXPORT(wmclient);
HelenOS homepage, sources at GitHub