Example #1
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;
}
Example #2
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;
}
Example #4
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);
}
Example #5
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);
  }
}