File: | testsuite/a11y/children.c |
Warning: | line 170, column 30 1st function call argument is an uninitialized value |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * Copyright (C) 2011 Red Hat Inc. | |||
3 | * | |||
4 | * Author: | |||
5 | * Matthias Clasen <mclasen@redhat.com> | |||
6 | * | |||
7 | * This library is free software; you can redistribute it and/or | |||
8 | * modify it under the terms of the GNU Library General Public | |||
9 | * License as published by the Free Software Foundation; either | |||
10 | * version 2 of the License, or (at your option) any later version. | |||
11 | * | |||
12 | * This library is distributed in the hope that it will be useful, | |||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
15 | * Library General Public License for more details. | |||
16 | * | |||
17 | * You should have received a copy of the GNU Library General Public | |||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
19 | */ | |||
20 | ||||
21 | #define CDK_DISABLE_DEPRECATION_WARNINGS | |||
22 | #undef CTK_DISABLE_DEPRECATED | |||
23 | ||||
24 | #include <ctk/ctk.h> | |||
25 | #include <string.h> | |||
26 | ||||
27 | typedef struct | |||
28 | { | |||
29 | CtkWidget *widget; | |||
30 | gpointer child[3]; | |||
31 | } STATE; | |||
32 | ||||
33 | static void | |||
34 | test_scrolled_window_child_count (void) | |||
35 | { | |||
36 | CtkWidget *sw; | |||
37 | AtkObject *accessible; | |||
38 | ||||
39 | sw = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | |||
40 | g_object_ref_sink (sw)((__typeof__ (sw)) (g_object_ref_sink) (sw)); | |||
41 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (sw)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((sw)), ((ctk_scrolled_window_get_type ()))) ))), | |||
42 | CTK_POLICY_ALWAYS, CTK_POLICY_ALWAYS); | |||
43 | ctk_container_add (CTK_CONTAINER (sw)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sw)), ((ctk_container_get_type ())))))), ctk_label_new ("Bla")); | |||
44 | ||||
45 | accessible = ctk_widget_get_accessible (sw); | |||
46 | g_assert_cmpint (atk_object_get_n_accessible_children (accessible), ==, 3)do { gint64 __n1 = (atk_object_get_n_accessible_children (accessible )), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c", 46, ((const char*) (__func__)), "atk_object_get_n_accessible_children (accessible)" " " "==" " " "3", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); | |||
47 | ||||
48 | g_object_unref (sw); | |||
49 | } | |||
50 | ||||
51 | typedef struct { | |||
52 | gint count; | |||
53 | gint index; | |||
54 | gint n_children; | |||
55 | gpointer parent; | |||
56 | } SignalData; | |||
57 | ||||
58 | static void | |||
59 | children_changed (AtkObject *accessible, | |||
60 | guint index, | |||
61 | gpointer child, | |||
62 | SignalData *data) | |||
63 | { | |||
64 | data->count++; | |||
65 | data->index = index; | |||
66 | data->n_children = atk_object_get_n_accessible_children (accessible); | |||
67 | } | |||
68 | ||||
69 | static void | |||
70 | remove_child (STATE *state, | |||
71 | gint i) | |||
72 | { | |||
73 | CtkWidget *child; | |||
74 | ||||
75 | if (CTK_IS_ENTRY (state->widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (state->widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
76 | { | |||
77 | switch (i) | |||
78 | { | |||
79 | case 0: | |||
80 | ctk_entry_set_icon_from_gicon (CTK_ENTRY (state->widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_entry_get_type ())))))), | |||
81 | CTK_ENTRY_ICON_PRIMARY, | |||
82 | NULL((void*)0)); | |||
83 | return; | |||
84 | case 1: | |||
85 | ctk_entry_set_icon_from_gicon (CTK_ENTRY (state->widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_entry_get_type ())))))), | |||
86 | CTK_ENTRY_ICON_SECONDARY, | |||
87 | NULL((void*)0)); | |||
88 | return; | |||
89 | default: | |||
90 | return; | |||
91 | } | |||
92 | } | |||
93 | ||||
94 | child = state->child [i]; | |||
95 | if (CTK_IS_SCROLLED_WINDOW (state->widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (state->widget)); GType __t = ((ctk_scrolled_window_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
96 | { | |||
97 | if (ctk_widget_get_parent (child) != state->widget) | |||
98 | child = ctk_widget_get_parent (child); | |||
99 | } | |||
100 | ||||
101 | ctk_container_remove (CTK_CONTAINER (state->widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_container_get_type ())))))), child); | |||
102 | } | |||
103 | ||||
104 | static void | |||
105 | parent_notify (AtkObject *obj, GParamSpec *pspec, SignalData *data) | |||
106 | { | |||
107 | data->count++; | |||
108 | data->parent = atk_object_get_parent (obj); | |||
109 | } | |||
110 | ||||
111 | gboolean | |||
112 | do_create_child (STATE *state, gint i) | |||
113 | { | |||
114 | if (CTK_IS_ENTRY (state->widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (state->widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
115 | { | |||
116 | switch (i) | |||
117 | { | |||
118 | case 0: | |||
119 | ctk_entry_set_icon_from_icon_name (CTK_ENTRY (state->widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_entry_get_type ())))))), | |||
120 | CTK_ENTRY_ICON_PRIMARY, | |||
121 | "dialog-warning-symbolic"); | |||
122 | return TRUE(!(0)); | |||
123 | case 1: | |||
124 | ctk_entry_set_icon_from_icon_name (CTK_ENTRY (state->widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_entry_get_type ())))))), | |||
125 | CTK_ENTRY_ICON_SECONDARY, | |||
126 | "edit-clear"); | |||
127 | return TRUE(!(0)); | |||
128 | default: | |||
129 | return FALSE(0); | |||
130 | } | |||
131 | } | |||
132 | else if (ctk_container_child_type (CTK_CONTAINER (state->widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((state->widget)), ((ctk_container_get_type ()))))))) == G_TYPE_NONE((GType) ((1) << (2)))) | |||
133 | return FALSE(0); | |||
134 | ||||
135 | state->child[i] = ctk_label_new ("bla"); | |||
136 | return TRUE(!(0)); | |||
137 | } | |||
138 | ||||
139 | static void | |||
140 | test_add_remove (CtkWidget *widget) | |||
141 | { | |||
142 | AtkObject *accessible; | |||
143 | AtkObject *child_accessible; | |||
144 | SignalData add_data; | |||
145 | SignalData remove_data; | |||
146 | SignalData parent_data[3] = { { 0, }, }; | |||
147 | STATE state; | |||
148 | gint i, j; | |||
149 | gint step_children; | |||
150 | ||||
151 | state.widget = widget; | |||
152 | accessible = ctk_widget_get_accessible (widget); | |||
153 | ||||
154 | add_data.count = 0; | |||
155 | remove_data.count = 0; | |||
156 | g_signal_connect (accessible, "children_changed::add",g_signal_connect_data ((accessible), ("children_changed::add" ), (((GCallback) (children_changed))), (&add_data), ((void *)0), (GConnectFlags) 0) | |||
157 | G_CALLBACK (children_changed), &add_data)g_signal_connect_data ((accessible), ("children_changed::add" ), (((GCallback) (children_changed))), (&add_data), ((void *)0), (GConnectFlags) 0); | |||
158 | g_signal_connect (accessible, "children_changed::remove",g_signal_connect_data ((accessible), ("children_changed::remove" ), (((GCallback) (children_changed))), (&remove_data), (( void*)0), (GConnectFlags) 0) | |||
159 | G_CALLBACK (children_changed), &remove_data)g_signal_connect_data ((accessible), ("children_changed::remove" ), (((GCallback) (children_changed))), (&remove_data), (( void*)0), (GConnectFlags) 0); | |||
160 | ||||
161 | step_children = atk_object_get_n_accessible_children (accessible); | |||
162 | ||||
163 | for (i = 0; i < 3; i++) | |||
| ||||
164 | { | |||
165 | if (!do_create_child (&state, i)) | |||
166 | break; | |||
167 | if (!CTK_IS_ENTRY (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
168 | { | |||
169 | parent_data[i].count = 0; | |||
170 | child_accessible = ctk_widget_get_accessible (state.child[i]); | |||
| ||||
171 | g_signal_connect (child_accessible, "notify::accessible-parent",g_signal_connect_data ((child_accessible), ("notify::accessible-parent" ), (((GCallback) (parent_notify))), (&(parent_data[i])), ( (void*)0), (GConnectFlags) 0) | |||
172 | G_CALLBACK (parent_notify), &(parent_data[i]))g_signal_connect_data ((child_accessible), ("notify::accessible-parent" ), (((GCallback) (parent_notify))), (&(parent_data[i])), ( (void*)0), (GConnectFlags) 0); | |||
173 | ctk_container_add (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), state.child[i]); | |||
174 | } | |||
175 | else | |||
176 | child_accessible = atk_object_ref_accessible_child (accessible, i); | |||
177 | ||||
178 | g_assert_cmpint (add_data.count, ==, i + 1)do { gint64 __n1 = (add_data.count), __n2 = (i + 1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c" , 178, ((const char*) (__func__)), "add_data.count" " " "==" " " "i + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); | |||
179 | g_assert_cmpint (add_data.n_children, ==, step_children + i + 1)do { gint64 __n1 = (add_data.n_children), __n2 = (step_children + i + 1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c", 179, ((const char*) (__func__)) , "add_data.n_children" " " "==" " " "step_children + i + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
180 | g_assert_cmpint (remove_data.count, ==, 0)do { gint64 __n1 = (remove_data.count), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c" , 180, ((const char*) (__func__)), "remove_data.count" " " "==" " " "0", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); | |||
181 | if (!CTK_IS_ENTRY (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
182 | g_assert_cmpint (parent_data[i].count, ==, 1)do { gint64 __n1 = (parent_data[i].count), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c" , 182, ((const char*) (__func__)), "parent_data[i].count" " " "==" " " "1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
183 | if (CTK_IS_SCROLLED_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_scrolled_window_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) || | |||
184 | CTK_IS_NOTEBOOK (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_notebook_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
185 | g_assert (atk_object_get_parent (ATK_OBJECT (parent_data[i].parent)) == accessible)do { if (atk_object_get_parent (((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent_data[i].parent)), ((atk_object_get_type ()))))))) == accessible) ; else g_assertion_message_expr ((( gchar*) 0), "children.c", 185, ((const char*) (__func__)), "atk_object_get_parent (ATK_OBJECT (parent_data[i].parent)) == accessible" ); } while (0); | |||
186 | else if (CTK_IS_ENTRY (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
187 | g_assert (atk_object_get_parent (child_accessible) == accessible)do { if (atk_object_get_parent (child_accessible) == accessible ) ; else g_assertion_message_expr (((gchar*) 0), "children.c" , 187, ((const char*) (__func__)), "atk_object_get_parent (child_accessible) == accessible" ); } while (0); | |||
188 | else | |||
189 | g_assert (parent_data[i].parent == accessible)do { if (parent_data[i].parent == accessible) ; else g_assertion_message_expr (((gchar*) 0), "children.c", 189, ((const char*) (__func__)) , "parent_data[i].parent == accessible"); } while (0); | |||
190 | ||||
191 | if (CTK_IS_ENTRY (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
192 | g_object_unref (child_accessible); | |||
193 | } | |||
194 | for (j = 0 ; j < i; j++) | |||
195 | { | |||
196 | remove_child (&state, j); | |||
197 | g_assert_cmpint (add_data.count, ==, i)do { gint64 __n1 = (add_data.count), __n2 = (i); if (__n1 == __n2 ) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c" , 197, ((const char*) (__func__)), "add_data.count" " " "==" " " "i", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
198 | g_assert_cmpint (remove_data.count, ==, j + 1)do { gint64 __n1 = (remove_data.count), __n2 = (j + 1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c" , 198, ((const char*) (__func__)), "remove_data.count" " " "==" " " "j + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
199 | g_assert_cmpint (remove_data.n_children, ==, step_children + i - j - 1)do { gint64 __n1 = (remove_data.n_children), __n2 = (step_children + i - j - 1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "children.c", 199, ((const char*) (__func__)) , "remove_data.n_children" " " "==" " " "step_children + i - j - 1" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
200 | if (parent_data[j].count == 2) | |||
201 | g_assert (parent_data[j].parent == NULL)do { if (parent_data[j].parent == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "children.c", 201, ((const char*) (__func__)) , "parent_data[j].parent == NULL"); } while (0); | |||
202 | else if (!CTK_IS_ENTRY (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_entry_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
203 | { | |||
204 | AtkStateSet *set; | |||
205 | set = atk_object_ref_state_set (ATK_OBJECT (parent_data[j].parent)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent_data[j].parent)), ((atk_object_get_type ()))))))); | |||
206 | g_assert (atk_state_set_contains_state (set, ATK_STATE_DEFUNCT))do { if (atk_state_set_contains_state (set, ATK_STATE_DEFUNCT )) ; else g_assertion_message_expr (((gchar*) 0), "children.c" , 206, ((const char*) (__func__)), "atk_state_set_contains_state (set, ATK_STATE_DEFUNCT)" ); } while (0); | |||
207 | g_object_unref (set); | |||
208 | } | |||
209 | } | |||
210 | ||||
211 | g_signal_handlers_disconnect_by_func (accessible, G_CALLBACK (children_changed), &add_data)g_signal_handlers_disconnect_matched ((accessible), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (children_changed))), (&add_data)); | |||
212 | g_signal_handlers_disconnect_by_func (accessible, G_CALLBACK (children_changed), &remove_data)g_signal_handlers_disconnect_matched ((accessible), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (children_changed))), (&remove_data)); | |||
213 | } | |||
214 | ||||
215 | static void | |||
216 | add_child_test (const gchar *prefix, | |||
217 | GTestFixtureFunc test_func, | |||
218 | CtkWidget *widget) | |||
219 | { | |||
220 | gchar *path; | |||
221 | ||||
222 | path = g_strdup_printf ("%s/%s", prefix, G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))-> g_class))->g_type)))))); | |||
223 | g_test_add_vtable (path, | |||
224 | 0, | |||
225 | g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget)), | |||
226 | 0, | |||
227 | (GTestFixtureFunc) test_func, | |||
228 | (GTestFixtureFunc) g_object_unref); | |||
229 | g_free (path); | |||
230 | } | |||
231 | ||||
232 | static void | |||
233 | add_child_tests (CtkWidget *widget) | |||
234 | { | |||
235 | g_object_ref_sink (widget)((__typeof__ (widget)) (g_object_ref_sink) (widget)); | |||
236 | add_child_test ("/child/add-remove", (GTestFixtureFunc)test_add_remove, widget); | |||
237 | g_object_unref (widget); | |||
238 | } | |||
239 | ||||
240 | int | |||
241 | main (int argc, char *argv[]) | |||
242 | { | |||
243 | ctk_test_init (&argc, &argv, NULL((void*)0)); | |||
244 | ||||
245 | g_test_add_func ("/scrolledwindow/child-count", test_scrolled_window_child_count); | |||
246 | ||||
247 | add_child_tests (ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0))); | |||
248 | add_child_tests (ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0)); | |||
249 | add_child_tests (ctk_paned_new (CTK_ORIENTATION_HORIZONTAL)); | |||
250 | add_child_tests (ctk_grid_new ()); | |||
251 | add_child_tests (ctk_event_box_new ()); | |||
252 | add_child_tests (ctk_window_new (CTK_WINDOW_TOPLEVEL)); | |||
253 | add_child_tests (ctk_assistant_new ()); | |||
254 | add_child_tests (ctk_frame_new ("frame")); | |||
255 | add_child_tests (ctk_expander_new ("expander")); | |||
256 | add_child_tests (ctk_table_new (2, 2, FALSE(0))); | |||
257 | add_child_tests (ctk_text_view_new ()); | |||
258 | add_child_tests (ctk_tree_view_new ()); | |||
259 | #if 0 | |||
260 | /* cail doesn't handle non-label children in these */ | |||
261 | add_child_tests (ctk_button_new ()); | |||
262 | add_child_tests (ctk_statusbar_new ()); | |||
263 | #endif | |||
264 | add_child_tests (ctk_notebook_new ()); | |||
265 | add_child_tests (ctk_entry_new ()); | |||
266 | ||||
267 | return g_test_run (); | |||
268 | } | |||
269 |