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); }
void _do_test(AtkObject *obj) { const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj)); g_assert(ATK_IS_OBJECT(obj)); g_assert_cmpstr(type_name, ==, "EailFlipselector"); g_assert(atk_object_get_n_accessible_children(obj) == ITEMS_COUNT); /* * AtkSelection tests */ g_assert(ATK_IS_SELECTION(obj)); /* atk_selection_add_selection test */ g_assert(atk_selection_add_selection(ATK_SELECTION(obj), ITEM_SEL_EINA)); g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_EINA)); /* atk_selection_clear_selection test */ g_assert(atk_selection_clear_selection(ATK_SELECTION(obj)) == FALSE); /* eail_flipselector_ref_selection test */ g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_EINA)); /* atk_selection_get_selection_count test */ g_assert(atk_selection_get_selection_count(ATK_SELECTION(obj)) == MAX_SELECTIONS); /* atk_selection_is_child_selected test */ g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_EINA)); /* atk_selection_remove_selection test */ g_assert(atk_selection_remove_selection(ATK_SELECTION(obj), ITEM_SEL_EINA)); g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_ELM)); /* atk_selection_select_all_selection test */ g_assert(atk_selection_select_all_selection(ATK_SELECTION(obj)) == FALSE); /* * AtkAction tests */ g_assert(ATK_IS_ACTION(obj)); /* atk_action_get_n_actions test */ g_assert(atk_action_get_n_actions(ATK_ACTION(obj)) == ACTIONS_COUNT); /* test existing actions */ g_assert(atk_selection_add_selection(ATK_SELECTION(obj), ITEM_SEL_EINA)); eailu_test_action_activate(ATK_ACTION(obj), "next"); g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_EDJE)); eailu_test_action_activate(ATK_ACTION(obj), "prev"); g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), ITEM_SEL_EINA)); /* test for non-existing action */ g_assert((eailu_get_action_number(ATK_ACTION(obj), "typo")) == -1); /* test set/get action description */ eailu_test_action_description_all(ATK_ACTION(obj)); }
static gboolean gal_a11y_e_cell_grab_focus (AtkComponent *component) { GalA11yECell *a11y; gint index; GtkWidget *toplevel; GalA11yETableItem *a11yTableItem; a11y = GAL_A11Y_E_CELL (component); /* for e_cell_vbox's children, we just grab the e_cell_vbox */ if (GAL_A11Y_IS_E_CELL_VBOX (a11y->parent)) { return atk_component_grab_focus (ATK_COMPONENT (a11y->parent)); } a11yTableItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent); index = atk_object_get_index_in_parent (ATK_OBJECT (a11y)); atk_selection_clear_selection (ATK_SELECTION (a11yTableItem)); atk_selection_add_selection (ATK_SELECTION (a11yTableItem), index); gtk_widget_grab_focus ( GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas)); toplevel = gtk_widget_get_toplevel ( GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas)); if (toplevel && gtk_widget_is_toplevel (toplevel)) gtk_window_present (GTK_WINDOW (toplevel)); return TRUE; }
JNIEXPORT jboolean JNICALL Java_org_gnome_atk_AtkSelection_atk_1selection_1add_1selection ( JNIEnv* env, jclass cls, jlong _self, jint _i ) { gboolean result; jboolean _result; AtkSelection* self; gint i; // convert parameter self self = (AtkSelection*) _self; // convert parameter i i = (gint) _i; // call function result = atk_selection_add_selection(self, i); // cleanup parameter self // cleanup parameter i // translate return value to JNI type _result = (jboolean) result; // and finally return _result; }
static void _test_index_child_for_object(AtkObject *obj, int index) { g_assert(0 == atk_selection_get_selection_count(ATK_SELECTION(obj))); g_assert(atk_selection_add_selection(ATK_SELECTION(obj), index)); g_assert(atk_selection_is_child_selected(ATK_SELECTION(obj), index)); g_assert(1 == atk_selection_get_selection_count(ATK_SELECTION(obj))); g_assert(atk_selection_clear_selection(ATK_SELECTION(obj))); g_assert(0 == atk_selection_get_selection_count(ATK_SELECTION(obj))); }
static gint _close_combo_list (gpointer data) { AtkObject *obj = ATK_OBJECT (data); gint count; gint n_children; AtkObject *list; count = atk_selection_get_selection_count (ATK_SELECTION (obj)); g_return_val_if_fail (count == 0, FALSE); 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); atk_action_do_action (ATK_ACTION (obj), 0); return FALSE; }
static void _test_slideshow_object(AtkObject *obj) { int child_count, selection_count, action_count; AtkObject *child, *selection; gboolean result; const gchar *action_name, *action_description; /*sometimes this is called several times*/ static int tested = 0; fprintf(stdout, "Testing slideshow\n"); if (tested > 0) return; tested++; g_object_ref(obj); g_assert(eailu_is_object_with_role(obj, ATK_ROLE_LIST)); child_count = atk_object_get_n_accessible_children(obj); g_assert(child_count == 9); for (int i = 0; i < child_count; i++) { child = atk_object_ref_accessible_child(obj, i); AtkRole role = atk_object_get_role(child); fprintf(stdout, "index %d child role: %s\n", i, atk_role_get_name(role)); g_assert(eailu_is_object_with_role(child, ATK_ROLE_IMAGE)); g_object_unref(child); } /*test AtkSelectionIface*/ g_assert(ATK_IS_SELECTION(obj)); selection = atk_selection_ref_selection(ATK_SELECTION(obj), 0); /*this may fail due to a problem with slideshow cache*/ g_assert(ATK_IS_OBJECT(selection)); g_assert(eailu_is_object_with_role(selection, ATK_ROLE_IMAGE)); g_object_unref(selection); selection_count = atk_selection_get_selection_count(ATK_SELECTION(obj)); g_assert(selection_count == 1); result = atk_selection_add_selection(ATK_SELECTION(obj), 5); g_assert(result); result = atk_selection_is_child_selected(ATK_SELECTION(obj), 5); g_assert(result); /*test AtkActionIface*/ g_assert(ATK_IS_ACTION(obj)); /* test set/get action description */ eailu_test_action_description_all(ATK_ACTION(obj)); action_count = atk_action_get_n_actions(ATK_ACTION(obj)); g_assert(4 == action_count); action_name = atk_action_get_name(ATK_ACTION(obj), 0); g_assert(!strcmp("next", action_name)); action_name = atk_action_get_name(ATK_ACTION(obj), 1); g_assert(!strcmp("previous", action_name)); result = atk_action_set_description(ATK_ACTION(obj), 2, "start the slideshow"); g_assert(result); action_description = atk_action_get_description(ATK_ACTION(obj), 2); g_assert(!strcmp("start the slideshow", action_description)); result = atk_action_do_action(ATK_ACTION(obj), 0); g_assert(result); result = atk_selection_is_child_selected(ATK_SELECTION(obj), 6); g_assert(result); eailu_test_atk_focus(obj, TRUE); g_object_unref(obj); eail_test_code_called = TRUE; }