2 * Copyright (c) 2023 Jiri Svoboda
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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>
32 #include <pcut/pcut.h>
35 #include <ui/control.h>
37 #include <ui/tabset.h>
38 #include <ui/testctl.h>
40 #include <ui/window.h>
41 #include "../private/resource.h"
42 #include "../private/tab.h"
43 #include "../private/tabset.h"
49 /** Create and destroy tab */
50 PCUT_TEST(create_destroy
)
53 ui_window_t
*window
= NULL
;
54 ui_wnd_params_t params
;
56 ui_tab_set_t
*tabset
= NULL
;
60 rc
= ui_create_disp(NULL
, &ui
);
61 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
63 ui_wnd_params_init(¶ms
);
64 params
.caption
= "Hello";
66 rc
= ui_window_create(ui
, ¶ms
, &window
);
67 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
68 PCUT_ASSERT_NOT_NULL(window
);
70 res
= ui_window_get_res(window
);
72 rc
= ui_tab_set_create(res
, &tabset
);
73 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
75 rc
= ui_tab_create(tabset
, "Test", &tab
);
76 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
77 PCUT_ASSERT_NOT_NULL(tab
);
80 * Normally we don't need to destroy a tab explicitly, it will
81 * be destroyed along with tab bar, but here we'll test destroying
85 ui_tab_set_destroy(tabset
);
87 ui_window_destroy(window
);
91 /** Destroy tab implicitly by destroying the tab set */
92 PCUT_TEST(implicit_destroy
)
95 ui_window_t
*window
= NULL
;
96 ui_wnd_params_t params
;
98 ui_tab_set_t
*tabset
= NULL
;
102 rc
= ui_create_disp(NULL
, &ui
);
103 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
105 ui_wnd_params_init(¶ms
);
106 params
.caption
= "Hello";
108 rc
= ui_window_create(ui
, ¶ms
, &window
);
109 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
110 PCUT_ASSERT_NOT_NULL(window
);
112 res
= ui_window_get_res(window
);
114 rc
= ui_tab_set_create(res
, &tabset
);
115 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
117 rc
= ui_tab_create(tabset
, "Test", &tab
);
118 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
119 PCUT_ASSERT_NOT_NULL(tab
);
121 /* Let the tab be destroyed as part of destroying tab set */
122 ui_tab_set_destroy(tabset
);
124 ui_window_destroy(window
);
128 /** ui_tab_destroy() can take NULL argument (no-op) */
129 PCUT_TEST(destroy_null
)
131 ui_tab_destroy(NULL
);
134 /** ui_tab_first() / ui_tab_next() iterate over tabs */
135 PCUT_TEST(first_next
)
138 ui_window_t
*window
= NULL
;
139 ui_wnd_params_t params
;
141 ui_tab_set_t
*tabset
= NULL
;
142 ui_tab_t
*tab1
= NULL
;
143 ui_tab_t
*tab2
= NULL
;
147 rc
= ui_create_disp(NULL
, &ui
);
148 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
150 ui_wnd_params_init(¶ms
);
151 params
.caption
= "Hello";
153 rc
= ui_window_create(ui
, ¶ms
, &window
);
154 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
155 PCUT_ASSERT_NOT_NULL(window
);
157 res
= ui_window_get_res(window
);
159 rc
= ui_tab_set_create(res
, &tabset
);
160 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
161 PCUT_ASSERT_NOT_NULL(tabset
);
163 rc
= ui_tab_create(tabset
, "Test 1", &tab1
);
164 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
165 PCUT_ASSERT_NOT_NULL(tab1
);
167 rc
= ui_tab_create(tabset
, "Test 2", &tab2
);
168 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
169 PCUT_ASSERT_NOT_NULL(tab2
);
171 t
= ui_tab_first(tabset
);
172 PCUT_ASSERT_EQUALS(tab1
, t
);
175 PCUT_ASSERT_EQUALS(tab2
, t
);
180 ui_tab_set_destroy(tabset
);
181 ui_window_destroy(window
);
185 /** ui_tab_last() / ui_tab_prev() iterate over tabs in reverse */
189 ui_window_t
*window
= NULL
;
190 ui_wnd_params_t params
;
192 ui_tab_set_t
*tabset
= NULL
;
193 ui_tab_t
*tab1
= NULL
;
194 ui_tab_t
*tab2
= NULL
;
198 rc
= ui_create_disp(NULL
, &ui
);
199 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
201 ui_wnd_params_init(¶ms
);
202 params
.caption
= "Hello";
204 rc
= ui_window_create(ui
, ¶ms
, &window
);
205 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
206 PCUT_ASSERT_NOT_NULL(window
);
208 res
= ui_window_get_res(window
);
210 rc
= ui_tab_set_create(res
, &tabset
);
211 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
212 PCUT_ASSERT_NOT_NULL(tabset
);
214 rc
= ui_tab_create(tabset
, "Test 1", &tab1
);
215 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
216 PCUT_ASSERT_NOT_NULL(tab1
);
218 rc
= ui_tab_create(tabset
, "Test 2", &tab2
);
219 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
220 PCUT_ASSERT_NOT_NULL(tab2
);
222 t
= ui_tab_last(tabset
);
223 PCUT_ASSERT_EQUALS(tab2
, t
);
226 PCUT_ASSERT_EQUALS(tab1
, t
);
231 ui_tab_set_destroy(tabset
);
232 ui_window_destroy(window
);
236 /** ui_tab_is_selected() correctly returns tab state */
237 PCUT_TEST(is_selected
)
240 ui_window_t
*window
= NULL
;
241 ui_wnd_params_t params
;
243 ui_tab_set_t
*tabset
= NULL
;
244 ui_tab_t
*tab1
= NULL
;
245 ui_tab_t
*tab2
= NULL
;
248 rc
= ui_create_disp(NULL
, &ui
);
249 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
251 ui_wnd_params_init(¶ms
);
252 params
.caption
= "Hello";
254 rc
= ui_window_create(ui
, ¶ms
, &window
);
255 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
256 PCUT_ASSERT_NOT_NULL(window
);
258 res
= ui_window_get_res(window
);
260 rc
= ui_tab_set_create(res
, &tabset
);
261 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
262 PCUT_ASSERT_NOT_NULL(tabset
);
264 rc
= ui_tab_create(tabset
, "Test 1", &tab1
);
265 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
267 /* The first added tab should be automatically selected */
268 PCUT_ASSERT_TRUE(ui_tab_is_selected(tab1
));
270 rc
= ui_tab_create(tabset
, "Test 2", &tab2
);
271 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
273 /* After adding a second tab the first should still be selected */
274 PCUT_ASSERT_TRUE(ui_tab_is_selected(tab1
));
275 PCUT_ASSERT_FALSE(ui_tab_is_selected(tab2
));
277 /* Select second tab */
278 ui_tab_set_select(tabset
, tab2
);
280 /* Now the second tab should be selected */
281 PCUT_ASSERT_FALSE(ui_tab_is_selected(tab1
));
282 PCUT_ASSERT_TRUE(ui_tab_is_selected(tab2
));
284 ui_tab_set_destroy(tabset
);
285 ui_window_destroy(window
);
289 /** ui_tab_add() adds control to tab */
293 ui_window_t
*window
= NULL
;
294 ui_wnd_params_t params
;
296 ui_tab_set_t
*tabset
= NULL
;
297 ui_tab_t
*tab
= NULL
;
298 ui_test_ctl_t
*testctl
= NULL
;
302 rc
= ui_create_disp(NULL
, &ui
);
303 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
305 ui_wnd_params_init(¶ms
);
306 params
.caption
= "Hello";
308 rc
= ui_window_create(ui
, ¶ms
, &window
);
309 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
310 PCUT_ASSERT_NOT_NULL(window
);
312 res
= ui_window_get_res(window
);
314 rc
= ui_tab_set_create(res
, &tabset
);
315 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
316 PCUT_ASSERT_NOT_NULL(tabset
);
318 rc
= ui_tab_create(tabset
, "Test", &tab
);
319 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
320 PCUT_ASSERT_NOT_NULL(tab
);
322 rc
= ui_test_ctl_create(&resp
, &testctl
);
323 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
325 /* Add test control to tab */
326 ui_tab_add(tab
, ui_test_ctl_ctl(testctl
));
328 resp
.destroy
= false;
330 ui_tab_set_destroy(tabset
);
332 /* Destroying the tab should have destroyed the control as well */
333 PCUT_ASSERT_TRUE(resp
.destroy
);
335 ui_window_destroy(window
);
339 /** ui_tab_remove() removes control to tab */
343 ui_window_t
*window
= NULL
;
344 ui_wnd_params_t params
;
346 ui_tab_set_t
*tabset
= NULL
;
347 ui_tab_t
*tab
= NULL
;
348 ui_test_ctl_t
*testctl
= NULL
;
352 rc
= ui_create_disp(NULL
, &ui
);
353 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
355 ui_wnd_params_init(¶ms
);
356 params
.caption
= "Hello";
358 rc
= ui_window_create(ui
, ¶ms
, &window
);
359 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
360 PCUT_ASSERT_NOT_NULL(window
);
362 res
= ui_window_get_res(window
);
364 rc
= ui_tab_set_create(res
, &tabset
);
365 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
366 PCUT_ASSERT_NOT_NULL(tabset
);
368 rc
= ui_tab_create(tabset
, "Test", &tab
);
369 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
370 PCUT_ASSERT_NOT_NULL(tab
);
372 rc
= ui_test_ctl_create(&resp
, &testctl
);
373 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
375 /* Add test control to tab */
376 ui_tab_add(tab
, ui_test_ctl_ctl(testctl
));
378 /* Rmove control from tab */
379 ui_tab_remove(tab
, ui_test_ctl_ctl(testctl
));
381 resp
.destroy
= false;
383 ui_tab_set_destroy(tabset
);
385 /* Destroying the tab should NOT have destroyed the control */
386 PCUT_ASSERT_FALSE(resp
.destroy
);
388 ui_test_ctl_destroy(testctl
);
389 ui_window_destroy(window
);
397 ui_window_t
*window
= NULL
;
398 ui_wnd_params_t params
;
400 ui_tab_set_t
*tabset
= NULL
;
401 ui_tab_t
*tab
= NULL
;
404 rc
= ui_create_disp(NULL
, &ui
);
405 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
407 ui_wnd_params_init(¶ms
);
408 params
.caption
= "Hello";
410 rc
= ui_window_create(ui
, ¶ms
, &window
);
411 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
412 PCUT_ASSERT_NOT_NULL(window
);
414 res
= ui_window_get_res(window
);
416 rc
= ui_tab_set_create(res
, &tabset
);
417 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
418 PCUT_ASSERT_NOT_NULL(tabset
);
420 rc
= ui_tab_create(tabset
, "Test", &tab
);
421 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
422 PCUT_ASSERT_NOT_NULL(tab
);
424 rc
= ui_tab_paint(tab
);
425 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
427 ui_tab_set_destroy(tabset
);
428 ui_window_destroy(window
);
432 /** ui_tab_kbd_event() delivers keyboard event */
436 ui_window_t
*window
= NULL
;
437 ui_wnd_params_t params
;
439 ui_tab_set_t
*tabset
= NULL
;
440 ui_tab_t
*tab
= NULL
;
441 ui_evclaim_t claimed
;
443 ui_test_ctl_t
*testctl
= NULL
;
447 rc
= ui_create_disp(NULL
, &ui
);
448 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
450 ui_wnd_params_init(¶ms
);
451 params
.caption
= "Hello";
453 rc
= ui_window_create(ui
, ¶ms
, &window
);
454 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
455 PCUT_ASSERT_NOT_NULL(window
);
457 res
= ui_window_get_res(window
);
459 rc
= ui_tab_set_create(res
, &tabset
);
460 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
461 PCUT_ASSERT_NOT_NULL(tabset
);
463 /* Without anytabs, event should be unclaimed */
464 event
.type
= KEY_PRESS
;
465 event
.key
= KC_ENTER
;
467 claimed
= ui_tab_set_kbd_event(tabset
, &event
);
468 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
469 PCUT_ASSERT_EQUALS(ui_unclaimed
, claimed
);
471 rc
= ui_tab_create(tabset
, "Test", &tab
);
472 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
473 PCUT_ASSERT_NOT_NULL(tab
);
475 rc
= ui_test_ctl_create(&resp
, &testctl
);
476 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
478 /* Set up response */
479 ui_tab_add(tab
, ui_test_ctl_ctl(testctl
));
480 resp
.claim
= ui_claimed
;
483 /* Send keyboard event */
484 event
.type
= KEY_PRESS
;
487 claimed
= ui_tab_kbd_event(tab
, &event
);
488 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
489 PCUT_ASSERT_EQUALS(ui_claimed
, claimed
);
491 /* Make sure event was delivered */
492 PCUT_ASSERT_TRUE(resp
.kbd
);
493 PCUT_ASSERT_EQUALS(event
.type
, resp
.kevent
.type
);
494 PCUT_ASSERT_EQUALS(event
.key
, resp
.kevent
.key
);
495 PCUT_ASSERT_EQUALS(event
.mods
, resp
.kevent
.mods
);
497 ui_tab_set_destroy(tabset
);
498 ui_window_destroy(window
);
502 /** ui_tab_pos_event() delivers position event */
506 ui_window_t
*window
= NULL
;
507 ui_wnd_params_t params
;
509 ui_tab_set_t
*tabset
= NULL
;
511 ui_tab_t
*tab
= NULL
;
512 ui_evclaim_t claimed
;
514 ui_test_ctl_t
*testctl
= NULL
;
518 rc
= ui_create_disp(NULL
, &ui
);
519 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
521 ui_wnd_params_init(¶ms
);
522 params
.caption
= "Hello";
524 rc
= ui_window_create(ui
, ¶ms
, &window
);
525 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
526 PCUT_ASSERT_NOT_NULL(window
);
528 res
= ui_window_get_res(window
);
530 rc
= ui_tab_set_create(res
, &tabset
);
531 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
532 PCUT_ASSERT_NOT_NULL(tabset
);
538 ui_tab_set_set_rect(tabset
, &rect
);
540 rc
= ui_tab_create(tabset
, "Test", &tab
);
541 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
542 PCUT_ASSERT_NOT_NULL(tab
);
544 rc
= ui_test_ctl_create(&resp
, &testctl
);
545 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
547 /* Set up response */
548 ui_tab_add(tab
, ui_test_ctl_ctl(testctl
));
549 resp
.claim
= ui_claimed
;
552 /* Send position event */
553 event
.type
= POS_PRESS
;
556 claimed
= ui_tab_pos_event(tab
, &event
);
557 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
558 PCUT_ASSERT_EQUALS(ui_claimed
, claimed
);
560 /* Make sure event was delivered */
561 PCUT_ASSERT_TRUE(resp
.pos
);
562 PCUT_ASSERT_EQUALS(event
.type
, resp
.pevent
.type
);
563 PCUT_ASSERT_EQUALS(event
.hpos
, resp
.pevent
.hpos
);
564 PCUT_ASSERT_EQUALS(event
.vpos
, resp
.pevent
.vpos
);
566 ui_tab_set_destroy(tabset
);
567 ui_window_destroy(window
);
571 /** ui_tab_handle_width() and ui_tab_handle_height() return dimensions */
572 PCUT_TEST(handle_width_height
)
575 ui_window_t
*window
= NULL
;
576 ui_wnd_params_t params
;
578 ui_tab_set_t
*tabset
= NULL
;
579 ui_tab_t
*tab
= NULL
;
583 rc
= ui_create_disp(NULL
, &ui
);
584 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
586 ui_wnd_params_init(¶ms
);
587 params
.caption
= "Hello";
589 rc
= ui_window_create(ui
, ¶ms
, &window
);
590 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
591 PCUT_ASSERT_NOT_NULL(window
);
593 res
= ui_window_get_res(window
);
595 rc
= ui_tab_set_create(res
, &tabset
);
596 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
597 PCUT_ASSERT_NOT_NULL(tabset
);
599 rc
= ui_tab_create(tabset
, "Test", &tab
);
600 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
601 PCUT_ASSERT_NOT_NULL(tab
);
603 w
= ui_tab_handle_width(tab
);
604 h
= ui_tab_handle_height(tab
);
606 PCUT_ASSERT_INT_EQUALS(50, w
);
607 PCUT_ASSERT_INT_EQUALS(25, h
);
609 ui_tab_set_destroy(tabset
);
610 ui_window_destroy(window
);
614 /** Computing tab geometry */
618 ui_window_t
*window
= NULL
;
619 ui_wnd_params_t params
;
621 ui_tab_set_t
*tabset
= NULL
;
622 ui_tab_t
*tab
= NULL
;
627 rc
= ui_create_disp(NULL
, &ui
);
628 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
630 ui_wnd_params_init(¶ms
);
631 params
.caption
= "Hello";
633 rc
= ui_window_create(ui
, ¶ms
, &window
);
634 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
635 PCUT_ASSERT_NOT_NULL(window
);
637 res
= ui_window_get_res(window
);
639 rc
= ui_tab_set_create(res
, &tabset
);
640 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
641 PCUT_ASSERT_NOT_NULL(tabset
);
647 ui_tab_set_set_rect(tabset
, &rect
);
649 rc
= ui_tab_create(tabset
, "Test", &tab
);
650 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
651 PCUT_ASSERT_NOT_NULL(tab
);
653 ui_tab_get_geom(tab
, &geom
);
655 PCUT_ASSERT_INT_EQUALS(1006, geom
.handle
.p0
.x
);
656 PCUT_ASSERT_INT_EQUALS(2000, geom
.handle
.p0
.y
);
657 PCUT_ASSERT_INT_EQUALS(1056, geom
.handle
.p1
.x
);
658 PCUT_ASSERT_INT_EQUALS(2027, geom
.handle
.p1
.y
);
660 PCUT_ASSERT_INT_EQUALS(1006, geom
.handle_area
.p0
.x
);
661 PCUT_ASSERT_INT_EQUALS(2000, geom
.handle_area
.p0
.y
);
662 PCUT_ASSERT_INT_EQUALS(1056, geom
.handle_area
.p1
.x
);
663 PCUT_ASSERT_INT_EQUALS(2027, geom
.handle_area
.p1
.y
);
665 PCUT_ASSERT_INT_EQUALS(1000, geom
.body
.p0
.x
);
666 PCUT_ASSERT_INT_EQUALS(2025, geom
.body
.p0
.y
);
667 PCUT_ASSERT_INT_EQUALS(1100, geom
.body
.p1
.x
);
668 PCUT_ASSERT_INT_EQUALS(2200, geom
.body
.p1
.y
);
670 PCUT_ASSERT_INT_EQUALS(1014, geom
.text_pos
.x
);
671 PCUT_ASSERT_INT_EQUALS(2007, geom
.text_pos
.y
);
673 ui_tab_set_destroy(tabset
);
674 ui_window_destroy(window
);
678 /** ui_tab_patint_handle_frame() */
679 PCUT_TEST(paint_handle_frame
)
682 ui_window_t
*window
= NULL
;
683 ui_wnd_params_t params
;
689 gfx_color_t
*hi_color
;
690 gfx_color_t
*sh_color
;
693 rc
= ui_create_disp(NULL
, &ui
);
694 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
696 ui_wnd_params_init(¶ms
);
697 params
.caption
= "Hello";
699 rc
= ui_window_create(ui
, ¶ms
, &window
);
700 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
701 PCUT_ASSERT_NOT_NULL(window
);
703 res
= ui_window_get_res(window
);
704 gc
= ui_window_get_gc(window
);
713 hi_color
= res
->wnd_highlight_color
;
714 sh_color
= res
->wnd_shadow_color
;
716 rc
= ui_tab_paint_handle_frame(gc
, &rect
, chamfer
, hi_color
, sh_color
,
718 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
720 rc
= ui_tab_paint_handle_frame(gc
, &rect
, chamfer
, hi_color
, sh_color
,
722 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
724 ui_window_destroy(window
);
728 /** ui_tab_paint_body_frame() */
729 PCUT_TEST(paint_body_frame
)
732 ui_window_t
*window
= NULL
;
733 ui_wnd_params_t params
;
735 ui_tab_set_t
*tabset
= NULL
;
736 ui_tab_t
*tab
= NULL
;
739 rc
= ui_create_disp(NULL
, &ui
);
740 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
742 ui_wnd_params_init(¶ms
);
743 params
.caption
= "Hello";
745 rc
= ui_window_create(ui
, ¶ms
, &window
);
746 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
747 PCUT_ASSERT_NOT_NULL(window
);
749 res
= ui_window_get_res(window
);
751 rc
= ui_tab_set_create(res
, &tabset
);
752 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
753 PCUT_ASSERT_NOT_NULL(tabset
);
755 rc
= ui_tab_create(tabset
, "Test", &tab
);
756 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
757 PCUT_ASSERT_NOT_NULL(tab
);
759 rc
= ui_tab_paint_body_frame(tab
);
760 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
762 ui_tab_set_destroy(tabset
);
763 ui_window_destroy(window
);
767 /** ui_tab_paint_frame() */
768 PCUT_TEST(paint_frame
)
771 ui_window_t
*window
= NULL
;
772 ui_wnd_params_t params
;
774 ui_tab_set_t
*tabset
= NULL
;
775 ui_tab_t
*tab
= NULL
;
778 rc
= ui_create_disp(NULL
, &ui
);
779 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
781 ui_wnd_params_init(¶ms
);
782 params
.caption
= "Hello";
784 rc
= ui_window_create(ui
, ¶ms
, &window
);
785 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
786 PCUT_ASSERT_NOT_NULL(window
);
788 res
= ui_window_get_res(window
);
790 rc
= ui_tab_set_create(res
, &tabset
);
791 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
792 PCUT_ASSERT_NOT_NULL(tabset
);
794 rc
= ui_tab_create(tabset
, "Test", &tab
);
795 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
796 PCUT_ASSERT_NOT_NULL(tab
);
798 rc
= ui_tab_paint_frame(tab
);
799 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
801 ui_tab_set_destroy(tabset
);
802 ui_window_destroy(window
);
806 /** ui_tab_get_res() returns the resource */
810 ui_window_t
*window
= NULL
;
811 ui_wnd_params_t params
;
813 ui_tab_set_t
*tabset
= NULL
;
814 ui_tab_t
*tab
= NULL
;
817 rc
= ui_create_disp(NULL
, &ui
);
818 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
820 ui_wnd_params_init(¶ms
);
821 params
.caption
= "Hello";
823 rc
= ui_window_create(ui
, ¶ms
, &window
);
824 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
825 PCUT_ASSERT_NOT_NULL(window
);
827 res
= ui_window_get_res(window
);
829 rc
= ui_tab_set_create(res
, &tabset
);
830 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
831 PCUT_ASSERT_NOT_NULL(tabset
);
833 rc
= ui_tab_create(tabset
, "Test", &tab
);
834 PCUT_ASSERT_ERRNO_VAL(EOK
, rc
);
835 PCUT_ASSERT_NOT_NULL(tab
);
837 PCUT_ASSERT_EQUALS(res
, ui_tab_get_res(tab
));
839 ui_tab_set_destroy(tabset
);
840 ui_window_destroy(window
);