File: | testsuite/a11y/children.c |
Warning: | line 172, 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 G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
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, | |||
106 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
107 | SignalData *data) | |||
108 | { | |||
109 | data->count++; | |||
110 | data->parent = atk_object_get_parent (obj); | |||
111 | } | |||
112 | ||||
113 | gboolean | |||
114 | do_create_child (STATE *state, gint i) | |||
115 | { | |||
116 | 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; }))))) | |||
117 | { | |||
118 | switch (i) | |||
119 | { | |||
120 | case 0: | |||
121 | 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 ())))))), | |||
122 | CTK_ENTRY_ICON_PRIMARY, | |||
123 | "dialog-warning-symbolic"); | |||
124 | return TRUE(!(0)); | |||
125 | case 1: | |||
126 | 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 ())))))), | |||
127 | CTK_ENTRY_ICON_SECONDARY, | |||
128 | "edit-clear"); | |||
129 | return TRUE(!(0)); | |||
130 | default: | |||
131 | return FALSE(0); | |||
132 | } | |||
133 | } | |||
134 | 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)))) | |||
135 | return FALSE(0); | |||
136 | ||||
137 | state->child[i] = ctk_label_new ("bla"); | |||
138 | return TRUE(!(0)); | |||
139 | } | |||
140 | ||||
141 | static void | |||
142 | test_add_remove (CtkWidget *widget) | |||
143 | { | |||
144 | AtkObject *accessible; | |||
145 | AtkObject *child_accessible; | |||
146 | SignalData add_data; | |||
147 | SignalData remove_data; | |||
148 | SignalData parent_data[3] = { { 0, }, }; | |||
149 | STATE state; | |||
150 | gint i, j; | |||
151 | gint step_children; | |||
152 | ||||
153 | state.widget = widget; | |||
154 | accessible = ctk_widget_get_accessible (widget); | |||
155 | ||||
156 | add_data.count = 0; | |||
157 | remove_data.count = 0; | |||
158 | g_signal_connect (accessible, "children_changed::add",g_signal_connect_data ((accessible), ("children_changed::add" ), (((GCallback) (children_changed))), (&add_data), ((void *)0), (GConnectFlags) 0) | |||
159 | G_CALLBACK (children_changed), &add_data)g_signal_connect_data ((accessible), ("children_changed::add" ), (((GCallback) (children_changed))), (&add_data), ((void *)0), (GConnectFlags) 0); | |||
160 | g_signal_connect (accessible, "children_changed::remove",g_signal_connect_data ((accessible), ("children_changed::remove" ), (((GCallback) (children_changed))), (&remove_data), (( void*)0), (GConnectFlags) 0) | |||
161 | G_CALLBACK (children_changed), &remove_data)g_signal_connect_data ((accessible), ("children_changed::remove" ), (((GCallback) (children_changed))), (&remove_data), (( void*)0), (GConnectFlags) 0); | |||
162 | ||||
163 | step_children = atk_object_get_n_accessible_children (accessible); | |||
164 | ||||
165 | for (i = 0; i < 3; i++) | |||
| ||||
166 | { | |||
167 | if (!do_create_child (&state, i)) | |||
168 | break; | |||
169 | 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; }))))) | |||
170 | { | |||
171 | parent_data[i].count = 0; | |||
172 | child_accessible = ctk_widget_get_accessible (state.child[i]); | |||
| ||||
173 | 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) | |||
174 | 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); | |||
175 | ctk_container_add (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), state.child[i]); | |||
176 | } | |||
177 | else | |||
178 | child_accessible = atk_object_ref_accessible_child (accessible, i); | |||
179 | ||||
180 | 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" , 180, ((const char*) (__func__)), "add_data.count" " " "==" " " "i + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); | |||
181 | 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", 181, ((const char*) (__func__)) , "add_data.n_children" " " "==" " " "step_children + i + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
182 | 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" , 182, ((const char*) (__func__)), "remove_data.count" " " "==" " " "0", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); | |||
183 | 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; }))))) | |||
184 | 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" , 184, ((const char*) (__func__)), "parent_data[i].count" " " "==" " " "1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
185 | 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; })))) || | |||
186 | 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; }))))) | |||
187 | 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", 187, ((const char*) (__func__)), "atk_object_get_parent (ATK_OBJECT (parent_data[i].parent)) == accessible" ); } while (0); | |||
188 | 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; }))))) | |||
189 | 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" , 189, ((const char*) (__func__)), "atk_object_get_parent (child_accessible) == accessible" ); } while (0); | |||
190 | else | |||
191 | g_assert (parent_data[i].parent == accessible)do { if (parent_data[i].parent == accessible) ; else g_assertion_message_expr (((gchar*) 0), "children.c", 191, ((const char*) (__func__)) , "parent_data[i].parent == accessible"); } while (0); | |||
192 | ||||
193 | 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; }))))) | |||
194 | g_object_unref (child_accessible); | |||
195 | } | |||
196 | for (j = 0 ; j < i; j++) | |||
197 | { | |||
198 | remove_child (&state, j); | |||
199 | 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" , 199, ((const char*) (__func__)), "add_data.count" " " "==" " " "i", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
200 | 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" , 200, ((const char*) (__func__)), "remove_data.count" " " "==" " " "j + 1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
201 | 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", 201, ((const char*) (__func__)) , "remove_data.n_children" " " "==" " " "step_children + i - j - 1" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); | |||
202 | if (parent_data[j].count == 2) | |||
203 | g_assert (parent_data[j].parent == NULL)do { if (parent_data[j].parent == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "children.c", 203, ((const char*) (__func__)) , "parent_data[j].parent == NULL"); } while (0); | |||
204 | 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; }))))) | |||
205 | { | |||
206 | AtkStateSet *set; | |||
207 | 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 ()))))))); | |||
208 | 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" , 208, ((const char*) (__func__)), "atk_state_set_contains_state (set, ATK_STATE_DEFUNCT)" ); } while (0); | |||
209 | g_object_unref (set); | |||
210 | } | |||
211 | } | |||
212 | ||||
213 | 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)); | |||
214 | 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)); | |||
215 | } | |||
216 | ||||
217 | static void | |||
218 | add_child_test (const gchar *prefix, | |||
219 | GTestFixtureFunc test_func, | |||
220 | CtkWidget *widget) | |||
221 | { | |||
222 | gchar *path; | |||
223 | ||||
224 | path = g_strdup_printf ("%s/%s", prefix, G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))-> g_class))->g_type)))))); | |||
225 | g_test_add_vtable (path, | |||
226 | 0, | |||
227 | g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget)), | |||
228 | 0, | |||
229 | (GTestFixtureFunc) test_func, | |||
230 | (GTestFixtureFunc) g_object_unref); | |||
231 | g_free (path); | |||
232 | } | |||
233 | ||||
234 | static void | |||
235 | add_child_tests (CtkWidget *widget) | |||
236 | { | |||
237 | g_object_ref_sink (widget)((__typeof__ (widget)) (g_object_ref_sink) (widget)); | |||
238 | add_child_test ("/child/add-remove", (GTestFixtureFunc)test_add_remove, widget); | |||
239 | g_object_unref (widget); | |||
240 | } | |||
241 | ||||
242 | int | |||
243 | main (int argc, char *argv[]) | |||
244 | { | |||
245 | ctk_test_init (&argc, &argv, NULL((void*)0)); | |||
246 | ||||
247 | g_test_add_func ("/scrolledwindow/child-count", test_scrolled_window_child_count); | |||
248 | ||||
249 | add_child_tests (ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0))); | |||
250 | add_child_tests (ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0)); | |||
251 | add_child_tests (ctk_paned_new (CTK_ORIENTATION_HORIZONTAL)); | |||
252 | add_child_tests (ctk_grid_new ()); | |||
253 | add_child_tests (ctk_event_box_new ()); | |||
254 | add_child_tests (ctk_window_new (CTK_WINDOW_TOPLEVEL)); | |||
255 | add_child_tests (ctk_assistant_new ()); | |||
256 | add_child_tests (ctk_frame_new ("frame")); | |||
257 | add_child_tests (ctk_expander_new ("expander")); | |||
258 | add_child_tests (ctk_table_new (2, 2, FALSE(0))); | |||
259 | add_child_tests (ctk_text_view_new ()); | |||
260 | add_child_tests (ctk_tree_view_new ()); | |||
261 | #if 0 | |||
262 | /* cail doesn't handle non-label children in these */ | |||
263 | add_child_tests (ctk_button_new ()); | |||
264 | add_child_tests (ctk_statusbar_new ()); | |||
265 | #endif | |||
266 | add_child_tests (ctk_notebook_new ()); | |||
267 | add_child_tests (ctk_entry_new ()); | |||
268 | ||||
269 | return g_test_run (); | |||
270 | } | |||
271 |