1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "gx_api.h"
6 #include "gx_validation_utility.h"
7 #include "gx_widget.h"
8 #include "gx_system.h"
9
10 TEST_PARAM test_parameter = {
11 "guix_widget_no_output", /* Test name */
12 0, 0, 0, 0 /* Define the coordinates of the capture area.*/
13 };
14
main(int argc,char ** argv)15 int main(int argc, char ** argv)
16 {
17 /* Start ThreadX system */
18 tx_kernel_enter();
19 return(0);
20 }
21
22 static VOID control_thread_entry(ULONG);
23
tx_application_define(void * first_unused_memory)24 VOID tx_application_define(void *first_unused_memory)
25 {
26 gx_validation_application_define(first_unused_memory);
27
28 /* Termiante the test if it runs for more than 100 ticks */
29 /* This function is not implemented yet. */
30 gx_validation_watchdog_create(100);
31
32 /* Create a dedicated thread to perform various operations
33 on the pixelmap drawing example. These operations simulate
34 user input. */
35 gx_validation_control_thread_create(control_thread_entry);
36 }
37
38
39 #ifdef WIN32
40 #undef WIN32
41 #endif
42
43 #include "gx_validation_wrapper.h"
44 #include "demo_guix_all_widgets.c"
45
46
control_thread_entry(ULONG input)47 static VOID control_thread_entry(ULONG input)
48 {
49 INT failed_tests = 0;
50 UINT status;
51 INT index;
52 GX_COLOR color;
53 GX_FONT *font;
54 GX_WIDGET *widget;
55 GX_WIDGET parent;
56 GX_EVENT my_event;
57
58 memset(&my_event, 0, sizeof(GX_EVENT));
59
60 /* Test _gx_widget_client_index_get. */
61 index = _gx_widget_client_index_get((GX_WIDGET *)&button_screen.button_screen_base_button_1, (GX_WIDGET *)&button_screen.button_screen_text_button_1);
62 EXPECT_EQ(0, index);
63
64 /* Test _gx_widget_last_client_child_get. */
65 widget = _gx_widget_last_client_child_get((GX_WIDGET *)&button_screen.button_screen_base_button_1);
66 EXPECT_EQ(GX_NULL, widget);
67
68 /* Test _gx_widget_clipping_update. */
69 _gx_widget_clipping_update(GX_NULL);
70
71 /* Test _gx_widget_event_process. */
72 widget = (GX_WIDGET *)&button_screen.button_screen_base_button_1;
73
74 for(index = 0; index < 2; index++)
75 {
76 if(index == 0)
77 {
78 gx_widget_style_remove(widget, GX_STYLE_ENABLED);
79 }
80 else
81 {
82 gx_widget_style_add(widget, GX_STYLE_ENABLED);
83 }
84
85 gx_widget_style_remove(widget, GX_STYLE_BUTTON_REPEAT);
86 my_event.gx_event_target = widget;
87 my_event.gx_event_type = GX_EVENT_KEY_DOWN;
88 my_event.gx_event_payload.gx_event_ushortdata[0] = GX_KEY_SELECT;
89 gx_system_event_send(&my_event);
90
91 my_event.gx_event_type = GX_EVENT_DESELECT;
92 gx_system_event_send(&my_event);
93 }
94 gx_widget_status_add(widget, GX_STATUS_NOTIFY_ON_GAIN_FOCUS);
95 gx_system_focus_claim((GX_WIDGET *)&button_screen.button_screen_text_button_1);
96 gx_system_focus_claim(widget);
97
98 EXPECT_EQ(1, button_focus_gain_count);
99 EXPECT_EQ(1, button_click_count);
100
101 /* Test _gx_widget_color_get. */
102 gx_widget_detach(widget);
103 widget->gx_widget_status |= GX_STATUS_VISIBLE;
104 status = gx_widget_color_get(widget, 0, &color);
105 EXPECT_EQ(GX_INVALID_CANVAS, status);
106
107 status = gx_widget_font_get(widget, 0, &font);
108 EXPECT_EQ(GX_INVALID_CANVAS, status);
109
110 /* Test _gx_widget_find. */
111 status = _gx_widget_find(GX_NULL, 0, 0, &widget);
112 EXPECT_EQ(GX_NOT_FOUND, status);
113
114 /* Test _gx_widget_focus_next. */
115 status = _gx_widget_focus_next(GX_NULL);
116 EXPECT_EQ(GX_FAILURE, status);
117
118 /* Test _gx_widget_focus_previous. */
119 status = _gx_widget_focus_previous(GX_NULL);
120 EXPECT_EQ(GX_FAILURE, status);
121
122 /* Test _gx_widget_front_move. */
123 ToggleScreen((GX_WINDOW *)&window_screen, (GX_WINDOW *)&button_screen);
124 widget = (GX_WIDGET *)&window_screen.window_screen_scroll_frame_1;
125 gx_widget_front_move(widget, GX_NULL);
126 status = widget->gx_widget_status & GX_STATUS_HAS_FOCUS;
127 EXPECT_EQ(0, status);
128
129 gx_widget_show(&button_screen);
130 gx_system_focus_claim(&button_screen);
131 widget = (GX_WIDGET *)&window_screen.window_screen_window_5;
132 gx_widget_style_add(widget, GX_STYLE_ENABLED);
133 gx_widget_status_add(widget, GX_STATUS_ACCEPTS_FOCUS);
134 gx_widget_front_move(widget, GX_NULL);
135 status = widget->gx_widget_status & GX_STATUS_HAS_FOCUS;
136 EXPECT_EQ(0, status);
137
138 /* Test _gx_widget_text_draw. */
139 gx_widget_text_draw(GX_NULL, 0, 0, GX_NULL, 0, 0);
140 gx_widget_text_draw_ext(GX_NULL, 0, 0, GX_NULL, 0, 0);
141
142 #ifndef GX_DISABLE_ERROR_CHECKING
143
144 parent.gx_widget_type = 0;
145
146 /* Test gx_widget_first_child_get. */
147 status = gx_widget_first_child_get(GX_NULL, &widget);
148 EXPECT_EQ(GX_PTR_ERROR, status);
149
150 status = gx_widget_first_child_get((GX_WIDGET *)&button_screen, GX_NULL);
151 EXPECT_EQ(GX_PTR_ERROR, status);
152
153 status = gx_widget_first_child_get((GX_WIDGET *)&parent, &widget);
154 EXPECT_EQ(GX_INVALID_WIDGET, status);
155
156
157 /* Test gx_widget_last_child_get. */
158 status = gx_widget_last_child_get(GX_NULL, &widget);
159 EXPECT_EQ(GX_PTR_ERROR, status);
160
161 status = gx_widget_last_child_get((GX_WIDGET *)&button_screen, GX_NULL);
162 EXPECT_EQ(GX_PTR_ERROR, status);
163
164 status = gx_widget_last_child_get((GX_WIDGET *)&parent, &widget);
165 EXPECT_EQ(GX_INVALID_WIDGET, status);
166
167 /* Test gx_widget_next_sibling_get. */
168 status = gx_widget_next_sibling_get(GX_NULL, &widget);
169 EXPECT_EQ(GX_PTR_ERROR, status);
170
171 status = gx_widget_next_sibling_get((GX_WIDGET *)&button_screen, GX_NULL);
172 EXPECT_EQ(GX_PTR_ERROR, status);
173
174 status = gx_widget_next_sibling_get((GX_WIDGET *)&parent, &widget);
175 EXPECT_EQ(GX_INVALID_WIDGET, status);
176
177 /* Test gx_widget_parent_get. */
178 status = gx_widget_parent_get(GX_NULL, &widget);
179 EXPECT_EQ(GX_PTR_ERROR, status);
180
181 status = gx_widget_parent_get((GX_WIDGET *)&button_screen, GX_NULL);
182 EXPECT_EQ(GX_PTR_ERROR, status);
183
184 status = gx_widget_parent_get((GX_WIDGET *)&parent, &widget);
185 EXPECT_EQ(GX_INVALID_WIDGET, status);
186
187 /* Test gx_widget_previous_sibling_get. */
188 status = gx_widget_previous_sibling_get(GX_NULL, &widget);
189 EXPECT_EQ(GX_PTR_ERROR, status);
190
191 status = gx_widget_previous_sibling_get((GX_WIDGET *)&button_screen, GX_NULL);
192 EXPECT_EQ(GX_PTR_ERROR, status);
193
194 status = gx_widget_previous_sibling_get((GX_WIDGET *)&parent, &widget);
195 EXPECT_EQ(GX_INVALID_WIDGET, status);
196
197 /* Test gx_widget_top_visible_child_find. */
198 status = gx_widget_top_visible_child_find(GX_NULL, &widget);
199 EXPECT_EQ(GX_PTR_ERROR, status);
200
201 status = gx_widget_top_visible_child_find((GX_WIDGET *)&button_screen, GX_NULL);
202 EXPECT_EQ(GX_PTR_ERROR, status);
203
204 status = gx_widget_top_visible_child_find(&parent, &widget);
205 EXPECT_EQ(GX_INVALID_WIDGET, status);
206 #endif
207
208 status = gx_widget_top_visible_child_find((GX_WIDGET *)&button_screen, &widget);
209 EXPECT_EQ(GX_SUCCESS, status);
210
211 gx_widget_detach(&window_screen.window_screen_window_4);
212 widget = _gx_widget_first_visible_client_child_get(&window_screen.window_screen_scroll_frame_1);
213 EXPECT_EQ(widget, GX_NULL);
214
215 widget = _gx_widget_last_visible_client_child_get(&window_screen.window_screen_scroll_frame_1);
216 EXPECT_EQ(widget, GX_NULL);
217
218 widget = window_screen.window_screen_scroll_frame_1.gx_widget_first_child;
219 widget = _gx_widget_next_visible_client_child_get(widget);
220 EXPECT_EQ(widget, GX_NULL);
221
222 if(failed_tests == 0)
223 {
224 gx_validation_print_test_result(TEST_SUCCESS);
225 exit(0);
226 }
227 else
228 {
229 gx_validation_print_test_result(TEST_FAIL);
230 exit(1);
231 }
232 }
233