static void test_webkit_atk_get_text_at_offset_text_input(void) { WebKitWebView* webView; AtkObject* obj; GMainLoop* loop; AtkText* text_obj; webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_object_ref_sink(webView); GtkAllocation alloc = { 0, 0, 800, 600 }; gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); webkit_web_view_load_string(webView, contentsInTextInput, NULL, NULL, NULL); loop = g_main_loop_new(NULL, TRUE); g_timeout_add(100, (GSourceFunc)bail_out, loop); g_main_loop_run(loop); /* Get to the inner AtkText object */ obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); g_assert(obj); obj = atk_object_ref_accessible_child(obj, 0); g_assert(obj); obj = atk_object_ref_accessible_child(obj, 0); g_assert(obj); text_obj = ATK_TEXT(obj); g_assert(ATK_IS_TEXT(text_obj)); run_get_text_tests(text_obj); g_object_unref(webView); }
static void test_webkit_atk_get_role_combobox(AtkRolesFixture *fixture, gconstpointer data) { AtkObject* comboboxMenu; // This is an extraneous object of ATK_ROLE_PANEL which we should get rid of. fixture->obj = atk_object_ref_accessible_child(fixture->documentFrame, 0); g_assert(fixture->obj); fixture->obj = atk_object_ref_accessible_child(fixture->obj, 0); g_assert(fixture->obj); fixture->role = atk_object_get_role(fixture->obj); g_assert(fixture->role == ATK_ROLE_COMBO_BOX); comboboxMenu = atk_object_ref_accessible_child(fixture->obj, 0); g_assert(comboboxMenu); fixture->role = atk_object_get_role(comboboxMenu); g_assert(fixture->role == ATK_ROLE_MENU); get_child_and_test_role(comboboxMenu, 0, ATK_ROLE_MENU_ITEM); get_child_and_test_role(comboboxMenu, 1, ATK_ROLE_MENU_ITEM); get_child_and_test_role(comboboxMenu, 2, ATK_ROLE_MENU_ITEM); g_object_unref(fixture->obj); g_object_unref(comboboxMenu); }
/* * We redefine atk_class->ref_relation_set instead of just calling * atk_object_add_relationship on ev_page_accessible_new because at * that moment not all the pages could be created, being easier add * the relation on demand. */ static AtkRelationSet * ev_page_accessible_ref_relation_set (AtkObject *accessible) { gint n_pages; EvPageAccessible *self; AtkRelationSet *relation_set; AtkObject *accessible_array[1]; AtkRelation *relation; g_return_val_if_fail (EV_IS_PAGE_ACCESSIBLE (accessible), NULL); self = EV_PAGE_ACCESSIBLE (accessible); relation_set = ATK_OBJECT_CLASS (ev_page_accessible_parent_class)->ref_relation_set (accessible); if (relation_set == NULL) return NULL; n_pages = ev_view_accessible_get_n_pages (self->priv->view_accessible); if (n_pages == 0) return relation_set; if ((self->priv->page + 1) < n_pages && !atk_relation_set_contains (relation_set, ATK_RELATION_FLOWS_TO)) { AtkObject *next_page; next_page = atk_object_ref_accessible_child (ATK_OBJECT (self->priv->view_accessible), self->priv->page + 1); accessible_array [0] = next_page; relation = atk_relation_new (accessible_array, 1, ATK_RELATION_FLOWS_TO); atk_relation_set_add (relation_set, relation); g_object_unref (relation); g_object_unref (next_page); } if (self->priv->page > 0 && !atk_relation_set_contains (relation_set, ATK_RELATION_FLOWS_FROM)) { AtkObject *prev_page; prev_page = atk_object_ref_accessible_child (ATK_OBJECT (self->priv->view_accessible), self->priv->page - 1); accessible_array [0] = prev_page; relation = atk_relation_new (accessible_array, 1, ATK_RELATION_FLOWS_FROM); atk_relation_set_add (relation_set, relation); g_object_unref (relation); g_object_unref (prev_page); } return relation_set; }
static void gail_notebook_page_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type) { AtkObject *atk_label; g_return_if_fail (GAIL_IS_NOTEBOOK_PAGE (component)); atk_label = _gail_notebook_page_get_tab_label (GAIL_NOTEBOOK_PAGE (component)); if (!atk_label) { AtkObject *child; *width = 0; *height = 0; child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0); gail_return_if_fail (child); atk_component_get_position (ATK_COMPONENT (child), x, y, coord_type); g_object_unref (child); } else { atk_component_get_extents (ATK_COMPONENT (atk_label), x, y, width, height, coord_type); } return; }
static void _test_layout_object(AtkObject *object) { int child_count; eail_test_code_called++; child_count = atk_object_get_n_accessible_children(object); if (eail_test_code_called == 1) g_assert(2 == child_count); else g_assert(3 == child_count); for(int i =0; i < child_count; i++) { AtkObject *child = atk_object_ref_accessible_child(object, i); gboolean success = FALSE; if (eail_test_code_called == 1) success = eailu_is_object_with_role(child, ATK_ROLE_ICON); else success = eailu_is_object_with_role(child, ATK_ROLE_PUSH_BUTTON); g_object_unref(child); g_assert(success); } g_assert(eailu_is_object_with_role(object, ATK_ROLE_FILLER)); }
static void _do_test(AtkObject *obj) { const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj)); const char *type_name_child; AtkObject *xobj; _printf("type_name: %s\n", type_name); g_assert_cmpstr(type_name, ==, "EailBubble"); // test children g_assert(2 == atk_object_get_n_accessible_children(obj)); for (int count = 0; 2 > count; count++) { xobj = atk_object_ref_accessible_child(obj, count); g_assert(xobj); type_name_child = g_type_name(G_TYPE_FROM_INSTANCE(xobj)); _printf(" child num: %d, type_name: %s\n", count, type_name_child); g_assert(!strcmp(type_name_child, "EailIcon") || !strcmp(type_name_child, "EailLabel")); } // test AtkAction g_assert(ACTIONS_NUMBER == atk_action_get_n_actions(ATK_ACTION(obj))); eailu_test_action_activate(ATK_ACTION(obj), "click"); g_assert(-1 == (eailu_get_action_number(ATK_ACTION(obj), "typo"))); eailu_test_action_description_all(ATK_ACTION(obj)); /* bubble object does not support focus */ eailu_test_atk_focus(obj, FALSE); }
static AtkObject* gtk_icon_view_accessible_ref_selection (AtkSelection *selection, gint i) { GList *l; GtkWidget *widget; GtkIconView *icon_view; GtkIconViewItem *item; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); if (widget == NULL) return NULL; icon_view = GTK_ICON_VIEW (widget); l = icon_view->priv->items; while (l) { item = l->data; if (item->selected) { if (i == 0) return atk_object_ref_accessible_child (gtk_widget_get_accessible (widget), item->index); else i--; } l = l->next; } return NULL; }
static AtkObject* gail_combo_box_ref_selection (AtkSelection *selection, gint i) { GtkComboBox *combo_box; GtkWidget *widget; AtkObject *obj; gint index; widget = GTK_ACCESSIBLE (selection)->widget; if (widget == NULL) /* * State is defunct */ return NULL; combo_box = GTK_COMBO_BOX (widget); /* * A combo_box box can have only one selection. */ if (i != 0) return NULL; obj = gtk_combo_box_get_popup_accessible (combo_box); index = gtk_combo_box_get_active (combo_box); return atk_object_ref_accessible_child (obj, index); }
static void _test_selection (AtkObject *obj) { gint count; gint n_children; AtkObject *list; count = atk_selection_get_selection_count (ATK_SELECTION (obj)); g_return_if_fail (count == 0); list = atk_object_ref_accessible_child (obj, 0); n_children = atk_object_get_n_accessible_children (list); g_object_unref (G_OBJECT (list)); atk_selection_add_selection (ATK_SELECTION (obj), n_children - 1); count = atk_selection_get_selection_count (ATK_SELECTION (obj)); g_return_if_fail (count == 1); g_return_if_fail (atk_selection_is_child_selected (ATK_SELECTION (obj), n_children - 1)); atk_selection_add_selection (ATK_SELECTION (obj), 0); count = atk_selection_get_selection_count (ATK_SELECTION (obj)); g_return_if_fail (count == 1); g_return_if_fail (atk_selection_is_child_selected (ATK_SELECTION (obj), 0)); atk_selection_clear_selection (ATK_SELECTION (obj)); count = atk_selection_get_selection_count (ATK_SELECTION (obj)); g_return_if_fail (count == 0); }
static DBusMessage * impl_GetChildren (DBusConnection * bus, DBusMessage * message, void *user_data) { AtkObject *object = (AtkObject *) user_data; gint i; gint count; DBusMessage *reply; DBusMessageIter iter, iter_array; g_return_val_if_fail (ATK_IS_OBJECT (user_data), droute_not_yet_handled_error (message)); count = atk_object_get_n_accessible_children (object); reply = dbus_message_new_method_return (message); if (!reply) goto oom; dbus_message_iter_init_append (reply, &iter); if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(so)", &iter_array)) goto oom; for (i = 0; i < count; i++) { AtkObject *child = atk_object_ref_accessible_child (object, i); spi_object_append_reference (&iter_array, child); if (child) g_object_unref (child); } if (!dbus_message_iter_close_container (&iter, &iter_array)) goto oom; return reply; oom: // TODO: handle out-of-memory return reply; }
static AtkObject* _find_object (AtkObject *obj, AtkRole role) { /* * Find the first object which is a descendant of the specified object * which matches the specified role. * * This function returns a reference to the AtkObject which should be * removed when finished with the object. */ gint i; gint n_children; AtkObject *child; n_children = atk_object_get_n_accessible_children (obj); for (i = 0; i < n_children; i++) { AtkObject* found_obj; child = atk_object_ref_accessible_child (obj, i); if (atk_object_get_role (child) == role) { return child; } found_obj = _find_object (child, role); g_object_unref (child); if (found_obj) { return found_obj; } } return NULL; }
static gboolean gail_notebook_check_focus_tab (gpointer data) { GtkWidget *widget; AtkObject *atk_obj; gint focus_page_num, old_focus_page_num; GailNotebook *gail_notebook; GtkNotebook *gtk_notebook; atk_obj = ATK_OBJECT (data); gail_notebook = GAIL_NOTEBOOK (atk_obj); widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_obj)); gtk_notebook = GTK_NOTEBOOK (widget); gail_notebook->idle_focus_id = 0; focus_page_num = gtk_notebook_get_current_page (gtk_notebook); if (focus_page_num == -1) return FALSE; old_focus_page_num = gail_notebook->focus_tab_page; gail_notebook->focus_tab_page = focus_page_num; if (old_focus_page_num != focus_page_num) { AtkObject *obj; obj = atk_object_ref_accessible_child (atk_obj, focus_page_num); atk_focus_tracker_notify (obj); g_object_unref (obj); } return FALSE; }
static void testWebkitAtkGetTextInTable(void) { WebKitWebView* webView; AtkObject* obj; GMainLoop* loop; webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_object_ref_sink(webView); GtkAllocation alloc = { 0, 0, 800, 600 }; gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); webkit_web_view_load_string(webView, contentsInTable, NULL, NULL, NULL); loop = g_main_loop_new(NULL, TRUE); g_timeout_add(100, (GSourceFunc)bail_out, loop); g_main_loop_run(loop); obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); g_assert(obj); obj = atk_object_ref_accessible_child(obj, 0); g_assert(obj); /* Tables should not implement AtkText */ g_assert(G_TYPE_INSTANCE_GET_INTERFACE(obj, ATK_TYPE_TEXT, AtkTextIface) == NULL); g_object_unref(obj); g_object_unref(webView); }
void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned start, unsigned end) { for (unsigned i = start; i < end; i++) { AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i); elementVector.append(AccessibilityUIElement(child)); } }
void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>& children) { int count = childrenCount(); for (int i = 0; i < count; i++) { AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i); children.append(AccessibilityUIElement(child)); } }
static AtkObject* get_accessible_for_widget (GtkWidget *widget, gboolean *transient) { AtkObject *obj = NULL; *transient = FALSE; if (!widget) return NULL; if (GTK_IS_ENTRY (widget)) ; else if (GTK_IS_NOTEBOOK (widget)) { GtkNotebook *notebook; gint page_num = -1; notebook = GTK_NOTEBOOK (widget); page_num = gtk_notebook_get_current_page (notebook); if (page_num != -1) { obj = gtk_widget_get_accessible (widget); obj = atk_object_ref_accessible_child (obj, page_num); g_object_unref (obj); } } else if (GTK_IS_TOGGLE_BUTTON (widget)) { GtkWidget *other_widget = gtk_widget_get_parent (widget); if (GTK_IS_COMBO_BOX (other_widget)) { gail_set_focus_widget (other_widget, widget); widget = other_widget; } } if (obj == NULL) { AtkObject *focus_object; obj = gtk_widget_get_accessible (widget); focus_object = g_object_get_qdata (G_OBJECT (obj), quark_focus_object); /* * We check whether the object for this focus_object has been deleted. * This can happen when navigating to an empty directory in nautilus. * See bug #141907. */ if (ATK_IS_GOBJECT_ACCESSIBLE (focus_object)) { if (!atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (focus_object))) focus_object = NULL; } if (focus_object) obj = focus_object; } return obj; }
static void _check_children (AtkObject *obj) { gint n_children, i, j; AtkObject *child; AtkObject *grand_child; n_children = atk_object_get_n_accessible_children (obj); if (n_children > 1) { g_print ("*** Unexpected number of children for combo box: %d\n", n_children); return; } if (n_children == 2) { child = atk_object_ref_accessible_child (obj, 1); g_return_if_fail (atk_object_get_role (child) == ATK_ROLE_TEXT); j = atk_object_get_index_in_parent (child); if (j != 1) g_print ("*** inconsistency between parent and children %d %d ***\n", 1, j); g_object_unref (G_OBJECT (child)); } child = atk_object_ref_accessible_child (obj, 0); g_return_if_fail (atk_object_get_role (child) == ATK_ROLE_LIST); j = atk_object_get_index_in_parent (child); if (j != 0) g_print ("*** inconsistency between parent and children %d %d ***\n", 0, j); n_children = atk_object_get_n_accessible_children (child); for (i = 0; i < n_children; i++) { G_CONST_RETURN gchar *name; grand_child = atk_object_ref_accessible_child (child, i); name = atk_object_get_name (grand_child); g_print ("Index: %d Name: %s\n", i, name ? name : "<NULL>"); g_object_unref (G_OBJECT (grand_child)); } g_object_unref (G_OBJECT (child)); }
static void testWebkitAtkGetTextInParagraphAndBodyModerate(void) { WebKitWebView* webView; AtkObject* obj; AtkObject* obj1; AtkObject* obj2; GMainLoop* loop; AtkText* textObj1; AtkText* textObj2; webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_object_ref_sink(webView); GtkAllocation alloc = { 0, 0, 800, 600 }; gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, NULL, NULL, NULL); loop = g_main_loop_new(NULL, TRUE); g_timeout_add(100, (GSourceFunc)bail_out, loop); g_main_loop_run(loop); /* Get to the inner AtkText object */ obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); g_assert(obj); obj1 = atk_object_ref_accessible_child(obj, 0); g_assert(obj1); obj2 = atk_object_ref_accessible_child(obj, 1); g_assert(obj2); textObj1 = ATK_TEXT(obj1); g_assert(ATK_IS_TEXT(textObj1)); textObj2 = ATK_TEXT(obj2); g_assert(ATK_IS_TEXT(textObj2)); char *text = atk_text_get_text(textObj1, 0, -1); g_assert_cmpstr(text, ==, "This is a test."); text = atk_text_get_text(textObj2, 0, 53); g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not."); g_object_unref(obj1); g_object_unref(obj2); g_object_unref(webView); }
void AccessibilityUIElement::getChildrenWithRange(Vector<RefPtr<AccessibilityUIElement> >& children, unsigned location, unsigned length) { if (!ATK_IS_OBJECT(m_element.get())) return; unsigned end = location + length; for (unsigned i = location; i < end; i++) { GRefPtr<AtkObject> child = adoptGRef(atk_object_ref_accessible_child(ATK_OBJECT(m_element.get()), i)); children.append(AccessibilityUIElement::create(child.get())); } }
static void test_webkit_atk_get_role_listbox(AtkRolesFixture* fixture, gconstpointer data) { AtkObject* listboxObj; // This is an extraneous object of ATK_ROLE_PANEL which we should get rid of. fixture->obj = atk_object_ref_accessible_child(fixture->documentFrame, 0); g_assert(fixture->obj); listboxObj = atk_object_ref_accessible_child(fixture->obj, 0); g_assert(listboxObj); fixture->role = atk_object_get_role(listboxObj); g_assert(fixture->role == ATK_ROLE_LIST); get_child_and_test_role(listboxObj, 0, ATK_ROLE_LIST_ITEM); get_child_and_test_role(listboxObj, 1, ATK_ROLE_LIST_ITEM); get_child_and_test_role(listboxObj, 2, ATK_ROLE_LIST_ITEM); g_object_unref(fixture->obj); g_object_unref(listboxObj); }
static void test_webkit_atk_get_role_radio_button(AtkRolesFixture* fixture, gconstpointer data) { // This is an extraneous object of ATK_ROLE_PANEL which we should get rid of. fixture->obj = atk_object_ref_accessible_child(fixture->documentFrame, 0); g_assert(fixture->obj); get_child_and_test_role(fixture->obj, 0, ATK_ROLE_RADIO_BUTTON); g_object_unref(fixture->obj); }
void _register_cb(void *data, Evas_Object *win, void *event_info) { Evas_Object *eo = (Evas_Object *)data; AtkObject *obj, *obj_item; obj = eail_factory_get_accessible(eo); atk_object_set_description(obj, DESCRITPION); atk_object_set_name (obj, NAME); obj_item = atk_object_ref_accessible_child(obj,0); atk_object_set_description(obj_item, DESCRITPION_ITEM); atk_object_set_name (obj_item, NAME_ITEM); }
void AccessibilityUIElement::getChildren(Vector<RefPtr<AccessibilityUIElement> >& children) { if (!ATK_IS_OBJECT(m_element.get())) return; int count = childrenCount(); for (int i = 0; i < count; i++) { GRefPtr<AtkObject> child = adoptGRef(atk_object_ref_accessible_child(ATK_OBJECT(m_element.get()), i)); children.append(AccessibilityUIElement::create(child.get())); } }
static gint gtk_widget_accessible_get_index_in_parent (AtkObject *accessible) { GtkWidget *widget; GtkWidget *parent_widget; gint index; GList *children; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (widget == NULL) return -1; if (accessible->accessible_parent) { AtkObject *parent; parent = accessible->accessible_parent; if (GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE (parent)) return 0; else { gint n_children, i; gboolean found = FALSE; n_children = atk_object_get_n_accessible_children (parent); for (i = 0; i < n_children; i++) { AtkObject *child; child = atk_object_ref_accessible_child (parent, i); if (child == accessible) found = TRUE; g_object_unref (child); if (found) return i; } } } if (!GTK_IS_WIDGET (widget)) return -1; parent_widget = gtk_widget_get_parent (widget); if (!GTK_IS_CONTAINER (parent_widget)) return -1; children = gtk_container_get_children (GTK_CONTAINER (parent_widget)); index = g_list_index (children, widget); g_list_free (children); return index; }
static gboolean my_atk_selection_add_selection (AtkSelection *selection, gint i) { MyAtkSelection *self = MY_ATK_SELECTION(selection); if (!self) return FALSE; AtkObject *child = atk_object_ref_accessible_child (ATK_OBJECT (selection), i); AtkStateSet *ss = atk_object_ref_state_set (child); atk_state_set_add_state (ss, ATK_STATE_SELECTED); return atk_state_set_contains_state (ss, ATK_STATE_SELECTED); }
static void get_child_and_test_role(AtkObject* obj, gint pos, AtkRole role) { AtkObject* child; AtkRole child_role; child = atk_object_ref_accessible_child(obj, pos); g_assert(child); child_role = atk_object_get_role(child); g_assert(child_role == role); g_object_unref(child); }
static void test_webkit_atk_get_role_list_and_item(AtkRolesFixture* fixture, gconstpointer data) { AtkObject* listObj; listObj = atk_object_ref_accessible_child(fixture->documentFrame, 0); g_assert(listObj); fixture->role = atk_object_get_role(listObj); g_assert(fixture->role == ATK_ROLE_LIST); get_child_and_test_role(listObj, 0, ATK_ROLE_LIST_ITEM); get_child_and_test_role(listObj, 1, ATK_ROLE_LIST_ITEM); g_object_unref(listObj); listObj = atk_object_ref_accessible_child(fixture->documentFrame, 1); g_assert(listObj); fixture->role = atk_object_get_role(listObj); g_assert(fixture->role == ATK_ROLE_LIST); get_child_and_test_role(listObj, 0, ATK_ROLE_LIST_ITEM); get_child_and_test_role(listObj, 1, ATK_ROLE_LIST_ITEM); g_object_unref(listObj); }
/* * CORBA Accessibility::Accessible::getChildAtIndex method implementation */ static Accessibility_Accessible impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant, const CORBA_long index, CORBA_Environment *ev) { AtkObject *child; AtkObject *object = get_atkobject_from_servant (servant); g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL); child = atk_object_ref_accessible_child (object, index); return spi_accessible_new_return (child, TRUE, ev); }
static gboolean my_atk_selection_is_child_selected (AtkSelection *selection, gint i) { MyAtkSelection *self = MY_ATK_SELECTION(selection); if (!self) return FALSE; AtkObject *child = NULL; AtkStateSet *states = NULL; child = atk_object_ref_accessible_child (ATK_OBJECT (selection), i); states = atk_object_ref_state_set (child); if (atk_state_set_contains_state (states, ATK_STATE_SELECTED)) return TRUE; return FALSE; }
static void _traverse_children (AtkObject *obj) { gint n_children, i; n_children = atk_object_get_n_accessible_children (obj); for (i = 0; i < n_children; i++) { AtkObject *child; child = atk_object_ref_accessible_child (obj, i); _print_image_info(child); _traverse_children (child); g_object_unref (G_OBJECT (child)); } }