1 | #include <gtk/gtk.h> |
2 | #include "gtk/gtkaccessibleprivate.h" |
3 | |
4 | /* These tests verify that the GtkAccessible machinery works, independent |
5 | * of any concrete widget accessible implementations. Therefore, we use |
6 | * a dummy object that implements GtkAccessible |
7 | */ |
8 | typedef struct |
9 | { |
10 | GObject parent_instance; |
11 | |
12 | GtkAccessibleRole role; |
13 | GtkATContext *at_context; |
14 | } TestObject; |
15 | |
16 | typedef struct |
17 | { |
18 | GObjectClass parent_class; |
19 | } TestObjectClass; |
20 | |
21 | enum { |
22 | PROP_ACCESSIBLE_ROLE = 1, |
23 | NUM_PROPERTIES |
24 | }; |
25 | |
26 | static GtkATContext * |
27 | test_object_accessible_get_at_context (GtkAccessible *accessible) |
28 | { |
29 | TestObject *self = (TestObject*)accessible; |
30 | |
31 | if (self->at_context == NULL) |
32 | self->at_context = gtk_at_context_create (accessible_role: self->role, |
33 | accessible, |
34 | display: gdk_display_get_default ()); |
35 | |
36 | return self->at_context; |
37 | } |
38 | |
39 | static void |
40 | test_object_accessible_init (GtkAccessibleInterface *iface) |
41 | { |
42 | iface->get_at_context = test_object_accessible_get_at_context; |
43 | } |
44 | |
45 | G_DEFINE_TYPE_WITH_CODE (TestObject, test_object, G_TYPE_OBJECT, |
46 | G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, |
47 | test_object_accessible_init)) |
48 | |
49 | static void |
50 | test_object_init (TestObject *self) |
51 | { |
52 | self->role = GTK_ACCESSIBLE_ROLE_WIDGET; |
53 | } |
54 | |
55 | static void |
56 | test_object_set_property (GObject *object, |
57 | guint prop_id, |
58 | const GValue *value, |
59 | GParamSpec *pspec) |
60 | { |
61 | TestObject *self = (TestObject *)object; |
62 | |
63 | switch (prop_id) |
64 | { |
65 | case PROP_ACCESSIBLE_ROLE: |
66 | self->role = g_value_get_enum (value); |
67 | break; |
68 | default: |
69 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
70 | } |
71 | } |
72 | |
73 | static void |
74 | test_object_get_property (GObject *object, |
75 | guint prop_id, |
76 | GValue *value, |
77 | GParamSpec *pspec) |
78 | { |
79 | TestObject *self = (TestObject *)object; |
80 | |
81 | switch (prop_id) |
82 | { |
83 | case PROP_ACCESSIBLE_ROLE: |
84 | g_value_set_enum (value, v_enum: self->role); |
85 | break; |
86 | default: |
87 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
88 | } |
89 | } |
90 | |
91 | static void |
92 | test_object_class_init (TestObjectClass *class) |
93 | { |
94 | GObjectClass *gobject_class = G_OBJECT_CLASS (class); |
95 | |
96 | gobject_class->set_property = test_object_set_property; |
97 | gobject_class->get_property = test_object_get_property; |
98 | |
99 | g_object_class_override_property (oclass: gobject_class, property_id: PROP_ACCESSIBLE_ROLE, name: "accessible-role" ); |
100 | } |
101 | |
102 | static TestObject * |
103 | test_object_new (GtkAccessibleRole role) |
104 | { |
105 | return g_object_new (object_type: test_object_get_type (), |
106 | first_property_name: "accessible-role" , role, |
107 | NULL); |
108 | } |
109 | |
110 | /* Tests for states */ |
111 | |
112 | static void |
113 | test_boolean_state (gconstpointer data) |
114 | { |
115 | GtkAccessibleState state = GPOINTER_TO_UINT (data); |
116 | TestObject *object; |
117 | |
118 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
119 | |
120 | gtk_test_accessible_assert_state (object, state, FALSE); |
121 | |
122 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
123 | first_state: state, TRUE, |
124 | -1); |
125 | gtk_test_accessible_assert_state (object, state, TRUE); |
126 | |
127 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
128 | first_state: state, FALSE, |
129 | -1); |
130 | gtk_test_accessible_assert_state (object, state, FALSE); |
131 | |
132 | g_object_unref (object); |
133 | } |
134 | |
135 | static void |
136 | test_maybe_boolean_state (gconstpointer data) |
137 | { |
138 | GtkAccessibleState state = GPOINTER_TO_UINT (data); |
139 | TestObject *object; |
140 | |
141 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
142 | |
143 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
144 | |
145 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
146 | first_state: state, TRUE, |
147 | -1); |
148 | gtk_test_accessible_assert_state (object, state, TRUE); |
149 | |
150 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
151 | first_state: state, FALSE, |
152 | -1); |
153 | gtk_test_accessible_assert_state (object, state, FALSE); |
154 | |
155 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
156 | first_state: state, GTK_ACCESSIBLE_VALUE_UNDEFINED, |
157 | -1); |
158 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
159 | |
160 | g_object_unref (object); |
161 | } |
162 | |
163 | static void |
164 | test_tristate_state (gconstpointer data) |
165 | { |
166 | GtkAccessibleState state = GPOINTER_TO_UINT (data); |
167 | TestObject *object; |
168 | |
169 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
170 | |
171 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
172 | |
173 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
174 | |
175 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
176 | first_state: state, GTK_ACCESSIBLE_TRISTATE_FALSE, |
177 | -1); |
178 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_TRISTATE_FALSE); |
179 | |
180 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
181 | first_state: state, GTK_ACCESSIBLE_TRISTATE_TRUE, |
182 | -1); |
183 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_TRISTATE_TRUE); |
184 | |
185 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
186 | first_state: state, GTK_ACCESSIBLE_TRISTATE_MIXED, |
187 | -1); |
188 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_TRISTATE_MIXED); |
189 | |
190 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
191 | first_state: state, GTK_ACCESSIBLE_VALUE_UNDEFINED, |
192 | -1); |
193 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
194 | |
195 | g_object_unref (object); |
196 | } |
197 | |
198 | static void |
199 | test_invalid_state (gconstpointer data) |
200 | { |
201 | GtkAccessibleState state = GPOINTER_TO_UINT (data); |
202 | TestObject *object; |
203 | |
204 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
205 | |
206 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
207 | |
208 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_INVALID_FALSE); |
209 | |
210 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
211 | first_state: state, GTK_ACCESSIBLE_INVALID_TRUE, |
212 | -1); |
213 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_INVALID_TRUE); |
214 | |
215 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
216 | first_state: state, GTK_ACCESSIBLE_INVALID_GRAMMAR, |
217 | -1); |
218 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_INVALID_GRAMMAR); |
219 | |
220 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
221 | first_state: state, GTK_ACCESSIBLE_INVALID_SPELLING, |
222 | -1); |
223 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_INVALID_SPELLING); |
224 | |
225 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
226 | first_state: state, GTK_ACCESSIBLE_INVALID_FALSE, |
227 | -1); |
228 | gtk_test_accessible_assert_state (object, state, GTK_ACCESSIBLE_INVALID_FALSE); |
229 | |
230 | g_object_unref (object); |
231 | } |
232 | |
233 | static void |
234 | test_update_multiple_states (void) |
235 | { |
236 | TestObject *object; |
237 | |
238 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
239 | |
240 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
241 | first_state: GTK_ACCESSIBLE_STATE_BUSY, TRUE, |
242 | GTK_ACCESSIBLE_STATE_CHECKED, GTK_ACCESSIBLE_TRISTATE_MIXED, |
243 | -1); |
244 | |
245 | gtk_test_accessible_assert_state (object, GTK_ACCESSIBLE_STATE_BUSY, TRUE); |
246 | gtk_test_accessible_assert_state (object, GTK_ACCESSIBLE_STATE_CHECKED, GTK_ACCESSIBLE_TRISTATE_MIXED); |
247 | |
248 | gtk_accessible_update_state (self: GTK_ACCESSIBLE (ptr: object), |
249 | first_state: GTK_ACCESSIBLE_STATE_BUSY, FALSE, |
250 | GTK_ACCESSIBLE_STATE_CHECKED, GTK_ACCESSIBLE_TRISTATE_TRUE, |
251 | GTK_ACCESSIBLE_STATE_BUSY, TRUE, |
252 | GTK_ACCESSIBLE_STATE_BUSY, FALSE, |
253 | -1); |
254 | |
255 | gtk_test_accessible_assert_state (object, GTK_ACCESSIBLE_STATE_BUSY, FALSE); |
256 | gtk_test_accessible_assert_state (object, GTK_ACCESSIBLE_STATE_CHECKED, GTK_ACCESSIBLE_TRISTATE_TRUE); |
257 | |
258 | g_object_unref (object); |
259 | } |
260 | |
261 | static void |
262 | test_autocomplete_property (gconstpointer data) |
263 | { |
264 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
265 | TestObject *object; |
266 | |
267 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
268 | |
269 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
270 | |
271 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_AUTOCOMPLETE_NONE); |
272 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
273 | first_property: property, GTK_ACCESSIBLE_AUTOCOMPLETE_INLINE, |
274 | -1); |
275 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_AUTOCOMPLETE_INLINE); |
276 | |
277 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
278 | first_property: property, GTK_ACCESSIBLE_AUTOCOMPLETE_LIST, |
279 | -1); |
280 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_AUTOCOMPLETE_LIST); |
281 | |
282 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
283 | first_property: property, GTK_ACCESSIBLE_AUTOCOMPLETE_BOTH, |
284 | -1); |
285 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_AUTOCOMPLETE_BOTH); |
286 | |
287 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
288 | first_property: property, GTK_ACCESSIBLE_AUTOCOMPLETE_NONE, |
289 | -1); |
290 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_AUTOCOMPLETE_NONE); |
291 | |
292 | g_object_unref (object); |
293 | } |
294 | |
295 | static void |
296 | test_string_property (gconstpointer data) |
297 | { |
298 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
299 | TestObject *object; |
300 | |
301 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
302 | |
303 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
304 | |
305 | gtk_test_accessible_assert_property (object, property, NULL); |
306 | |
307 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
308 | first_property: property, "some string that holds no particular value" , |
309 | -1); |
310 | gtk_test_accessible_assert_property (object, property, "some string that holds no particular value" ); |
311 | |
312 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
313 | first_property: property, "see\nif\nnewlines\nwork ?!" , |
314 | -1); |
315 | gtk_test_accessible_assert_property (object, property, "see\nif\nnewlines\nwork ?!" ); |
316 | |
317 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
318 | first_property: property, "" , |
319 | -1); |
320 | gtk_test_accessible_assert_property (object, property, "" ); |
321 | |
322 | g_object_unref (object); |
323 | } |
324 | |
325 | static void |
326 | test_boolean_property (gconstpointer data) |
327 | { |
328 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
329 | TestObject *object; |
330 | |
331 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
332 | |
333 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
334 | |
335 | gtk_test_accessible_assert_property (object, property, FALSE); |
336 | |
337 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
338 | first_property: property, TRUE, |
339 | -1); |
340 | gtk_test_accessible_assert_property (object, property, TRUE); |
341 | |
342 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
343 | first_property: property, FALSE, |
344 | -1); |
345 | gtk_test_accessible_assert_property (object, property, FALSE); |
346 | |
347 | g_object_unref (object); |
348 | } |
349 | |
350 | static void |
351 | test_int_property (gconstpointer data) |
352 | { |
353 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
354 | TestObject *object; |
355 | |
356 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
357 | |
358 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
359 | |
360 | gtk_test_accessible_assert_property (object, property, 0); |
361 | |
362 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
363 | first_property: property, 1, |
364 | -1); |
365 | gtk_test_accessible_assert_property (object, property, 1); |
366 | |
367 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
368 | first_property: property, -1, |
369 | -1); |
370 | gtk_test_accessible_assert_property (object, property, -1); |
371 | |
372 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
373 | first_property: property, 100, |
374 | -1); |
375 | gtk_test_accessible_assert_property (object, property, 100); |
376 | |
377 | g_object_unref (object); |
378 | } |
379 | |
380 | static void |
381 | test_number_property (gconstpointer data) |
382 | { |
383 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
384 | TestObject *object; |
385 | |
386 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
387 | |
388 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
389 | |
390 | gtk_test_accessible_assert_property (object, property, 0.); |
391 | |
392 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
393 | first_property: property, 1.5, |
394 | -1); |
395 | gtk_test_accessible_assert_property (object, property, 1.5); |
396 | |
397 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
398 | first_property: property, -1., |
399 | -1); |
400 | gtk_test_accessible_assert_property (object, property, -1.); |
401 | |
402 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
403 | first_property: property, 1e6, |
404 | -1); |
405 | gtk_test_accessible_assert_property (object, property, 1e6); |
406 | |
407 | g_object_unref (object); |
408 | } |
409 | |
410 | static void |
411 | test_orientation_property (gconstpointer data) |
412 | { |
413 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
414 | TestObject *object; |
415 | |
416 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
417 | |
418 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
419 | |
420 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
421 | |
422 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
423 | first_property: property, GTK_ORIENTATION_HORIZONTAL, |
424 | -1); |
425 | gtk_test_accessible_assert_property (object, property, GTK_ORIENTATION_HORIZONTAL); |
426 | |
427 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
428 | first_property: property, GTK_ORIENTATION_VERTICAL, |
429 | -1); |
430 | gtk_test_accessible_assert_property (object, property, GTK_ORIENTATION_VERTICAL); |
431 | |
432 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
433 | first_property: property, GTK_ACCESSIBLE_VALUE_UNDEFINED, |
434 | -1); |
435 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_VALUE_UNDEFINED); |
436 | |
437 | g_object_unref (object); |
438 | } |
439 | |
440 | static void |
441 | test_sort_property (gconstpointer data) |
442 | { |
443 | GtkAccessibleProperty property = GPOINTER_TO_UINT (data); |
444 | TestObject *object; |
445 | |
446 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
447 | |
448 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
449 | |
450 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_SORT_NONE); |
451 | |
452 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
453 | first_property: property, GTK_ACCESSIBLE_SORT_ASCENDING, |
454 | -1); |
455 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_SORT_ASCENDING); |
456 | |
457 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
458 | first_property: property, GTK_ACCESSIBLE_SORT_DESCENDING, |
459 | -1); |
460 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_SORT_DESCENDING); |
461 | |
462 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
463 | first_property: property, GTK_ACCESSIBLE_SORT_OTHER, |
464 | -1); |
465 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_SORT_OTHER); |
466 | |
467 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
468 | first_property: property, GTK_ACCESSIBLE_SORT_NONE, |
469 | -1); |
470 | gtk_test_accessible_assert_property (object, property, GTK_ACCESSIBLE_SORT_NONE); |
471 | |
472 | g_object_unref (object); |
473 | } |
474 | |
475 | static void |
476 | test_update_multiple_properties (void) |
477 | { |
478 | TestObject *object; |
479 | |
480 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
481 | |
482 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
483 | first_property: GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100., |
484 | GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 10., |
485 | -1); |
486 | |
487 | gtk_test_accessible_assert_property (object, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100.); |
488 | gtk_test_accessible_assert_property (object, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 10.); |
489 | |
490 | gtk_accessible_update_property (self: GTK_ACCESSIBLE (ptr: object), |
491 | first_property: GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 99., |
492 | GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 11., |
493 | GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 98., |
494 | GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 97., |
495 | -1); |
496 | |
497 | gtk_test_accessible_assert_property (object, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 97.); |
498 | gtk_test_accessible_assert_property (object, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 11.); |
499 | |
500 | g_object_unref (object); |
501 | } |
502 | |
503 | static void |
504 | test_int_relation (gconstpointer data) |
505 | { |
506 | GtkAccessibleRelation relation = GPOINTER_TO_UINT (data); |
507 | TestObject *object; |
508 | |
509 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
510 | |
511 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
512 | |
513 | gtk_test_accessible_assert_relation (object, relation, 0); |
514 | |
515 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
516 | first_relation: relation, 1, |
517 | -1); |
518 | gtk_test_accessible_assert_relation (object, relation, 1); |
519 | |
520 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
521 | first_relation: relation, -1, |
522 | -1); |
523 | gtk_test_accessible_assert_relation (object, relation, -1); |
524 | |
525 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
526 | first_relation: relation, 100, |
527 | -1); |
528 | gtk_test_accessible_assert_relation (object, relation, 100); |
529 | |
530 | g_object_unref (object); |
531 | } |
532 | |
533 | static void |
534 | test_string_relation (gconstpointer data) |
535 | { |
536 | GtkAccessibleRelation relation = GPOINTER_TO_UINT (data); |
537 | TestObject *object; |
538 | |
539 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
540 | |
541 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
542 | |
543 | gtk_test_accessible_assert_relation (object, relation, NULL); |
544 | |
545 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
546 | first_relation: relation, "some string that holds no particular value" , |
547 | -1); |
548 | gtk_test_accessible_assert_relation (object, relation, "some string that holds no particular value" ); |
549 | |
550 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
551 | first_relation: relation, "see\nif\nnewlines\nwork ?!" , |
552 | -1); |
553 | gtk_test_accessible_assert_relation (object, relation, "see\nif\nnewlines\nwork ?!" ); |
554 | |
555 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
556 | first_relation: relation, "" , |
557 | -1); |
558 | gtk_test_accessible_assert_relation (object, relation, "" ); |
559 | |
560 | g_object_unref (object); |
561 | } |
562 | |
563 | static void |
564 | test_ref_relation (gconstpointer data) |
565 | { |
566 | GtkAccessibleRelation relation = GPOINTER_TO_UINT (data); |
567 | TestObject *object; |
568 | TestObject *other; |
569 | |
570 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
571 | other = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
572 | |
573 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
574 | |
575 | gtk_test_accessible_assert_relation (object, relation, NULL); |
576 | |
577 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
578 | first_relation: relation, other, |
579 | -1); |
580 | gtk_test_accessible_assert_relation (object, relation, other); |
581 | |
582 | g_object_unref (object); |
583 | g_object_unref (object: other); |
584 | } |
585 | |
586 | static void |
587 | test_reflist_relation (gconstpointer data) |
588 | { |
589 | GtkAccessibleRelation relation = GPOINTER_TO_UINT (data); |
590 | TestObject *object; |
591 | TestObject *other; |
592 | TestObject *third; |
593 | |
594 | object = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
595 | other = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
596 | third = test_object_new (role: GTK_ACCESSIBLE_ROLE_CHECKBOX); |
597 | |
598 | gtk_test_accessible_assert_role (object, GTK_ACCESSIBLE_ROLE_CHECKBOX); |
599 | |
600 | gtk_test_accessible_assert_relation (object, relation, NULL); |
601 | |
602 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
603 | first_relation: relation, other, NULL, |
604 | -1); |
605 | gtk_test_accessible_assert_relation (object, relation, other, NULL); |
606 | |
607 | gtk_accessible_update_relation (self: GTK_ACCESSIBLE (ptr: object), |
608 | first_relation: relation, other, third, NULL, |
609 | -1); |
610 | gtk_test_accessible_assert_relation (object, relation, other, third, NULL); |
611 | |
612 | g_object_unref (object); |
613 | g_object_unref (object: other); |
614 | g_object_unref (object: third); |
615 | } |
616 | |
617 | int |
618 | main (int argc, char *argv[]) |
619 | { |
620 | gtk_test_init (argcp: &argc, argvp: &argv, NULL); |
621 | |
622 | g_test_add_data_func (testpath: "/a11y/state/busy" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_BUSY), test_func: test_boolean_state); |
623 | g_test_add_data_func (testpath: "/a11y/state/checked" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_CHECKED), test_func: test_tristate_state); |
624 | g_test_add_data_func (testpath: "/a11y/state/disabled" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_DISABLED), test_func: test_boolean_state); |
625 | g_test_add_data_func (testpath: "/a11y/state/expanded" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_EXPANDED), test_func: test_maybe_boolean_state); |
626 | g_test_add_data_func (testpath: "/a11y/state/hidden" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_HIDDEN), test_func: test_boolean_state); |
627 | g_test_add_data_func (testpath: "/a11y/state/invalid" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_INVALID), test_func: test_invalid_state); |
628 | g_test_add_data_func (testpath: "/a11y/state/pressed" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_PRESSED), test_func: test_tristate_state); |
629 | g_test_add_data_func (testpath: "/a11y/state/selected" , GUINT_TO_POINTER (GTK_ACCESSIBLE_STATE_SELECTED), test_func: test_maybe_boolean_state); |
630 | |
631 | g_test_add_func (testpath: "/a11y/state/update-multiple" , test_func: test_update_multiple_states); |
632 | |
633 | g_test_add_data_func (testpath: "/a11y/property/autocomplete" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE), test_func: test_autocomplete_property); |
634 | g_test_add_data_func (testpath: "/a11y/property/description" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_DESCRIPTION), test_func: test_string_property); |
635 | g_test_add_data_func (testpath: "/a11y/property/has-popup" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_HAS_POPUP), test_func: test_boolean_property); |
636 | g_test_add_data_func (testpath: "/a11y/property/key-shortcuts" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_KEY_SHORTCUTS), test_func: test_string_property); |
637 | g_test_add_data_func (testpath: "/a11y/property/label" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_LABEL), test_func: test_string_property); |
638 | g_test_add_data_func (testpath: "/a11y/property/level" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_LEVEL), test_func: test_int_property); |
639 | g_test_add_data_func (testpath: "/a11y/property/modal" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_MODAL), test_func: test_boolean_property); |
640 | g_test_add_data_func (testpath: "/a11y/property/multi-line" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_MULTI_LINE), test_func: test_boolean_property); |
641 | g_test_add_data_func (testpath: "/a11y/property/multi-selectable" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE), test_func: test_boolean_property); |
642 | g_test_add_data_func (testpath: "/a11y/property/orientation" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_ORIENTATION), test_func: test_orientation_property); |
643 | g_test_add_data_func (testpath: "/a11y/property/placeholder" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER), test_func: test_string_property); |
644 | g_test_add_data_func (testpath: "/a11y/property/read-only" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_READ_ONLY), test_func: test_boolean_property); |
645 | g_test_add_data_func (testpath: "/a11y/property/required" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_REQUIRED), test_func: test_boolean_property); |
646 | g_test_add_data_func (testpath: "/a11y/property/role-description" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION), test_func: test_string_property); |
647 | g_test_add_data_func (testpath: "/a11y/property/sort" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_SORT), test_func: test_sort_property); |
648 | g_test_add_data_func (testpath: "/a11y/property/value-max" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_VALUE_MAX), test_func: test_number_property); |
649 | g_test_add_data_func (testpath: "/a11y/property/value-min" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_VALUE_MIN), test_func: test_number_property); |
650 | g_test_add_data_func (testpath: "/a11y/property/value-now" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_VALUE_NOW), test_func: test_number_property); |
651 | g_test_add_data_func (testpath: "/a11y/property/value-text" , GUINT_TO_POINTER (GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT), test_func: test_string_property); |
652 | |
653 | g_test_add_func (testpath: "/a11y/property/update-multiple" , test_func: test_update_multiple_properties); |
654 | |
655 | g_test_add_data_func (testpath: "/a11y/relation/active-descendant" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT), test_func: test_ref_relation); |
656 | g_test_add_data_func (testpath: "/a11y/relation/col-count" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_COL_COUNT), test_func: test_int_relation); |
657 | g_test_add_data_func (testpath: "/a11y/relation/col-index" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_COL_INDEX), test_func: test_int_relation); |
658 | g_test_add_data_func (testpath: "/a11y/relation/col-index-text" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_COL_INDEX_TEXT), test_func: test_string_relation); |
659 | g_test_add_data_func (testpath: "/a11y/relation/col-span" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_COL_SPAN), test_func: test_int_relation); |
660 | g_test_add_data_func (testpath: "/a11y/relation/controls" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_CONTROLS), test_func: test_reflist_relation); |
661 | g_test_add_data_func (testpath: "/a11y/relation/described-by" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_DESCRIBED_BY), test_func: test_reflist_relation); |
662 | g_test_add_data_func (testpath: "/a11y/relation/details" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_DETAILS), test_func: test_reflist_relation); |
663 | g_test_add_data_func (testpath: "/a11y/relation/error-message" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE), test_func: test_ref_relation); |
664 | g_test_add_data_func (testpath: "/a11y/relation/flow-to" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_FLOW_TO), test_func: test_reflist_relation); |
665 | g_test_add_data_func (testpath: "/a11y/relation/labelled-by" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_LABELLED_BY), test_func: test_reflist_relation); |
666 | g_test_add_data_func (testpath: "/a11y/relation/owns" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_OWNS), test_func: test_reflist_relation); |
667 | g_test_add_data_func (testpath: "/a11y/relation/pos-in-set" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_POS_IN_SET), test_func: test_int_relation); |
668 | g_test_add_data_func (testpath: "/a11y/relation/row-count" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ROW_COUNT), test_func: test_int_relation); |
669 | g_test_add_data_func (testpath: "/a11y/relation/row-index" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ROW_INDEX), test_func: test_int_relation); |
670 | g_test_add_data_func (testpath: "/a11y/relation/row-index-text" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ROW_INDEX_TEXT), test_func: test_string_relation); |
671 | g_test_add_data_func (testpath: "/a11y/relation/row-span" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_ROW_SPAN), test_func: test_int_relation); |
672 | g_test_add_data_func (testpath: "/a11y/relation/set-size" , GUINT_TO_POINTER (GTK_ACCESSIBLE_RELATION_SET_SIZE), test_func: test_int_relation); |
673 | |
674 | return g_test_run (); |
675 | } |
676 | |