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-component.xml"
29 teardown_component_test (gpointer fixture, gconstpointer user_data)
35 atk_test_component_sample (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, 1, NULL);
40 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
41 g_assert (iface != NULL);
45 atk_test_component_contains (gpointer fixture, gconstpointer user_data)
47 AtspiAccessible *obj = get_root_obj (DATA_FILE);
48 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
49 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
50 g_assert (iface != NULL);
52 gboolean ret = atspi_component_contains (iface, 400, 300, ATSPI_COORD_TYPE_SCREEN, NULL);
53 g_assert (ret != FALSE);
57 atk_test_component_get_accessible_at_point (gpointer fixture, gconstpointer user_data)
59 AtspiAccessible *obj = get_root_obj (DATA_FILE);
60 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
61 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
62 g_assert (iface != NULL);
64 AtspiAccessible *r = atspi_component_get_accessible_at_point (iface,
67 ATSPI_COORD_TYPE_SCREEN,
73 atk_test_component_get_extents (gpointer fixture, gconstpointer user_data)
75 AtspiAccessible *obj = get_root_obj (DATA_FILE);
76 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
77 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
78 g_assert (iface != NULL);
80 AtspiRect *r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL);
81 g_assert_cmpint (r->x, ==, 350);
82 g_assert_cmpint (r->y, ==, 200);
83 g_assert_cmpint (r->width, ==, 250);
84 g_assert_cmpint (r->height, ==, 250);
89 atk_test_component_get_layer (gpointer fixture, gconstpointer user_data)
91 AtspiAccessible *obj = get_root_obj (DATA_FILE);
92 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
93 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
94 g_assert (iface != NULL);
96 AtspiComponentLayer layer = atspi_component_get_layer (iface, NULL);
97 g_assert_cmpint (layer, ==, ATSPI_LAYER_WIDGET);
101 atk_test_component_get_mdi_z_order (gpointer fixture, gconstpointer user_data)
103 AtspiAccessible *obj = get_root_obj (DATA_FILE);
104 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
105 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
106 g_assert (iface != NULL);
108 gshort ret = atspi_component_get_mdi_z_order (iface, NULL);
109 g_assert_cmpint (ret, ==, 2);
113 atk_test_component_grab_focus (gpointer fixture, gconstpointer user_data)
115 AtspiAccessible *obj = get_root_obj (DATA_FILE);
116 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
117 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
118 g_assert (iface != NULL);
120 gboolean ret = atspi_component_grab_focus (iface, NULL);
121 g_assert (ret != FALSE);
125 atk_test_component_get_alpha (gpointer fixture, gconstpointer user_data)
127 AtspiAccessible *obj = get_root_obj (DATA_FILE);
128 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
129 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
130 g_assert (iface != NULL);
132 gdouble ret = atspi_component_get_alpha (iface, NULL);
133 g_assert_cmpint (ret, ==, 2.5);
137 atk_test_component_set_extents (gpointer fixture, gconstpointer user_data)
139 AtspiAccessible *obj = get_root_obj (DATA_FILE);
140 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
141 AtspiComponent *iface = atspi_accessible_get_component_iface (child);
142 g_assert (iface != NULL);
144 AtspiRect *r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL);
145 g_assert_cmpint (r->x, ==, 350);
146 g_assert_cmpint (r->y, ==, 200);
147 g_assert_cmpint (r->width, ==, 250);
148 g_assert_cmpint (r->height, ==, 250);
151 gboolean ret = atspi_component_set_extents (iface, 100, 100, 100, 100, ATSPI_COORD_TYPE_SCREEN, NULL);
152 g_assert (ret != FALSE);
154 r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL);
155 g_assert_cmpint (r->x, ==, 100);
156 g_assert_cmpint (r->y, ==, 100);
157 g_assert_cmpint (r->width, ==, 100);
158 g_assert_cmpint (r->height, ==, 100);
163 atk_test_component (void)
165 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_sample",
166 0, NULL, NULL, atk_test_component_sample, teardown_component_test);
167 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_contains",
168 0, NULL, NULL, atk_test_component_contains, teardown_component_test);
169 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_accessible_at_point",
170 0, NULL, NULL, atk_test_component_get_accessible_at_point, teardown_component_test);
171 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_extents",
172 0, NULL, NULL, atk_test_component_get_extents, teardown_component_test);
173 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_layer",
174 0, NULL, NULL, atk_test_component_get_layer, teardown_component_test);
175 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_mdi_z_order",
176 0, NULL, NULL, atk_test_component_get_mdi_z_order, teardown_component_test);
177 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_grab_focus",
178 0, NULL, NULL, atk_test_component_grab_focus, teardown_component_test);
179 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_alpha",
180 0, NULL, NULL, atk_test_component_get_alpha, teardown_component_test);
181 g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_set_extents",
182 0, NULL, NULL, atk_test_component_set_extents, teardown_component_test);