Editor needs to hide cursor when menu bar is activated
[helenos.git] / uspace / lib / ui / test / wdecor.c
blob9d5873f73b8a5fbbfd7f41172e962f1a68462ed6
1 /*
2 * Copyright (c) 2024 Jiri Svoboda
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
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.
29 #include <gfx/context.h>
30 #include <gfx/coord.h>
31 #include <mem.h>
32 #include <pcut/pcut.h>
33 #include <stdbool.h>
34 #include <ui/pbutton.h>
35 #include <ui/resource.h>
36 #include <ui/ui.h>
37 #include <ui/wdecor.h>
38 #include "../private/wdecor.h"
40 PCUT_INIT;
42 PCUT_TEST_SUITE(wdecor);
44 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
45 static errno_t testgc_set_color(void *, gfx_color_t *);
46 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
47 static errno_t testgc_update(void *);
48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
49 gfx_bitmap_alloc_t *, void **);
50 static errno_t testgc_bitmap_destroy(void *);
51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
54 static gfx_context_ops_t ops = {
55 .set_clip_rect = testgc_set_clip_rect,
56 .set_color = testgc_set_color,
57 .fill_rect = testgc_fill_rect,
58 .update = testgc_update,
59 .bitmap_create = testgc_bitmap_create,
60 .bitmap_destroy = testgc_bitmap_destroy,
61 .bitmap_render = testgc_bitmap_render,
62 .bitmap_get_alloc = testgc_bitmap_get_alloc
65 static void test_wdecor_sysmenu_open(ui_wdecor_t *, void *, sysarg_t);
66 static void test_wdecor_sysmenu_left(ui_wdecor_t *, void *, sysarg_t);
67 static void test_wdecor_sysmenu_right(ui_wdecor_t *, void *, sysarg_t);
68 static void test_wdecor_sysmenu_accel(ui_wdecor_t *, void *, char32_t,
69 sysarg_t);
70 static void test_wdecor_minimize(ui_wdecor_t *, void *);
71 static void test_wdecor_maximize(ui_wdecor_t *, void *);
72 static void test_wdecor_unmaximize(ui_wdecor_t *, void *);
73 static void test_wdecor_close(ui_wdecor_t *, void *);
74 static void test_wdecor_move(ui_wdecor_t *, void *, gfx_coord2_t *, sysarg_t);
75 static void test_wdecor_resize(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,
76 gfx_coord2_t *, sysarg_t);
77 static void test_wdecor_set_cursor(ui_wdecor_t *, void *, ui_stock_cursor_t);
79 static ui_wdecor_cb_t test_wdecor_cb = {
80 .sysmenu_open = test_wdecor_sysmenu_open,
81 .sysmenu_left = test_wdecor_sysmenu_left,
82 .sysmenu_right = test_wdecor_sysmenu_right,
83 .sysmenu_accel = test_wdecor_sysmenu_accel,
84 .minimize = test_wdecor_minimize,
85 .maximize = test_wdecor_maximize,
86 .unmaximize = test_wdecor_unmaximize,
87 .close = test_wdecor_close,
88 .move = test_wdecor_move,
89 .resize = test_wdecor_resize,
90 .set_cursor = test_wdecor_set_cursor
93 static ui_wdecor_cb_t dummy_wdecor_cb = {
96 typedef struct {
97 bool bm_created;
98 bool bm_destroyed;
99 gfx_bitmap_params_t bm_params;
100 void *bm_pixels;
101 gfx_rect_t bm_srect;
102 gfx_coord2_t bm_offs;
103 bool bm_rendered;
104 bool bm_got_alloc;
105 } test_gc_t;
107 typedef struct {
108 test_gc_t *tgc;
109 gfx_bitmap_alloc_t alloc;
110 bool myalloc;
111 } testgc_bitmap_t;
113 typedef struct {
114 bool sysmenu_open;
115 bool sysmenu_left;
116 bool sysmenu_right;
117 bool sysmenu_accel;
118 bool minimize;
119 bool maximize;
120 bool unmaximize;
121 bool close;
122 bool move;
123 gfx_coord2_t pos;
124 sysarg_t pos_id;
125 sysarg_t idev_id;
126 char32_t accel;
127 bool resize;
128 ui_wdecor_rsztype_t rsztype;
129 bool set_cursor;
130 ui_stock_cursor_t cursor;
131 } test_cb_resp_t;
133 /** Create and destroy window decoration */
134 PCUT_TEST(create_destroy)
136 ui_wdecor_t *wdecor = NULL;
137 errno_t rc;
139 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
140 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
141 PCUT_ASSERT_NOT_NULL(wdecor);
143 ui_wdecor_destroy(wdecor);
146 /** ui_wdecor_destroy() can take NULL argument (no-op) */
147 PCUT_TEST(destroy_null)
149 ui_wdecor_destroy(NULL);
152 /** Set window decoration rectangle sets internal field */
153 PCUT_TEST(set_rect)
155 gfx_context_t *gc = NULL;
156 test_gc_t tgc;
157 ui_resource_t *resource = NULL;
158 ui_wdecor_t *wdecor;
159 gfx_rect_t rect;
160 errno_t rc;
162 memset(&tgc, 0, sizeof(tgc));
163 rc = gfx_context_new(&ops, &tgc, &gc);
164 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
166 rc = ui_resource_create(gc, false, &resource);
167 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
168 PCUT_ASSERT_NOT_NULL(resource);
170 rc = ui_wdecor_create(resource, "Hello", ui_wds_none, &wdecor);
171 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
173 rect.p0.x = 1;
174 rect.p0.y = 2;
175 rect.p1.x = 3;
176 rect.p1.y = 4;
178 ui_wdecor_set_rect(wdecor, &rect);
179 PCUT_ASSERT_INT_EQUALS(rect.p0.x, wdecor->rect.p0.x);
180 PCUT_ASSERT_INT_EQUALS(rect.p0.y, wdecor->rect.p0.y);
181 PCUT_ASSERT_INT_EQUALS(rect.p1.x, wdecor->rect.p1.x);
182 PCUT_ASSERT_INT_EQUALS(rect.p1.y, wdecor->rect.p1.y);
184 ui_wdecor_destroy(wdecor);
185 ui_resource_destroy(resource);
187 rc = gfx_context_delete(gc);
188 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
191 /** Set window decoration active sets internal field */
192 PCUT_TEST(set_active)
194 ui_wdecor_t *wdecor;
195 errno_t rc;
197 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
198 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
200 PCUT_ASSERT_TRUE(wdecor->active);
202 ui_wdecor_set_active(wdecor, false);
203 PCUT_ASSERT_FALSE(wdecor->active);
205 ui_wdecor_set_active(wdecor, true);
206 PCUT_ASSERT_TRUE(wdecor->active);
208 ui_wdecor_destroy(wdecor);
211 /** Set window decoration maximized sets internal field */
212 PCUT_TEST(set_maximized)
214 ui_wdecor_t *wdecor;
215 errno_t rc;
217 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
218 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
220 PCUT_ASSERT_TRUE(wdecor->active);
222 ui_wdecor_set_maximized(wdecor, false);
223 PCUT_ASSERT_FALSE(wdecor->maximized);
225 ui_wdecor_set_maximized(wdecor, true);
226 PCUT_ASSERT_TRUE(wdecor->maximized);
228 ui_wdecor_destroy(wdecor);
231 /** Setting system menu handle as active/inactive */
232 PCUT_TEST(sysmenu_hdl_set_active)
234 errno_t rc;
235 gfx_context_t *gc = NULL;
236 test_gc_t tgc;
237 ui_resource_t *resource = NULL;
238 ui_wdecor_t *wdecor;
240 memset(&tgc, 0, sizeof(tgc));
241 rc = gfx_context_new(&ops, &tgc, &gc);
242 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
244 rc = ui_resource_create(gc, false, &resource);
245 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
246 PCUT_ASSERT_NOT_NULL(resource);
248 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
249 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
251 PCUT_ASSERT_FALSE(wdecor->sysmenu_hdl_active);
252 ui_wdecor_sysmenu_hdl_set_active(wdecor, true);
253 PCUT_ASSERT_TRUE(wdecor->sysmenu_hdl_active);
254 ui_wdecor_sysmenu_hdl_set_active(wdecor, false);
255 PCUT_ASSERT_FALSE(wdecor->sysmenu_hdl_active);
257 ui_wdecor_destroy(wdecor);
258 ui_resource_destroy(resource);
260 rc = gfx_context_delete(gc);
261 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
264 /** Paint system menu handle */
265 PCUT_TEST(sysmenu_hdl_paint)
267 errno_t rc;
268 gfx_context_t *gc = NULL;
269 test_gc_t tgc;
270 ui_resource_t *resource = NULL;
271 ui_wdecor_t *wdecor;
272 ui_wdecor_geom_t geom;
274 memset(&tgc, 0, sizeof(tgc));
275 rc = gfx_context_new(&ops, &tgc, &gc);
276 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
278 rc = ui_resource_create(gc, false, &resource);
279 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
280 PCUT_ASSERT_NOT_NULL(resource);
282 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
283 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
285 ui_wdecor_get_geom(wdecor, &geom);
286 rc = ui_wdecor_sysmenu_hdl_paint(wdecor, &geom.sysmenu_hdl_rect);
287 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
289 ui_wdecor_destroy(wdecor);
290 ui_resource_destroy(resource);
292 rc = gfx_context_delete(gc);
293 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
296 /** Paint window decoration */
297 PCUT_TEST(paint)
299 errno_t rc;
300 gfx_context_t *gc = NULL;
301 test_gc_t tgc;
302 ui_resource_t *resource = NULL;
303 ui_wdecor_t *wdecor;
305 memset(&tgc, 0, sizeof(tgc));
306 rc = gfx_context_new(&ops, &tgc, &gc);
307 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
309 rc = ui_resource_create(gc, false, &resource);
310 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
311 PCUT_ASSERT_NOT_NULL(resource);
313 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
314 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
316 rc = ui_wdecor_paint(wdecor);
317 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
319 ui_wdecor_destroy(wdecor);
320 ui_resource_destroy(resource);
322 rc = gfx_context_delete(gc);
323 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
326 /** Test ui_wdecor_sysmenu_open() */
327 PCUT_TEST(sysmenu_open)
329 errno_t rc;
330 ui_wdecor_t *wdecor;
331 test_cb_resp_t resp;
333 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
334 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
336 /* Sysmenu open callback with no callbacks set */
337 ui_wdecor_sysmenu_open(wdecor, 42);
339 /* Sysmenu open callback with sysmenu callback not implemented */
340 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
341 ui_wdecor_sysmenu_open(wdecor, 42);
343 /* Sysmenu open callback with real callback set */
344 resp.sysmenu_open = false;
345 resp.idev_id = 0;
346 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
347 ui_wdecor_sysmenu_open(wdecor, 42);
348 PCUT_ASSERT_TRUE(resp.sysmenu_open);
349 PCUT_ASSERT_INT_EQUALS(42, resp.idev_id);
351 ui_wdecor_destroy(wdecor);
354 /** Test ui_wdecor_sysmenu_left() */
355 PCUT_TEST(sysmenu_left)
357 errno_t rc;
358 ui_wdecor_t *wdecor;
359 test_cb_resp_t resp;
361 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
362 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
364 /* Sysmenu left callback with no callbacks set */
365 ui_wdecor_sysmenu_left(wdecor, 42);
367 /* Sysmenu left callback with sysmenu callback not implemented */
368 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
369 ui_wdecor_sysmenu_left(wdecor, 42);
371 /* Sysmenu left callback with real callback set */
372 resp.sysmenu_left = false;
373 resp.idev_id = 0;
374 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
375 ui_wdecor_sysmenu_left(wdecor, 42);
376 PCUT_ASSERT_TRUE(resp.sysmenu_left);
377 PCUT_ASSERT_INT_EQUALS(42, resp.idev_id);
379 ui_wdecor_destroy(wdecor);
382 /** Test ui_wdecor_sysmenu_right() */
383 PCUT_TEST(sysmenu_right)
385 errno_t rc;
386 ui_wdecor_t *wdecor;
387 test_cb_resp_t resp;
389 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
390 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
392 /* Sysmenu right callback with no callbacks set */
393 ui_wdecor_sysmenu_right(wdecor, 42);
395 /* Sysmenu right callback with sysmenu callback not implemented */
396 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
397 ui_wdecor_sysmenu_right(wdecor, 42);
399 /* Sysmenu right callback with real callback set */
400 resp.sysmenu_right = false;
401 resp.idev_id = 0;
402 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
403 ui_wdecor_sysmenu_right(wdecor, 42);
404 PCUT_ASSERT_TRUE(resp.sysmenu_right);
405 PCUT_ASSERT_INT_EQUALS(42, resp.idev_id);
407 ui_wdecor_destroy(wdecor);
410 /** Test ui_wdecor_sysmenu_accel() */
411 PCUT_TEST(sysmenu_accel)
413 errno_t rc;
414 ui_wdecor_t *wdecor;
415 test_cb_resp_t resp;
417 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
418 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
420 /* Sysmenu accelerator callback with no callbacks set */
421 ui_wdecor_sysmenu_accel(wdecor, 'a', 42);
423 /* Sysmenu accelerator callback with sysmenu callback not implemented */
424 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
425 ui_wdecor_sysmenu_accel(wdecor, 'a', 42);
427 /* Sysmenu accelerator callback with real callback set */
428 resp.sysmenu_accel = false;
429 resp.idev_id = 0;
430 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
431 ui_wdecor_sysmenu_accel(wdecor, 'a', 42);
432 PCUT_ASSERT_TRUE(resp.sysmenu_accel);
433 PCUT_ASSERT_INT_EQUALS('a', resp.accel);
434 PCUT_ASSERT_INT_EQUALS(42, resp.idev_id);
436 ui_wdecor_destroy(wdecor);
439 /** Test ui_wdecor_minimize() */
440 PCUT_TEST(minimize)
442 errno_t rc;
443 ui_wdecor_t *wdecor;
444 test_cb_resp_t resp;
446 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
447 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
449 /* Minimize callback with no callbacks set */
450 ui_wdecor_minimize(wdecor);
452 /* Minimize callback with minimize callback not implemented */
453 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
454 ui_wdecor_minimize(wdecor);
456 /* Minimize callback with real callback set */
457 resp.minimize = false;
458 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
459 ui_wdecor_minimize(wdecor);
460 PCUT_ASSERT_TRUE(resp.minimize);
462 ui_wdecor_destroy(wdecor);
465 /** Test ui_wdecor_maximize() */
466 PCUT_TEST(maximize)
468 errno_t rc;
469 ui_wdecor_t *wdecor;
470 test_cb_resp_t resp;
472 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
473 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
475 /* Maximize callback with no callbacks set */
476 ui_wdecor_maximize(wdecor);
478 /* Maxmimize callback with maximize callback not implemented */
479 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
480 ui_wdecor_maximize(wdecor);
482 /* Maximize callback with real callback set */
483 resp.maximize = false;
484 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
485 ui_wdecor_maximize(wdecor);
486 PCUT_ASSERT_TRUE(resp.maximize);
488 ui_wdecor_destroy(wdecor);
491 /** Test ui_wdecor_unmaximize() */
492 PCUT_TEST(unmaximize)
494 errno_t rc;
495 ui_wdecor_t *wdecor;
496 test_cb_resp_t resp;
498 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
499 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
501 /* Unmaximize callback with no callbacks set */
502 ui_wdecor_unmaximize(wdecor);
504 /* Unmaximize callback with unmaximize callback not implemented */
505 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
506 ui_wdecor_unmaximize(wdecor);
508 /* Unmaximize callback with real callback set */
509 resp.unmaximize = false;
510 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
511 ui_wdecor_unmaximize(wdecor);
512 PCUT_ASSERT_TRUE(resp.unmaximize);
514 ui_wdecor_destroy(wdecor);
517 /** Test ui_wdecor_close() */
518 PCUT_TEST(close)
520 errno_t rc;
521 ui_wdecor_t *wdecor;
522 test_cb_resp_t resp;
524 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
525 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
527 /* Close callback with no callbacks set */
528 ui_wdecor_close(wdecor);
530 /* Close callback with close callback not implemented */
531 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
532 ui_wdecor_close(wdecor);
534 /* Close callback with real callback set */
535 resp.close = false;
536 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
537 ui_wdecor_close(wdecor);
538 PCUT_ASSERT_TRUE(resp.close);
540 ui_wdecor_destroy(wdecor);
543 /** Test ui_wdecor_move() */
544 PCUT_TEST(move)
546 errno_t rc;
547 ui_wdecor_t *wdecor;
548 test_cb_resp_t resp;
549 gfx_coord2_t pos;
550 sysarg_t pos_id;
552 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
553 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
555 pos.x = 3;
556 pos.y = 4;
557 pos_id = 5;
559 /* Move callback with no callbacks set */
560 ui_wdecor_move(wdecor, &pos, pos_id);
562 /* Move callback with move callback not implemented */
563 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
564 ui_wdecor_move(wdecor, &pos, pos_id);
566 /* Move callback with real callback set */
567 resp.move = false;
568 resp.pos.x = 0;
569 resp.pos.y = 0;
570 resp.pos_id = 0;
571 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
572 ui_wdecor_move(wdecor, &pos, pos_id);
573 PCUT_ASSERT_TRUE(resp.move);
574 PCUT_ASSERT_INT_EQUALS(pos.x, resp.pos.x);
575 PCUT_ASSERT_INT_EQUALS(pos.y, resp.pos.y);
576 PCUT_ASSERT_INT_EQUALS(pos_id, resp.pos_id);
578 ui_wdecor_destroy(wdecor);
581 /** Test ui_wdecor_resize() */
582 PCUT_TEST(resize)
584 errno_t rc;
585 ui_wdecor_t *wdecor;
586 test_cb_resp_t resp;
587 ui_wdecor_rsztype_t rsztype;
588 gfx_coord2_t pos;
589 sysarg_t pos_id;
591 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
592 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
594 rsztype = ui_wr_bottom;
595 pos.x = 3;
596 pos.y = 4;
597 pos_id = 5;
599 /* Resize callback with no callbacks set */
600 ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
602 /* Resize callback with move callback not implemented */
603 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
604 ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
606 /* Resize callback with real callback set */
607 resp.resize = false;
608 resp.rsztype = ui_wr_none;
609 resp.pos.x = 0;
610 resp.pos.y = 0;
611 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
612 ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
613 PCUT_ASSERT_TRUE(resp.resize);
614 PCUT_ASSERT_INT_EQUALS(rsztype, resp.rsztype);
615 PCUT_ASSERT_INT_EQUALS(pos.x, resp.pos.x);
616 PCUT_ASSERT_INT_EQUALS(pos.y, resp.pos.y);
617 PCUT_ASSERT_INT_EQUALS(pos_id, resp.pos_id);
619 ui_wdecor_destroy(wdecor);
622 /** Test ui_wdecor_set_cursor() */
623 PCUT_TEST(set_cursor)
625 errno_t rc;
626 ui_wdecor_t *wdecor;
627 test_cb_resp_t resp;
628 ui_stock_cursor_t cursor;
630 rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
631 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
633 cursor = ui_curs_size_uldr;
635 /* Set cursor callback with no callbacks set */
636 ui_wdecor_set_cursor(wdecor, cursor);
638 /* Set cursor callback with move callback not implemented */
639 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
640 ui_wdecor_set_cursor(wdecor, cursor);
642 /* Set cursor callback with real callback set */
643 resp.set_cursor = false;
644 resp.cursor = ui_curs_arrow;
645 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
646 ui_wdecor_set_cursor(wdecor, cursor);
647 PCUT_ASSERT_TRUE(resp.set_cursor);
648 PCUT_ASSERT_INT_EQUALS(cursor, resp.cursor);
650 ui_wdecor_destroy(wdecor);
653 /** Clicking the close button generates close callback */
654 PCUT_TEST(close_btn_clicked)
656 gfx_context_t *gc = NULL;
657 test_gc_t tgc;
658 ui_resource_t *resource = NULL;
659 ui_wdecor_t *wdecor;
660 gfx_rect_t rect;
661 test_cb_resp_t resp;
662 errno_t rc;
664 memset(&tgc, 0, sizeof(tgc));
665 rc = gfx_context_new(&ops, &tgc, &gc);
666 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
668 rc = ui_resource_create(gc, false, &resource);
669 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
670 PCUT_ASSERT_NOT_NULL(resource);
672 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
673 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
675 rect.p0.x = 10;
676 rect.p0.y = 20;
677 rect.p1.x = 100;
678 rect.p1.y = 200;
680 ui_wdecor_set_rect(wdecor, &rect);
682 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
684 resp.close = false;
686 ui_pbutton_clicked(wdecor->btn_close);
687 PCUT_ASSERT_TRUE(resp.close);
689 ui_wdecor_destroy(wdecor);
690 ui_resource_destroy(resource);
692 rc = gfx_context_delete(gc);
693 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
696 /** Button press on title bar generates move callback */
697 PCUT_TEST(pos_event_move)
699 errno_t rc;
700 gfx_rect_t rect;
701 pos_event_t event;
702 gfx_context_t *gc = NULL;
703 test_gc_t tgc;
704 test_cb_resp_t resp;
705 ui_resource_t *resource = NULL;
706 ui_wdecor_t *wdecor;
708 memset(&tgc, 0, sizeof(tgc));
709 rc = gfx_context_new(&ops, &tgc, &gc);
710 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
712 rc = ui_resource_create(gc, false, &resource);
713 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
714 PCUT_ASSERT_NOT_NULL(resource);
716 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
717 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
719 rect.p0.x = 10;
720 rect.p0.y = 20;
721 rect.p1.x = 100;
722 rect.p1.y = 200;
724 ui_wdecor_set_rect(wdecor, &rect);
726 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
728 resp.move = false;
729 resp.pos.x = 0;
730 resp.pos.y = 0;
732 event.type = POS_PRESS;
733 event.hpos = 50;
734 event.vpos = 25;
735 ui_wdecor_pos_event(wdecor, &event);
737 PCUT_ASSERT_TRUE(resp.move);
738 PCUT_ASSERT_INT_EQUALS(event.hpos, resp.pos.x);
739 PCUT_ASSERT_INT_EQUALS(event.vpos, resp.pos.y);
741 ui_wdecor_destroy(wdecor);
742 ui_resource_destroy(resource);
744 rc = gfx_context_delete(gc);
745 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
748 /** Pressing F10 generates sysmenu event.
750 * Note that in a window with menu bar the menu bar would claim F10
751 * so it would never be delivered to window decoration.
753 PCUT_TEST(kbd_f10_sysmenu)
755 errno_t rc;
756 gfx_rect_t rect;
757 kbd_event_t event;
758 gfx_context_t *gc = NULL;
759 test_gc_t tgc;
760 test_cb_resp_t resp;
761 ui_resource_t *resource = NULL;
762 ui_wdecor_t *wdecor;
764 memset(&tgc, 0, sizeof(tgc));
765 rc = gfx_context_new(&ops, &tgc, &gc);
766 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
768 rc = ui_resource_create(gc, false, &resource);
769 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
770 PCUT_ASSERT_NOT_NULL(resource);
772 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
773 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
775 rect.p0.x = 10;
776 rect.p0.y = 20;
777 rect.p1.x = 100;
778 rect.p1.y = 200;
780 ui_wdecor_set_rect(wdecor, &rect);
782 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
784 resp.sysmenu_open = false;
786 event.type = KEY_PRESS;
787 event.mods = 0;
788 event.key = KC_F10;
789 event.kbd_id = 42;
790 ui_wdecor_kbd_event(wdecor, &event);
792 PCUT_ASSERT_TRUE(resp.sysmenu_open);
793 PCUT_ASSERT_INT_EQUALS(event.kbd_id, resp.idev_id);
795 ui_wdecor_destroy(wdecor);
796 ui_resource_destroy(resource);
798 rc = gfx_context_delete(gc);
799 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
802 /** Down key with active sysmenu handle generates sysmenu open event */
803 PCUT_TEST(kbd_down_sysmenu)
805 errno_t rc;
806 gfx_rect_t rect;
807 kbd_event_t event;
808 gfx_context_t *gc = NULL;
809 test_gc_t tgc;
810 test_cb_resp_t resp;
811 ui_resource_t *resource = NULL;
812 ui_wdecor_t *wdecor;
814 memset(&tgc, 0, sizeof(tgc));
815 rc = gfx_context_new(&ops, &tgc, &gc);
816 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
818 rc = ui_resource_create(gc, false, &resource);
819 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
820 PCUT_ASSERT_NOT_NULL(resource);
822 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
823 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
825 rect.p0.x = 10;
826 rect.p0.y = 20;
827 rect.p1.x = 100;
828 rect.p1.y = 200;
830 ui_wdecor_set_rect(wdecor, &rect);
832 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
834 ui_wdecor_sysmenu_hdl_set_active(wdecor, true);
836 resp.sysmenu_open = false;
838 event.type = KEY_PRESS;
839 event.mods = 0;
840 event.key = KC_DOWN;
841 event.kbd_id = 42;
842 ui_wdecor_kbd_event(wdecor, &event);
844 PCUT_ASSERT_TRUE(resp.sysmenu_open);
845 PCUT_ASSERT_INT_EQUALS(event.kbd_id, resp.idev_id);
847 ui_wdecor_destroy(wdecor);
848 ui_resource_destroy(resource);
850 rc = gfx_context_delete(gc);
851 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
854 /** Left key with active sysmenu handle generates sysmenu left event */
855 PCUT_TEST(kbd_left_sysmenu)
857 errno_t rc;
858 gfx_rect_t rect;
859 kbd_event_t event;
860 gfx_context_t *gc = NULL;
861 test_gc_t tgc;
862 test_cb_resp_t resp;
863 ui_resource_t *resource = NULL;
864 ui_wdecor_t *wdecor;
866 memset(&tgc, 0, sizeof(tgc));
867 rc = gfx_context_new(&ops, &tgc, &gc);
868 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
870 rc = ui_resource_create(gc, false, &resource);
871 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
872 PCUT_ASSERT_NOT_NULL(resource);
874 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
875 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
877 rect.p0.x = 10;
878 rect.p0.y = 20;
879 rect.p1.x = 100;
880 rect.p1.y = 200;
882 ui_wdecor_set_rect(wdecor, &rect);
884 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
886 ui_wdecor_sysmenu_hdl_set_active(wdecor, true);
888 resp.sysmenu_left = false;
890 event.type = KEY_PRESS;
891 event.mods = 0;
892 event.key = KC_LEFT;
893 event.kbd_id = 42;
894 ui_wdecor_kbd_event(wdecor, &event);
896 PCUT_ASSERT_TRUE(resp.sysmenu_left);
897 PCUT_ASSERT_INT_EQUALS(event.kbd_id, resp.idev_id);
899 ui_wdecor_destroy(wdecor);
900 ui_resource_destroy(resource);
902 rc = gfx_context_delete(gc);
903 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
906 /** Right key with active sysmenu handle generates sysmenu right event */
907 PCUT_TEST(kbd_right_sysmenu)
909 errno_t rc;
910 gfx_rect_t rect;
911 kbd_event_t event;
912 gfx_context_t *gc = NULL;
913 test_gc_t tgc;
914 test_cb_resp_t resp;
915 ui_resource_t *resource = NULL;
916 ui_wdecor_t *wdecor;
918 memset(&tgc, 0, sizeof(tgc));
919 rc = gfx_context_new(&ops, &tgc, &gc);
920 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
922 rc = ui_resource_create(gc, false, &resource);
923 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
924 PCUT_ASSERT_NOT_NULL(resource);
926 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
927 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
929 rect.p0.x = 10;
930 rect.p0.y = 20;
931 rect.p1.x = 100;
932 rect.p1.y = 200;
934 ui_wdecor_set_rect(wdecor, &rect);
936 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
938 ui_wdecor_sysmenu_hdl_set_active(wdecor, true);
940 resp.sysmenu_right = false;
942 event.type = KEY_PRESS;
943 event.mods = 0;
944 event.key = KC_RIGHT;
945 event.kbd_id = 42;
946 ui_wdecor_kbd_event(wdecor, &event);
948 PCUT_ASSERT_TRUE(resp.sysmenu_right);
949 PCUT_ASSERT_INT_EQUALS(event.kbd_id, resp.idev_id);
951 ui_wdecor_destroy(wdecor);
952 ui_resource_destroy(resource);
954 rc = gfx_context_delete(gc);
955 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
958 /** Character key with active sysmenu handle generates sysmenu accel event */
959 PCUT_TEST(kbd_accel_sysmenu)
961 errno_t rc;
962 gfx_rect_t rect;
963 kbd_event_t event;
964 gfx_context_t *gc = NULL;
965 test_gc_t tgc;
966 test_cb_resp_t resp;
967 ui_resource_t *resource = NULL;
968 ui_wdecor_t *wdecor;
970 memset(&tgc, 0, sizeof(tgc));
971 rc = gfx_context_new(&ops, &tgc, &gc);
972 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
974 rc = ui_resource_create(gc, false, &resource);
975 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
976 PCUT_ASSERT_NOT_NULL(resource);
978 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
979 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
981 rect.p0.x = 10;
982 rect.p0.y = 20;
983 rect.p1.x = 100;
984 rect.p1.y = 200;
986 ui_wdecor_set_rect(wdecor, &rect);
988 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
990 ui_wdecor_sysmenu_hdl_set_active(wdecor, true);
992 resp.sysmenu_accel = false;
994 event.type = KEY_PRESS;
995 event.mods = 0;
996 event.key = KC_A;
997 event.c = 'a';
998 event.kbd_id = 42;
999 ui_wdecor_kbd_event(wdecor, &event);
1001 PCUT_ASSERT_TRUE(resp.sysmenu_accel);
1002 PCUT_ASSERT_INT_EQUALS(event.c, resp.accel);
1003 PCUT_ASSERT_INT_EQUALS(event.kbd_id, resp.idev_id);
1005 ui_wdecor_destroy(wdecor);
1006 ui_resource_destroy(resource);
1008 rc = gfx_context_delete(gc);
1009 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1012 /** ui_wdecor_get_geom() with ui_wds_none produces the correct geometry */
1013 PCUT_TEST(get_geom_none)
1015 gfx_context_t *gc = NULL;
1016 test_gc_t tgc;
1017 ui_resource_t *resource = NULL;
1018 ui_wdecor_t *wdecor;
1019 gfx_rect_t rect;
1020 ui_wdecor_geom_t geom;
1021 errno_t rc;
1023 memset(&tgc, 0, sizeof(tgc));
1024 rc = gfx_context_new(&ops, &tgc, &gc);
1025 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1027 rc = ui_resource_create(gc, false, &resource);
1028 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1029 PCUT_ASSERT_NOT_NULL(resource);
1031 rc = ui_wdecor_create(resource, "Hello", ui_wds_none, &wdecor);
1032 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1034 rect.p0.x = 10;
1035 rect.p0.y = 20;
1036 rect.p1.x = 100;
1037 rect.p1.y = 200;
1039 ui_wdecor_set_rect(wdecor, &rect);
1040 ui_wdecor_get_geom(wdecor, &geom);
1042 PCUT_ASSERT_INT_EQUALS(10, geom.interior_rect.p0.x);
1043 PCUT_ASSERT_INT_EQUALS(20, geom.interior_rect.p0.y);
1044 PCUT_ASSERT_INT_EQUALS(100, geom.interior_rect.p1.x);
1045 PCUT_ASSERT_INT_EQUALS(200, geom.interior_rect.p1.y);
1047 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p0.x);
1048 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p0.y);
1049 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p1.x);
1050 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p1.y);
1052 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.x);
1053 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.y);
1054 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.x);
1055 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.y);
1057 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p0.x);
1058 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p0.y);
1059 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p1.x);
1060 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p1.y);
1062 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.x);
1063 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.y);
1064 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.x);
1065 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.y);
1067 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.x);
1068 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.y);
1069 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.x);
1070 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.y);
1072 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.x);
1073 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.y);
1074 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.x);
1075 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.y);
1077 PCUT_ASSERT_INT_EQUALS(10, geom.app_area_rect.p0.x);
1078 PCUT_ASSERT_INT_EQUALS(20, geom.app_area_rect.p0.y);
1079 PCUT_ASSERT_INT_EQUALS(100, geom.app_area_rect.p1.x);
1080 PCUT_ASSERT_INT_EQUALS(200, geom.app_area_rect.p1.y);
1082 ui_wdecor_destroy(wdecor);
1083 ui_resource_destroy(resource);
1085 rc = gfx_context_delete(gc);
1086 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1089 /** ui_wdecor_get_geom() with ui_wds_frame produces the correct geometry */
1090 PCUT_TEST(get_geom_frame)
1092 gfx_context_t *gc = NULL;
1093 test_gc_t tgc;
1094 ui_resource_t *resource = NULL;
1095 ui_wdecor_t *wdecor;
1096 gfx_rect_t rect;
1097 ui_wdecor_geom_t geom;
1098 errno_t rc;
1100 memset(&tgc, 0, sizeof(tgc));
1101 rc = gfx_context_new(&ops, &tgc, &gc);
1102 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1104 rc = ui_resource_create(gc, false, &resource);
1105 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1106 PCUT_ASSERT_NOT_NULL(resource);
1108 rc = ui_wdecor_create(resource, "Hello", ui_wds_frame, &wdecor);
1109 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1111 rect.p0.x = 10;
1112 rect.p0.y = 20;
1113 rect.p1.x = 100;
1114 rect.p1.y = 200;
1116 ui_wdecor_set_rect(wdecor, &rect);
1117 ui_wdecor_get_geom(wdecor, &geom);
1119 PCUT_ASSERT_INT_EQUALS(14, geom.interior_rect.p0.x);
1120 PCUT_ASSERT_INT_EQUALS(24, geom.interior_rect.p0.y);
1121 PCUT_ASSERT_INT_EQUALS(96, geom.interior_rect.p1.x);
1122 PCUT_ASSERT_INT_EQUALS(196, geom.interior_rect.p1.y);
1124 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p0.x);
1125 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p0.y);
1126 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p1.x);
1127 PCUT_ASSERT_INT_EQUALS(0, geom.title_bar_rect.p1.y);
1129 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.x);
1130 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.y);
1131 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.x);
1132 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.y);
1134 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p0.x);
1135 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p0.y);
1136 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p1.x);
1137 PCUT_ASSERT_INT_EQUALS(0, geom.caption_rect.p1.y);
1139 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.x);
1140 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.y);
1141 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.x);
1142 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.y);
1144 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.x);
1145 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.y);
1146 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.x);
1147 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.y);
1149 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.x);
1150 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.y);
1151 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.x);
1152 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.y);
1154 PCUT_ASSERT_INT_EQUALS(14, geom.app_area_rect.p0.x);
1155 PCUT_ASSERT_INT_EQUALS(24, geom.app_area_rect.p0.y);
1156 PCUT_ASSERT_INT_EQUALS(96, geom.app_area_rect.p1.x);
1157 PCUT_ASSERT_INT_EQUALS(196, geom.app_area_rect.p1.y);
1159 ui_wdecor_destroy(wdecor);
1160 ui_resource_destroy(resource);
1162 rc = gfx_context_delete(gc);
1163 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1166 /** ui_wdecor_get_geom() with ui_wds_frame | ui_wds_titlebar */
1167 PCUT_TEST(get_geom_frame_titlebar)
1169 gfx_context_t *gc = NULL;
1170 test_gc_t tgc;
1171 ui_resource_t *resource = NULL;
1172 ui_wdecor_t *wdecor;
1173 gfx_rect_t rect;
1174 ui_wdecor_geom_t geom;
1175 errno_t rc;
1177 memset(&tgc, 0, sizeof(tgc));
1178 rc = gfx_context_new(&ops, &tgc, &gc);
1179 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1181 rc = ui_resource_create(gc, false, &resource);
1182 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1183 PCUT_ASSERT_NOT_NULL(resource);
1185 rc = ui_wdecor_create(resource, "Hello", ui_wds_frame | ui_wds_titlebar,
1186 &wdecor);
1187 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1189 rect.p0.x = 10;
1190 rect.p0.y = 20;
1191 rect.p1.x = 100;
1192 rect.p1.y = 200;
1194 ui_wdecor_set_rect(wdecor, &rect);
1195 ui_wdecor_get_geom(wdecor, &geom);
1197 PCUT_ASSERT_INT_EQUALS(14, geom.interior_rect.p0.x);
1198 PCUT_ASSERT_INT_EQUALS(24, geom.interior_rect.p0.y);
1199 PCUT_ASSERT_INT_EQUALS(96, geom.interior_rect.p1.x);
1200 PCUT_ASSERT_INT_EQUALS(196, geom.interior_rect.p1.y);
1202 PCUT_ASSERT_INT_EQUALS(14, geom.title_bar_rect.p0.x);
1203 PCUT_ASSERT_INT_EQUALS(24, geom.title_bar_rect.p0.y);
1204 PCUT_ASSERT_INT_EQUALS(96, geom.title_bar_rect.p1.x);
1205 PCUT_ASSERT_INT_EQUALS(46, geom.title_bar_rect.p1.y);
1207 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.x);
1208 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p0.y);
1209 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.x);
1210 PCUT_ASSERT_INT_EQUALS(0, geom.sysmenu_hdl_rect.p1.y);
1212 PCUT_ASSERT_INT_EQUALS(18, geom.caption_rect.p0.x);
1213 PCUT_ASSERT_INT_EQUALS(24, geom.caption_rect.p0.y);
1214 PCUT_ASSERT_INT_EQUALS(91, geom.caption_rect.p1.x);
1215 PCUT_ASSERT_INT_EQUALS(46, geom.caption_rect.p1.y);
1217 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.x);
1218 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p0.y);
1219 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.x);
1220 PCUT_ASSERT_INT_EQUALS(0, geom.btn_min_rect.p1.y);
1222 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.x);
1223 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.y);
1224 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.x);
1225 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.y);
1227 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.x);
1228 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p0.y);
1229 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.x);
1230 PCUT_ASSERT_INT_EQUALS(0, geom.btn_close_rect.p1.y);
1232 PCUT_ASSERT_INT_EQUALS(14, geom.app_area_rect.p0.x);
1233 PCUT_ASSERT_INT_EQUALS(46, geom.app_area_rect.p0.y);
1234 PCUT_ASSERT_INT_EQUALS(96, geom.app_area_rect.p1.x);
1235 PCUT_ASSERT_INT_EQUALS(196, geom.app_area_rect.p1.y);
1237 ui_wdecor_destroy(wdecor);
1238 ui_resource_destroy(resource);
1240 rc = gfx_context_delete(gc);
1241 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1244 /** ui_wdecor_get_geom() with ui_wds_decorated produces the correct geometry */
1245 PCUT_TEST(get_geom_decorated)
1247 gfx_context_t *gc = NULL;
1248 test_gc_t tgc;
1249 ui_resource_t *resource = NULL;
1250 ui_wdecor_t *wdecor;
1251 gfx_rect_t rect;
1252 ui_wdecor_geom_t geom;
1253 errno_t rc;
1255 memset(&tgc, 0, sizeof(tgc));
1256 rc = gfx_context_new(&ops, &tgc, &gc);
1257 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1259 rc = ui_resource_create(gc, false, &resource);
1260 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1261 PCUT_ASSERT_NOT_NULL(resource);
1263 rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
1264 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1266 rect.p0.x = 10;
1267 rect.p0.y = 20;
1268 rect.p1.x = 100;
1269 rect.p1.y = 200;
1271 ui_wdecor_set_rect(wdecor, &rect);
1272 ui_wdecor_get_geom(wdecor, &geom);
1274 PCUT_ASSERT_INT_EQUALS(14, geom.interior_rect.p0.x);
1275 PCUT_ASSERT_INT_EQUALS(24, geom.interior_rect.p0.y);
1276 PCUT_ASSERT_INT_EQUALS(96, geom.interior_rect.p1.x);
1277 PCUT_ASSERT_INT_EQUALS(196, geom.interior_rect.p1.y);
1279 PCUT_ASSERT_INT_EQUALS(14, geom.title_bar_rect.p0.x);
1280 PCUT_ASSERT_INT_EQUALS(24, geom.title_bar_rect.p0.y);
1281 PCUT_ASSERT_INT_EQUALS(96, geom.title_bar_rect.p1.x);
1282 PCUT_ASSERT_INT_EQUALS(46, geom.title_bar_rect.p1.y);
1284 PCUT_ASSERT_INT_EQUALS(15, geom.sysmenu_hdl_rect.p0.x);
1285 PCUT_ASSERT_INT_EQUALS(25, geom.sysmenu_hdl_rect.p0.y);
1286 PCUT_ASSERT_INT_EQUALS(35, geom.sysmenu_hdl_rect.p1.x);
1287 PCUT_ASSERT_INT_EQUALS(45, geom.sysmenu_hdl_rect.p1.y);
1289 PCUT_ASSERT_INT_EQUALS(38, geom.caption_rect.p0.x);
1290 PCUT_ASSERT_INT_EQUALS(24, geom.caption_rect.p0.y);
1291 PCUT_ASSERT_INT_EQUALS(51, geom.caption_rect.p1.x);
1292 PCUT_ASSERT_INT_EQUALS(46, geom.caption_rect.p1.y);
1294 PCUT_ASSERT_INT_EQUALS(55, geom.btn_min_rect.p0.x);
1295 PCUT_ASSERT_INT_EQUALS(25, geom.btn_min_rect.p0.y);
1296 PCUT_ASSERT_INT_EQUALS(75, geom.btn_min_rect.p1.x);
1297 PCUT_ASSERT_INT_EQUALS(45, geom.btn_min_rect.p1.y);
1299 /* Maximize button is not in ui_wds_decorated */
1300 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.x);
1301 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p0.y);
1302 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.x);
1303 PCUT_ASSERT_INT_EQUALS(0, geom.btn_max_rect.p1.y);
1305 PCUT_ASSERT_INT_EQUALS(75, geom.btn_close_rect.p0.x);
1306 PCUT_ASSERT_INT_EQUALS(25, geom.btn_close_rect.p0.y);
1307 PCUT_ASSERT_INT_EQUALS(95, geom.btn_close_rect.p1.x);
1308 PCUT_ASSERT_INT_EQUALS(45, geom.btn_close_rect.p1.y);
1310 PCUT_ASSERT_INT_EQUALS(14, geom.app_area_rect.p0.x);
1311 PCUT_ASSERT_INT_EQUALS(46, geom.app_area_rect.p0.y);
1312 PCUT_ASSERT_INT_EQUALS(96, geom.app_area_rect.p1.x);
1313 PCUT_ASSERT_INT_EQUALS(196, geom.app_area_rect.p1.y);
1315 ui_wdecor_destroy(wdecor);
1316 ui_resource_destroy(resource);
1318 rc = gfx_context_delete(gc);
1319 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1322 /** ui_wdecor_rect_from_app() correctly converts application to window rect */
1323 PCUT_TEST(rect_from_app)
1325 errno_t rc;
1326 ui_t *ui = NULL;
1327 gfx_rect_t arect;
1328 gfx_rect_t rect;
1330 rc = ui_create_disp(NULL, &ui);
1331 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1333 arect.p0.x = 14;
1334 arect.p0.y = 46;
1335 arect.p1.x = 96;
1336 arect.p1.y = 196;
1338 ui_wdecor_rect_from_app(ui, ui_wds_none, &arect, &rect);
1340 PCUT_ASSERT_INT_EQUALS(14, rect.p0.x);
1341 PCUT_ASSERT_INT_EQUALS(46, rect.p0.y);
1342 PCUT_ASSERT_INT_EQUALS(96, rect.p1.x);
1343 PCUT_ASSERT_INT_EQUALS(196, rect.p1.y);
1345 ui_wdecor_rect_from_app(ui, ui_wds_frame, &arect, &rect);
1347 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
1348 PCUT_ASSERT_INT_EQUALS(42, rect.p0.y);
1349 PCUT_ASSERT_INT_EQUALS(100, rect.p1.x);
1350 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y);
1352 ui_wdecor_rect_from_app(ui, ui_wds_decorated, &arect, &rect);
1354 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
1355 PCUT_ASSERT_INT_EQUALS(20, rect.p0.y);
1356 PCUT_ASSERT_INT_EQUALS(100, rect.p1.x);
1357 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y);
1359 ui_destroy(ui);
1362 /** Test ui_wdecor_get_rsztype() */
1363 PCUT_TEST(get_rsztype)
1365 gfx_context_t *gc = NULL;
1366 test_gc_t tgc;
1367 ui_resource_t *resource = NULL;
1368 ui_wdecor_t *wdecor;
1369 gfx_rect_t rect;
1370 ui_wdecor_rsztype_t rsztype;
1371 gfx_coord2_t pos;
1372 errno_t rc;
1374 memset(&tgc, 0, sizeof(tgc));
1375 rc = gfx_context_new(&ops, &tgc, &gc);
1376 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1378 rc = ui_resource_create(gc, false, &resource);
1379 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1380 PCUT_ASSERT_NOT_NULL(resource);
1382 rc = ui_wdecor_create(resource, "Hello", ui_wds_resizable, &wdecor);
1383 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1385 rect.p0.x = 10;
1386 rect.p0.y = 20;
1387 rect.p1.x = 100;
1388 rect.p1.y = 200;
1390 ui_wdecor_set_rect(wdecor, &rect);
1392 /* Outside of the window */
1393 pos.x = 0;
1394 pos.y = -1;
1395 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1396 PCUT_ASSERT_EQUALS(ui_wr_none, rsztype);
1398 /* Middle of the window */
1399 pos.x = 50;
1400 pos.y = 100;
1401 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1402 PCUT_ASSERT_EQUALS(ui_wr_none, rsztype);
1404 /* Top-left corner, but not on edge */
1405 pos.x = 20;
1406 pos.y = 30;
1407 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1408 PCUT_ASSERT_EQUALS(ui_wr_none, rsztype);
1410 /* Top-left corner on top edge */
1411 pos.x = 20;
1412 pos.y = 20;
1413 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1414 PCUT_ASSERT_EQUALS(ui_wr_top_left, rsztype);
1416 /* Top-left corner on left edge */
1417 pos.x = 10;
1418 pos.y = 30;
1419 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1420 PCUT_ASSERT_EQUALS(ui_wr_top_left, rsztype);
1422 /* Top-right corner on top edge */
1423 pos.x = 90;
1424 pos.y = 20;
1425 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1426 PCUT_ASSERT_EQUALS(ui_wr_top_right, rsztype);
1428 /* Top-right corner on right edge */
1429 pos.x = 99;
1430 pos.y = 30;
1431 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1432 PCUT_ASSERT_EQUALS(ui_wr_top_right, rsztype);
1434 /* Top edge */
1435 pos.x = 50;
1436 pos.y = 20;
1437 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1438 PCUT_ASSERT_EQUALS(ui_wr_top, rsztype);
1440 /* Bottom edge */
1441 pos.x = 50;
1442 pos.y = 199;
1443 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1444 PCUT_ASSERT_EQUALS(ui_wr_bottom, rsztype);
1446 /* Left edge */
1447 pos.x = 10;
1448 pos.y = 100;
1449 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1450 PCUT_ASSERT_EQUALS(ui_wr_left, rsztype);
1452 /* Right edge */
1453 pos.x = 99;
1454 pos.y = 100;
1455 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1456 PCUT_ASSERT_EQUALS(ui_wr_right, rsztype);
1458 ui_wdecor_destroy(wdecor);
1460 /* Non-resizable window */
1462 rc = ui_wdecor_create(resource, "Hello", ui_wds_none, &wdecor);
1463 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1465 rect.p0.x = 10;
1466 rect.p0.y = 20;
1467 rect.p1.x = 100;
1468 rect.p1.y = 200;
1470 ui_wdecor_set_rect(wdecor, &rect);
1472 pos.x = 10;
1473 pos.y = 20;
1474 rsztype = ui_wdecor_get_rsztype(wdecor, &pos);
1475 PCUT_ASSERT_EQUALS(ui_wr_none, rsztype);
1477 ui_wdecor_destroy(wdecor);
1478 ui_resource_destroy(resource);
1480 rc = gfx_context_delete(gc);
1481 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1484 /** Test ui_wdecor_cursor_from_rsztype() */
1485 PCUT_TEST(cursor_from_rsztype)
1487 PCUT_ASSERT_EQUALS(ui_curs_arrow,
1488 ui_wdecor_cursor_from_rsztype(ui_wr_none));
1489 PCUT_ASSERT_EQUALS(ui_curs_size_ud,
1490 ui_wdecor_cursor_from_rsztype(ui_wr_top));
1491 PCUT_ASSERT_EQUALS(ui_curs_size_ud,
1492 ui_wdecor_cursor_from_rsztype(ui_wr_bottom));
1493 PCUT_ASSERT_EQUALS(ui_curs_size_lr,
1494 ui_wdecor_cursor_from_rsztype(ui_wr_left));
1495 PCUT_ASSERT_EQUALS(ui_curs_size_lr,
1496 ui_wdecor_cursor_from_rsztype(ui_wr_right));
1497 PCUT_ASSERT_EQUALS(ui_curs_size_uldr,
1498 ui_wdecor_cursor_from_rsztype(ui_wr_top_left));
1499 PCUT_ASSERT_EQUALS(ui_curs_size_uldr,
1500 ui_wdecor_cursor_from_rsztype(ui_wr_bottom_right));
1501 PCUT_ASSERT_EQUALS(ui_curs_size_urdl,
1502 ui_wdecor_cursor_from_rsztype(ui_wr_top_right));
1503 PCUT_ASSERT_EQUALS(ui_curs_size_urdl,
1504 ui_wdecor_cursor_from_rsztype(ui_wr_bottom_left));
1507 /** Test ui_wdecor_frame_pos_event() */
1508 PCUT_TEST(frame_pos_event)
1510 gfx_context_t *gc = NULL;
1511 test_gc_t tgc;
1512 ui_resource_t *resource = NULL;
1513 ui_wdecor_t *wdecor;
1514 gfx_rect_t rect;
1515 test_cb_resp_t resp;
1516 pos_event_t event;
1517 errno_t rc;
1519 memset(&tgc, 0, sizeof(tgc));
1520 rc = gfx_context_new(&ops, &tgc, &gc);
1521 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1523 rc = ui_resource_create(gc, false, &resource);
1524 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1525 PCUT_ASSERT_NOT_NULL(resource);
1527 rc = ui_wdecor_create(resource, "Hello", ui_wds_resizable, &wdecor);
1528 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1530 rect.p0.x = 10;
1531 rect.p0.y = 20;
1532 rect.p1.x = 100;
1533 rect.p1.y = 200;
1535 ui_wdecor_set_rect(wdecor, &rect);
1536 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
1538 /* Release on window border should do nothing */
1539 resp.resize = false;
1540 event.type = POS_RELEASE;
1541 event.hpos = 10;
1542 event.vpos = 10;
1543 ui_wdecor_frame_pos_event(wdecor, &event);
1544 PCUT_ASSERT_FALSE(resp.resize);
1546 /* Press in the middle of the window should do nothing */
1547 resp.resize = false;
1548 event.type = POS_PRESS;
1549 event.hpos = 50;
1550 event.vpos = 100;
1551 ui_wdecor_frame_pos_event(wdecor, &event);
1552 PCUT_ASSERT_FALSE(resp.resize);
1554 /* Press on window border should cause resize to be called */
1555 resp.resize = false;
1556 event.type = POS_PRESS;
1557 event.hpos = 10;
1558 event.vpos = 20;
1559 ui_wdecor_frame_pos_event(wdecor, &event);
1560 PCUT_ASSERT_TRUE(resp.resize);
1562 ui_wdecor_destroy(wdecor);
1563 ui_resource_destroy(resource);
1565 rc = gfx_context_delete(gc);
1566 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
1569 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
1571 (void) arg;
1572 (void) rect;
1573 return EOK;
1576 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
1578 (void) arg;
1579 (void) color;
1580 return EOK;
1583 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
1585 (void) arg;
1586 (void) rect;
1587 return EOK;
1590 static errno_t testgc_update(void *arg)
1592 (void) arg;
1593 return EOK;
1596 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
1597 gfx_bitmap_alloc_t *alloc, void **rbm)
1599 test_gc_t *tgc = (test_gc_t *) arg;
1600 testgc_bitmap_t *tbm;
1602 tbm = calloc(1, sizeof(testgc_bitmap_t));
1603 if (tbm == NULL)
1604 return ENOMEM;
1606 if (alloc == NULL) {
1607 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
1608 sizeof(uint32_t);
1609 tbm->alloc.off0 = 0;
1610 tbm->alloc.pixels = calloc(sizeof(uint32_t),
1611 (params->rect.p1.x - params->rect.p0.x) *
1612 (params->rect.p1.y - params->rect.p0.y));
1613 tbm->myalloc = true;
1614 if (tbm->alloc.pixels == NULL) {
1615 free(tbm);
1616 return ENOMEM;
1618 } else {
1619 tbm->alloc = *alloc;
1622 tbm->tgc = tgc;
1623 tgc->bm_created = true;
1624 tgc->bm_params = *params;
1625 tgc->bm_pixels = tbm->alloc.pixels;
1626 *rbm = (void *)tbm;
1627 return EOK;
1630 static errno_t testgc_bitmap_destroy(void *bm)
1632 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
1633 if (tbm->myalloc)
1634 free(tbm->alloc.pixels);
1635 tbm->tgc->bm_destroyed = true;
1636 free(tbm);
1637 return EOK;
1640 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
1641 gfx_coord2_t *offs)
1643 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
1644 tbm->tgc->bm_rendered = true;
1645 tbm->tgc->bm_srect = *srect;
1646 tbm->tgc->bm_offs = *offs;
1647 return EOK;
1650 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
1652 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
1653 *alloc = tbm->alloc;
1654 tbm->tgc->bm_got_alloc = true;
1655 return EOK;
1658 static void test_wdecor_sysmenu_open(ui_wdecor_t *wdecor, void *arg,
1659 sysarg_t idev_id)
1661 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1663 resp->sysmenu_open = true;
1664 resp->idev_id = idev_id;
1667 static void test_wdecor_sysmenu_left(ui_wdecor_t *wdecor, void *arg,
1668 sysarg_t idev_id)
1670 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1672 resp->sysmenu_left = true;
1673 resp->idev_id = idev_id;
1676 static void test_wdecor_sysmenu_right(ui_wdecor_t *wdecor, void *arg,
1677 sysarg_t idev_id)
1679 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1681 resp->sysmenu_right = true;
1682 resp->idev_id = idev_id;
1685 static void test_wdecor_sysmenu_accel(ui_wdecor_t *wdecor, void *arg,
1686 char32_t accel, sysarg_t idev_id)
1688 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1690 resp->sysmenu_accel = true;
1691 resp->accel = accel;
1692 resp->idev_id = idev_id;
1695 static void test_wdecor_minimize(ui_wdecor_t *wdecor, void *arg)
1697 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1699 resp->minimize = true;
1702 static void test_wdecor_maximize(ui_wdecor_t *wdecor, void *arg)
1704 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1706 resp->maximize = true;
1709 static void test_wdecor_unmaximize(ui_wdecor_t *wdecor, void *arg)
1711 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1713 resp->unmaximize = true;
1716 static void test_wdecor_close(ui_wdecor_t *wdecor, void *arg)
1718 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1720 resp->close = true;
1723 static void test_wdecor_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos,
1724 sysarg_t pos_id)
1726 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1728 resp->move = true;
1729 resp->pos = *pos;
1730 resp->pos_id = pos_id;
1733 static void test_wdecor_resize(ui_wdecor_t *wdecor, void *arg,
1734 ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
1736 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1738 resp->resize = true;
1739 resp->rsztype = rsztype;
1740 resp->pos = *pos;
1741 resp->pos_id = pos_id;
1744 static void test_wdecor_set_cursor(ui_wdecor_t *wdecor, void *arg,
1745 ui_stock_cursor_t cursor)
1747 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
1749 resp->set_cursor = true;
1750 resp->cursor = cursor;
1753 PCUT_EXPORT(wdecor);