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_system.h"
8 
9 TEST_PARAM test_parameter = {
10     "guix_scroll_wheel_scroll", /* Test name */
11     100, 117, 525, 336  /* Define the coordinates of the capture area.
12                          In this test, we only need to capture the line
13                          drawing area.  */
14 };
15 
16 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)17 int main(int argc, char ** argv)
18 {
19     /* Parse the command line argument. */
20     gx_validation_setup(argc, argv);
21 
22     /* Start ThreadX system */
23     tx_kernel_enter();
24     return(0);
25 }
26 
tx_application_define(void * first_unused_memory)27 VOID tx_application_define(void *first_unused_memory)
28 {
29 
30     /* Create a dedicated thread to perform various operations
31        on the line drawing example. These operations simulate
32        user input. */
33     gx_validation_control_thread_create(control_thread_entry);
34 
35     /* Termiante the test if it runs for more than 100 ticks */
36     /* This function is not implemented yet. */
37     gx_validation_watchdog_create(100);
38 
39     /* Call the actual line example routine. */
40     gx_validation_application_define(first_unused_memory);
41 
42 }
43 
44 
45 /* Replace the default graphics driver with the validation driver. */
46 #ifdef win32_graphics_driver_setup_24xrgb
47 #undef win32_graphics_driver_setup_24xrgb
48 #endif
49 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_24xrgb
50 
51 
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55 
56 #include "gx_validation_wrapper.h"
57 
58 #include "demo_guix_all_widgets.c"
59 
60 typedef struct TEST_STRUCT{
61 INT       event_type;
62 GX_VALUE  xpos;
63 GX_VALUE  ypos;
64 INT       wait_ticks;
65 GX_CHAR  *comments;
66 }TEST;
67 
68 #define XPOS 270
69 #define YPOS 235
70 
71 char test_comment[255];
72 
control_thread_entry(ULONG input)73 static VOID control_thread_entry(ULONG input)
74 {
75 INT                      frame_id = 1;
76 GX_EVENT                 my_event;
77 GX_STRING_SCROLL_WHEEL  *month_wheel;
78 INT                      index;
79 
80     memset(&my_event, 0, sizeof(GX_EVENT));
81     my_event.gx_event_display_handle = 1;
82 
83     /* Create scroll wheel screen dynamically. */
84     gx_studio_named_widget_create("scroll_wheel_screen", GX_NULL, (GX_WIDGET **)&pScrollWheelScreen);
85 
86     gx_widget_find(pScrollWheelScreen, ID_MONTH_WHEEL, GX_SEARCH_DEPTH_INFINITE, &month_wheel);
87 
88     /* Toggle from button screen to scroll wheel screen. */
89     ToggleScreen((GX_WINDOW *)pScrollWheelScreen, pButtonScreen);
90 
91     my_event.gx_event_target = (GX_WIDGET *)month_wheel;
92     for(index = 0; index < 2; index++)
93     {
94         if(index)
95         {
96             gx_widget_hide(month_wheel);
97             sprintf(test_comment, "hide widget, scroll up");
98         }
99         else
100         {
101             sprintf(test_comment, "scroll up");
102         }
103         month_wheel->gx_widget_id = 0;
104         my_event.gx_event_type = GX_EVENT_PEN_DOWN;
105         my_event.gx_event_payload.gx_event_pointdata.gx_point_x = XPOS;
106         my_event.gx_event_payload.gx_event_pointdata.gx_point_y = YPOS;
107         gx_system_event_send(&my_event);
108 
109         my_event.gx_event_type = GX_EVENT_PEN_DRAG;
110         my_event.gx_event_payload.gx_event_pointdata.gx_point_y = YPOS - 400;
111         gx_system_event_send(&my_event);
112 
113         gx_validation_set_frame_id(frame_id++);
114         gx_validation_set_frame_comment(test_comment);
115         gx_validation_screen_refresh();
116 
117         tx_thread_sleep(15);
118 
119         my_event.gx_event_type = GX_EVENT_PEN_UP;
120         gx_system_event_send(&my_event);
121 
122         while(month_wheel->gx_scroll_wheel_selected_yshift)
123         {
124             tx_thread_sleep(30);
125         }
126     }
127 
128     gx_scroll_wheel_selected_set(month_wheel, 0);
129     gx_widget_show(month_wheel);
130     gx_validation_set_frame_id(frame_id++);
131     gx_validation_set_frame_comment("set selected row to 0, show month wheel.");
132     gx_validation_screen_refresh();
133 
134     my_event.gx_event_type = GX_EVENT_PEN_DOWN;
135     my_event.gx_event_payload.gx_event_pointdata.gx_point_x = month_wheel->gx_widget_size.gx_rectangle_left + 10;
136     my_event.gx_event_payload.gx_event_pointdata.gx_point_y = month_wheel->gx_widget_size.gx_rectangle_top + 10;
137     gx_system_event_send(&my_event);
138 
139     gx_validation_set_frame_id(frame_id++);
140     gx_validation_set_frame_comment("pen down, drag up by 10");
141     my_event.gx_event_type = GX_EVENT_PEN_DRAG;
142     my_event.gx_event_payload.gx_event_pointdata.gx_point_y -= 10;
143     gx_system_event_send(&my_event);
144 
145     gx_validation_set_frame_id(frame_id++);
146     gx_validation_set_frame_comment("drag down by 9");
147     my_event.gx_event_type = GX_EVENT_PEN_DRAG;
148     my_event.gx_event_payload.gx_event_pointdata.gx_point_y += 9;
149     gx_system_event_send(&my_event);
150 
151     tx_thread_sleep(15);
152 
153     my_event.gx_event_type = GX_EVENT_PEN_UP;
154     gx_system_event_send(&my_event);
155 
156     /* Wait snap animation complete. */
157     while(month_wheel->gx_scroll_wheel_selected_yshift)
158     {
159         tx_thread_sleep(30);
160     }
161 
162     gx_validation_set_frame_id(frame_id++);
163     gx_validation_set_frame_comment("pen up");
164     gx_validation_screen_refresh();
165 
166     /* Signal the end of the test case.  Verify the output. */
167     gx_validation_end();
168 
169     exit(0);
170 }
171 
172