This source file includes following definitions.
- START_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define TEST_SUITE_NAME "lib/widget"
27
28 #include "tests/mctest.h"
29
30 #include "lib/widget.h"
31
32
33
34 START_TEST (test_widget_find_by_id)
35 {
36 WGroup *g, *g0;
37 Widget *w0;
38 WRect r;
39
40 g = g_new0 (WGroup, 1);
41 rect_init (&r, 0, 0, 20, 20);
42 group_init (g, &r, NULL, NULL);
43
44 g0 = g_new0 (WGroup, 1);
45 rect_init (&r, 0, 0, 10, 10);
46 group_init (g0, &r, NULL, NULL);
47 group_add_widget (g, g0);
48
49 w0 = g_new0 (Widget, 1);
50 rect_init (&r, 0, 0, 5, 5);
51 widget_init (w0, &r, widget_default_callback, NULL);
52 group_add_widget (g0, w0);
53
54 w0 = g_new0 (Widget, 1);
55 rect_init (&r, 5, 5, 5, 5);
56 widget_init (w0, &r, widget_default_callback, NULL);
57 group_add_widget (g0, w0);
58
59 g0 = g_new0 (WGroup, 1);
60 rect_init (&r, 10, 10, 10, 10);
61 group_init (g0, &r, NULL, NULL);
62 group_add_widget (g, g0);
63
64 w0 = g_new0 (Widget, 1);
65 rect_init (&r, 10, 10, 5, 5);
66 widget_init (w0, &r, widget_default_callback, NULL);
67 group_add_widget (g0, w0);
68
69 w0 = g_new0 (Widget, 1);
70 rect_init (&r, 15, 15, 5, 5);
71 widget_init (w0, &r, widget_default_callback, NULL);
72 group_add_widget (g0, w0);
73
74 w0 = g_new0 (Widget, 1);
75 rect_init (&r, 5, 5, 10, 10);
76 widget_init (w0, &r, widget_default_callback, NULL);
77 group_add_widget (g, w0);
78
79 w0 = WIDGET (g);
80
81 ck_assert_msg (widget_find_by_id (w0, 0) != NULL, "Not found ID=0");
82 ck_assert_msg (widget_find_by_id (w0, 1) != NULL, "Not found ID=1");
83 ck_assert_msg (widget_find_by_id (w0, 2) != NULL, "Not found ID=2");
84 ck_assert_msg (widget_find_by_id (w0, 3) != NULL, "Not found ID=3");
85 ck_assert_msg (widget_find_by_id (w0, 4) != NULL, "Not found ID=4");
86 ck_assert_msg (widget_find_by_id (w0, 5) != NULL, "Not found ID=5");
87 ck_assert_msg (widget_find_by_id (w0, 6) != NULL, "Not found ID=6");
88 ck_assert_msg (widget_find_by_id (w0, 7) != NULL, "Not found ID=7");
89 ck_assert_msg (widget_find_by_id (w0, 8) == NULL, "Found ID=8");
90
91 send_message (g, NULL, MSG_INIT, 0, NULL);
92 widget_destroy (w0);
93 }
94 END_TEST
95
96
97
98 int
99 main (void)
100 {
101 TCase *tc_core;
102
103 tc_core = tcase_create ("Core");
104
105
106 tcase_add_test (tc_core, test_widget_find_by_id);
107
108
109 return mctest_run_all (tc_core);
110 }
111
112