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 Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include "atk_test_util.h"
22 #include "atk_suite.h"
24 #define DATA_FILE TESTS_DATA_DIR"/test-hypertext.xml"
27 atk_test_hyperlink_get_n_anchors (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 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
35 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
37 gint n = atspi_hyperlink_get_n_anchors (obj, NULL);
38 g_assert_cmpint (n, ==, 1);
42 atk_test_hyperlink_get_uri (gpointer fixture, gconstpointer user_data)
44 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
46 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
48 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
50 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
52 gchar *str = atspi_hyperlink_get_uri (obj, 0, NULL);
54 g_assert_cmpstr (str, ==, "pinkbike.com");
58 atk_test_hyperlink_get_object (gpointer fixture, gconstpointer user_data)
60 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
62 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
64 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
66 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
68 AtspiAccessible *acc = atspi_hyperlink_get_object (obj, 0, NULL);
70 AtspiText *at = atspi_accessible_get_text_iface (acc);
72 gchar *text = atspi_text_get_text (at, 0, 12, NULL);
73 g_assert_cmpstr (text,==,"pinkbike.com");
78 atk_test_hyperlink_get_index_range (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 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
86 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
88 AtspiRange *range = atspi_hyperlink_get_index_range (obj, NULL);
91 ATK do not define this function
93 g_assert_cmpint (range->start_offset, ==, -1);
94 g_assert_cmpint (range->end_offset, ==, -1);
99 atk_test_hyperlink_get_start_index (gpointer fixture, gconstpointer user_data)
101 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
103 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
105 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
107 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
109 gint n = atspi_hyperlink_get_start_index (obj, NULL);
110 g_assert_cmpint (n, ==, 69);
114 atk_test_hyperlink_get_end_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 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
122 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
124 gint n = atspi_hyperlink_get_end_index (obj, NULL);
125 g_assert_cmpint (n, ==, 81);
129 atk_test_hyperlink_is_valid (gpointer fixture, gconstpointer user_data)
131 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
133 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
135 AtspiHypertext *obj1 = atspi_accessible_get_hypertext_iface (child);
137 AtspiHyperlink *obj = atspi_hypertext_get_link (obj1, 1, NULL);
139 g_assert (atspi_hyperlink_is_valid (obj, NULL));
143 teardown_hyperlink_test (gpointer fixture, gconstpointer user_data)
149 atk_test_hyperlink(void)
151 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_n_anchors",
152 0, NULL, NULL, atk_test_hyperlink_get_n_anchors, teardown_hyperlink_test );
153 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_uri",
154 0, NULL, NULL, atk_test_hyperlink_get_uri, teardown_hyperlink_test);
155 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_object",
156 0, NULL, NULL, atk_test_hyperlink_get_object, teardown_hyperlink_test);
157 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_index_range",
158 0, NULL, NULL, atk_test_hyperlink_get_index_range, teardown_hyperlink_test);
159 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_start_index",
160 0, NULL, NULL, atk_test_hyperlink_get_start_index, teardown_hyperlink_test);
161 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_get_end_index",
162 0, NULL, NULL, atk_test_hyperlink_get_end_index, teardown_hyperlink_test);
163 g_test_add_vtable(ATK_TEST_PATH_HYPERTEXT "/atk_test_hyperlink_is_valid",
164 0, NULL, NULL, atk_test_hyperlink_is_valid, teardown_hyperlink_test);