1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
|
/*
* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "atk_suite.h"
#include "atk_test_util.h"
#define DATA_FILE TESTS_DATA_DIR"/test-accessible.xml"
static void
teardown_accessible_test (gpointer fixture, gconstpointer user_data)
{
kill (child_pid, SIGTERM);
}
static void
atk_test_accessible_get_name (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
}
static void
atk_test_accessible_get_description (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
g_assert_cmpstr (atspi_accessible_get_description (obj, NULL), ==, "Root of the accessible tree" );
}
static void
atk_test_accessible_get_child_count (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gint child_c = atspi_accessible_get_child_count (obj, NULL);
g_assert_cmpint ( 3, ==, child_c );
}
static void
atk_test_accessible_get_parent (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL );
AtspiAccessible *parent = atspi_accessible_get_parent (child, NULL );
g_assert (parent == obj );
}
static void
atk_test_accessible_get_child_at_index (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL );
g_assert_cmpstr (atspi_accessible_get_name (child, NULL), ==, "obj2");
}
static void
atk_test_accessible_get_index_in_parent (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 2, NULL);
int index = atspi_accessible_get_index_in_parent (child, NULL);
g_assert_cmpint (index, ==, 2);
}
static void
atk_test_accessible_get_relation_set_1 (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *child1 = atspi_accessible_get_child_at_index (obj, 1, NULL);
AtspiAccessible *child = atspi_accessible_get_child_at_index (child1, 0, NULL);
GArray *rel_set = atspi_accessible_get_relation_set (child, NULL);
g_assert_cmpint (rel_set->len, == , 1);
}
static void
atk_test_accessible_get_relation_set_2 (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *obj2 = atspi_accessible_get_child_at_index (obj, 1, NULL);
AtspiAccessible *obj2_1 = atspi_accessible_get_child_at_index (obj2, 0, NULL);
GArray *rel_set = atspi_accessible_get_relation_set (obj2_1, NULL);
int i=0;
for (i = 0; i < rel_set->len; i++) {
AtspiRelation *a = g_array_index (rel_set, AtspiRelation *, i);
g_assert_cmpint (atspi_relation_get_relation_type (a), == , ATSPI_RELATION_CONTROLLER_FOR );
g_assert_cmpint (atspi_relation_get_n_targets (a), ==, 1);
AtspiAccessible *target = atspi_relation_get_target (a, 0);
g_assert_cmpstr (atspi_accessible_get_name (target,NULL), == , "obj2");
}
}
static void
atk_test_accessible_get_role (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiRole root_role = atspi_accessible_get_role (obj, NULL);
g_assert_cmpint (root_role, ==, ATSPI_ROLE_ACCELERATOR_LABEL);
}
static void
atk_test_accessible_get_role_name (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *root_role_name = atspi_accessible_get_role_name (obj, NULL);
g_assert_cmpstr (root_role_name, ==, "accelerator label");
}
static void
atk_test_accessible_get_localized_role_name (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *root_role_name = atspi_accessible_get_localized_role_name (obj, NULL);
g_assert_cmpstr (root_role_name, ==, "accelerator label");
}
static void
atk_test_accessible_get_state_set (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL);
AtspiStateSet *states = atspi_accessible_get_state_set (child);
GArray *states_arr = atspi_state_set_get_states (states);
AtspiStateType valid_states[] = {
ATSPI_STATE_MODAL,
ATSPI_STATE_MULTI_LINE,
};
g_assert_cmpint (states_arr->len, ==, 2);
int i = 0;
for (i = 0; i < states_arr->len; ++i) {
g_assert_cmpint (valid_states[i], ==, g_array_index (states_arr, AtspiStateType, i));
g_assert (atspi_state_set_contains (states, ATSPI_STATE_MODAL));
g_assert (atspi_state_set_contains(states, ATSPI_STATE_MULTI_LINE));
}
}
static void
atk_test_accessible_get_attributes (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
GHashTable *attr_hash_tab = atspi_accessible_get_attributes (obj, NULL);
GHashTableIter iter;
gpointer key, value;
gchar *valid_keys[] = { "atspi" };
gchar *valid_values[] = { "test" };
g_hash_table_iter_init (&iter, attr_hash_tab );
int i = 0;
while (g_hash_table_iter_next (&iter, &key, &value)) {
g_assert_cmpstr (valid_keys[i], ==, (gchar *)key );
g_assert_cmpstr (valid_values[i], ==, (gchar *)value );
++i;
}
}
static void
atk_test_accessible_get_attributes_as_array (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *valid_attr[] = { "atspi:test", NULL };
GArray *attr_arr = atspi_accessible_get_attributes_as_array ( obj, NULL);
int i = 0;
g_assert (attr_arr->len == (sizeof(valid_attr)/sizeof(gchar *))-1);
for( i = 0; i < attr_arr->len; ++i) {
g_assert_cmpstr (valid_attr[i], ==, g_array_index (attr_arr, gchar *, i));
}
}
static void
atk_test_accessible_get_toolkit_name (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *toolkit_name = atspi_accessible_get_toolkit_name (obj, NULL);
g_assert_cmpstr (toolkit_name, ==, "atspitesting-toolkit");
}
static void
atk_test_accessible_get_toolkit_version (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *toolkit_ver = atspi_accessible_get_toolkit_version (obj, NULL);
/* should be empty string, because no value is setted */
g_assert_cmpstr (toolkit_ver, ==, "");
}
static void
atk_test_accessible_get_atspi_version (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *atspi_version = atspi_accessible_get_atspi_version (obj, NULL);
g_assert_cmpstr (atspi_version, ==, "2.1");
}
static void
atk_test_accessible_get_id (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gint app_id = atspi_accessible_get_id (obj, NULL);
g_assert_cmpint (app_id, !=, -1);
}
static void
atk_test_accessible_get_application (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAccessible *app = atspi_accessible_get_application (obj, NULL);
g_assert (app != NULL);
}
static void
atk_test_accessible_get_action_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiAction *iface = atspi_accessible_get_action_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_collection_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiCollection *iface = atspi_accessible_get_collection_iface (obj);
g_assert (iface != NULL);
}
static void
atk_test_accessible_get_component_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiComponent *iface = atspi_accessible_get_component_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_document_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiDocument *iface = atspi_accessible_get_document_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_editable_text_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_hypertext_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiHypertext *iface = atspi_accessible_get_hypertext_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_image_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiImage *iface = atspi_accessible_get_image_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_selection_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiSelection *iface = atspi_accessible_get_selection_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_table_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiTable *iface = atspi_accessible_get_table_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_text_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiText *iface = atspi_accessible_get_text_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_value_iface (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiValue *iface = atspi_accessible_get_value_iface (obj);
g_assert (iface == NULL);
}
static void
atk_test_accessible_get_interfaces (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
gchar *valid_obj_ifaces[] = { "Accessible", "Collection" };
GArray *ifaces = atspi_accessible_get_interfaces (obj);
g_assert (ifaces->len == 2);
int i = 0;
for (i = 0; i < ifaces->len; ++i)
g_assert_cmpstr (valid_obj_ifaces[i], ==, g_array_index (ifaces, gchar *, i));
}
static void
atk_test_accessible_get_object_locale (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
const gchar *obj_locale = atspi_accessible_get_object_locale (obj, NULL);
g_assert_cmpstr (obj_locale, ==, setlocale (LC_MESSAGES, NULL));
}
static void
atk_test_accessible_set_cache_mask (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
AtspiCache cache_mask = ATSPI_CACHE_ROLE;
atspi_accessible_set_cache_mask (obj, cache_mask);
g_assert_cmpint (obj->parent.app->cache, ==, cache_mask);
}
static void
atk_test_check_cache_cleared (AtspiAccessible *obj)
{
g_assert_cmpint (obj->cached_properties, ==, ATSPI_CACHE_NONE);
GPtrArray *array = obj->children;
int i;
for (i=0; i<array->len; i++)
atk_test_check_cache_cleared (g_ptr_array_index (array, i));
}
static void
atk_test_accessible_clear_cache (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
atspi_accessible_clear_cache (obj);
atk_test_check_cache_cleared (obj);
}
static void
atk_test_accessible_get_process_id (gpointer fixture, gconstpointer user_data)
{
AtspiAccessible *obj = get_root_obj (DATA_FILE);
guint proc_id = atspi_accessible_get_process_id (obj, NULL);
g_assert_cmpint (proc_id, ==, child_pid);
}
void
atk_test_accessible (void)
{
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accesible_get_name",
0, NULL, NULL, atk_test_accessible_get_name, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_description",
0, NULL, NULL, atk_test_accessible_get_description, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_child_count",
0, NULL, NULL, atk_test_accessible_get_child_count, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_parent",
0, NULL, NULL, atk_test_accessible_get_parent, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_child_at_index",
0, NULL, NULL, atk_test_accessible_get_child_at_index, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_index_in_parent",
0, NULL, NULL, atk_test_accessible_get_index_in_parent, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_relation_set_1",
0, NULL, NULL, atk_test_accessible_get_relation_set_1, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_relation_set_2",
0, NULL, NULL, atk_test_accessible_get_relation_set_2, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_role",
0, NULL, NULL, atk_test_accessible_get_role, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_role_name",
0, NULL, NULL, atk_test_accessible_get_role_name, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_localized_role_name",
0, NULL, NULL, atk_test_accessible_get_localized_role_name, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_state_set",
0, NULL, NULL, atk_test_accessible_get_state_set, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_attributes",
0, NULL, NULL, atk_test_accessible_get_attributes, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_attributes_as_array",
0, NULL, NULL, atk_test_accessible_get_attributes_as_array, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_toolkit_name",
0, NULL, NULL, atk_test_accessible_get_toolkit_name, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_toolkit_version",
0, NULL, NULL, atk_test_accessible_get_toolkit_version, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_atspi_version",
0, NULL, NULL, atk_test_accessible_get_atspi_version, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_id",
0, NULL, NULL, atk_test_accessible_get_id, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_application",
0, NULL, NULL, atk_test_accessible_get_application, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_action_iface",
0, NULL, NULL, atk_test_accessible_get_action_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_collection_iface",
0, NULL, NULL, atk_test_accessible_get_collection_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_component_iface",
0, NULL, NULL, atk_test_accessible_get_component_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_document_iface",
0, NULL, NULL, atk_test_accessible_get_document_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_editable_text_iface",
0, NULL, NULL, atk_test_accessible_get_editable_text_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_hypertext_iface",
0, NULL, NULL, atk_test_accessible_get_hypertext_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_image_iface",
0, NULL, NULL, atk_test_accessible_get_image_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_selection_iface",
0, NULL, NULL, atk_test_accessible_get_selection_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_table_iface",
0, NULL, NULL, atk_test_accessible_get_table_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_text_iface",
0, NULL, NULL, atk_test_accessible_get_text_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_value_iface",
0, NULL, NULL, atk_test_accessible_get_value_iface, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_interfaces",
0, NULL, NULL, atk_test_accessible_get_interfaces, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_object_locale",
0, NULL, NULL, atk_test_accessible_get_object_locale, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_set_cache_mask",
0, NULL, NULL, atk_test_accessible_set_cache_mask, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_clear_cache",
0, NULL, NULL, atk_test_accessible_clear_cache, teardown_accessible_test);
g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_process_id",
0, NULL, NULL, atk_test_accessible_get_process_id, teardown_accessible_test);
}
|