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

Changeset a40ae0d in mainline for uspace/srv/hid/display/test/window.c


Ignore:
Timestamp:
2020-01-09T16:44:57Z (10 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
946a666
Parents:
8e9781f
git-author:
Jiri Svoboda <jiri@…> (2020-01-09 18:44:03)
git-committer:
Jiri Svoboda <jiri@…> (2020-01-09 16:44:57)
Message:

Moving windows by mouse drag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/test/window.c

    r8e9781f ra40ae0d  
    2929#include <disp_srv.h>
    3030#include <errno.h>
     31#include <gfx/context.h>
    3132#include <pcut/pcut.h>
    3233#include <stdio.h>
     
    4041
    4142PCUT_TEST_SUITE(window);
     43
     44static errno_t dummy_set_color(void *, gfx_color_t *);
     45static errno_t dummy_fill_rect(void *, gfx_rect_t *);
     46
     47static gfx_context_ops_t dummy_ops = {
     48        .set_color = dummy_set_color,
     49        .fill_rect = dummy_fill_rect
     50};
    4251
    4352/** Test ds_window_get_ctx(). */
     
    7281}
    7382
     83/** Test ds_window_post_pos_event() */
     84PCUT_TEST(window_post_pos_event)
     85{
     86        gfx_context_t *gc;
     87        ds_display_t *disp;
     88        ds_client_t *client;
     89        ds_window_t *wnd;
     90        display_wnd_params_t params;
     91        pos_event_t event;
     92        errno_t rc;
     93
     94        rc = gfx_context_new(&dummy_ops, NULL, &gc);
     95        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     96
     97        rc = ds_display_create(gc, &disp);
     98        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     99
     100        rc = ds_client_create(disp, NULL, NULL, &client);
     101        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     102
     103        display_wnd_params_init(&params);
     104        params.rect.p0.x = params.rect.p0.y = 0;
     105        params.rect.p1.x = params.rect.p1.y = 1;
     106
     107        rc = ds_window_create(client, &params, &wnd);
     108        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     109
     110        PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
     111
     112        event.type = POS_PRESS;
     113        event.hpos = 10;
     114        event.vpos = 10;
     115        rc = ds_window_post_pos_event(wnd, &event);
     116        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     117
     118        PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
     119
     120        event.type = POS_UPDATE;
     121        event.hpos = 11;
     122        event.vpos = 12;
     123        rc = ds_window_post_pos_event(wnd, &event);
     124        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     125
     126        PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
     127        PCUT_ASSERT_INT_EQUALS(wnd->dpos.x, 0);
     128        PCUT_ASSERT_INT_EQUALS(wnd->dpos.y, 0);
     129
     130        event.type = POS_RELEASE;
     131        event.hpos = 13;
     132        event.vpos = 14;
     133
     134        rc = ds_window_post_pos_event(wnd, &event);
     135        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     136
     137        PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
     138        PCUT_ASSERT_INT_EQUALS(wnd->dpos.x, 3);
     139        PCUT_ASSERT_INT_EQUALS(wnd->dpos.y, 4);
     140
     141        ds_window_destroy(wnd);
     142        ds_client_destroy(client);
     143        ds_display_destroy(disp);
     144}
     145
     146static errno_t dummy_set_color(void *arg, gfx_color_t *color)
     147{
     148        return EOK;
     149}
     150
     151static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect)
     152{
     153        return EOK;
     154}
     155
    74156PCUT_EXPORT(window);
Note: See TracChangeset for help on using the changeset viewer.