2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
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 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include "atk_suite.h"
25 #include "atk_test_util.h"
27 #define DATA_FILE TESTS_DATA_DIR"/test-collection.xml"
30 teardown_collection_test (gpointer fixture, gconstpointer user_data)
36 atk_test_collection_get_collection_iface (gpointer fixture, gconstpointer user_data)
38 AtspiAccessible *obj = get_root_obj (DATA_FILE);
39 AtspiCollection *iface = atspi_accessible_get_collection_iface (obj);
44 atk_test_collection_get_matches (gpointer fixture, gconstpointer user_data)
46 AtspiAccessible *obj = get_root_obj (DATA_FILE);
47 AtspiCollection *iface = atspi_accessible_get_collection_iface (obj);
50 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
52 AtspiMatchRule *rule = NULL;
53 AtspiStateSet *ss = atspi_accessible_get_state_set (child);
55 rule = atspi_match_rule_new (ss,
56 ATSPI_Collection_MATCH_ALL,
58 ATSPI_Collection_MATCH_ALL,
60 ATSPI_Collection_MATCH_ALL,
62 ATSPI_Collection_MATCH_ALL,
64 GArray *ret = atspi_collection_get_matches (iface,
66 ATSPI_Collection_SORT_ORDER_CANONICAL,
70 g_assert_cmpint (2, ==, ret->len);
72 AtspiAccessible *get = NULL;
73 get = g_array_index (ret, AtspiAccessible *, 0);
74 g_assert_cmpstr("obj1", ==, atspi_accessible_get_name (get, NULL));
75 get = g_array_index (ret, AtspiAccessible *, 1);
76 g_assert_cmpstr("obj3", ==, atspi_accessible_get_name (get, NULL));
80 atk_test_collection_get_matches_to (gpointer fixture, gconstpointer user_data)
82 AtspiAccessible *obj = get_root_obj (DATA_FILE);
83 AtspiCollection *iface = atspi_accessible_get_collection_iface (obj);
86 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
87 AtspiAccessible *child1 = atspi_accessible_get_child_at_index (obj, 1, NULL);
89 AtspiMatchRule *rule = NULL;
90 AtspiStateSet *ss = atspi_accessible_get_state_set (child);
92 rule = atspi_match_rule_new (ss,
93 ATSPI_Collection_MATCH_ALL,
95 ATSPI_Collection_MATCH_ALL,
97 ATSPI_Collection_MATCH_ALL,
99 ATSPI_Collection_MATCH_ALL,
101 GArray *ret = atspi_collection_get_matches_to (iface,
104 ATSPI_Collection_SORT_ORDER_CANONICAL,
105 ATSPI_Collection_TREE_INORDER,
110 g_assert_cmpint (1, ==, ret->len);
111 AtspiAccessible *get = NULL;
112 get = g_array_index (ret, AtspiAccessible *, 0);
113 g_assert_cmpstr("obj1", ==, atspi_accessible_get_name (get, NULL));
117 atk_test_collection_get_matches_from (gpointer fixture, gconstpointer user_data)
119 AtspiAccessible *obj = get_root_obj (DATA_FILE);
120 AtspiCollection *iface = atspi_accessible_get_collection_iface (obj);
123 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
124 AtspiAccessible *child1 = atspi_accessible_get_child_at_index (obj, 1, NULL);
126 AtspiMatchRule *rule = NULL;
127 AtspiStateSet *ss = atspi_accessible_get_state_set (child);
129 rule = atspi_match_rule_new (ss,
130 ATSPI_Collection_MATCH_ALL,
132 ATSPI_Collection_MATCH_ALL,
134 ATSPI_Collection_MATCH_ALL,
136 ATSPI_Collection_MATCH_ALL,
138 GArray *ret = atspi_collection_get_matches_from (iface,
141 ATSPI_Collection_SORT_ORDER_CANONICAL,
142 ATSPI_Collection_TREE_INORDER,
146 g_assert_cmpint (3, ==, ret->len);
147 AtspiAccessible *get = NULL;
148 get = g_array_index (ret, AtspiAccessible *, 0);
149 g_assert_cmpstr("obj2/1", ==, atspi_accessible_get_name (get, NULL));
150 get = g_array_index (ret, AtspiAccessible *, 1);
151 g_assert_cmpstr("obj3", ==, atspi_accessible_get_name (get, NULL));
152 get = g_array_index (ret, AtspiAccessible *, 2);
153 g_assert_cmpstr("obj3", ==, atspi_accessible_get_name (get, NULL));
158 atk_test_collection (void )
160 g_test_add_vtable (ATK_TEST_PATH_COLLECTION "/atk_test_collection_get_collection_iface",
161 0, NULL, NULL, atk_test_collection_get_collection_iface, teardown_collection_test );
162 g_test_add_vtable (ATK_TEST_PATH_COLLECTION "/atk_test_collection_get_matches",
163 0, NULL, NULL, atk_test_collection_get_matches, teardown_collection_test );
164 g_test_add_vtable (ATK_TEST_PATH_COLLECTION "/atk_test_collection_get_matches_to",
165 0, NULL, NULL, atk_test_collection_get_matches_to, teardown_collection_test );
166 g_test_add_vtable (ATK_TEST_PATH_COLLECTION "/atk_test_collection_get_matches_from",
167 0, NULL, NULL, atk_test_collection_get_matches_from, teardown_collection_test );