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_system_no_output", /* Test name */
11     0, 0, 0, 0  /* Define the coordinates of the capture area.*/
12 };
13 
main(int argc,char ** argv)14 int main(int argc, char ** argv)
15 {
16     /* Start ThreadX system */
17     tx_kernel_enter();
18     return(0);
19 }
20 
21 static VOID      control_thread_entry(ULONG);
22 
tx_application_define(void * first_unused_memory)23 VOID tx_application_define(void *first_unused_memory)
24 {
25     gx_validation_application_define(first_unused_memory);
26 
27     /* Termiante the test if it runs for more than 100 ticks */
28     /* This function is not implemented yet. */
29     gx_validation_watchdog_create(100);
30 
31     /* Create a dedicated thread to perform various operations
32        on the pixelmap drawing example. These operations simulate
33        user input. */
34     gx_validation_control_thread_create(control_thread_entry);
35 }
36 
37 #ifdef WIN32
38 #undef WIN32
39 #endif
40 
41 #include "gx_validation_wrapper.h"
42 #include "demo_guix_all_widgets.c"
43 
44 #define TEST_STRING_SIZE 0xccd
45 char test_string[TEST_STRING_SIZE + 1];
46 
47 int flick_count = 0;
test_event_handler(GX_WINDOW * window,GX_EVENT * event_ptr)48 UINT test_event_handler(GX_WINDOW *window, GX_EVENT *event_ptr)
49 {
50     switch(event_ptr->gx_event_type)
51     {
52     case GX_EVENT_VERTICAL_FLICK:
53         flick_count++;
54         break;
55     }
56     return gx_window_event_process(window, event_ptr);
57 }
58 
control_thread_entry(ULONG input)59 static VOID control_thread_entry(ULONG input)
60 {
61 UINT                     status;
62 GX_EVENT                 my_event;
63 GX_PEN_CONFIGURATION     configure;
64 int                      index;
65 GX_MULTI_LINE_TEXT_VIEW  view;
66 GX_FONT                 *font;
67 GX_VALUE                 width;
68 GX_STRING                string;
69 int                      failed_tests = 0;
70 
71     memset(&my_event, 0, sizeof(GX_EVENT));
72 
73     /* Test gx_system_input_release. */
74     _gx_system_input_capture((GX_WIDGET *)&button_screen);
75     status = _gx_system_input_release((GX_WIDGET *)&window_screen);
76     EXPECT_EQ(GX_NO_CHANGE, status);
77     window_screen.gx_widget_status |= GX_STATUS_OWNS_INPUT;
78     status = _gx_system_input_release((GX_WIDGET *)&window_screen);
79     EXPECT_EQ(GX_PTR_ERROR, status);
80 
81     /* Test _gx_system_pen_flick_test. */
82     configure.gx_pen_configuration_min_drag_dist = GX_FIXED_VAL_MAKE(10);
83     configure.gx_pen_configuration_max_pen_speed_ticks = 10;
84     gx_system_pen_configure(&configure);
85 
86     gx_widget_event_process_set(&button_screen, test_event_handler);
87     gx_widget_style_add(&button_screen, GX_STYLE_ENABLED);
88 
89     for(index = 0; index < 2; index++)
90     {
91         my_event.gx_event_display_handle = 1;
92         my_event.gx_event_type = GX_EVENT_PEN_DOWN;
93         my_event.gx_event_payload.gx_event_pointdata.gx_point_x = 80;
94         my_event.gx_event_payload.gx_event_pointdata.gx_point_y = 10;
95         gx_system_event_send(&my_event);
96 
97         tx_thread_sleep(2);
98         my_event.gx_event_type = GX_EVENT_PEN_DRAG;
99         if(index == 0)
100         {
101             my_event.gx_event_payload.gx_event_pointdata.gx_point_y += 40;
102         }
103         else
104         {
105             my_event.gx_event_payload.gx_event_pointdata.gx_point_y += 9;
106         }
107 
108         gx_system_event_send(&my_event);
109 
110         my_event.gx_event_type = GX_EVENT_PEN_UP;
111         gx_system_event_send(&my_event);
112         EXPECT_EQ(1, flick_count);
113     }
114 
115     /* Test _gx_system_private_string_delete. */
116     memset(&view, 0, sizeof(GX_MULTI_LINE_TEXT_VIEW));
117     gx_multi_line_text_view_create(&view, "test_view", &text_screen, 0, GX_STYLE_TEXT_COPY, 0, &text_screen.gx_widget_size);
118 
119     gx_multi_line_text_view_text_set(&view, GX_NULL);
120     gx_multi_line_text_view_text_set(&view, "test_string");
121     view.gx_multi_line_text_view_text_id = 1;
122     gx_widget_delete((GX_WIDGET *)&view);
123     if(view.gx_multi_line_text_view_text.gx_string_ptr == GX_NULL)
124     {
125         failed_tests++;
126         PRINT_ERROR("");
127 
128     }
129 
130     gx_multi_line_text_view_create(&view, "text_view", &text_screen, 0, GX_STYLE_TEXT_COPY, 0, &text_screen.gx_widget_size);
131     gx_widget_delete((GX_WIDGET *)&view);
132     EXPECT_EQ(GX_NULL, view.gx_multi_line_text_view_text.gx_string_ptr);
133 
134     gx_system_memory_allocator_set(GX_NULL, GX_NULL);
135 
136     /* Test _gx_system_dirty_mark. */
137     status = _gx_system_dirty_mark(GX_NULL);
138     EXPECT_EQ(GX_PTR_ERROR, status);
139 
140     /* Test _gx_system_dirty_partial_add. */
141     status = _gx_system_dirty_partial_add(GX_NULL, GX_NULL);
142     EXPECT_EQ(GX_PTR_ERROR, status);
143 
144     /* Test _gx_system_dirty_entry_shift. */
145     _gx_system_dirty_entry_shift(GX_NULL, 0, 0);
146     gx_widget_status_add(&window_screen, GX_STATUS_VISIBLE | GX_STATUS_DIRTY);
147     _gx_system_dirty_entry_shift((GX_WIDGET *)&window_screen, 10, 10);
148     EXPECT_EQ(0, _gx_system_lock_nesting);
149 
150     /* Test gx_system_string_width_get. */
151     memset(test_string, 'A', TEST_STRING_SIZE);
152     test_string[TEST_STRING_SIZE] = '\0';
153     gx_widget_font_get(&button_screen, GX_FONT_ID_SYSTEM, &font);
154 
155     string.gx_string_ptr = test_string;
156     string.gx_string_length = TEST_STRING_SIZE;
157     gx_system_string_width_get_ext(font, &string, &width);
158     EXPECT_EQ(0x7fff, width);
159 
160     if(!failed_tests)
161     {
162         gx_validation_print_test_result(TEST_SUCCESS);
163         exit(0);
164     }
165     else
166     {
167         gx_validation_print_test_result(TEST_FAIL);
168         exit(1);
169     }
170 }
171