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 
8 TEST_PARAM test_parameter = {
9     "guix_pixelmap_button_24xrgb", /* Test name */
10     130, 250, 255, 320  /* Define the coordinates of the capture area.
11                          In this test, we only need to capture the pixelmap
12                          drawing area.  */
13 };
14 
15 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)16 int main(int argc, char ** argv)
17 {
18     /* Parse the command line argument. */
19     gx_validation_setup(argc, argv);
20 
21     /* Start ThreadX system */
22     tx_kernel_enter();
23     return(0);
24 }
25 
tx_application_define(void * first_unused_memory)26 VOID tx_application_define(void *first_unused_memory)
27 {
28 
29     /* Create a dedicated thread to perform various operations
30        on the line drawing example. These operations simulate
31        user input. */
32     gx_validation_control_thread_create(control_thread_entry);
33 
34     /* Termiante the test if it runs for more than 100 ticks */
35     /* This function is not implemented yet. */
36     gx_validation_watchdog_create(100);
37 
38     /* Call the actual line example routine. */
39     gx_validation_application_define(first_unused_memory);
40 
41 }
42 
43 
44 /* Replace the default graphics driver with the validation driver. */
45 #ifdef win32_graphics_driver_setup_24xrgb
46 #undef win32_graphics_driver_setup_24xrgb
47 #endif
48 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_24xrgb
49 
50 
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54 
55 #include "gx_validation_wrapper.h"
56 #include "demo_guix_all_widgets.c"
57 
58 static GX_VALUE x_point[] = {140, 141, 165, 262, 263};
59 static GX_VALUE y_point[] = {250, 251, 261, 313, 314};
60 static ULONG event_type[] = {GX_EVENT_PEN_DOWN, GX_EVENT_PEN_UP};
61 
62 
63 char test_comment[256];
64 
65 /* This thread simulates user input.  Its priority is lower
66    than the GUIX thread, so that GUIX finishes an operation
67    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)68 static VOID control_thread_entry(ULONG input)
69 {
70 int x_index, y_index, type_index;
71 GX_EVENT my_event;
72 int frame_id = 1;
73 GX_PIXELMAP_BUTTON *pButton;
74 
75     gx_widget_find(pButtonScreen, ID_PIXELMAP_BUTTON, 0, (GX_WIDGET **) &pButton);
76 
77 
78     /* Remove the pixelmap button's pixelmap */
79     gx_pixelmap_button_pixelmap_set(pButton, GX_NULL, GX_NULL, GX_NULL);
80 
81     /* set the pixelmap button to transparent */
82     gx_widget_style_add(pButton, GX_STYLE_TRANSPARENT);
83 
84     memset(&my_event, 0, sizeof(GX_EVENT));
85     my_event.gx_event_type = GX_EVENT_PEN_DOWN;
86     my_event.gx_event_payload.gx_event_pointdata.gx_point_x = 165;
87     my_event.gx_event_payload.gx_event_pointdata.gx_point_y = 261;
88     my_event.gx_event_display_handle = 1;
89     gx_system_event_send(&my_event);
90     gx_validation_set_frame_id(frame_id);
91     sprintf(test_comment, "set the style to transparent for pixelmap button, pen down ");
92     gx_validation_set_frame_comment(test_comment);
93     /* Force a screen refresh. */
94     gx_validation_screen_refresh();
95 
96     frame_id ++;
97     my_event.gx_event_type = GX_EVENT_PEN_UP;
98     my_event.gx_event_display_handle = 1;
99     gx_system_event_send(&my_event);
100     gx_validation_set_frame_id(frame_id);
101     sprintf(test_comment, "set the style to transparent for pixelmap button, pen up ");
102     gx_validation_set_frame_comment(test_comment);
103     /* Force a screen refresh. */
104     gx_validation_screen_refresh();
105 
106 
107     frame_id ++;
108     /* remove the transparent style from pixelmap button */
109     gx_widget_style_remove(pButton, GX_STYLE_TRANSPARENT);
110 
111     my_event.gx_event_type = GX_EVENT_PEN_DOWN;
112     my_event.gx_event_display_handle = 1;
113     gx_system_event_send(&my_event);
114     gx_validation_set_frame_id(frame_id);
115     sprintf(test_comment, "remove the style to transparent for pixelmap button, pen down ");
116     gx_validation_set_frame_comment(test_comment);
117     /* Force a screen refresh. */
118     gx_validation_screen_refresh();
119 
120 
121     frame_id ++;
122     my_event.gx_event_type = GX_EVENT_PEN_UP;
123     my_event.gx_event_display_handle = 1;
124     gx_system_event_send(&my_event);
125     gx_validation_set_frame_id(frame_id);
126     sprintf(test_comment, "remove the style to transparent for pixelmap button, pen up ");
127     gx_validation_set_frame_comment(test_comment);
128     /* Force a screen refresh. */
129     gx_validation_screen_refresh();
130 
131 
132     frame_id ++;
133     /* Set the pixelmap button's background color. */
134     gx_widget_fill_color_set(pButton, GX_COLOR_ID_NEXT_BUTTON_UPPER, GX_COLOR_ID_NEXT_BUTTON_LOWER, GX_COLOR_ID_NEXT_BUTTON_UPPER);
135 
136     my_event.gx_event_type = GX_EVENT_PEN_DOWN;
137     my_event.gx_event_display_handle = 1;
138     gx_system_event_send(&my_event);
139     gx_validation_set_frame_id(frame_id);
140     sprintf(test_comment, "set the background color for pixelmap button, pen down ");
141     gx_validation_set_frame_comment(test_comment);
142     /* Force a screen refresh. */
143     gx_validation_screen_refresh();
144 
145 
146     frame_id ++;
147     my_event.gx_event_type = GX_EVENT_PEN_UP;
148     my_event.gx_event_display_handle = 1;
149     gx_system_event_send(&my_event);
150     gx_validation_set_frame_id(frame_id);
151     sprintf(test_comment, "set the background color for pixelmap button, pen up ");
152     gx_validation_set_frame_comment(test_comment);
153     /* Force a screen refresh. */
154     gx_validation_screen_refresh();
155 
156     frame_id ++;
157 
158     gx_pixelmap_button_pixelmap_set(pButton, GX_PIXELMAP_ID_FISH, GX_PIXELMAP_ID_FISH,
159                                     GX_PIXELMAP_ID_I_MEDICATIONSGREEN_LG);
160 
161     gx_widget_style_remove((GX_WIDGET *)pButton, GX_STYLE_ENABLED);
162     sprintf(test_comment, "set button pixelmaps, and disable button");
163     gx_validation_set_frame_id(frame_id++);
164     gx_validation_set_frame_comment(test_comment);
165     gx_validation_screen_refresh();
166 
167     /* Set the pixelmap for the pixelmap button. */
168     gx_widget_style_remove((GX_WIDGET *)pButton, GX_STYLE_TRANSPARENT);
169     gx_pixelmap_button_pixelmap_set(pButton, GX_PIXELMAP_ID_FISH,
170                                     GX_PIXELMAP_ID_I_PATIENTLIST_LG, GX_PIXELMAP_ID_I_MEDICATIONSGREEN_LG);
171     gx_widget_style_add((GX_WIDGET *)pButton, GX_STYLE_ENABLED);
172     sprintf(test_comment, "set button pixelmaps and enable button");
173     gx_validation_set_frame_id(frame_id++);
174     gx_validation_set_frame_comment(test_comment);
175     gx_validation_screen_refresh();
176 
177 
178     for (x_index = 0; x_index < (GX_VALUE)(sizeof(x_point) / sizeof(GX_VALUE)); x_index ++)
179     {
180         my_event.gx_event_payload.gx_event_pointdata.gx_point_x = x_point[x_index];
181 
182         for (y_index = 0; y_index < (GX_VALUE)(sizeof(y_point) / sizeof(GX_VALUE)); y_index ++)
183         {
184             my_event.gx_event_payload.gx_event_pointdata.gx_point_y = y_point[y_index];
185 
186             for (type_index = 0; type_index < (int)(sizeof(event_type) / sizeof(ULONG)); type_index ++)
187             {
188                 my_event.gx_event_type = event_type[type_index];
189                 my_event.gx_event_display_handle = 1;
190 
191 
192                 sprintf(test_comment, "x point %d y point %d ", x_point[x_index], y_point[y_index]);
193 
194                 if ((x_point[x_index] >= 141) && (x_point[x_index] <= 262) &&
195                     (y_point[y_index] >= 251) && (y_point[y_index] <= 313))
196                 {
197                     strcat(test_comment, "click inside the button ");
198 
199                     if (my_event.gx_event_type == GX_EVENT_PEN_DOWN)
200                         strcat(test_comment, "button down medications pixelmap ");
201                     else
202                         strcat(test_comment, "button up fish pixelmap ");
203                 }
204                 else
205                 {
206                     strcat(test_comment, "click outside the button ");
207 
208                     if (my_event.gx_event_type == GX_EVENT_PEN_DOWN)
209                         strcat(test_comment, "button down fish pixelmap ");
210                     else
211                         strcat(test_comment, "button up fish pixelmap ");
212                 }
213 
214                 gx_system_event_send(&my_event);
215                 gx_validation_set_frame_id(frame_id);
216                 gx_validation_set_frame_comment(test_comment);
217                 /* Force a screen refresh. */
218                 gx_validation_screen_refresh();
219                 /* Increment frame ID */
220                 frame_id ++;
221             }
222         }
223     }
224 
225     /* Signal the end of the test case.  Verify the output. */
226     gx_validation_end();
227 
228     exit(0);
229 }
230 
231 
232 
233 
234 
235