2 * Copyright 2008 Codethink Ltd.
3 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include "atk_test_util.h"
22 #include "atk_suite.h"
24 #define DATA_FILE TESTS_DATA_DIR"/test-table.xml"
27 atk_test_table_get_caption (gpointer fixture, gconstpointer user_data)
29 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
31 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
33 AtspiTable *obj = atspi_accessible_get_table_iface (child);
34 AtspiAccessible *acc = atspi_table_get_caption (obj, NULL);
36 g_assert_cmpstr ("caption name", ==, atspi_accessible_get_name (acc, NULL));
41 atk_test_table_get_summary (gpointer fixture, gconstpointer user_data)
43 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
45 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
47 AtspiTable *obj = atspi_accessible_get_table_iface (child);
48 AtspiAccessible *acc = atspi_table_get_summary (obj, NULL);
50 g_assert_cmpstr ("table summary name", ==, atspi_accessible_get_name (acc, NULL));
54 atk_test_table_get_n_columns (gpointer fixture, gconstpointer user_data)
56 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
58 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
60 AtspiTable *obj = atspi_accessible_get_table_iface (child);
61 gint cnt = atspi_table_get_n_columns (obj, NULL);
62 g_assert_cmpint (cnt, ==, 3);
66 atk_test_table_get_n_rows (gpointer fixture, gconstpointer user_data)
68 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
70 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
72 AtspiTable *obj = atspi_accessible_get_table_iface (child);
73 gint cnt = atspi_table_get_n_rows (obj, NULL);
74 g_assert_cmpint (cnt, ==, 4);
78 atk_test_table_get_accessible_at (gpointer fixture, gconstpointer user_data)
80 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
82 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
84 AtspiTable *obj = atspi_accessible_get_table_iface (child);
85 AtspiAccessible *acc = atspi_table_get_accessible_at (obj, 0, 0, NULL);
87 g_assert_cmpstr ("cell 0/0", ==, atspi_accessible_get_name (acc, NULL));
89 acc = atspi_table_get_accessible_at (obj, 3, 2, NULL);
91 g_assert_cmpstr ("cell 2/3", ==, atspi_accessible_get_name (acc, NULL));
95 atk_test_table_get_index_at (gpointer fixture, gconstpointer user_data)
97 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
99 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
101 AtspiTable *obj = atspi_accessible_get_table_iface (child);
103 gint cnt = atspi_table_get_index_at (obj, 0, 0, NULL);
104 g_assert_cmpint (cnt, ==, 0);
106 cnt = atspi_table_get_index_at (obj, 1, 0, NULL);
107 g_assert_cmpint (cnt, ==, 3);
109 cnt = atspi_table_get_index_at (obj, 0, 1, NULL);
110 g_assert_cmpint (cnt, ==, 1);
114 atk_test_table_get_row_at_index (gpointer fixture, gconstpointer user_data)
116 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
118 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
120 AtspiTable *obj = atspi_accessible_get_table_iface (child);
122 gint cnt = atspi_table_get_row_at_index (obj, 1, NULL);
123 g_assert_cmpint (cnt, ==, 0);
125 cnt = atspi_table_get_row_at_index (obj, 4, NULL);
126 g_assert_cmpint (cnt, ==, 1);
128 cnt = atspi_table_get_row_at_index (obj, 6, NULL);
129 g_assert_cmpint (cnt, ==, 2);
131 cnt = atspi_table_get_row_at_index (obj, 11, NULL);
132 g_assert_cmpint (cnt, ==, 3);
136 atk_test_table_get_column_at_index (gpointer fixture, gconstpointer user_data)
138 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
140 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
142 AtspiTable *obj = atspi_accessible_get_table_iface (child);
144 gint cnt = atspi_table_get_column_at_index (obj, 6, NULL);
145 g_assert_cmpint (cnt, ==, 0);
147 cnt = atspi_table_get_column_at_index (obj, 1, NULL);
148 g_assert_cmpint (cnt, ==, 1);
150 cnt = atspi_table_get_column_at_index (obj, 5, NULL);
151 g_assert_cmpint (cnt, ==, 2);
155 atk_test_table_get_row_description (gpointer fixture, gconstpointer user_data)
157 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
159 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
161 AtspiTable *obj = atspi_accessible_get_table_iface (child);
162 gchar *desc = atspi_table_get_row_description (obj, 0, NULL);
164 g_assert_cmpstr (desc, ==, "first row");
166 desc = atspi_table_get_row_description (obj, 2, NULL);
168 g_assert_cmpstr (desc, ==, "third row");
173 atk_test_table_get_column_description (gpointer fixture, gconstpointer user_data)
175 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
177 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
179 AtspiTable *obj = atspi_accessible_get_table_iface (child);
180 gchar *desc = atspi_table_get_column_description (obj, 0, NULL);
182 g_assert_cmpstr (desc, ==, "first column");
184 desc = atspi_table_get_column_description (obj, 2, NULL);
186 g_assert_cmpstr (desc, ==, "third column");
191 atk_test_table_get_row_extent_at (gpointer fixture, gconstpointer user_data)
193 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
195 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
197 AtspiTable *obj = atspi_accessible_get_table_iface (child);
198 gint cnt = atspi_table_get_row_extent_at (obj, 1, 1, NULL);
199 g_assert_cmpint (cnt, ==, 1);
203 atk_test_table_get_column_extent_at (gpointer fixture, gconstpointer user_data)
205 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
207 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
209 AtspiTable *obj = atspi_accessible_get_table_iface (child);
210 gint cnt = atspi_table_get_column_extent_at (obj, 1, 1, NULL);
211 g_assert_cmpint (cnt, ==, 1);
215 atk_test_table_get_row_header (gpointer fixture, gconstpointer user_data)
217 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
219 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
221 AtspiTable *obj = atspi_accessible_get_table_iface (child);
222 AtspiAccessible *acc = atspi_table_get_row_header (obj, 0, NULL);
224 g_assert_cmpstr ("row 1 header", ==, atspi_accessible_get_name (acc, NULL));
225 acc = atspi_table_get_row_header (obj, 3, NULL);
227 g_assert_cmpstr ("row 4 header", ==, atspi_accessible_get_name (acc, NULL));
231 atk_test_table_get_column_header (gpointer fixture, gconstpointer user_data)
233 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
235 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
237 AtspiTable *obj = atspi_accessible_get_table_iface (child);
238 AtspiAccessible *acc = atspi_table_get_column_header (obj, 0, NULL);
240 g_assert_cmpstr ("column 1 header", ==, atspi_accessible_get_name (acc, NULL));
241 acc = atspi_table_get_column_header (obj, 1, NULL);
243 g_assert_cmpstr ("column 2 header", ==, atspi_accessible_get_name (acc, NULL));
244 acc = atspi_table_get_column_header (obj, 2, NULL);
246 g_assert_cmpstr ("column 3 header", ==, atspi_accessible_get_name (acc, NULL));
250 atk_test_table_get_n_selected_rows (gpointer fixture, gconstpointer user_data)
252 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
254 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
256 AtspiTable *obj = atspi_accessible_get_table_iface (child);
257 gint cnt = atspi_table_get_n_selected_rows (obj, NULL);
258 g_assert_cmpint (cnt, ==, 2);
262 atk_test_table_get_selected_rows (gpointer fixture, gconstpointer user_data)
264 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
266 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
268 AtspiTable *obj = atspi_accessible_get_table_iface (child);
269 GArray *array = atspi_table_get_selected_rows (obj, NULL);
271 g_assert_cmpint (array->len, ==, 2);
272 g_assert_cmpint (g_array_index (array,gint, 0), ==, 0);
273 g_assert_cmpint (g_array_index (array,gint, 1), ==, 2);
274 g_array_free (array, TRUE);
278 atk_test_table_get_selected_columns (gpointer fixture, gconstpointer user_data)
280 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
282 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
284 AtspiTable *obj = atspi_accessible_get_table_iface (child);
285 GArray *array = atspi_table_get_selected_columns (obj, NULL);
287 g_assert_cmpint (array->len, ==, 1);
288 g_assert_cmpint (g_array_index (array, gint, 0), ==, 1);
290 g_array_free (array, TRUE);
294 atk_test_table_get_n_selected_columns (gpointer fixture, gconstpointer user_data)
296 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
298 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
301 AtspiTable *obj = atspi_accessible_get_table_iface (child);
303 gint cnt = atspi_table_get_n_selected_columns (obj, NULL);
304 g_assert_cmpint (cnt, ==, 1);
308 atk_test_table_is_row_selected (gpointer fixture, gconstpointer user_data)
310 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
312 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
314 AtspiTable *obj = atspi_accessible_get_table_iface (child);
315 g_assert_true (atspi_table_is_row_selected (obj, 0, NULL));
316 g_assert_false (atspi_table_is_row_selected (obj, 1, NULL));
320 atk_test_table_is_column_selected (gpointer fixture, gconstpointer user_data)
322 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
324 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
326 AtspiTable *obj = atspi_accessible_get_table_iface (child);
327 g_assert_true (atspi_table_is_column_selected (obj, 1, NULL));
328 g_assert_false (atspi_table_is_column_selected (obj, 0, NULL));
332 atk_test_table_add_row_selection (gpointer fixture, gconstpointer user_data)
334 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
336 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
338 AtspiTable *obj = atspi_accessible_get_table_iface (child);
339 g_assert_false (atspi_table_is_row_selected (obj, 1, NULL));
340 g_assert_true (atspi_table_add_row_selection (obj, 1, NULL));
341 g_assert_true (atspi_table_is_row_selected (obj, 1, NULL));
345 atk_test_table_add_column_selection (gpointer fixture, gconstpointer user_data)
347 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
349 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
351 AtspiTable *obj = atspi_accessible_get_table_iface (child);
352 g_assert_false (atspi_table_is_column_selected (obj, 2, NULL));
353 g_assert_true (atspi_table_add_column_selection (obj, 2, NULL));
354 g_assert_true (atspi_table_is_column_selected (obj, 2, NULL));
358 atk_test_table_remove_row_selection (gpointer fixture, gconstpointer user_data)
360 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
362 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
364 AtspiTable *obj = atspi_accessible_get_table_iface (child);
365 g_assert_true (atspi_table_is_row_selected (obj, 2, NULL));
366 g_assert_true (atspi_table_remove_row_selection (obj, 2, NULL));
367 g_assert_false (atspi_table_is_row_selected (obj, 2, NULL));
371 atk_test_table_remove_column_selection (gpointer fixture, gconstpointer user_data)
373 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
375 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
377 AtspiTable *obj = atspi_accessible_get_table_iface (child);
378 g_assert_true (atspi_table_is_column_selected (obj, 1, NULL));
379 g_assert_true (atspi_table_remove_column_selection (obj, 1, NULL));
380 g_assert_false (atspi_table_is_column_selected (obj, 1, NULL));
384 atk_test_table_get_row_column_extents_at_index (gpointer fixture, gconstpointer user_data)
386 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
388 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
390 AtspiTable *obj = atspi_accessible_get_table_iface (child);
395 gboolean is_selected;
396 g_assert_true (atspi_table_get_row_column_extents_at_index (obj, 0, &row, &col, &row_ext, &col_ext, &is_selected, NULL));
398 g_assert_cmpint (row, ==, 0);
399 g_assert_cmpint (col, ==, 0);
400 g_assert_cmpint (row_ext, ==, 2);
401 g_assert_cmpint (col_ext, ==, 1);
402 g_assert_false (is_selected);
406 atk_test_table_is_selected (gpointer fixture, gconstpointer user_data)
408 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
410 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
412 AtspiTable *obj = atspi_accessible_get_table_iface (child);
413 g_assert_true (atspi_table_is_selected (obj, 0, 2, NULL));
414 g_assert_false (atspi_table_is_selected (obj, 1, 0, NULL));
418 teardown_table_test (gpointer fixture, gconstpointer user_data)
420 kill (child_pid, SIGTERM);
426 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_caption",
427 0, NULL, NULL, atk_test_table_get_caption, teardown_table_test);
428 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_summary",
429 0, NULL, NULL, atk_test_table_get_summary, teardown_table_test);
430 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_n_columns",
431 0, NULL, NULL, atk_test_table_get_n_columns, teardown_table_test);
432 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_n_rows",
433 0, NULL, NULL, atk_test_table_get_n_rows, teardown_table_test);
434 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_accessible_at",
435 0, NULL, NULL, atk_test_table_get_accessible_at, teardown_table_test);
436 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_index_at",
437 0, NULL, NULL, atk_test_table_get_index_at, teardown_table_test);
438 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_row_at_index",
439 0, NULL, NULL, atk_test_table_get_row_at_index, teardown_table_test);
440 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_column_at_index",
441 0, NULL, NULL, atk_test_table_get_column_at_index, teardown_table_test);
442 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_row_description",
443 0, NULL, NULL, atk_test_table_get_row_description, teardown_table_test);
444 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_column_description",
445 0, NULL, NULL, atk_test_table_get_column_description, teardown_table_test);
446 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_row_extent_at",
447 0, NULL, NULL, atk_test_table_get_row_extent_at, teardown_table_test);
448 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_column_extent_at",
449 0, NULL, NULL, atk_test_table_get_column_extent_at, teardown_table_test);
450 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_row_header",
451 0, NULL, NULL, atk_test_table_get_row_header, teardown_table_test);
452 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_column_header",
453 0, NULL, NULL, atk_test_table_get_column_header, teardown_table_test);
454 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_n_selected_rows",
455 0, NULL, NULL, atk_test_table_get_n_selected_rows, teardown_table_test);
456 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_selected_rows",
457 0, NULL, NULL, atk_test_table_get_selected_rows, teardown_table_test);
458 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_selected_columns",
459 0, NULL, NULL, atk_test_table_get_selected_columns, teardown_table_test);
460 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_n_selected_columns",
461 0, NULL, NULL, atk_test_table_get_n_selected_columns, teardown_table_test);
462 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_is_row_selected",
463 0, NULL, NULL, atk_test_table_is_row_selected, teardown_table_test);
464 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_is_column_selected",
465 0, NULL, NULL, atk_test_table_is_column_selected, teardown_table_test);
466 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_add_row_selection",
467 0, NULL, NULL, atk_test_table_add_row_selection, teardown_table_test);
468 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_add_column_selection",
469 0, NULL, NULL, atk_test_table_add_column_selection, teardown_table_test);
470 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_remove_row_selection",
471 0, NULL, NULL, atk_test_table_remove_row_selection, teardown_table_test);
472 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_remove_column_selection",
473 0, NULL, NULL, atk_test_table_remove_column_selection, teardown_table_test);
474 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_get_row_column_extents_at_index",
475 0, NULL, NULL, atk_test_table_get_row_column_extents_at_index, teardown_table_test);
476 g_test_add_vtable (ATK_TEST_PATH_TABLE "/atk_test_table_is_selected",
477 0, NULL, NULL, atk_test_table_is_selected, teardown_table_test);