[c8cf261] | 1 | /*
|
---|
[d8503fd] | 2 | * Copyright (c) 2023 Jiri Svoboda
|
---|
[c8cf261] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[3434233] | 29 | #include <disp_srv.h>
|
---|
[6af4b4f] | 30 | #include <errno.h>
|
---|
| 31 | #include <pcut/pcut.h>
|
---|
| 32 | #include <str.h>
|
---|
[c8cf261] | 33 |
|
---|
[d8503fd] | 34 | #include "../cfgclient.h"
|
---|
[b3c185b6] | 35 | #include "../client.h"
|
---|
[6af4b4f] | 36 | #include "../display.h"
|
---|
[b3eeae5] | 37 | #include "../idevcfg.h"
|
---|
[cf32dbd] | 38 | #include "../seat.h"
|
---|
[b2d1df3] | 39 | #include "../window.h"
|
---|
[913add60] | 40 | #include "../wmclient.h"
|
---|
[c8cf261] | 41 |
|
---|
[6af4b4f] | 42 | PCUT_INIT;
|
---|
[c8cf261] | 43 |
|
---|
[6af4b4f] | 44 | PCUT_TEST_SUITE(display);
|
---|
[c8cf261] | 45 |
|
---|
[be15256] | 46 | static void test_ds_ev_pending(void *);
|
---|
| 47 |
|
---|
| 48 | static ds_client_cb_t test_ds_client_cb = {
|
---|
| 49 | .ev_pending = test_ds_ev_pending
|
---|
| 50 | };
|
---|
| 51 |
|
---|
[913add60] | 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_pending
|
---|
| 56 | };
|
---|
| 57 |
|
---|
[d8503fd] | 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_pending
|
---|
| 62 | };
|
---|
| 63 |
|
---|
[be15256] | 64 | static void test_ds_ev_pending(void *arg)
|
---|
| 65 | {
|
---|
[b2d1df3] | 66 | bool *called_cb = (bool *) arg;
|
---|
| 67 | *called_cb = true;
|
---|
| 68 | }
|
---|
[be15256] | 69 |
|
---|
[913add60] | 70 | static void test_ds_wmev_pending(void *arg)
|
---|
| 71 | {
|
---|
| 72 | bool *called_cb = (bool *) arg;
|
---|
| 73 | *called_cb = true;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[d8503fd] | 76 | static void test_ds_cfgev_pending(void *arg)
|
---|
| 77 | {
|
---|
| 78 | bool *called_cb = (bool *) arg;
|
---|
| 79 | *called_cb = true;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[6af4b4f] | 82 | /** Display creation and destruction. */
|
---|
[bef51cf] | 83 | PCUT_TEST(display_create_destroy)
|
---|
[6af4b4f] | 84 | {
|
---|
| 85 | ds_display_t *disp;
|
---|
| 86 | errno_t rc;
|
---|
[c8cf261] | 87 |
|
---|
[8aef01c] | 88 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[6af4b4f] | 89 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 90 |
|
---|
| 91 | ds_display_destroy(disp);
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[b3c185b6] | 94 | /** Basic client operation. */
|
---|
| 95 | PCUT_TEST(display_client)
|
---|
[bef51cf] | 96 | {
|
---|
| 97 | ds_display_t *disp;
|
---|
[b3c185b6] | 98 | ds_client_t *client;
|
---|
| 99 | ds_client_t *c0, *c1;
|
---|
[bef51cf] | 100 | errno_t rc;
|
---|
| 101 |
|
---|
[8aef01c] | 102 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[bef51cf] | 103 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 104 |
|
---|
[be15256] | 105 | rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client);
|
---|
[bef51cf] | 106 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 107 |
|
---|
[b3c185b6] | 108 | c0 = ds_display_first_client(disp);
|
---|
| 109 | PCUT_ASSERT_EQUALS(c0, client);
|
---|
[bef51cf] | 110 |
|
---|
[b3c185b6] | 111 | c1 = ds_display_next_client(c0);
|
---|
| 112 | PCUT_ASSERT_NULL(c1);
|
---|
[bef51cf] | 113 |
|
---|
[b3c185b6] | 114 | ds_client_destroy(client);
|
---|
[bef51cf] | 115 | ds_display_destroy(disp);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[913add60] | 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 |
|
---|
[d8503fd] | 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 |
|
---|
[b2d1df3] | 159 | /** Test ds_display_find_window(). */
|
---|
| 160 | PCUT_TEST(display_find_window)
|
---|
| 161 | {
|
---|
| 162 | ds_display_t *disp;
|
---|
| 163 | ds_client_t *client;
|
---|
[9e84d2c] | 164 | ds_seat_t *seat;
|
---|
[b2d1df3] | 165 | ds_window_t *w0;
|
---|
| 166 | ds_window_t *w1;
|
---|
| 167 | ds_window_t *wnd;
|
---|
[3434233] | 168 | display_wnd_params_t params;
|
---|
[9e84d2c] | 169 | bool called_cb = false;
|
---|
[b2d1df3] | 170 | errno_t rc;
|
---|
| 171 |
|
---|
[8aef01c] | 172 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 173 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 174 |
|
---|
[9e84d2c] | 175 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 176 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 177 |
|
---|
[d8503fd] | 178 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[b2d1df3] | 179 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 180 |
|
---|
[3434233] | 181 | display_wnd_params_init(¶ms);
|
---|
| 182 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 183 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 184 |
|
---|
| 185 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[b2d1df3] | 186 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 187 |
|
---|
[3434233] | 188 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[b2d1df3] | 189 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 190 |
|
---|
[bd1f9a6d] | 191 | wnd = ds_display_first_window(disp);
|
---|
| 192 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 193 |
|
---|
| 194 | wnd = ds_display_next_window(wnd);
|
---|
| 195 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 196 |
|
---|
| 197 | wnd = ds_display_next_window(wnd);
|
---|
| 198 | PCUT_ASSERT_NULL(wnd);
|
---|
| 199 |
|
---|
[2012fe0] | 200 | wnd = ds_display_last_window(disp);
|
---|
| 201 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 202 |
|
---|
| 203 | wnd = ds_display_prev_window(wnd);
|
---|
| 204 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 205 |
|
---|
| 206 | wnd = ds_display_prev_window(wnd);
|
---|
| 207 | PCUT_ASSERT_NULL(wnd);
|
---|
| 208 |
|
---|
[b2d1df3] | 209 | wnd = ds_display_find_window(disp, w0->id);
|
---|
| 210 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 211 |
|
---|
| 212 | wnd = ds_display_find_window(disp, w1->id);
|
---|
| 213 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 214 |
|
---|
| 215 | wnd = ds_display_find_window(disp, 0);
|
---|
| 216 | PCUT_ASSERT_NULL(wnd);
|
---|
| 217 |
|
---|
[bd1f9a6d] | 218 | wnd = ds_display_find_window(disp, w0->id + 1);
|
---|
[b2d1df3] | 219 | PCUT_ASSERT_NULL(wnd);
|
---|
| 220 |
|
---|
[648e2ac] | 221 | ds_window_destroy(w0);
|
---|
| 222 | ds_window_destroy(w1);
|
---|
[9e84d2c] | 223 | ds_seat_destroy(seat);
|
---|
[b2d1df3] | 224 | ds_client_destroy(client);
|
---|
| 225 | ds_display_destroy(disp);
|
---|
| 226 | }
|
---|
| 227 |
|
---|
[5d62130] | 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 |
|
---|
[d8503fd] | 249 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[5d62130] | 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 |
|
---|
[913add60] | 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 |
|
---|
[d8503fd] | 320 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[913add60] | 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 | ds_client_destroy(client);
|
---|
| 341 | ds_display_destroy(disp);
|
---|
| 342 | }
|
---|
| 343 |
|
---|
[24cf391a] | 344 | /** Test ds_display_window_by_pos(). */
|
---|
| 345 | PCUT_TEST(display_window_by_pos)
|
---|
| 346 | {
|
---|
| 347 | ds_display_t *disp;
|
---|
| 348 | ds_client_t *client;
|
---|
[9e84d2c] | 349 | ds_seat_t *seat;
|
---|
[24cf391a] | 350 | ds_window_t *w0;
|
---|
| 351 | ds_window_t *w1;
|
---|
| 352 | ds_window_t *wnd;
|
---|
[3434233] | 353 | display_wnd_params_t params;
|
---|
[24cf391a] | 354 | gfx_coord2_t pos;
|
---|
[9e84d2c] | 355 | bool called_cb = false;
|
---|
[24cf391a] | 356 | errno_t rc;
|
---|
| 357 |
|
---|
[8aef01c] | 358 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 359 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 360 |
|
---|
[9e84d2c] | 361 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 362 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 363 |
|
---|
[d8503fd] | 364 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[24cf391a] | 365 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 366 |
|
---|
[3434233] | 367 | display_wnd_params_init(¶ms);
|
---|
| 368 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 369 | params.rect.p1.x = params.rect.p1.y = 100;
|
---|
| 370 |
|
---|
| 371 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 372 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 373 |
|
---|
[3434233] | 374 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 375 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 376 |
|
---|
| 377 | w0->dpos.x = 10;
|
---|
| 378 | w0->dpos.y = 10;
|
---|
| 379 |
|
---|
| 380 | w1->dpos.x = 400;
|
---|
| 381 | w1->dpos.y = 400;
|
---|
| 382 |
|
---|
| 383 | pos.x = 10;
|
---|
| 384 | pos.y = 10;
|
---|
| 385 | wnd = ds_display_window_by_pos(disp, &pos);
|
---|
| 386 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 387 |
|
---|
| 388 | pos.x = 400;
|
---|
| 389 | pos.y = 400;
|
---|
| 390 | wnd = ds_display_window_by_pos(disp, &pos);
|
---|
| 391 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 392 |
|
---|
| 393 | ds_window_destroy(w0);
|
---|
| 394 | ds_window_destroy(w1);
|
---|
[9e84d2c] | 395 | ds_seat_destroy(seat);
|
---|
[24cf391a] | 396 | ds_client_destroy(client);
|
---|
| 397 | ds_display_destroy(disp);
|
---|
| 398 | }
|
---|
| 399 |
|
---|
[b3eeae5] | 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);
|
---|
| 420 | ds_display_destroy(disp);
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[cf32dbd] | 423 | /** Basic seat operation. */
|
---|
| 424 | PCUT_TEST(display_seat)
|
---|
| 425 | {
|
---|
| 426 | ds_display_t *disp;
|
---|
| 427 | ds_seat_t *seat;
|
---|
[d8503fd] | 428 | ds_seat_t *s0, *s1, *s2;
|
---|
[cf32dbd] | 429 | errno_t rc;
|
---|
| 430 |
|
---|
[8aef01c] | 431 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[cf32dbd] | 432 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 433 |
|
---|
[d8503fd] | 434 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[cf32dbd] | 435 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 436 |
|
---|
| 437 | s0 = ds_display_first_seat(disp);
|
---|
| 438 | PCUT_ASSERT_EQUALS(s0, seat);
|
---|
| 439 |
|
---|
| 440 | s1 = ds_display_next_seat(s0);
|
---|
| 441 | PCUT_ASSERT_NULL(s1);
|
---|
| 442 |
|
---|
[d8503fd] | 443 | s2 = ds_display_find_seat(disp, seat->id);
|
---|
| 444 | PCUT_ASSERT_EQUALS(s2, seat);
|
---|
| 445 |
|
---|
[cf32dbd] | 446 | ds_seat_destroy(seat);
|
---|
| 447 | ds_display_destroy(disp);
|
---|
| 448 | }
|
---|
| 449 |
|
---|
[88d828e] | 450 | /** ds_display_seat_by_idev() returns the correct seat. */
|
---|
| 451 | PCUT_TEST(display_seat_by_idev)
|
---|
| 452 | {
|
---|
| 453 | // XXX TODO
|
---|
| 454 | }
|
---|
| 455 |
|
---|
[24cf391a] | 456 | /** Test ds_display_post_kbd_event() delivers event to client callback.
|
---|
| 457 | */
|
---|
[b2d1df3] | 458 | PCUT_TEST(display_post_kbd_event)
|
---|
| 459 | {
|
---|
| 460 | ds_display_t *disp;
|
---|
[cf32dbd] | 461 | ds_seat_t *seat;
|
---|
[b2d1df3] | 462 | ds_client_t *client;
|
---|
| 463 | ds_window_t *wnd;
|
---|
[3434233] | 464 | display_wnd_params_t params;
|
---|
[b2d1df3] | 465 | kbd_event_t event;
|
---|
[24cf391a] | 466 | bool called_cb = false;
|
---|
[b2d1df3] | 467 | errno_t rc;
|
---|
| 468 |
|
---|
[8aef01c] | 469 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 470 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 471 |
|
---|
[d8503fd] | 472 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[cf32dbd] | 473 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 474 |
|
---|
[b2d1df3] | 475 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 476 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 477 |
|
---|
[3434233] | 478 | display_wnd_params_init(¶ms);
|
---|
| 479 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 480 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 481 |
|
---|
| 482 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
[b2d1df3] | 483 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 484 |
|
---|
[94635b30] | 485 | ds_seat_set_focus(seat, wnd);
|
---|
| 486 |
|
---|
[b2d1df3] | 487 | event.type = KEY_PRESS;
|
---|
| 488 | event.key = KC_ENTER;
|
---|
| 489 | event.mods = 0;
|
---|
| 490 | event.c = L'\0';
|
---|
| 491 |
|
---|
[0e6e77f] | 492 | called_cb = false;
|
---|
[b2d1df3] | 493 |
|
---|
| 494 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 495 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 496 | PCUT_ASSERT_TRUE(called_cb);
|
---|
| 497 |
|
---|
[648e2ac] | 498 | ds_window_destroy(wnd);
|
---|
[b2d1df3] | 499 | ds_client_destroy(client);
|
---|
[cf32dbd] | 500 | ds_seat_destroy(seat);
|
---|
[b2d1df3] | 501 | ds_display_destroy(disp);
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[24cf391a] | 504 | /** Test ds_display_post_kbd_event() with Alt-Tab switches focus.
|
---|
| 505 | */
|
---|
| 506 | PCUT_TEST(display_post_kbd_event_alt_tab)
|
---|
| 507 | {
|
---|
| 508 | ds_display_t *disp;
|
---|
| 509 | ds_seat_t *seat;
|
---|
| 510 | ds_client_t *client;
|
---|
| 511 | ds_window_t *w0, *w1;
|
---|
[3434233] | 512 | display_wnd_params_t params;
|
---|
[24cf391a] | 513 | kbd_event_t event;
|
---|
| 514 | bool called_cb = false;
|
---|
| 515 | errno_t rc;
|
---|
| 516 |
|
---|
[8aef01c] | 517 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 518 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 519 |
|
---|
[d8503fd] | 520 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[24cf391a] | 521 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 522 |
|
---|
| 523 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 524 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 525 |
|
---|
[3434233] | 526 | display_wnd_params_init(¶ms);
|
---|
| 527 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 528 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 529 |
|
---|
| 530 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 531 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 532 |
|
---|
[3434233] | 533 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 534 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 535 |
|
---|
| 536 | ds_seat_set_focus(seat, w0);
|
---|
| 537 |
|
---|
| 538 | event.type = KEY_PRESS;
|
---|
| 539 | event.key = KC_TAB;
|
---|
| 540 | event.mods = KM_ALT;
|
---|
| 541 | event.c = L'\0';
|
---|
| 542 |
|
---|
[0e6e77f] | 543 | called_cb = false;
|
---|
[24cf391a] | 544 |
|
---|
| 545 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 546 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[0e6e77f] | 547 |
|
---|
| 548 | /* Got gocus/unfocus events */
|
---|
| 549 | PCUT_ASSERT_TRUE(called_cb);
|
---|
[24cf391a] | 550 |
|
---|
| 551 | /* Next window should be focused */
|
---|
| 552 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
---|
| 553 |
|
---|
[0e6e77f] | 554 | called_cb = false;
|
---|
| 555 |
|
---|
[24cf391a] | 556 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 557 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[0e6e77f] | 558 |
|
---|
| 559 | /* Got gocus/unfocus events */
|
---|
| 560 | PCUT_ASSERT_TRUE(called_cb);
|
---|
[24cf391a] | 561 |
|
---|
| 562 | /* Focus should be back to the first window */
|
---|
| 563 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
---|
| 564 |
|
---|
| 565 | ds_window_destroy(w0);
|
---|
| 566 | ds_window_destroy(w1);
|
---|
| 567 | ds_client_destroy(client);
|
---|
| 568 | ds_seat_destroy(seat);
|
---|
| 569 | ds_display_destroy(disp);
|
---|
| 570 | }
|
---|
| 571 |
|
---|
[4fbdc3d] | 572 | /** Test ds_display_post_ptd_event() with click on window switches focus
|
---|
[24cf391a] | 573 | */
|
---|
[4fbdc3d] | 574 | PCUT_TEST(display_post_ptd_event_wnd_switch)
|
---|
[24cf391a] | 575 | {
|
---|
| 576 | ds_display_t *disp;
|
---|
| 577 | ds_seat_t *seat;
|
---|
| 578 | ds_client_t *client;
|
---|
| 579 | ds_window_t *w0, *w1;
|
---|
[3434233] | 580 | display_wnd_params_t params;
|
---|
[4fbdc3d] | 581 | ptd_event_t event;
|
---|
[24cf391a] | 582 | bool called_cb = false;
|
---|
| 583 | errno_t rc;
|
---|
| 584 |
|
---|
[8aef01c] | 585 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 586 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 587 |
|
---|
[d8503fd] | 588 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[24cf391a] | 589 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 590 |
|
---|
| 591 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 592 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 593 |
|
---|
[0e6e77f] | 594 | /*
|
---|
| 595 | * For PTD_MOVE to work we need to set display dimensions (as pointer
|
---|
| 596 | * move is clipped to the display rectangle. Here we do it directly
|
---|
| 597 | * instead of adding a display device.
|
---|
| 598 | */
|
---|
| 599 | disp->rect.p0.x = 0;
|
---|
| 600 | disp->rect.p0.y = 0;
|
---|
| 601 | disp->rect.p1.x = 500;
|
---|
| 602 | disp->rect.p1.y = 500;
|
---|
| 603 |
|
---|
[3434233] | 604 | display_wnd_params_init(¶ms);
|
---|
| 605 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 606 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 607 |
|
---|
| 608 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 609 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 610 |
|
---|
[3434233] | 611 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 612 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 613 |
|
---|
| 614 | w0->dpos.x = 10;
|
---|
| 615 | w0->dpos.y = 10;
|
---|
| 616 |
|
---|
| 617 | w1->dpos.x = 400;
|
---|
| 618 | w1->dpos.y = 400;
|
---|
| 619 |
|
---|
[4fbdc3d] | 620 | ds_seat_set_focus(seat, w0);
|
---|
[24cf391a] | 621 |
|
---|
[4fbdc3d] | 622 | event.type = PTD_MOVE;
|
---|
| 623 | event.dmove.x = 400;
|
---|
| 624 | event.dmove.y = 400;
|
---|
| 625 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 626 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[24cf391a] | 627 |
|
---|
[4fbdc3d] | 628 | event.type = PTD_PRESS;
|
---|
| 629 | event.btn_num = 1;
|
---|
| 630 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
[24cf391a] | 631 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 632 |
|
---|
| 633 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
---|
| 634 |
|
---|
[f5191b4] | 635 | event.type = PTD_RELEASE;
|
---|
| 636 | event.btn_num = 1;
|
---|
| 637 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 638 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 639 |
|
---|
[4fbdc3d] | 640 | event.type = PTD_MOVE;
|
---|
[a40ae0d] | 641 | event.dmove.x = -400 + 10;
|
---|
| 642 | event.dmove.y = -400 + 10;
|
---|
[4fbdc3d] | 643 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 644 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 645 |
|
---|
| 646 | event.type = PTD_PRESS;
|
---|
| 647 | event.btn_num = 1;
|
---|
| 648 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
[24cf391a] | 649 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 650 |
|
---|
| 651 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
---|
| 652 |
|
---|
| 653 | ds_window_destroy(w0);
|
---|
| 654 | ds_window_destroy(w1);
|
---|
| 655 | ds_client_destroy(client);
|
---|
| 656 | ds_seat_destroy(seat);
|
---|
| 657 | ds_display_destroy(disp);
|
---|
| 658 | }
|
---|
| 659 |
|
---|
[29a5a99] | 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 |
|
---|
[d8503fd] | 673 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[29a5a99] | 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 directly
|
---|
| 681 | * 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 because
|
---|
| 706 | * 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 |
|
---|
[6af4b4f] | 826 | PCUT_EXPORT(display);
|
---|