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_system.h"
7 #include "gx_validation_utility.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_focus_management", /* Test name */
11 0, 0, 639, 479 /* 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_focus_management.c"
59 char test_comments[256];
60
control_thread_entry(ULONG input)61 static VOID control_thread_entry(ULONG input)
62 {
63 int frame_id = 1;
64 int index;
65 GX_BOOL failed = GX_FALSE;
66
67 for(index = 0; index < 6; index++)
68 {
69 switch(index)
70 {
71 case 0:
72 sprintf(test_comments, "child window and prompt 3 has default focus");
73 break;
74
75 case 1:
76 gx_widget_hide(&main_screen.main_screen_prompt_3);
77 sprintf(test_comments, "hide prompt 3, focus should move to prompt 4");
78 break;
79
80 case 2:
81 gx_widget_hide(&main_screen.main_screen_window);
82 sprintf(test_comments, "hide child window, focus should move to prompt 1");
83 break;
84
85 case 3:
86 gx_widget_show(&main_screen.main_screen_window);
87 gx_system_focus_claim(&main_screen.main_screen_prompt_2);
88 sprintf(test_comments, "show child window, set focus to prompt 2");
89 break;
90
91 case 4:
92 gx_widget_hide(&main_screen.main_screen_prompt_2);
93 sprintf(test_comments, "hide prompt 2, focus should move to prompt 4");
94 break;
95
96 case 5:
97 gx_widget_hide(&main_screen.main_screen_prompt_4);
98 sprintf(test_comments, "hide prompt 4, focus should move to parent window");
99 if(_gx_system_focus_owner != (GX_WIDGET *)&main_screen.main_screen_window)
100 {
101 PRINT_ERROR("focus should move to parent window.");
102 failed = GX_TRUE;
103 }
104 break;
105 }
106
107 gx_validation_set_frame_id(frame_id++);
108 gx_validation_set_frame_comment(test_comments);
109 gx_validation_screen_refresh();
110 }
111
112 /* Signal the end of the test case. Verify the output. */
113 gx_validation_end();
114
115 if(failed)
116 {
117 exit(-1);
118 }
119 else
120 {
121 exit(0);
122 }
123 }
124