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_canvas_pie_draw", /* Test name */
10     10, 9, 401, 428  /* Define the coordinates of the capture area.
11                          In this test, we only need to capture the graphics
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     /* Call the actual line example routine. */
29     gx_validation_application_define(first_unused_memory);
30 
31     /* Termiante the test if it runs for more than 100 ticks */
32     /* This function is not implemented yet. */
33     gx_validation_watchdog_create(100);
34 
35     /* Create a dedicated thread to perform various operations
36        on the pixelmap drawing example. These operations simulate
37        user input. */
38     gx_validation_control_thread_create(control_thread_entry);
39 
40 }
41 
42 
43 /* Replace the default graphics driver with the validation driver. */
44 #ifdef win32_graphics_driver_setup_monochrome
45 #undef win32_graphics_driver_setup_monochrome
46 #endif
47 #define win32_graphics_driver_setup_monochrome  gx_validation_graphics_driver_setup_monochrome
48 
49 
50 #ifdef WIN32
51 #undef WIN32
52 #endif
53 
54 #include "gx_validation_wrapper.h"
55 
56 #include "demo_guix_all_widgets_1bpp.c"
57 
58 char test_comment[256];
59 extern INT draw_shape;
60 /* This thread simulates user input.  Its priority is lower
61    than the GUIX thread, so that GUIX finishes an operation
62    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)63 static VOID control_thread_entry(ULONG input)
64 {
65 INT frame_id = 1;
66 GX_RECTANGLE size;
67 
68     /* part1, original screen. */
69     gx_widget_detach(pSpriteScreen);
70     gx_widget_attach(root, pShapesScreen);
71     draw_shape = 2; //2 is pie
72 
73     /* Set frame id. */
74     gx_validation_set_frame_id(frame_id++);
75     sprintf(test_comment, "Set brush properties and draw original pie.");
76     gx_validation_set_frame_comment(test_comment);
77     gx_system_dirty_mark(pShapesScreen);
78     gx_validation_screen_refresh();
79 
80     /* part2, draw area covered by others. */
81     while(pSpriteScreen->gx_widget_first_child)
82     {
83         gx_widget_detach(pSpriteScreen->gx_widget_first_child);
84     }
85 
86     size = shapes_screen.shapes_screen_graphics_window.gx_widget_size;
87     size.gx_rectangle_left += 20;
88     size.gx_rectangle_right += 20;
89     size.gx_rectangle_top += 20;
90     size.gx_rectangle_bottom += 20;
91 
92     gx_widget_resize(pSpriteScreen, &size);
93     gx_widget_attach(root, pSpriteScreen);
94 
95     /* Set frame id. */
96     gx_validation_set_frame_id(frame_id++);
97     sprintf(test_comment, "Add a window to cover view where the pie should be draw.");
98     gx_validation_set_frame_comment(test_comment);
99     gx_system_dirty_mark(pShapesScreen);
100     gx_validation_screen_refresh();
101 
102     /* part3, draw area outside the screen. */
103     gx_widget_detach(pSpriteScreen);
104     size = shapes_screen.shapes_screen_graphics_window.gx_widget_size;
105     size.gx_rectangle_left += 380;
106     size.gx_rectangle_top += 410;
107     gx_widget_resize(pShapesScreen, &size);
108 
109     /* Set frame id. */
110     gx_validation_set_frame_id(frame_id++);
111     sprintf(test_comment, "Draw pie outside the window client.");
112     gx_validation_set_frame_comment(test_comment);
113     gx_system_dirty_mark(pShapesScreen);
114     gx_validation_screen_refresh();
115 
116     /* Signal the end of the test case, Verify the outout.  */
117     gx_validation_end();
118 
119     exit(0);
120 }
121