Changeset a40ae0d in mainline for uspace/srv/hid/display/test/window.c
- Timestamp:
- 2020-01-09T16:44:57Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/window.c
r8e9781f ra40ae0d 29 29 #include <disp_srv.h> 30 30 #include <errno.h> 31 #include <gfx/context.h> 31 32 #include <pcut/pcut.h> 32 33 #include <stdio.h> … … 40 41 41 42 PCUT_TEST_SUITE(window); 43 44 static errno_t dummy_set_color(void *, gfx_color_t *); 45 static errno_t dummy_fill_rect(void *, gfx_rect_t *); 46 47 static gfx_context_ops_t dummy_ops = { 48 .set_color = dummy_set_color, 49 .fill_rect = dummy_fill_rect 50 }; 42 51 43 52 /** Test ds_window_get_ctx(). */ … … 72 81 } 73 82 83 /** Test ds_window_post_pos_event() */ 84 PCUT_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(¶ms); 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, ¶ms, &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 146 static errno_t dummy_set_color(void *arg, gfx_color_t *color) 147 { 148 return EOK; 149 } 150 151 static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect) 152 { 153 return EOK; 154 } 155 74 156 PCUT_EXPORT(window);
Note:
See TracChangeset
for help on using the changeset viewer.