Changes in uspace/srv/hid/display/test/display.c [b3eeae5:195b7b3] in mainline
- File:
-
- 1 edited
-
uspace/srv/hid/display/test/display.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/display.c
rb3eeae5 r195b7b3 1 1 /* 2 * Copyright (c) 20 23Jiri Svoboda2 * Copyright (c) 2019 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 32 32 #include <str.h> 33 33 34 #include "../cfgclient.h"35 34 #include "../client.h" 36 35 #include "../display.h" 37 #include "../idevcfg.h"38 36 #include "../seat.h" 39 37 #include "../window.h" 40 #include "../wmclient.h"41 38 42 39 PCUT_INIT; … … 50 47 }; 51 48 52 static void test_ds_wmev_pending(void *);53 54 static ds_wmclient_cb_t test_ds_wmclient_cb = {55 .ev_pending = test_ds_wmev_pending56 };57 58 static void test_ds_cfgev_pending(void *);59 60 static ds_cfgclient_cb_t test_ds_cfgclient_cb = {61 .ev_pending = test_ds_cfgev_pending62 };63 64 49 static void test_ds_ev_pending(void *arg) 65 50 { … … 68 53 } 69 54 70 static void test_ds_wmev_pending(void *arg)71 {72 bool *called_cb = (bool *) arg;73 *called_cb = true;74 }75 76 static void test_ds_cfgev_pending(void *arg)77 {78 bool *called_cb = (bool *) arg;79 *called_cb = true;80 }81 82 55 /** Display creation and destruction. */ 83 56 PCUT_TEST(display_create_destroy) … … 116 89 } 117 90 118 /** Basic WM client operation. */119 PCUT_TEST(display_wmclient)120 {121 ds_display_t *disp;122 ds_wmclient_t *wmclient;123 ds_wmclient_t *c0, *c1;124 errno_t rc;125 126 rc = ds_display_create(NULL, df_none, &disp);127 PCUT_ASSERT_ERRNO_VAL(EOK, rc);128 129 rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, NULL, &wmclient);130 PCUT_ASSERT_ERRNO_VAL(EOK, rc);131 132 c0 = ds_display_first_wmclient(disp);133 PCUT_ASSERT_EQUALS(c0, wmclient);134 135 c1 = ds_display_next_wmclient(c0);136 PCUT_ASSERT_NULL(c1);137 138 ds_wmclient_destroy(wmclient);139 ds_display_destroy(disp);140 }141 142 /** Basic CFG client operation. */143 PCUT_TEST(display_cfgclient)144 {145 ds_display_t *disp;146 ds_cfgclient_t *cfgclient;147 errno_t rc;148 149 rc = ds_display_create(NULL, df_none, &disp);150 PCUT_ASSERT_ERRNO_VAL(EOK, rc);151 152 rc = ds_cfgclient_create(disp, &test_ds_cfgclient_cb, NULL, &cfgclient);153 PCUT_ASSERT_ERRNO_VAL(EOK, rc);154 155 ds_cfgclient_destroy(cfgclient);156 ds_display_destroy(disp);157 }158 159 91 /** Test ds_display_find_window(). */ 160 92 PCUT_TEST(display_find_window) … … 162 94 ds_display_t *disp; 163 95 ds_client_t *client; 164 ds_seat_t *seat;165 96 ds_window_t *w0; 166 97 ds_window_t *w1; 167 98 ds_window_t *wnd; 168 99 display_wnd_params_t params; 169 bool called_cb = false; 170 errno_t rc; 171 172 rc = ds_display_create(NULL, df_none, &disp); 173 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 174 175 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 176 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 177 178 rc = ds_seat_create(disp, "Alice", &seat); 100 errno_t rc; 101 102 rc = ds_display_create(NULL, df_none, &disp); 103 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 104 105 rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client); 179 106 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 180 107 … … 221 148 ds_window_destroy(w0); 222 149 ds_window_destroy(w1); 223 ds_seat_destroy(seat);224 ds_client_destroy(client);225 ds_display_destroy(disp);226 }227 228 /** Test ds_display_enlist_window() */229 PCUT_TEST(display_enlist_window)230 {231 ds_display_t *disp;232 ds_client_t *client;233 ds_seat_t *seat;234 ds_window_t *w0;235 ds_window_t *w1;236 ds_window_t *w2;237 ds_window_t *w3;238 ds_window_t *w;239 display_wnd_params_t params;240 bool called_cb = false;241 errno_t rc;242 243 rc = ds_display_create(NULL, df_none, &disp);244 PCUT_ASSERT_ERRNO_VAL(EOK, rc);245 246 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);247 PCUT_ASSERT_ERRNO_VAL(EOK, rc);248 249 rc = ds_seat_create(disp, "Alice", &seat);250 PCUT_ASSERT_ERRNO_VAL(EOK, rc);251 252 display_wnd_params_init(¶ms);253 params.rect.p0.x = params.rect.p0.y = 0;254 params.rect.p1.x = params.rect.p1.y = 100;255 256 /* Regular windows */257 258 rc = ds_window_create(client, ¶ms, &w0);259 PCUT_ASSERT_ERRNO_VAL(EOK, rc);260 261 rc = ds_window_create(client, ¶ms, &w1);262 PCUT_ASSERT_ERRNO_VAL(EOK, rc);263 264 /* Topmost windows */265 266 params.flags |= wndf_topmost;267 268 rc = ds_window_create(client, ¶ms, &w2);269 PCUT_ASSERT_ERRNO_VAL(EOK, rc);270 271 rc = ds_window_create(client, ¶ms, &w3);272 PCUT_ASSERT_ERRNO_VAL(EOK, rc);273 274 /* Delist w1 and w2 */275 list_remove(&w1->ldwindows);276 list_remove(&w2->ldwindows);277 278 /* Enlist the windows back and check their order */279 ds_display_enlist_window(disp, w1);280 ds_display_enlist_window(disp, w2);281 282 w = ds_display_first_window(disp);283 PCUT_ASSERT_EQUALS(w2, w);284 w = ds_display_next_window(w);285 PCUT_ASSERT_EQUALS(w3, w);286 w = ds_display_next_window(w);287 PCUT_ASSERT_EQUALS(w1, w);288 w = ds_display_next_window(w);289 PCUT_ASSERT_EQUALS(w0, w);290 w = ds_display_next_window(w);291 PCUT_ASSERT_EQUALS(NULL, w);292 293 ds_window_destroy(w0);294 ds_window_destroy(w1);295 ds_window_destroy(w2);296 ds_window_destroy(w3);297 ds_seat_destroy(seat);298 ds_client_destroy(client);299 ds_display_destroy(disp);300 }301 302 /** Test ds_display_window_to_top() */303 PCUT_TEST(display_window_to_top)304 {305 ds_display_t *disp;306 ds_client_t *client;307 ds_seat_t *seat;308 ds_window_t *w0;309 ds_window_t *w1;310 display_wnd_params_t params;311 bool called_cb = false;312 errno_t rc;313 314 rc = ds_display_create(NULL, df_none, &disp);315 PCUT_ASSERT_ERRNO_VAL(EOK, rc);316 317 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);318 PCUT_ASSERT_ERRNO_VAL(EOK, rc);319 320 rc = ds_seat_create(disp, "Alice", &seat);321 PCUT_ASSERT_ERRNO_VAL(EOK, rc);322 323 display_wnd_params_init(¶ms);324 params.rect.p0.x = params.rect.p0.y = 0;325 params.rect.p1.x = params.rect.p1.y = 100;326 327 rc = ds_window_create(client, ¶ms, &w0);328 PCUT_ASSERT_ERRNO_VAL(EOK, rc);329 330 rc = ds_window_create(client, ¶ms, &w1);331 PCUT_ASSERT_ERRNO_VAL(EOK, rc);332 333 PCUT_ASSERT_EQUALS(w1, ds_display_first_window(disp));334 ds_display_window_to_top(w0);335 PCUT_ASSERT_EQUALS(w0, ds_display_first_window(disp));336 337 ds_window_destroy(w0);338 ds_window_destroy(w1);339 ds_seat_destroy(seat);340 150 ds_client_destroy(client); 341 151 ds_display_destroy(disp); … … 347 157 ds_display_t *disp; 348 158 ds_client_t *client; 349 ds_seat_t *seat;350 159 ds_window_t *w0; 351 160 ds_window_t *w1; … … 353 162 display_wnd_params_t params; 354 163 gfx_coord2_t pos; 355 bool called_cb = false; 356 errno_t rc; 357 358 rc = ds_display_create(NULL, df_none, &disp); 359 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 360 361 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 362 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 363 364 rc = ds_seat_create(disp, "Alice", &seat); 164 errno_t rc; 165 166 rc = ds_display_create(NULL, df_none, &disp); 167 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 168 169 rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client); 365 170 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 366 171 … … 393 198 ds_window_destroy(w0); 394 199 ds_window_destroy(w1); 395 ds_seat_destroy(seat); 396 ds_client_destroy(client); 397 ds_display_destroy(disp); 398 } 399 400 /** Basic idevcfg operation */ 401 PCUT_TEST(display_idevcfg) 402 { 403 ds_display_t *disp; 404 ds_seat_t *seat; 405 ds_idevcfg_t *idevcfg; 406 errno_t rc; 407 408 rc = ds_display_create(NULL, df_none, &disp); 409 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 410 411 rc = ds_seat_create(disp, "Alice", &seat); 412 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 413 414 rc = ds_idevcfg_create(disp, 42, seat, &idevcfg); 415 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 416 417 ds_idevcfg_destroy(idevcfg); 418 419 ds_seat_destroy(seat); 200 ds_client_destroy(client); 420 201 ds_display_destroy(disp); 421 202 } … … 426 207 ds_display_t *disp; 427 208 ds_seat_t *seat; 428 ds_seat_t *s0, *s1 , *s2;429 errno_t rc; 430 431 rc = ds_display_create(NULL, df_none, &disp); 432 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 433 434 rc = ds_seat_create(disp, "Alice",&seat);209 ds_seat_t *s0, *s1; 210 errno_t rc; 211 212 rc = ds_display_create(NULL, df_none, &disp); 213 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 214 215 rc = ds_seat_create(disp, &seat); 435 216 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 436 217 … … 441 222 PCUT_ASSERT_NULL(s1); 442 223 443 s2 = ds_display_find_seat(disp, seat->id);444 PCUT_ASSERT_EQUALS(s2, seat);445 446 224 ds_seat_destroy(seat); 447 225 ds_display_destroy(disp); 448 }449 450 /** ds_display_seat_by_idev() returns the correct seat. */451 PCUT_TEST(display_seat_by_idev)452 {453 // XXX TODO454 226 } 455 227 … … 470 242 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 471 243 472 rc = ds_seat_create(disp, "Alice",&seat);244 rc = ds_seat_create(disp, &seat); 473 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 474 246 … … 518 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 519 291 520 rc = ds_seat_create(disp, "Alice",&seat);292 rc = ds_seat_create(disp, &seat); 521 293 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 522 294 … … 586 358 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 587 359 588 rc = ds_seat_create(disp, "Alice",&seat);360 rc = ds_seat_create(disp, &seat); 589 361 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 590 362 … … 658 430 } 659 431 660 /** ds_display_update_max_rect() updates maximization rectangle */661 PCUT_TEST(display_update_max_rect)662 {663 ds_display_t *disp;664 ds_seat_t *seat;665 ds_client_t *client;666 ds_window_t *wnd;667 display_wnd_params_t params;668 errno_t rc;669 670 rc = ds_display_create(NULL, df_none, &disp);671 PCUT_ASSERT_ERRNO_VAL(EOK, rc);672 673 rc = ds_seat_create(disp, "Alice", &seat);674 PCUT_ASSERT_ERRNO_VAL(EOK, rc);675 676 rc = ds_client_create(disp, NULL, NULL, &client);677 PCUT_ASSERT_ERRNO_VAL(EOK, rc);678 679 /*680 * We need to set display dimensions Here we do it directly681 * instead of adding a display device.682 */683 disp->rect.p0.x = 0;684 disp->rect.p0.y = 0;685 disp->rect.p1.x = 500;686 disp->rect.p1.y = 500;687 688 /* Set maximize rectangle as well */689 disp->max_rect = disp->rect;690 691 /* A panel-like window at the bottom */692 display_wnd_params_init(¶ms);693 params.flags |= wndf_setpos;694 params.pos.x = 0;695 params.pos.y = 450;696 params.rect.p0.x = 0;697 params.rect.p0.y = 0;698 params.rect.p1.x = 500;699 params.rect.p1.y = 50;700 701 rc = ds_window_create(client, ¶ms, &wnd);702 PCUT_ASSERT_ERRNO_VAL(EOK, rc);703 704 /*705 * At this point the maximize rect should be unaltered because706 * the avoid flag has not been set.707 */708 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x);709 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y);710 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x);711 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.y);712 713 wnd->flags |= wndf_avoid;714 715 /* Update maximize rectangle */716 ds_display_update_max_rect(disp);717 718 /* Verify maximize rectangle */719 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x);720 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y);721 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x);722 PCUT_ASSERT_INT_EQUALS(450, disp->max_rect.p1.y);723 724 ds_window_destroy(wnd);725 ds_client_destroy(client);726 ds_seat_destroy(seat);727 ds_display_destroy(disp);728 }729 730 /** Cropping maximization rectangle from the top */731 PCUT_TEST(display_crop_max_rect_top)732 {733 gfx_rect_t arect;734 gfx_rect_t mrect;735 736 arect.p0.x = 10;737 arect.p0.y = 20;738 arect.p1.x = 30;739 arect.p1.y = 5;740 741 mrect.p0.x = 10;742 mrect.p0.y = 20;743 mrect.p1.x = 30;744 mrect.p1.y = 40;745 746 ds_display_crop_max_rect(&arect, &mrect);747 748 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x);749 PCUT_ASSERT_INT_EQUALS(5, mrect.p0.y);750 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x);751 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y);752 }753 754 /** Cropping maximization rectangle from the bottom */755 PCUT_TEST(display_crop_max_rect_bottom)756 {757 gfx_rect_t arect;758 gfx_rect_t mrect;759 760 arect.p0.x = 10;761 arect.p0.y = 35;762 arect.p1.x = 30;763 arect.p1.y = 40;764 765 mrect.p0.x = 10;766 mrect.p0.y = 20;767 mrect.p1.x = 30;768 mrect.p1.y = 40;769 770 ds_display_crop_max_rect(&arect, &mrect);771 772 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x);773 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y);774 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x);775 PCUT_ASSERT_INT_EQUALS(35, mrect.p1.y);776 }777 778 /** Cropping maximization rectangle from the left */779 PCUT_TEST(display_crop_max_rect_left)780 {781 gfx_rect_t arect;782 gfx_rect_t mrect;783 784 arect.p0.x = 10;785 arect.p0.y = 20;786 arect.p1.x = 15;787 arect.p1.y = 40;788 789 mrect.p0.x = 10;790 mrect.p0.y = 20;791 mrect.p1.x = 30;792 mrect.p1.y = 40;793 794 ds_display_crop_max_rect(&arect, &mrect);795 796 PCUT_ASSERT_INT_EQUALS(15, mrect.p0.x);797 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y);798 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x);799 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y);800 }801 802 /** Cropping maximization rectangle from the right */803 PCUT_TEST(display_crop_max_rect_right)804 {805 gfx_rect_t arect;806 gfx_rect_t mrect;807 808 arect.p0.x = 25;809 arect.p0.y = 20;810 arect.p1.x = 30;811 arect.p1.y = 40;812 813 mrect.p0.x = 10;814 mrect.p0.y = 20;815 mrect.p1.x = 30;816 mrect.p1.y = 40;817 818 ds_display_crop_max_rect(&arect, &mrect);819 820 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x);821 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y);822 PCUT_ASSERT_INT_EQUALS(25, mrect.p1.x);823 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y);824 }825 826 432 PCUT_EXPORT(display);
Note:
See TracChangeset
for help on using the changeset viewer.
