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_menu.h"
8 #include "gx_system.h"
9
10 TEST_PARAM test_parameter = {
11 "guix_all_widgets_execute", /* Test name */
12 0, 0, 639, 479 /* Define the coordinates of the capture area.
13 In this test, we only need to capture the line
14 drawing area. */
15 };
16
17 static VOID control_thread_entry(ULONG);
main(int argc,char ** argv)18 int main(int argc, char ** argv)
19 {
20 /* Parse the command line argument. */
21 gx_validation_setup(argc, argv);
22
23 /* Start ThreadX system */
24 tx_kernel_enter();
25 return(0);
26 }
27
tx_application_define(void * first_unused_memory)28 VOID tx_application_define(void *first_unused_memory)
29 {
30
31 /* Create a dedicated thread to perform various operations
32 on the line drawing example. These operations simulate
33 user input. */
34 gx_validation_control_thread_create(control_thread_entry);
35
36 /* Termiante the test if it runs for more than 100 ticks */
37 /* This function is not implemented yet. */
38 gx_validation_watchdog_create(100);
39
40 /* Call the actual line example routine. */
41 gx_validation_application_define(first_unused_memory);
42
43 }
44
45
46 /* Replace the default graphics driver with the validation driver. */
47 #ifdef win32_graphics_driver_setup_24xrgb
48 #undef win32_graphics_driver_setup_24xrgb
49 #endif
50 #define win32_graphics_driver_setup_24xrgb gx_validation_graphics_driver_setup_24xrgb
51
52
53 #ifdef WIN32
54 #undef WIN32
55 #endif
56
57 #include "gx_validation_wrapper.h"
58 #include "demo_guix_all_widgets_execute.c"
59
60 char *test_comment[1];
61
62 typedef struct SCREEN_INFO_STRUCT{
63 GX_RESOURCE_ID id;
64 char *name;
65 int animation_steps;
66 }SCREEN_INFO;
67
68 SCREEN_INFO screen_info[]={
69 {ID_BUTTON_SCREEN, "button_screen", 21},
70 {ID_WINDOW_SCREEN, "window_screen", 21},
71 {ID_INDICATOR_SCREEN, "indicator_screen", 37},
72 {ID_TEXT_SCREEN, "text_screen", 1},
73 {ID_GAUGE_SCREEN, "gauge_screen", 11},
74 {ID_SPRITE_SCREEN, "sprite_screen", 1},
75 {ID_SCROLL_WHEEL_SCREEN, "scroll_wheel_screen", 21},
76 {ID_MENU_SCREEN, "menu", 21},
77 {0, "", 0}
78 };
79
control_thread_entry(ULONG input)80 static VOID control_thread_entry(ULONG input)
81 {
82 INT frame_id;
83 GX_EVENT my_event;
84 GX_WIDGET *parent;
85 SCREEN_INFO *entry = screen_info;
86
87 memset(&my_event, 0, sizeof(GX_EVENT));
88
89 test_comment[0] = (char *)malloc(256);
90
91 while(entry->id)
92 {
93 gx_widget_find((GX_WIDGET *)root, entry->id, GX_SEARCH_DEPTH_INFINITE, &parent);
94
95 if(entry->id == ID_BUTTON_SCREEN)
96 {
97 /* Test window execute. */
98 gx_validation_current_frame_id_get(&frame_id);
99 frame_id++;
100 gx_validation_set_frame_id(frame_id);
101 sprintf(test_comment[0], "Execute Window");
102 gx_validation_set_frame_comment(test_comment[0]);
103
104 /* Simulate click on text button to execute window. */
105 my_event.gx_event_type = GX_SIGNAL(ID_TEXT_BUTTON, GX_EVENT_CLICKED);
106 my_event.gx_event_target = parent;
107 my_event.gx_event_sender = ID_TEXT_BUTTON;
108
109 gx_system_event_send(&my_event);
110
111 gx_validation_current_frame_id_get(&frame_id);
112 frame_id++;
113 gx_validation_set_frame_id(frame_id);
114 sprintf(test_comment[0], "Stop Execute Window");
115 gx_validation_set_frame_comment(test_comment[0]);
116
117 /* Simulate click on ok button to stop window execute. */
118 my_event.gx_event_type = GX_SIGNAL(IDB_OK, GX_EVENT_CLICKED);
119 my_event.gx_event_target = (GX_WIDGET *)&popup_modal;
120 my_event.gx_event_sender = IDB_OK;
121 gx_system_event_send(&my_event);
122 }
123
124 /* Search next button. */
125 GX_ENTER_CRITICAL
126 my_event.gx_event_type = GX_SIGNAL(IDB_NEXT, GX_EVENT_CLICKED);
127 my_event.gx_event_target = parent;
128 my_event.gx_event_sender = IDB_NEXT;
129
130 sprintf(test_comment[0], "Switch from %s to next", entry->name);
131
132 gx_validation_current_frame_id_get(&frame_id);
133 frame_id ++;
134
135 /* start_id, expected_frames, comments, num_comments, max_time. */
136 gx_validation_capture_frames(frame_id, entry->animation_steps, (char **)test_comment, 1, 1000);
137 gx_system_event_send(&my_event);
138 GX_EXIT_CRITICAL
139 gx_validation_capture_frames_wait();
140
141 tx_thread_sleep(2);
142 entry++;
143 }
144
145 free(test_comment[0]);
146 gx_validation_end();
147
148 exit(0);
149 }
150
151