Blame tests/atk_test_hypertext.c

Packit f2f3b5
/*
Packit f2f3b5
 * Copyright 2008 Codethink Ltd.
Packit f2f3b5
 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
Packit f2f3b5
 *
Packit f2f3b5
 * This library is free software; you can redistribute it and/or
Packit f2f3b5
 * modify it under the terms of the GNU Library General Public
Packit f2f3b5
 * License as published by the Free Software Foundation; either
Packit f2f3b5
 * version 2 of the License, or (at your option) any later version.
Packit f2f3b5
 *
Packit f2f3b5
 * This library is distributed in the hope that it will be useful,
Packit f2f3b5
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f2f3b5
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f2f3b5
 * Library General Public License for more details.
Packit f2f3b5
 *
Packit f2f3b5
 * You should have received a copy of the GNU Library General Public
Packit f2f3b5
 * License along with this library; if not, write to the
Packit f2f3b5
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit f2f3b5
 * Boston, MA 02111-1307, USA.
Packit f2f3b5
 */
Packit f2f3b5
Packit f2f3b5
#include "atk_test_util.h"
Packit f2f3b5
#include "atk_suite.h"
Packit f2f3b5
Packit f2f3b5
#define DATA_FILE TESTS_DATA_DIR"/test-hypertext.xml"
Packit f2f3b5
Packit f2f3b5
static void
Packit f2f3b5
atk_test_hypertext_get_n_links (gpointer fixture, gconstpointer user_data)
Packit f2f3b5
{
Packit f2f3b5
  AtspiAccessible *_obj = get_root_obj (DATA_FILE);
Packit f2f3b5
  g_assert (_obj);
Packit f2f3b5
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
Packit f2f3b5
  g_assert (child);
Packit f2f3b5
  AtspiHypertext *obj = atspi_accessible_get_hypertext_iface (child);
Packit f2f3b5
  g_assert (obj);
Packit f2f3b5
  gint cnt = atspi_hypertext_get_n_links (obj, NULL);
Packit f2f3b5
  g_assert_cmpint (cnt, ==, 2);
Packit f2f3b5
}
Packit f2f3b5
Packit f2f3b5
static void
Packit f2f3b5
atk_test_hypertext_get_link (gpointer fixture, gconstpointer user_data)
Packit f2f3b5
{
Packit f2f3b5
  AtspiAccessible *_obj = get_root_obj (DATA_FILE);
Packit f2f3b5
  g_assert (_obj);
Packit f2f3b5
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
Packit f2f3b5
  g_assert (child);
Packit f2f3b5
  AtspiHypertext *obj = atspi_accessible_get_hypertext_iface (child);
Packit f2f3b5
  g_assert (obj);
Packit f2f3b5
  AtspiHyperlink *link = atspi_hypertext_get_link (obj, 1, NULL);
Packit f2f3b5
  g_assert (link);
Packit f2f3b5
  gchar *str = atspi_hyperlink_get_uri (link, 0, NULL);
Packit f2f3b5
  g_assert (str);
Packit f2f3b5
  g_assert_cmpstr (str, ==, "pinkbike.com");
Packit f2f3b5
Packit f2f3b5
  g_free (str);
Packit f2f3b5
Packit f2f3b5
  link = atspi_hypertext_get_link (obj, 0, NULL);
Packit f2f3b5
  str = atspi_hyperlink_get_uri (link, 0, NULL);
Packit f2f3b5
  g_assert_cmpstr (str, ==, "dh-zone.com");
Packit f2f3b5
Packit f2f3b5
  g_free (str);
Packit f2f3b5
}
Packit f2f3b5
Packit f2f3b5
static void
Packit f2f3b5
atk_test_hypertext_get_link_index (gpointer fixture, gconstpointer user_data)
Packit f2f3b5
{
Packit f2f3b5
  AtspiAccessible *_obj = get_root_obj (DATA_FILE);
Packit f2f3b5
  g_assert (_obj);
Packit f2f3b5
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
Packit f2f3b5
  g_assert (child);
Packit f2f3b5
  AtspiHypertext *obj = atspi_accessible_get_hypertext_iface (child);
Packit f2f3b5
  g_assert (obj);
Packit f2f3b5
  gint cnt = atspi_hypertext_get_link_index (obj, 15, NULL);
Packit f2f3b5
  g_assert_cmpint (cnt, ==, -1);
Packit f2f3b5
  cnt = atspi_hypertext_get_link_index (obj, 55, NULL);
Packit f2f3b5
  g_assert_cmpint (cnt, ==, 0);
Packit f2f3b5
  cnt = atspi_hypertext_get_link_index (obj, 70, NULL);
Packit f2f3b5
  g_assert_cmpint (cnt, ==, 1);
Packit f2f3b5
}
Packit f2f3b5
Packit f2f3b5
static void
Packit f2f3b5
teardown_hypertext_test (gpointer fixture, gconstpointer user_data)
Packit f2f3b5
{
Packit f2f3b5
  kill (child_pid, SIGTERM);
Packit f2f3b5
}
Packit f2f3b5
Packit f2f3b5
void
Packit f2f3b5
atk_test_hypertext (void)
Packit f2f3b5
{
Packit f2f3b5
  g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_n_links",
Packit f2f3b5
                     0, NULL, NULL, atk_test_hypertext_get_n_links, teardown_hypertext_test );
Packit f2f3b5
  g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_links",
Packit f2f3b5
                     0, NULL, NULL, atk_test_hypertext_get_link, teardown_hypertext_test );
Packit f2f3b5
  g_test_add_vtable (ATK_TEST_PATH_HYPERTEXT "/atk_test_hypertext_get_link_index",
Packit f2f3b5
                     0, NULL, NULL, atk_test_hypertext_get_link_index, teardown_hypertext_test );
Packit f2f3b5
}