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.
23 #include "atk_suite.h"
24 #include "atk_test_util.h"
26 #define DATA_FILE TESTS_DATA_DIR"/test-selection.xml"
29 teardown_selection_test (gpointer fixture, gconstpointer user_data)
35 atk_test_selection_sample_get_interface (gpointer fixture, gconstpointer user_data)
37 AtspiAccessible *obj = get_root_obj (DATA_FILE);
38 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
39 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
40 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
41 g_assert (iface != NULL);
45 atk_test_selection_get_n_selected_children (gpointer fixture, gconstpointer user_data)
47 AtspiAccessible *obj = get_root_obj (DATA_FILE);
48 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
49 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
50 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
51 g_assert (iface != NULL);
53 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
57 atk_test_selection_get_selected_child (gpointer fixture, gconstpointer user_data)
59 AtspiAccessible *obj = get_root_obj (DATA_FILE);
60 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
61 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
62 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
63 g_assert (iface != NULL);
64 gchar* valid_names[] = { "obj2/1", "obj2/2", "obj3/1"};
66 AtspiAccessible *o = NULL;
68 int selected_count = atspi_selection_get_n_selected_children (iface, NULL);
69 for (i=0; i<selected_count; i++) {
70 o = atspi_selection_get_selected_child (iface, i, NULL);
71 g_assert_cmpstr (atspi_accessible_get_name (o, NULL), ==, valid_names[i]);
76 atk_test_selection_select_child (gpointer fixture, gconstpointer user_data)
78 AtspiAccessible *obj = get_root_obj (DATA_FILE);
79 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
80 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
81 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
82 g_assert (iface != NULL);
84 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
86 atspi_selection_select_child (iface, 2, NULL);
87 atspi_selection_select_child (iface, 3, NULL);
88 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 5);
92 atk_test_selection_deselect_selected (gpointer fixture, gconstpointer user_data)
94 AtspiAccessible *obj = get_root_obj (DATA_FILE);
95 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
96 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
97 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
98 g_assert (iface != NULL);
100 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
102 atspi_selection_select_child (iface, 2, NULL);
103 atspi_selection_select_child (iface, 3, NULL);
104 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 5);
106 atspi_selection_deselect_selected_child (iface, 2, NULL);
107 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 4);
111 atk_test_selection_deselect_child (gpointer fixture, gconstpointer user_data)
113 AtspiAccessible *obj = get_root_obj (DATA_FILE);
114 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
115 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
116 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
117 g_assert (iface != NULL);
119 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
121 atspi_selection_select_child (iface, 2, NULL);
122 atspi_selection_select_child (iface, 3, NULL);
123 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 5);
125 atspi_selection_deselect_child (iface, 2, NULL);
126 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 4);
130 atk_test_selection_is_child_selected (gpointer fixture, gconstpointer user_data)
132 AtspiAccessible *obj = get_root_obj (DATA_FILE);
133 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
134 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
135 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
136 g_assert (iface != NULL);
138 g_assert (atspi_selection_is_child_selected (iface, 0, NULL));
139 g_assert (atspi_selection_is_child_selected (iface, 1, NULL));
140 g_assert (atspi_selection_is_child_selected (iface, 4, NULL));
141 g_assert (!atspi_selection_is_child_selected (iface, 2, NULL));
142 g_assert (!atspi_selection_is_child_selected (iface, 3, NULL));
146 atk_test_selection_select_all (gpointer fixture, gconstpointer user_data)
148 AtspiAccessible *obj = get_root_obj (DATA_FILE);
149 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
150 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
151 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
152 g_assert (iface != NULL);
154 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
155 atspi_selection_select_all (iface, NULL);
156 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 5);
160 atk_test_selection_clear_selection (gpointer fixture, gconstpointer user_data)
162 AtspiAccessible *obj = get_root_obj (DATA_FILE);
163 g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
164 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
165 AtspiSelection *iface = atspi_accessible_get_selection_iface (child);
166 g_assert (iface != NULL);
168 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 3);
169 atspi_selection_clear_selection (iface, NULL);
170 g_assert_cmpint (atspi_selection_get_n_selected_children (iface, NULL), ==, 0);
174 atk_test_selection (void)
176 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_sample_get_interface",
177 0, NULL, NULL, atk_test_selection_sample_get_interface, teardown_selection_test);
178 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_get_n_selected_children",
179 0, NULL, NULL, atk_test_selection_get_n_selected_children, teardown_selection_test);
180 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_get_selected_child",
181 0, NULL, NULL, atk_test_selection_get_selected_child, teardown_selection_test);
182 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_select_child",
183 0, NULL, NULL, atk_test_selection_select_child, teardown_selection_test);
184 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_deselect_selected",
185 0, NULL, NULL, atk_test_selection_deselect_selected, teardown_selection_test);
186 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_deselect_child",
187 0, NULL, NULL, atk_test_selection_deselect_child, teardown_selection_test);
188 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_is_child_selected",
189 0, NULL, NULL, atk_test_selection_is_child_selected, teardown_selection_test);
190 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_select_all",
191 0, NULL, NULL, atk_test_selection_select_all, teardown_selection_test);
192 g_test_add_vtable (ATK_TEST_PATH_SELECTION "/atk_test_selection_clear_selection",
193 0, NULL, NULL, atk_test_selection_clear_selection, teardown_selection_test);