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_scrollbar_thumb_24xrgb", /* Test name */
10 347, 43, 567, 187 /* Define the coordinates of the capture area.
11 In this test, we only need to capture the scrollbar
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 scrollbar 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 scrollbar 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 scrollbar 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
57 #include "demo_guix_all_widgets.c"
58
59 char test_comment[256];
60
61 /* This thread simulates user input. Its priority is lower
62 than the GUIX thread, so that GUIX finishes an operation
63 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)64 static VOID control_thread_entry(ULONG input)
65 {
66 int vertical_index, horizontal_index;
67 GX_POINT vertical_value = {550, 75};
68 GX_POINT horizontal_value = {400, 170};
69 int frame_id = 1;
70 GX_EVENT my_event;
71
72 ToggleScreen(pWindowScreen, pButtonScreen);
73 memset(&my_event, 0, sizeof(GX_EVENT));
74 my_event.gx_event_display_handle = 1;
75
76 for(vertical_index = 0; vertical_index < 23; vertical_index++)
77 {
78 if(vertical_index > 0)
79 {
80 my_event.gx_event_type = GX_EVENT_PEN_DOWN;
81 my_event.gx_event_payload.gx_event_pointdata.gx_point_x = vertical_value.gx_point_x;
82 my_event.gx_event_payload.gx_event_pointdata.gx_point_y = vertical_value.gx_point_y;
83 gx_system_event_send(&my_event);
84 if(vertical_index < 12)
85 {
86 vertical_value.gx_point_y += 5;
87 }
88 else
89 {
90 vertical_value.gx_point_y -= 5;
91 }
92 my_event.gx_event_payload.gx_event_pointdata.gx_point_y = vertical_value.gx_point_y;
93 my_event.gx_event_type = GX_EVENT_PEN_DRAG;
94 gx_system_event_send(&my_event);
95 my_event.gx_event_type = GX_EVENT_PEN_UP;
96 gx_system_event_send(&my_event);
97 }
98
99 for(horizontal_index = 0; horizontal_index < 33; horizontal_index++)
100 {
101 if(horizontal_index > 0)
102 {
103 my_event.gx_event_type = GX_EVENT_PEN_DOWN;
104 my_event.gx_event_payload.gx_event_pointdata.gx_point_x = horizontal_value.gx_point_x;
105 my_event.gx_event_payload.gx_event_pointdata.gx_point_y = horizontal_value.gx_point_y;
106 gx_system_event_send(&my_event);
107 if(horizontal_index < 17)
108 {
109 horizontal_value.gx_point_x += 5;
110 }
111 else
112 {
113 horizontal_value.gx_point_x -= 5;
114 }
115 my_event.gx_event_payload.gx_event_pointdata.gx_point_x = horizontal_value.gx_point_x;
116 my_event.gx_event_type = GX_EVENT_PEN_DRAG;
117 gx_system_event_send(&my_event);
118 my_event.gx_event_type = GX_EVENT_PEN_UP;
119 gx_system_event_send(&my_event);
120 }
121
122 gx_validation_set_frame_id(frame_id);
123
124 sprintf(test_comment, "horizontal_scroll ");
125 if(horizontal_index > 0 && horizontal_index < 17)
126 {
127 strcat(test_comment, "right ");
128 }
129 else if(horizontal_index >= 17)
130 {
131 strcat(test_comment, "left ");
132 }
133 else
134 {
135 strcat(test_comment, "notmove ");
136 }
137 if(horizontal_index == 0 && vertical_index < 12 && vertical_index > 0)
138 {
139 strcat(test_comment, "vertical_scroll down ");
140 }
141 else if(horizontal_index == 0 && vertical_index >= 12)
142 {
143 strcat(test_comment, "vertical_scroll up ");
144 }
145
146 gx_validation_set_frame_comment(test_comment);
147
148 /* Mark the window "dirty" */
149 gx_system_dirty_mark(pWindowScreen);
150
151 /* Force a screen refresh. */
152 gx_validation_screen_refresh();
153
154 /* Increment frame ID */
155 frame_id ++;
156 }
157 }
158
159 /* Signal the end of the test case. Verify the output. */
160 gx_validation_end();
161
162 exit(0);
163 }
164