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