HelenOS sources
This source file includes following definitions.
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
#include <errno.h>
#include <gfx/coord.h>
#include <pcut/pcut.h>
#include <ui/ui.h>
#include <ui/window.h>
#include "../clock.h"
PCUT_INIT;
PCUT_TEST_SUITE(clock);
PCUT_TEST(create_destroy)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_TEST(paint)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = taskbar_clock_paint(clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_TEST(kbd_event)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
kbd_event_t event;
ui_evclaim_t claim;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
event.type = KEY_PRESS;
event.key = KC_ENTER;
event.mods = 0;
claim = taskbar_clock_kbd_event(clock, &event);
PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_TEST(pos_event)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
pos_event_t event;
ui_evclaim_t claim;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
event.type = POS_PRESS;
event.hpos = 0;
event.vpos = 0;
claim = taskbar_clock_pos_event(clock, &event);
PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_TEST(ctl)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
ui_control_t *ctl;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ctl = taskbar_clock_ctl(clock);
PCUT_ASSERT_NOT_NULL(ctl);
rc = ui_control_paint(ctl);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_TEST(set_rect)
{
errno_t rc;
ui_t *ui = NULL;
ui_wnd_params_t params;
ui_window_t *window = NULL;
taskbar_clock_t *clock;
gfx_rect_t rect;
rc = ui_create_disp(NULL, &ui);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
ui_wnd_params_init(¶ms);
params.caption = "Hello";
rc = ui_window_create(ui, ¶ms, &window);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);
rc = taskbar_clock_create(window, &clock);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rect.p0.x = 1;
rect.p0.y = 2;
rect.p1.x = 3;
rect.p1.y = 4;
taskbar_clock_set_rect(clock, &rect);
PCUT_ASSERT_INT_EQUALS(rect.p0.x, clock->rect.p0.x);
PCUT_ASSERT_INT_EQUALS(rect.p0.y, clock->rect.p0.y);
PCUT_ASSERT_INT_EQUALS(rect.p1.x, clock->rect.p1.x);
PCUT_ASSERT_INT_EQUALS(rect.p1.y, clock->rect.p1.y);
taskbar_clock_destroy(clock);
ui_window_destroy(window);
ui_destroy(ui);
}
PCUT_EXPORT(clock);
HelenOS homepage, sources at GitHub