Changeset 24cf391a in mainline for uspace/srv/hid/display/test/display.c
- Timestamp:
- 2019-12-03T10:59:47Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 973efd36
- Parents:
- 79949f3
- git-author:
- Jiri Svoboda <jiri@…> (2019-11-02 18:59:43)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-12-03 10:59:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/display.c
r79949f3 r24cf391a 140 140 } 141 141 142 /** Test ds_display_window_by_pos(). */ 143 PCUT_TEST(display_window_by_pos) 144 { 145 ds_display_t *disp; 146 ds_client_t *client; 147 ds_window_t *w0; 148 ds_window_t *w1; 149 ds_window_t *wnd; 150 gfx_coord2_t pos; 151 errno_t rc; 152 153 rc = ds_display_create(NULL, &disp); 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 155 156 rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 159 rc = ds_window_create(client, &w0); 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 162 rc = ds_window_create(client, &w1); 163 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 164 165 w0->dpos.x = 10; 166 w0->dpos.y = 10; 167 168 w1->dpos.x = 400; 169 w1->dpos.y = 400; 170 171 pos.x = 10; 172 pos.y = 10; 173 wnd = ds_display_window_by_pos(disp, &pos); 174 PCUT_ASSERT_EQUALS(w0, wnd); 175 176 pos.x = 400; 177 pos.y = 400; 178 wnd = ds_display_window_by_pos(disp, &pos); 179 PCUT_ASSERT_EQUALS(w1, wnd); 180 181 ds_window_destroy(w0); 182 ds_window_destroy(w1); 183 ds_client_destroy(client); 184 ds_display_destroy(disp); 185 } 186 142 187 /** Basic seat operation. */ 143 188 PCUT_TEST(display_seat) … … 164 209 } 165 210 166 /** Test ds_display_post_kbd_event(). */ 211 /** Test ds_display_post_kbd_event() delivers event to client callback. 212 */ 167 213 PCUT_TEST(display_post_kbd_event) 168 214 { … … 172 218 ds_window_t *wnd; 173 219 kbd_event_t event; 174 bool called_cb = NULL;220 bool called_cb = false; 175 221 errno_t rc; 176 222 … … 206 252 } 207 253 254 /** Test ds_display_post_kbd_event() with Alt-Tab switches focus. 255 */ 256 PCUT_TEST(display_post_kbd_event_alt_tab) 257 { 258 ds_display_t *disp; 259 ds_seat_t *seat; 260 ds_client_t *client; 261 ds_window_t *w0, *w1; 262 kbd_event_t event; 263 bool called_cb = false; 264 errno_t rc; 265 266 rc = ds_display_create(NULL, &disp); 267 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 268 269 rc = ds_seat_create(disp, &seat); 270 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 271 272 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 273 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 274 275 rc = ds_window_create(client, &w0); 276 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 277 278 rc = ds_window_create(client, &w1); 279 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 280 281 ds_seat_set_focus(seat, w0); 282 283 event.type = KEY_PRESS; 284 event.key = KC_TAB; 285 event.mods = KM_ALT; 286 event.c = L'\0'; 287 288 PCUT_ASSERT_FALSE(called_cb); 289 290 rc = ds_display_post_kbd_event(disp, &event); 291 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 292 PCUT_ASSERT_FALSE(called_cb); 293 294 /* Next window should be focused */ 295 PCUT_ASSERT_EQUALS(w1, seat->focus); 296 297 rc = ds_display_post_kbd_event(disp, &event); 298 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 299 PCUT_ASSERT_FALSE(called_cb); 300 301 /* Focus should be back to the first window */ 302 PCUT_ASSERT_EQUALS(w0, seat->focus); 303 304 ds_window_destroy(w0); 305 ds_window_destroy(w1); 306 ds_client_destroy(client); 307 ds_seat_destroy(seat); 308 ds_display_destroy(disp); 309 } 310 311 /** Test ds_display_post_pos_event() with click on window switches focus 312 */ 313 PCUT_TEST(display_post_pos_event_wnd_switch) 314 { 315 ds_display_t *disp; 316 ds_seat_t *seat; 317 ds_client_t *client; 318 ds_window_t *w0, *w1; 319 pos_event_t event; 320 bool called_cb = false; 321 errno_t rc; 322 323 rc = ds_display_create(NULL, &disp); 324 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 325 326 rc = ds_seat_create(disp, &seat); 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 328 329 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 330 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 331 332 rc = ds_window_create(client, &w0); 333 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 334 335 rc = ds_window_create(client, &w1); 336 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 337 338 w0->dpos.x = 10; 339 w0->dpos.y = 10; 340 341 w1->dpos.x = 400; 342 w1->dpos.y = 400; 343 344 ds_seat_set_focus(seat, w0); 345 346 event.type = POS_PRESS; 347 event.btn_num = 1; 348 349 PCUT_ASSERT_FALSE(called_cb); 350 351 event.hpos = 400; 352 event.vpos = 400; 353 rc = ds_display_post_pos_event(disp, &event); 354 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 355 PCUT_ASSERT_FALSE(called_cb); 356 357 PCUT_ASSERT_EQUALS(w1, seat->focus); 358 359 event.hpos = 10; 360 event.vpos = 10; 361 rc = ds_display_post_pos_event(disp, &event); 362 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 363 PCUT_ASSERT_FALSE(called_cb); 364 365 PCUT_ASSERT_EQUALS(w0, seat->focus); 366 367 ds_window_destroy(w0); 368 ds_window_destroy(w1); 369 ds_client_destroy(client); 370 ds_seat_destroy(seat); 371 ds_display_destroy(disp); 372 } 373 208 374 PCUT_EXPORT(display);
Note:
See TracChangeset
for help on using the changeset viewer.