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