static void testAtspiBasicHierarchy(WebViewTest* test, gconstpointer)
{
    // The test server's accessibility object (UI Process).
    GRefPtr<AtspiAccessible> testServerApp = findTestServerApplication();
    g_assert(ATSPI_IS_ACCESSIBLE(testServerApp.get()));
    checkAtspiAccessible(testServerApp.get(), "AccessibilityTestServer", ATSPI_ROLE_APPLICATION);

    // The main window's accessibility object (UI Process).
    GRefPtr<AtspiAccessible> currentParent = testServerApp;
    GRefPtr<AtspiAccessible> currentChild = adoptGRef(atspi_accessible_get_child_at_index(currentParent.get(), 0, 0));
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FRAME);

    // The WebView's accessibility object (UI Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);

    // The WebPage's accessibility object (Web Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);

    // HTML root element's accessible element (Web Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));

    // HTML body's accessible element (Web Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_DOCUMENT_FRAME);

    // HTML H1's accessible element (Web Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "This is a test", ATSPI_ROLE_HEADING);

    // HTML first paragraph's accessible element (Web Process).
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 1, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);

    // HTML second paragraph's accessible element (Web Process).
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 2, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);

    // HTML link's accessible element (Web Process).
    currentParent = currentChild;
    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
    g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get()));
    checkAtspiAccessible(currentChild.get(), "a link", ATSPI_ROLE_LINK);
}
Ejemplo n.º 2
0
int main(int argc, gchar **argv)
{
  gint i;
  AtspiAccessible *desktop = NULL;
  AtspiAccessible *app = NULL;
  gchar *app_name = NULL;
  gboolean found = FALSE;

  app_name = parse_args (&argc, &argv);
  if (!app_name) {
    g_print ("ERROR: We only dump the content of a specific app, specify the name\n");
    return 0;
  }

  atspi_init ();

  desktop = atspi_get_desktop (0);
  for (i = 0; i < atspi_accessible_get_child_count (desktop, NULL); i++) {
    app = atspi_accessible_get_child_at_index (desktop, i, NULL);
    if (!g_strcmp0 (atspi_accessible_get_name (app, NULL), app_name)) {
      found = TRUE;
      dump_node_content (app, "  ");
    }
    g_object_unref (app);
  }

  if (!found) {
    g_print ("ERROR: Application \"%s\" not found\n", app_name);
    return 0;
  }

  return 1;
}
Ejemplo n.º 3
0
AtspiAccessible * get_root_obj (const char *file_name)
{
  int i;
  AtspiAccessible *obj = NULL;

  run_app (file_name);

  /* sleep is needed to wait for fored test application*/
  sleep (1);

  obj = atspi_get_desktop (0);
  gint child_count = atspi_accessible_get_child_count (obj, NULL);
  if (child_count < 1) {
    g_test_message ("Fail, test application not found\n");
    g_test_fail ();
    kill (child_pid, SIGTERM);
    return NULL;
  }

  for (i=0; i<child_count; i++) {
    AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,i, NULL);
    if (!strcmp (atspi_accessible_get_name (child, NULL), "root_object"))
      return child;
  }
  g_test_message ("test object not found\n");
  g_test_fail ();

  kill (child_pid, SIGTERM);
  return NULL;
}
static GRefPtr<AtspiAccessible> findTestServerApplication()
{
    // Only one desktop is supported by ATSPI at the moment.
    GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0));

    // Look for the server application in the list of apps.
    GRefPtr<AtspiAccessible> current;
    int childCount = atspi_accessible_get_child_count(desktop.get(), 0);
    for (int i = 0; i < childCount; i++) {
        current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, 0));
        if (!g_strcmp0(atspi_accessible_get_name(current.get(), 0), kTestServerAppName))
            return current;
    }

    return 0;
}
Ejemplo n.º 5
0
static void
dump_node_content (AtspiAccessible *node,
                   gchar *padding)
{
  AtspiAccessible *inner_node = NULL;
  gint c;
  gchar *new_padding = g_strdup_printf ("  %s", padding);
  gchar *string = NULL;

  string = print_info (node);
  g_print ("%s%s\n", padding, string);

  for (c = 0; c < atspi_accessible_get_child_count (node, NULL); c++) {
    inner_node = atspi_accessible_get_child_at_index (node, c, NULL);
    dump_node_content (inner_node, new_padding);
    g_object_unref (inner_node);
  }

  g_free (string);
  g_free (new_padding);
}
Ejemplo n.º 6
0
void
basic (AtspiAccessible *obj)
{
  gchar *str;
  gint count;
  gint i;
  AtspiAccessible *accessible;
  GError *error = NULL;

  str = atspi_accessible_get_name (obj, &error);
  if (str)
    g_free (str);
  accessible = atspi_accessible_get_parent (obj, NULL);
  if (accessible)
    g_object_unref (accessible);
  count = atspi_accessible_get_child_count (obj, &error);
  for (i = 0; i < count; i++)
  {
    accessible = atspi_accessible_get_child_at_index (obj, i, &error);
    if (accessible)
      g_object_unref (accessible);
  }
}