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_hypertext_get_n_links (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 *obj = atspi_accessible_get_hypertext_iface (child);
35 gint cnt = atspi_hypertext_get_n_links (obj, NULL);
36 g_assert_cmpint (cnt, ==, 2);
40 atk_test_hypertext_get_link (gpointer fixture, gconstpointer user_data)
42 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
44 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
46 AtspiHypertext *obj = atspi_accessible_get_hypertext_iface (child);
48 AtspiHyperlink *link = atspi_hypertext_get_link (obj, 1, NULL);
50 gchar *str = atspi_hyperlink_get_uri (link, 0, NULL);
52 g_assert_cmpstr (str, ==, "pinkbike.com");
56 link = atspi_hypertext_get_link (obj, 0, NULL);
57 str = atspi_hyperlink_get_uri (link, 0, NULL);
58 g_assert_cmpstr (str, ==, "dh-zone.com");
64 atk_test_hypertext_get_link_index (gpointer fixture, gconstpointer user_data)
66 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
68 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
70 AtspiHypertext *obj = atspi_accessible_get_hypertext_iface (child);
72 gint cnt = atspi_hypertext_get_link_index (obj, 15, NULL);
73 g_assert_cmpint (cnt, ==, -1);
74 cnt = atspi_hypertext_get_link_index (obj, 55, NULL);
75 g_assert_cmpint (cnt, ==, 0);
76 cnt = atspi_hypertext_get_link_index (obj, 70, NULL);
77 g_assert_cmpint (cnt, ==, 1);
81 teardown_hypertext_test (gpointer fixture, gconstpointer user_data)
87 atk_test_hypertext (void)
89 g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_n_links",
90 0, NULL, NULL, atk_test_hypertext_get_n_links, teardown_hypertext_test );
91 g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_links",
92 0, NULL, NULL, atk_test_hypertext_get_link, teardown_hypertext_test );
93 g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_link_index",
94 0, NULL, NULL, atk_test_hypertext_get_link_index, teardown_hypertext_test );