Remove the old gail tests

This is not what we are looking for in tests, and it hasn't been
touched in ages.
This commit is contained in:
Matthias Clasen 2011-06-16 22:38:48 -04:00
parent 773df067e8
commit d3ab2fe19c
24 changed files with 0 additions and 9066 deletions

View File

@ -1,260 +0,0 @@
## Makefile.am for gtk+/tests
include $(top_srcdir)/Makefile.decl
if PLATFORM_WIN32
no_undefined = -no-undefined
endif
moduledir = $(libdir)/gtk-3.0/modules
if !OS_WIN32
module_LTLIBRARIES = \
libferret.la
endif
noinst_LTLIBRARIES = \
libtestaction.la \
libtestbutton.la \
libtestcombo.la \
libtestcomponent.la \
libtestimage.la \
libtestnotebook.la \
libtestobject.la \
libtestmenuitem.la \
libtestpaned.la \
libtestprops.la \
libtestselection.la \
libteststatusbar.la \
libtesttable.la \
libtesttext.la \
libtesttoplevel.la \
libtesttreetable.la \
libtestvalues.la
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
-I$(top_srcdir)/gtk \
-I$(top_builddir)/gtk \
-DGDK_DISABLE_DEPRECATED\
-DGTK_DISABLE_DEPRECATED
AM_CFLAGS = \
$(GTK_DEP_CFLAGS) \
$(GTK_DEBUG_FLAGS)
if !OS_WIN32
libferret_la_SOURCES = \
testlib.c \
testlib.h \
ferret.c
libferret_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version \
$(no_undefined) \
$(LDFLAGS)
libferret_la_LIBADD = \
$(top_builddir)/gtk/libgtk-3.la \
$(GTK_DEP_LIBS) \
$(GAIL_INET_LIBS)
endif
libtestaction_la_SOURCES = \
testaction.c
libtestaction_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestbutton_la_SOURCES = \
testlib.c \
testlib.h \
testbutton.c
libtestbutton_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestcombo_la_SOURCES = \
testlib.c \
testlib.h \
testcombo.c
libtestcombo_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestcomponent_la_SOURCES = \
testcomponent.c
libtestcomponent_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestimage_la_SOURCES = \
testimage.c
libtestimage_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestmenuitem_la_SOURCES = \
testlib.c \
testlib.h \
testmenuitem.c
libtestmenuitem_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestnotebook_la_SOURCES = \
testlib.c \
testlib.h \
testnotebook.c
libtestnotebook_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestobject_la_SOURCES = \
testlib.c \
testlib.h \
testobject.c
libtestobject_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestpaned_la_SOURCES = \
testlib.c \
testlib.h \
testpaned.c
libtestpaned_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestprops_la_SOURCES = \
testlib.c \
testlib.h \
testprops.c
libtestprops_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestselection_la_SOURCES = \
testselection.c
libtestselection_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libteststatusbar_la_SOURCES = \
teststatusbar.c
libteststatusbar_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtesttable_la_SOURCES = \
testlib.c \
testlib.h \
testtextlib.c \
testtextlib.h \
testtable.c
libtesttable_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtesttext_la_SOURCES = \
testlib.c \
testlib.h \
testtextlib.c \
testtextlib.h \
testtext.c
libtesttext_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtesttoplevel_la_SOURCES = \
testlib.c \
testlib.h \
testtoplevel.c
libtesttoplevel_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtesttreetable_la_SOURCES = \
testlib.c \
testlib.h \
testtreetable.c
libtesttreetable_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
libtestvalues_la_SOURCES = \
testvalues.c
libtestvalues_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version $(no_undefined) \
$(top_builddir)/gtk/libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
$(GTK_DEP_LIBS) \
$(LDFLAGS)
-include $(top_srcdir)/git.mk

View File

@ -1,306 +0,0 @@
============================
GAIL README
Last Updated: August 2, 2001
============================
General Info
============
This README describes how to use the various test programs
in the gail/tests directory.
To run the various test programs described in this README,
the test libraries must be built and installed. Running
"make", then "make install" in the gail top-level directory
will take care of this. Then do the following:
1. Set the environment variable GTK_MODULES to
"libgail:lib<testname>"
For example, for ferret, it would be "libgail:libferret"
2. Run the GTK+ test program specified. These test programs
are found in the GTK+ build directory in the subdirectory
called "tests".
Most test programs will display output directly to the
terminal window where the GTK+ test program was launched.
Some test programs (testtable and testtext) will launch a
test GUI program which allows more interactive testing.
The test GUI has two windows. The first window is the
"Test Control" window and the second window is the
"Test Output" window. In the "Test Control" window,
press the button(s) that corresponds to the tests to run
and press the "Run Tests" button at the bottom of the
screen. Some tests have associated text entry fields
which become active when the button is toggled on. These
text entry fields correspond to arguments that affect how
the test is executed. They are pre-filled with default
values but the user can change them if desired. The
output from the tests is displayed in the "Test Output"
window.
testlib
=======
Contains general purpose functionality that is used by the
various tests. These include functions that find a specific
widget/AtkObject in the test program, and functions used by
tests that use the Gail Test GUI.
ferret
======
Ferret is a passive in-process test tool for ATK and GAIL.
Run a GTK+-2.0 application such as "testgtk", and ferret will
display a window on screen. In this window accessibility
information about the GTK+ widgets will appear as they
receive focus.
The ferret window has several tabs, one for each of the
following ATK interfaces.
Object
Action
Component
Image
Table
Text
Value
Tabs that do not apply to the current widget in focus will be
displayed as inactive. Clicking on an active tab will display
information about the AtkObject accessed via the ATK API. In the
Action tab the various actions are displayed as buttons. When
a button is clicked, the action specified on the button's
label is performed.
If you have installed the "festival" speech synthesis system,
running festival in server mode (festival --server) and turning
on Ferret's Festival support will cause the following to happen:
1. AtkObject accessible names, roles, and keybindings will be
spoken as they receive focus.
2. When the caret (cursor) is moved in a text field, the
current line will be spoken, unless the caret is moved
just a single character. In the later case, only the
single character after the caret will be spoken.
Festival support can be turned on by checking "Festival" in the
menu, or by setting the environment variable FERRET_FESTIVAL
prior to starting the test. By checking "Festival Terse" or
by setting the environment variable FERRET_TERSE, only the
name of the AtkObject will be spoken (and not the roles and
keybindings).
A magnifier can be turned on to enlarge the widget in focus
by checking "Magnifier" in the menu, or by setting the
environment variable FERRET_MAGNIFIER. This requires that
the magnifier standalone code is running.
Checking "Track Mouse in the menu or by setting the environment
variable FERRET_MOUSETRACK causes ferret to display information
about the widget that is under the mouse rather than the widget
that has focus. The mouse is tracked via GtkWidget
"enter_notify_event" signals, so flyweight objects are not tracked.
Checking "Terminal Output" in the menu or by setting the
environment variable FERRET_ASCII will display the information
that is normally displayed to the ferret GUI window to the
terminal screen.
Checking "No ATK Signals" in the menu or by setting the
environment variable FERRET_NOSIGNALS will cause ferret to
ignore any ATK signals, and it will not update its display
when such signals occur.
testaction
==========
This is a GTK+ module used to test the implementation of the ATK
interface AtkAction, except for atk_action_do_action() in the GAIL
library. It is normally used with the GTK+ test program testgtk.
testbutton
==========
This is a GTK+ module used to test the accessible implementation
for buttons. It is normally used with the GTK+ test program testgtk.
Set the TEST_ACCESSIBLE_NAME environment variable to have the test
driver attach to a widget by widget name (compared via the
gtk_widget_get_name function call).
Set the environment variable TEST_ACCESSIBLE_AUTO and the program
will execute the action defined for a GailButton once.
testcombo
=========
This is a GTK+ module used to test the implementation of the ATK action
interfaces on GailCombo. It is normally used with the GTK+ test program
testgtk by putting the focus in the GtkCombo in entry window.
testcomponent
=============
This is a GTK+ module used to test the implementation of the ATK
interface AtkComponent in the GAIL library. It is normally used with the
GTK+ test program testgtk.
testimage
=========
This is a GTK+ module used to test the implementation of the ATK
interface AtkImage in the GAIL library. It is normally used with the GTK+
test program testgtk, but can also be used with testdnd when you want
to test GtkPixmap. This modules pops up an extra dialog on startup , containing
GtkArrows and a GtkImage. This dialog has to be closed before control is returned to main window.
testmenuitem
============
This is a GTK+ module used to test the accessible implementation
for menu items. It is normally used with the GTK+ test program testgtk.
Set the TEST_ACCESSIBLE_NAME environment variable to have the test
driver attach to a widget by widget name (compared via the
gtk_widget_get_name function call).
Set the environment variable TEST_ACCESSIBLE_AUTO and the program
will execute the action defined for a GailButton once.
testnotebook
=============
This is a GTK+ module used to test the implementation of the ATK
interface AtkSelection for GailNotebook. It is normally used with the
GTK+ test program testgtk.
testobject
==========
This is a GTK+ module used to test the implementation of the ATK
interface in atkobject.h in the GAIL library. It is normally used with the
GTK+ test program testgtk.
testpaned
=========
This is a GTK+ module used to test the implementation of the ATK
interface AtkValue for GailPaned. It is normally used with the
GTK+ test program testgtk. It checks the setting of the position
programmatically and that notification is received if the position
is changed interactively.
testprops
==========
This is a GTK+ module used to test the implementation of ATK properties
and property change handlers in the GAIL library. It is normally used with
the GTK+ test program testgtk. To see the changing of the state
ATK_STATE_SHOWING use menus in "progress bar". To see the changing of the
state ATK_STATE_SENSITIVE uses "labels". To see changing of child and parent
use resize check box in "panes".
Set the TEST_ACCESSIBLE_NAME environment variable to have the test
driver attach to a widget by widget name (compared via the
gtk_widget_get_name function call).
testselection
=============
This is a GTK+ module used to test the implementation of the AtkSelection
interface works for the GAIL library. It is normally used with the GTK+
test program testgtk and clicking on the menus option. It can also be used
with the GtkCombo which can be accessed by clicking on the entry option.
teststatusbar
=============
This is a GTK+ module used to test that the text on the statusbar
can be retrieved using GailStatusbar. It is normally used with the GTK+
test program testgtk and clicking on statusbar button.
testtable
=========
This is GTK+ module used to test the implementation of AtkTable
interfaces. It can be used with GailTreeView, for example. It
can be used with any of the following GTK+ test programs:
testtreecolumns, testtreefocus, testtreesort, testtreeview,
or treestoretest.
Set the TEST_ACCESSIBLE_NO_PROPERTIES environment variable
to not receive information about property values changing
(like cell state changes).
Set the TEST_ACCESSIBLE_NO_GUI environment variable to run the
test without the GUI program.
testtext
========
This is a GTK+ module used to test the implementation of AtkText and
AtkEditableText interfaces on GailTextView. It is normally used with
the GTK+ test program testtext started with a text file loaded.
It can also be used with the GTK+ test program testgtk, and then
click on the "entry" or "label" button.
Set the TEST_ACCESSIBLE_NAME environment variable to have the test
driver attach to a widget by widget name (compared via the
gtk_widget_get_name function call).
Set the TEST_ACCESSIBLE_DELAY environment variable to an integer
and the test driver will attach to only a widget on the nth screen
that is displayed.
testtoplevel
============
This test exercises the AtkUtil functions. It accesses the
atk_get_root() toplevel object, sets/removes global listeners,
and displays the ATK implementation name/version.
Set the TEST_ACCESSIBLE_DEPTH environment variable to control
how deep the children of the toplevel object are displayed.
The default is a depth of 2. Specifying a depth of -1 will
show the complete hierarchy.
testvalues
==========
This is a GTK+ module used to test the implementation of AtkValue interface
works for the GAIL library. GailProgressbar, GailSpinbutton and GailRange
can all be tested using this module.
GAIL README Authors
===================
-Brian Cameron (brian.cameron@sun.com)
-Bill Haneman (bill.haneman@sun.com)
-Padraig O'Briain (padraig.obriain@sun.com)

File diff suppressed because it is too large Load Diff

View File

@ -1,87 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "testlib.h"
/*
* This module is used to test the implementation of AtkAction,
* i.e. the getting of the name and the getting and setting of description
*/
static void _create_event_watcher (void);
static void _check_object (AtkObject *obj);
static void
_check_object (AtkObject *obj)
{
const char *accessible_name;
const gchar * typename = NULL;
if (GTK_IS_ACCESSIBLE (obj))
{
GtkWidget* widget = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
typename = g_type_name (G_OBJECT_TYPE (widget));
g_print ("Widget type name: %s\n", typename ? typename : "NULL");
}
typename = g_type_name (G_OBJECT_TYPE (obj));
g_print ("Accessible type name: %s\n", typename ? typename : "NULL");
accessible_name = atk_object_get_name (obj);
if (accessible_name)
g_print ("Name: %s\n", accessible_name);
if (ATK_IS_ACTION (obj))
{
AtkAction *action = ATK_ACTION (obj);
gint n_actions, i;
const gchar *action_name;
const gchar *action_desc;
const gchar *action_binding;
const gchar *desc = "Test description";
n_actions = atk_action_get_n_actions (action);
g_print ("AtkAction supported number of actions: %d\n", n_actions);
for (i = 0; i < n_actions; i++)
{
action_name = atk_action_get_name (action, i);
g_print ("Name of Action %d: %s\n", i, action_name);
action_binding = atk_action_get_keybinding (action, i);
if (action_binding)
g_print ("Name of Action Keybinding %d: %s\n", i, action_binding);
if (!atk_action_set_description (action, i, desc))
{
g_print ("atk_action_set_description failed\n");
}
else
{
action_desc = atk_action_get_description (action, i);
if (strcmp (desc, action_desc) != 0)
{
g_print ("Problem with setting and getting action description\n");
}
}
}
if (atk_action_set_description (action, n_actions, desc))
{
g_print ("atk_action_set_description succeeded but should not have\n");
}
}
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_object);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testaction Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,206 +0,0 @@
#include <gtk/gtk.h>
#include "testlib.h"
/*
* This module is used to test the accessible implementation for buttons
*
* 1) It verifies that ATK_STATE_ARMED is set when a button is pressed
* To check this click on the button whose name is specified in the
* environment variable TEST_ACCESSIBLE_NAME or "button box" if the
* environment variable is not set.
*
* 2) If the environment variable TEST_ACCESSIBLE_AUTO is set the program
* will execute the action defined for a GailButton once.
*
* 3) Change an inconsistent toggle button to be consistent and vice versa.
*
* Note that currently this code needs to be changed manually to test
* different actions.
*/
static void _create_event_watcher (void);
static void _check_object (AtkObject *obj);
static void button_pressed_handler (GtkButton *button);
static void _print_states (AtkObject *obj);
static void _print_button_image_info(AtkObject *obj);
static gint _do_button_action (gpointer data);
static gint _toggle_inconsistent (gpointer data);
static gint _finish_button_action (gpointer data);
#define NUM_VALID_ROLES 4
static void
_check_object (AtkObject *obj)
{
AtkRole role;
static gboolean first_time = TRUE;
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME)
/*
* Find the specified button in the window
*/
{
AtkRole valid_roles[NUM_VALID_ROLES];
const char *name;
AtkObject *atk_button;
GtkWidget *widget;
valid_roles[0] = ATK_ROLE_PUSH_BUTTON;
valid_roles[1] = ATK_ROLE_TOGGLE_BUTTON;
valid_roles[2] = ATK_ROLE_CHECK_BOX;
valid_roles[3] = ATK_ROLE_RADIO_BUTTON;
name = g_getenv ("TEST_ACCESSIBLE_NAME");
if (name == NULL)
name = "button box";
atk_button = find_object_by_accessible_name_and_role (obj, name,
valid_roles, NUM_VALID_ROLES);
if (atk_button == NULL)
{
g_print ("Object not found for %s\n", name);
return;
}
g_assert (GTK_IS_ACCESSIBLE (atk_button));
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_button));
g_assert (GTK_IS_BUTTON (widget));
g_signal_connect (widget,
"pressed",
G_CALLBACK (button_pressed_handler),
NULL);
if (GTK_IS_TOGGLE_BUTTON (widget))
{
_toggle_inconsistent (GTK_TOGGLE_BUTTON (widget));
}
if (first_time)
first_time = FALSE;
else
return;
if (g_getenv ("TEST_ACCESSIBLE_AUTO"))
{
g_idle_add (_do_button_action, atk_button);
}
}
}
static gint _toggle_inconsistent (gpointer data)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (data);
if (gtk_toggle_button_get_inconsistent (toggle_button))
{
gtk_toggle_button_set_inconsistent (toggle_button, FALSE);
}
else
{
gtk_toggle_button_set_inconsistent (toggle_button, TRUE);
}
return FALSE;
}
static gint _do_button_action (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
atk_action_do_action (ATK_ACTION (obj), 2);
g_timeout_add (5000, _finish_button_action, obj);
return FALSE;
}
static gint _finish_button_action (gpointer data)
{
#if 0
AtkObject *obj = ATK_OBJECT (data);
atk_action_do_action (ATK_ACTION (obj), 0);
#endif
return FALSE;
}
static void
button_pressed_handler (GtkButton *button)
{
AtkObject *obj;
obj = gtk_widget_get_accessible (GTK_WIDGET (button));
_print_states (obj);
_print_button_image_info (obj);
if (GTK_IS_TOGGLE_BUTTON (button))
{
g_idle_add (_toggle_inconsistent, GTK_TOGGLE_BUTTON (button));
}
}
static void
_print_states (AtkObject *obj)
{
AtkStateSet *state_set;
gint i;
state_set = atk_object_ref_state_set (obj);
g_print ("*** Start states ***\n");
for (i = 0; i < 64; i++)
{
AtkStateType one_state;
const gchar *name;
if (atk_state_set_contains_state (state_set, i))
{
one_state = i;
name = atk_state_type_get_name (one_state);
if (name)
g_print("%s\n", name);
}
}
g_object_unref (state_set);
g_print ("*** End states ***\n");
}
static void
_print_button_image_info(AtkObject *obj) {
gint height, width;
const gchar *desc;
height = width = 0;
if(!ATK_IS_IMAGE(obj))
return;
g_print("*** Start Button Image Info ***\n");
desc = atk_image_get_image_description(ATK_IMAGE(obj));
g_print ("atk_image_get_image_desc returns : %s\n", desc ? desc : "<NULL>");
atk_image_get_image_size(ATK_IMAGE(obj), &height ,&width);
g_print("atk_image_get_image_size returns: height %d width %d\n",height,width);
if(atk_image_set_image_description(ATK_IMAGE(obj), "New image Description")){
desc = atk_image_get_image_description(ATK_IMAGE(obj));
g_print ("atk_image_get_image_desc now returns : %s\n",desc ?desc:"<NULL>");
}
g_print("*** End Button Image Info ***\n");
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_object);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testbutton Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,188 +0,0 @@
#include <gtk/gtk.h>
#include "testlib.h"
static void _test_selection (AtkObject *obj);
static void _check_combo_box (AtkObject *obj);
static void _check_children (AtkObject *obj);
static gint _open_combo_list (gpointer data);
static gint _close_combo_list (gpointer data);
#define NUM_VALID_ROLES 1
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++)
{
const 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 _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 void _check_combo_box (AtkObject *obj)
{
static gboolean done = FALSE;
static gboolean done_selection = FALSE;
AtkRole role;
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME)
{
AtkRole roles[NUM_VALID_ROLES];
AtkObject *combo_obj;
if (done_selection)
return;
roles[0] = ATK_ROLE_COMBO_BOX;
combo_obj = find_object_by_role (obj, roles, NUM_VALID_ROLES);
if (combo_obj)
{
if (!done_selection)
{
done_selection = TRUE;
}
if (g_getenv ("TEST_ACCESSIBLE_COMBO_NOEDIT") != NULL)
{
GtkWidget *combo;
GtkEntry *entry;
combo = gtk_accessible_get_widget (GTK_ACCESSIBLE (combo_obj));
entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo)));
gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
}
_check_children (combo_obj);
_test_selection (combo_obj);
}
return;
}
if (role != ATK_ROLE_COMBO_BOX)
return;
g_print ("*** Start ComboBox ***\n");
_check_children (obj);
if (!done)
{
g_idle_add ((GSourceFunc)_open_combo_list, obj);
done = TRUE;
}
else
return;
g_print ("*** End ComboBox ***\n");
}
static gint _open_combo_list (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
g_print ("_open_combo_list\n");
atk_action_do_action (ATK_ACTION (obj), 0);
g_timeout_add (5000, _close_combo_list, obj);
return FALSE;
}
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
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_combo_box);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testcombo Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,121 +0,0 @@
#include <atk/atk.h>
static void _check_position (AtkObject *obj);
static void _check_position (AtkObject *obj)
{
AtkObject *parent, *ret_object;
gint x, y, width, height;
gint x1, y1, width1, height1;
x = y = width = height = 0;
x1 = y1 = width1 = height1 = 0;
if (!ATK_IS_COMPONENT (obj))
return;
atk_component_get_extents (ATK_COMPONENT(obj), &x, &y, &width, &height, ATK_XY_SCREEN);
atk_component_get_position (ATK_COMPONENT(obj), &x1, &y1, ATK_XY_SCREEN );
atk_component_get_size (ATK_COMPONENT(obj), &width1, &height1);
if ((x1 != x) || (y1 != y))
{
g_print ("atk_component_get_extents and atk_get_position give different"
" values: %d,%d %d,%d\n", x, y, x1, y1);
}
if ((width1 != width) || (height1 != height))
{
g_print ("atk_component_get_extents and atk_get_size give different"
" values: %d,%d %d,%d\n", width, height, width1, height1);
}
atk_component_get_position (ATK_COMPONENT(obj), &x1, &y1, ATK_XY_SCREEN);
g_print ("Object Type: %s\n", g_type_name (G_OBJECT_TYPE (obj)));
g_print ("Object at %d, %d on screen\n", x1, y1);
g_print ("Object at %d, %d, size: %d, %d\n", x, y, width, height);
parent = atk_object_get_parent (obj);
if (ATK_IS_COMPONENT (parent))
{
gint px, py, pwidth, pheight;
atk_component_get_extents (ATK_COMPONENT(parent),
&px, &py, &pwidth, &pheight, ATK_XY_SCREEN);
g_print ("Parent Type: %s\n", g_type_name (G_OBJECT_TYPE (parent)));
g_print ("Parent at %d, %d, size: %d, %d\n", px, py, pwidth, pheight);
ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
x, y, ATK_XY_SCREEN);
if (!ret_object)
{
g_print ("1:atk_component_ref_accessible_at_point returns NULL\n");
}
else if (ret_object != obj)
{
g_print ("1:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
x, y);
atk_component_get_extents (ATK_COMPONENT(ret_object),
&px, &py, &pwidth, &pheight, ATK_XY_SCREEN);
g_print ("ret_object at %d, %d, size: %d, %d\n", px, py, pwidth, pheight);
}
if (ret_object)
g_object_unref (G_OBJECT (ret_object));
ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
x+width-1, y+height-1, ATK_XY_SCREEN);
if (!ret_object)
{
g_print ("2:atk_component_ref_accessible_at_point returns NULL\n");
}
else if (ret_object != obj)
{
g_print ("2:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
x+width-1, y+height-1);
}
if (ret_object)
g_object_unref (G_OBJECT (ret_object));
ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
x-1, y-1, ATK_XY_SCREEN);
if ((ret_object) && (ret_object == obj))
{
g_print ("3:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
x-1, y-1);
}
if (ret_object)
g_object_unref (G_OBJECT (ret_object));
ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
x+width, y+height, ATK_XY_SCREEN);
if ((ret_object) && (ret_object == obj))
{
g_print ("4:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
x+width, y+height);
}
if (ret_object)
g_object_unref (G_OBJECT (ret_object));
}
if (!atk_component_contains (ATK_COMPONENT(obj), x, y, ATK_XY_SCREEN))
g_print ("Component does not contain position, %d %d\n", x, y);
if (atk_component_contains (ATK_COMPONENT(obj), x-1, y-1, ATK_XY_SCREEN))
g_print ("Component does contain position, %d %d\n", x-1, y-1);
if (!atk_component_contains (ATK_COMPONENT(obj), x+width-1, y+height-1, ATK_XY_SCREEN))
g_print ("Component does not contain position, %d %d\n",
x+width-1, y+height-1);
if (atk_component_contains (ATK_COMPONENT(obj), x+width, y+height, ATK_XY_SCREEN))
g_print ("Component does contain position, %d %d\n", x+width, y+height);
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_position);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testcomponent Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,155 +0,0 @@
#include <gtk/gtk.h>
#include "testlib.h"
#include <stdlib.h>
/*
* This test modules tests the AtkImage interface. When the module is loaded
* with testgtk , it also creates a dialog that contains GtkArrows and a
* GtkImage.
*
*/
typedef struct
{
GtkWidget *dialog;
GtkWidget *arrow1;
GtkWidget *arrow2;
GtkWidget *arrow3;
GtkWidget *arrow4;
GtkWidget *close_button;
GtkImage *image;
}MainDialog;
static void destroy (GtkWidget *widget, gpointer data)
{
gtk_widget_destroy(GTK_WIDGET(data));
}
static void _check_arrows (AtkObject *obj)
{
GtkWidget *content_area, *action_area;
AtkRole role;
MainDialog *md;
static gint visibleDialog = 0;
role = atk_object_get_role(obj);
if(role == ATK_ROLE_FRAME) {
md = (MainDialog *) malloc (sizeof(MainDialog));
if (visibleDialog == 0)
{
md->arrow1 = gtk_arrow_new(GTK_ARROW_UP,GTK_SHADOW_IN);
md->arrow2 = gtk_arrow_new(GTK_ARROW_DOWN,GTK_SHADOW_IN);
md->arrow3 = gtk_arrow_new(GTK_ARROW_LEFT,GTK_SHADOW_OUT);
md->arrow4 = gtk_arrow_new(GTK_ARROW_RIGHT,GTK_SHADOW_OUT);
md->dialog = gtk_dialog_new();
gtk_window_set_modal(GTK_WINDOW(md->dialog), TRUE);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (md->dialog));
action_area = gtk_dialog_get_action_area (GTK_DIALOG (md->dialog));
gtk_box_pack_start(GTK_BOX (content_area), md->arrow1, TRUE,TRUE, 0);
gtk_box_pack_start(GTK_BOX (content_area), md->arrow2, TRUE,TRUE, 0);
gtk_box_pack_start(GTK_BOX (content_area), md->arrow3, TRUE,TRUE, 0);
gtk_box_pack_start(GTK_BOX (content_area), md->arrow4, TRUE,TRUE, 0);
g_signal_connect(md->dialog, "destroy",
G_CALLBACK (destroy), md->dialog);
md->image = GTK_IMAGE(gtk_image_new_from_file("circles.xbm"));
gtk_box_pack_start(GTK_BOX (content_area), GTK_WIDGET(md->image), TRUE,TRUE, 0);
md->close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
g_signal_connect(md->close_button, "clicked",
G_CALLBACK (destroy), md->dialog);
gtk_box_pack_start(GTK_BOX (action_area), md->close_button, TRUE,TRUE, 0);
gtk_widget_show_all(md->dialog);
visibleDialog = 1;
}
}
}
static void
_print_image_info(AtkObject *obj) {
gint height, width;
const gchar *desc;
const gchar *name = atk_object_get_name (obj);
const gchar *type_name = g_type_name(G_TYPE_FROM_INSTANCE (obj));
height = width = 0;
if(!ATK_IS_IMAGE(obj))
return;
g_print("atk_object_get_name : %s\n", name ? name : "<NULL>");
g_print("atk_object_get_type_name : %s\n",type_name ?type_name :"<NULL>");
g_print("*** Start Image Info ***\n");
desc = atk_image_get_image_description(ATK_IMAGE(obj));
g_print ("atk_image_get_image_desc returns : %s\n",desc ? desc:"<NULL>");
atk_image_get_image_size(ATK_IMAGE(obj), &height ,&width);
g_print("atk_image_get_image_size returns: height %d width %d\n",
height,width);
if(atk_image_set_image_description(ATK_IMAGE(obj),"New image Description")){
desc = atk_image_get_image_description(ATK_IMAGE(obj));
g_print ("atk_image_get_image_desc now returns : %s\n",desc?desc:"<NULL>");
}
g_print("*** End Image Info ***\n");
}
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));
}
}
static void _check_objects (AtkObject *obj)
{
AtkRole role;
g_print ("Start of _check_values\n");
_check_arrows(obj);
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME || role == ATK_ROLE_DIALOG)
{
/*
* Add handlers to all children.
*/
_traverse_children (obj);
}
g_print ("End of _check_values\n");
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_objects);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testimages Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,953 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "testlib.h"
static gint _get_position_in_array (gint window,
gchar *the_test_name);
static gint _get_position_in_parameters (gint window,
gchar *label,
gint position);
static void _create_output_window (OutputWindow **outwin);
static gboolean _create_select_tests_window (AtkObject *obj,
TLruntest runtest,
OutputWindow **outwin);
static void _toggle_selectedcb (GtkWidget *widget,
gpointer test);
static void _testselectioncb (GtkWidget *widget,
gpointer data);
static void _destroy (GtkWidget *widget,
gpointer data);
/* General functions */
/**
* find_object_by_role:
* @obj: An #AtkObject
* @roles: An array of roles to search for
* @num_roles: The number of entries in @roles
*
* Find the #AtkObject which is a decendant of the specified @obj
* which is of an #AtkRole type specified in the @roles array.
*
* Returns: the #AtkObject that meets the specified criteria or NULL
* if no object is found.
**/
AtkObject*
find_object_by_role (AtkObject *obj,
AtkRole *roles,
gint num_roles)
{
/*
* 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, j;
gint n_children;
AtkObject *child;
if (obj == NULL)
return NULL;
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (obj) == roles[j])
return obj;
}
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 (child == NULL)
continue;
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (child) == roles[j])
return child;
}
found_obj = find_object_by_role (child, roles, num_roles);
g_object_unref (child);
if (found_obj)
return found_obj;
}
return NULL;
}
/**
* find_object_by_name_and_role:
* @obj: An #AtkObject
* @name: The GTK widget name
* @roles: An array of roles to search for
* @num_roles: The number of entries in @roles
*
* Find the #AtkObject which is a decendant of the specified @obj
* which is of an #AtkRole type specified in the @roles array which
* also has the GTK widget name specified in @name.
*
* Returns: the #AtkObject that meets the specified criteria or NULL
* if no object is found.
**/
AtkObject*
find_object_by_name_and_role(AtkObject *obj,
const gchar *name,
AtkRole *roles,
gint num_roles)
{
AtkObject *child;
GtkWidget* widget;
gint i, j;
gint n_children;
if (obj == NULL)
return NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (GTK_IS_WIDGET (widget))
{
if (strcmp (name, gtk_widget_get_name(GTK_WIDGET (widget))) == 0)
{
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (obj) == roles[j])
return obj;
}
}
}
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 (child == NULL)
continue;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (child));
if (GTK_IS_WIDGET (widget))
{
if (strcmp(name, gtk_widget_get_name(GTK_WIDGET (widget))) == 0)
{
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (child) == roles[j])
return child;
}
}
}
found_obj = find_object_by_name_and_role (child, name, roles, num_roles);
g_object_unref (child);
if (found_obj)
return found_obj;
}
return NULL;
}
/**
* find_object_by_accessible_name_and_role:
* @obj: An #AtkObject
* @name: The accessible name
* @roles: An array of roles to search for
* @num_roles: The number of entries in @roles
*
* Find the #AtkObject which is a decendant of the specified @obj
* which has the specified @name and matches one of the
* specified @roles.
*
* Returns: the #AtkObject that meets the specified criteria or NULL
* if no object is found.
*/
AtkObject*
find_object_by_accessible_name_and_role (AtkObject *obj,
const gchar *name,
AtkRole *roles,
gint num_roles)
{
AtkObject *child;
gint i, j;
gint n_children;
const gchar *accessible_name;
if (obj == NULL)
return NULL;
accessible_name = atk_object_get_name (obj);
if (accessible_name && (strcmp(name, accessible_name) == 0))
{
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (obj) == roles[j])
return obj;
}
}
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 (child == NULL)
continue;
accessible_name = atk_object_get_name (child);
if (accessible_name && (strcmp(name, accessible_name) == 0))
{
for (j=0; j < num_roles; j++)
{
if (atk_object_get_role (child) == roles[j])
return child;
}
}
found_obj = find_object_by_accessible_name_and_role (child, name,
roles, num_roles);
g_object_unref (child);
if (found_obj)
return found_obj;
}
return NULL;
}
/**
* find_object_by_name_and_role:
* @obj: An #AtkObject
* @type: The type
*
* Find the #AtkObject which is a decendant of the specified @obj
* which has the specified @type.
*
* Returns: the #AtkObject that meets the specified criteria or NULL
* if no object is found.
*/
AtkObject*
find_object_by_type (AtkObject *obj,
gchar *type)
{
/*
* Find the first object which is a descendant of the specified object
* which matches the specified type.
*
* This function returns a reference to the AtkObject which should be
* removed when finished with the object.
*/
gint i;
gint n_children;
AtkObject *child;
const gchar * typename = NULL;
if (obj == NULL)
return NULL;
typename = g_type_name (G_OBJECT_TYPE (obj));
if (strcmp (typename, type) == 0)
return obj;
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 (child == NULL)
continue;
typename = g_type_name (G_OBJECT_TYPE (child));
if (strcmp (typename, type) == 0)
return child;
found_obj = find_object_by_type (child, type);
g_object_unref (child);
if (found_obj)
return found_obj;
}
return NULL;
}
/**
* already_accessed_atk_object
* @obj: An #AtkObject
*
* Keeps a static GPtrArray of objects that have been passed into this
* function.
*
* Returns: TRUE if @obj has been passed into this function before
* and FALSE otherwise.
*/
gboolean
already_accessed_atk_object (AtkObject *obj)
{
static GPtrArray *obj_array = NULL;
gboolean found = FALSE;
gint i;
/*
* We create a property handler for each object if one was not associated
* with it already.
*
* We add it to our array of objects which have property handlers; if an
* object is destroyed it remains in the array.
*/
if (obj_array == NULL)
obj_array = g_ptr_array_new ();
for (i = 0; i < obj_array->len; i++)
{
if (obj == g_ptr_array_index (obj_array, i))
{
found = TRUE;
break;
}
}
if (!found)
g_ptr_array_add (obj_array, obj);
return found;
}
/**
* display_children
* @obj: An #AtkObject
* @depth: Number of spaces to indent output.
* @child_number: The child number of this object.
*
* Displays the hierarchy of widgets starting from @obj.
**/
void
display_children (AtkObject *obj,
gint depth,
gint child_number)
{
display_children_to_depth(obj, -1, depth, child_number);
}
/**
* display_children_to_depth
* @obj: An #AtkObject
* @to_depth: Display to this depth.
* @depth: Number of spaces to indent output.
* @child_number: The child number of this object.
*
* Displays the hierarchy of widgets starting from @obj only
* to the specified depth.
**/
void
display_children_to_depth (AtkObject *obj,
gint to_depth,
gint depth,
gint child_number)
{
AtkRole role;
const gchar *rolename;
const gchar *typename;
gint n_children, parent_index, i;
if (to_depth >= 0 && depth > to_depth)
return;
if (obj == NULL)
return;
for (i=0; i < depth; i++)
g_print(" ");
role = atk_object_get_role (obj);
rolename = atk_role_get_name (role);
/*
* Note that child_number and parent_index should be the same
* unless there is an error.
*/
parent_index = atk_object_get_index_in_parent(obj);
g_print("child <%d == %d> ", child_number, parent_index);
n_children = atk_object_get_n_accessible_children (obj);
g_print ("children <%d> ", n_children);
if (rolename)
g_print("role <%s>, ", rolename);
else
g_print("role <error>");
if (GTK_IS_ACCESSIBLE(obj))
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
g_print("name <%s>, ", gtk_widget_get_name(GTK_WIDGET (widget)));
}
else
g_print("name <NULL>, ");
typename = g_type_name (G_OBJECT_TYPE (obj));
g_print ("typename <%s>\n", typename);
for (i = 0; i < n_children; i++)
{
AtkObject *child;
child = atk_object_ref_accessible_child (obj, i);
if (child != NULL)
{
display_children_to_depth (child, to_depth, depth + 1, i);
g_object_unref (G_OBJECT (child));
}
}
}
/* Test GUI logic */
/* GUI Information for the Select Tests Window */
typedef struct
{
GtkWidget *selecttestsWindow;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *textInsert;
GtkWidget *button;
gchar *selecttestsTitle;
}MainDialog;
/* Functionality information about each added test */
typedef struct
{
GtkWidget *toggleButton;
GtkWidget *hbox;
GtkWidget *parameterLabel[MAX_PARAMS];
GtkWidget *parameterInput[MAX_PARAMS];
gchar *testName;
gint numParameters;
}TestList;
typedef struct
{
TLruntest runtest;
AtkObject* obj;
gint win_num;
}TestCB;
static MainDialog *md[MAX_WINDOWS];
static OutputWindow *ow;
/* An array containing function information on all of the tests */
static TestList listoftests[MAX_WINDOWS][MAX_TESTS];
/* A counter for the actual number of added tests */
gint counter;
/* A global for keeping track of the window numbers */
static gint window_no = 0;
/* An array containing the names of the tests that are "on" */
static gchar *onTests[MAX_WINDOWS][MAX_TESTS];
static gint g_visibleDialog = 0;
static gint testcount[MAX_WINDOWS];
static TestCB testcb[MAX_WINDOWS];
/**
* create_windows:
* @obj: An #AtkObject
* @runtest: The callback function to run when the "Run Tests" button
* is clicked.
* @outwin: The output window to use. If NULL is passed in, then
* create a new one.
*
* Creates the test window and the output window (if @outwin is NULL)
* Runs _create_output_window() and _create_select_tests_window()
* and sets g_visibleDialog to 1
*
* Returns: The window number of the created window if successful, -1 otherwise.
**/
gint
create_windows (AtkObject *obj,
TLruntest runtest,
OutputWindow **outwin)
{
gboolean valid;
gint tmp;
g_visibleDialog = 1;
_create_output_window(outwin);
valid = _create_select_tests_window(obj, runtest, outwin);
if (valid)
{
tmp = window_no;
window_no++;
return tmp;
}
else
return -1;
}
/**
* _create_output_window
* @outwin: If outwin is passed in as NULL, a new output window is created
* otherwise, the outwin passed in is shared.
*
* Creates the Test Result Output Window .
**/
static void
_create_output_window (OutputWindow **outwin)
{
GtkWidget *view;
GtkWidget *scrolled_window;
OutputWindow *localow;
if (*outwin == NULL)
{
localow = (OutputWindow *) malloc (sizeof(OutputWindow));
localow->outputBuffer = gtk_text_buffer_new(NULL);
view = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(localow->outputBuffer));
gtk_widget_set_size_request (view, 700, 500);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
localow->outputWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(localow->outputWindow), "Test Output");
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(localow->outputWindow), scrolled_window);
gtk_container_add(GTK_CONTAINER(scrolled_window), view);
gtk_text_buffer_get_iter_at_offset(localow->outputBuffer, &localow->outputIter, 0);
gtk_widget_show(view);
gtk_widget_show(scrolled_window);
gtk_widget_show(localow->outputWindow);
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(localow->outputBuffer),
"\n\nWelcome to the test GUI:\nTest results are printed here\n\n", 58);
gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(localow->outputBuffer),
&localow->outputIter, 0);
*outwin = localow;
ow = *outwin;
}
}
/**
* _create_select_tests_window:
* @obj: An #AtkObject
* @runtest: The callback function that is run when the "Run Tests"
* button is clicked.
* @outwin: The output window to use.
*
* Creates the Test Select Window
*
* Returns: TRUE if successful, FALSE otherwise
**/
static gboolean
_create_select_tests_window (AtkObject *obj,
TLruntest runtest,
OutputWindow **outwin)
{
GtkWidget *hbuttonbox;
GtkWidget *scrolledWindow;
if (window_no >= 0 && window_no < MAX_WINDOWS)
{
md[window_no] = (MainDialog *) malloc (sizeof(MainDialog));
/* Setup Window */
md[window_no]->selecttestsTitle = "Test Setting";
md[window_no]->selecttestsWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW( ow->outputWindow),
md[window_no]->selecttestsTitle);
gtk_window_set_resizable (GTK_WINDOW(md[window_no]->selecttestsWindow),
FALSE);
gtk_window_set_position (GTK_WINDOW(md[window_no]->selecttestsWindow),
GTK_WIN_POS_CENTER);
g_signal_connect (md[window_no]->selecttestsWindow,
"destroy",
G_CALLBACK (_destroy),
&md[window_no]->selecttestsWindow);
/* Setup Scrolling */
scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_set_size_request (scrolledWindow, 500, 600);
gtk_container_add (GTK_CONTAINER (md[window_no]->selecttestsWindow),
scrolledWindow);
/* Setup Layout */
md[window_no]->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (md[window_no]->vbox), TRUE);
md[window_no]->button = gtk_button_new_with_mnemonic ("_Run Tests");
hbuttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox),
GTK_BUTTONBOX_SPREAD);
gtk_box_pack_end (GTK_BOX (hbuttonbox),
GTK_WIDGET (md[window_no]->button), TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (md[window_no]->vbox), hbuttonbox,
TRUE, TRUE, 0);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledWindow),
md[window_no]->vbox);
testcb[window_no].runtest = runtest;
testcb[window_no].obj = obj;
testcb[window_no].win_num = window_no;
g_signal_connect (md[window_no]->button,
"clicked",
G_CALLBACK (_testselectioncb),
(gpointer)&testcb[window_no]);
/* Show all */
gtk_widget_grab_focus (md[window_no]->button);
gtk_widget_show (md[window_no]->button);
gtk_widget_show (hbuttonbox);
gtk_widget_show (scrolledWindow);
gtk_widget_show_all (GTK_WIDGET (md[window_no]->selecttestsWindow));
return TRUE;
}
else
return FALSE;
}
/**
* add_test
* @window: The window number
* @name: The test name
* @num_params: The number of arguments the test uses.
* @parameter_names: The names of each argument.
* @default_names: The default values of each argument.
*
* Adds a Test with the passed-in details to the Tests Select Window.
*
* Returns: FALSE if the num_params passed in is greater than
* MAX_PARAMS, otherwise returns TRUE
*
**/
gboolean
add_test (gint window,
gchar *name,
gint num_params,
gchar* parameter_names[],
gchar* default_names[])
{
gint i;
if (num_params > MAX_PARAMS)
return FALSE;
else
{
md[window]->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing (GTK_BOX (md[window]->hbox), 10);
gtk_container_set_border_width (GTK_CONTAINER (md[window]->hbox), 10);
gtk_container_add (GTK_CONTAINER (md[window]->vbox), md[window]->hbox);
listoftests[window][testcount[window]].toggleButton =
gtk_toggle_button_new_with_label (name);
gtk_box_pack_start (GTK_BOX (md[window]->hbox),
listoftests[window][testcount[window]].toggleButton, FALSE, FALSE, 0);
listoftests[window][testcount[window]].testName = name;
listoftests[window][testcount[window]].numParameters = num_params;
for (i=0; i<num_params; i++)
{
listoftests[window][testcount[window]].parameterLabel[i] =
gtk_label_new (parameter_names[i]);
gtk_box_pack_start (GTK_BOX (md[window]->hbox),
listoftests[window][testcount[window]].parameterLabel[i], FALSE, FALSE, 0);
listoftests[window][testcount[window]].parameterInput[i] = gtk_entry_new();
gtk_entry_set_text (GTK_ENTRY (listoftests[window][testcount[window]].parameterInput[i]),
default_names[i]);
gtk_widget_set_size_request (listoftests[window][testcount[window]].parameterInput[i], 50, 22);
gtk_box_pack_start (GTK_BOX (md[window]->hbox),
listoftests[window][testcount[window]].parameterInput[i], FALSE, FALSE, 0);
gtk_widget_set_sensitive (
GTK_WIDGET (listoftests[window][testcount[window]].parameterLabel[i]), FALSE);
gtk_widget_set_sensitive (
GTK_WIDGET (listoftests[window][testcount[window]].parameterInput[i]), FALSE);
gtk_widget_show (listoftests[window][testcount[window]].parameterLabel[i]);
gtk_widget_show (listoftests[window][testcount[window]].parameterInput[i]);
}
g_signal_connect (listoftests[window][testcount[window]].toggleButton,
"toggled",
G_CALLBACK (_toggle_selectedcb),
(gpointer)&(listoftests[window][testcount[window]]));
gtk_widget_show (listoftests[window][testcount[window]].toggleButton);
gtk_widget_show (md[window]->hbox);
gtk_widget_show (md[window]->vbox);
testcount[window]++;
counter++;
return TRUE;
}
}
/**
* tests_set:
* @window: The window number
* @count: Passes back the number of tests on.
*
* Gets an array of strings corresponding to the tests that are "on".
* A test is assumed on if the toggle button is on and if all its
* parameters have values.
*
* Returns: an array of strings corresponding to the tests that
* are "on".
**/
gchar **tests_set(gint window, int *count)
{
gint i =0, j = 0, num;
gboolean nullparam;
gchar* input;
*count = 0;
for (i = 0; i < MAX_TESTS; i++)
onTests[window][i] = NULL;
for (i = 0; i < testcount[window]; i++)
{
nullparam = FALSE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (listoftests[window][i].toggleButton)))
{
num = listoftests[window][i].numParameters;
for (j = 0; j < num; j++)
{
input = gtk_editable_get_chars (
GTK_EDITABLE (listoftests[window][i].parameterInput[j]), 0, -1);
if (input != NULL && (! strcmp(input, "")))
nullparam = TRUE;
}
if (!nullparam)
{
onTests[window][*count] = listoftests[window][i].testName;
*count = *count + 1;
}
}
}
return onTests[window];
}
/**
* _get_position_in_array:
* @window: The window number
* @the_test_name: The name of the test
*
* Gets the index of the passed-in @the_test_name.
*
* Returns: the position in listoftests[] of @the_test_name
**/
static gint
_get_position_in_array(gint window,
gchar *the_test_name)
{
gint i;
for (i = 0; i < testcount[window]; i++)
{
if (strcmp(listoftests[window][i].testName, the_test_name) == 0)
return i;
}
return -1;
}
/**
* _get_position_in_parameters:
* @window: The window number
* @label: The label name
* @position: The parameter position
*
* Gets the index of the passed-in parameter @label.
*
* Returns: the position in parameterLabel[] (a member of
* listoftests[]) of @label
**/
static gint
_get_position_in_parameters(gint window,
gchar *label,
gint position)
{
gint i;
const gchar *label_string;
for (i = 0; i < MAX_PARAMS; i++)
{
label_string = gtk_label_get_text(
GTK_LABEL (listoftests[window][position].parameterLabel[i]));
if (strcmp(label_string, label) == 0)
return i;
}
return -1;
}
/**
* set_output_buffer:
* @output: The string to add to the output buffer
*
* Tidies up the output Window
**/
void
set_output_buffer(gchar *output)
{
gtk_text_buffer_insert (GTK_TEXT_BUFFER (ow->outputBuffer),
&ow->outputIter, output, strlen(output));
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (ow->outputBuffer),
&ow->outputIter, 0);
}
/**
* isVisibleDialog:
*
* Informs user if a visible test window running.
*
* Returns: TRUE if g_visibleDialog is set to 1, otherwise FALSE
**/
gboolean
isVisibleDialog(void)
{
if (g_visibleDialog >= 1)
return TRUE;
else
return FALSE;
}
/**
* get_arg_of_func:
* @window: The window number
* @function_name: The name of the function
* @arg_label: The label of the argument.
*
* Gets the user input associated with the @function_name and @arg_label.
*
* Returns: the user input associated with the @function_name and @arg_label.
**/
gchar*
get_arg_of_func (gint window,
gchar *function_name,
gchar *arg_label)
{
const gchar *argString;
gchar *retString;
gint position, paramPosition;
position = _get_position_in_array(window, function_name);
if (position == -1)
{
g_print("No such function\n");
return NULL;
}
paramPosition = _get_position_in_parameters(window, arg_label, position);
if (paramPosition == -1)
{
g_print("No such parameter Label\n");
return NULL;
}
if (position != -1 && paramPosition != -1)
{
argString = gtk_editable_get_chars (
GTK_EDITABLE (listoftests[window][position].parameterInput[paramPosition]),
0, -1);
retString = g_strdup(argString);
}
else
retString = NULL;
return retString;
}
/**
* string_to_int:
* @the_string: The string to convert
*
* Converts the passed-in string to an integer
*
* Returns: An integer corresponding to @the_string.
**/
int
string_to_int (const char *the_string)
{
char *end_ptr;
double ret_val;
int int_ret_val;
while (1)
{
ret_val = strtod( the_string, &end_ptr);
if (*end_ptr == '\0')
break;
else
printf("\nError: input must be a number\n");
}
int_ret_val = (int) ret_val;
return (int_ret_val);
}
/**
* _toggle_selectedcb:
* @widget: The ToggleButton widget
* @test: user data containing the TestList structure.
*
* Toggle Button Callback, activating the text entry fields
**/
static void
_toggle_selectedcb (GtkWidget *widget,
gpointer test)
{
int i;
TestList *testlist = (TestList *) test;
gboolean toggled;
gboolean sensitive;
toggled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
if (toggled)
sensitive = TRUE;
else
sensitive = FALSE;
for (i=0; i < testlist->numParameters; i++)
{
gtk_widget_set_sensitive (GTK_WIDGET (testlist->parameterLabel[i]),
sensitive);
gtk_widget_set_sensitive (GTK_WIDGET (testlist->parameterInput[i]),
sensitive);
}
}
/*
* _testselectioncb:
* widget: The Button widget
* data: The user data containing a TestCB structure
*
* Callback for when the "Run Tests" button is pressed
**/
static void
_testselectioncb (GtkWidget *widget,
gpointer data)
{
TestCB* local_testcb = (TestCB *)data;
local_testcb->runtest(local_testcb->obj, local_testcb->win_num);
}
/**
* _destroy:
* @widget: The GUI widget
* @data: User data, not used.
*
* Destroy Callback.
**/
static void
_destroy (GtkWidget *widget,
gpointer data)
{
gtk_main_quit();
}

View File

@ -1,70 +0,0 @@
#include <stdio.h>
#include <gtk/gtk.h>
/* Maximum characters in the output buffer */
#define MAX_LINE_SIZE 1000
/* Maximum number of tests */
#define MAX_TESTS 30
/* Maximum number of test windows */
#define MAX_WINDOWS 5
/* Maximum number of parameters any test can have */
#define MAX_PARAMS 3
/* Information on the Output Window */
typedef struct
{
GtkWidget *outputWindow;
GtkTextBuffer *outputBuffer;
GtkTextIter outputIter;
}OutputWindow;
typedef void (*TLruntest) (AtkObject * obj, gint win_num);
/* General purpose functions */
gboolean already_accessed_atk_object (AtkObject *obj);
AtkObject* find_object_by_role (AtkObject *obj,
AtkRole *role,
gint num_roles);
AtkObject* find_object_by_type (AtkObject *obj,
gchar *type);
AtkObject* find_object_by_name_and_role (AtkObject *obj,
const gchar *name,
AtkRole *roles,
gint num_roles);
AtkObject* find_object_by_accessible_name_and_role (AtkObject *obj,
const gchar *name,
AtkRole *roles,
gint num_roles);
void display_children (AtkObject *obj,
gint depth,
gint child_number);
void display_children_to_depth (AtkObject *obj,
gint to_depth,
gint depth,
gint child_number);
/* Test GUI functions */
gint create_windows (AtkObject *obj,
TLruntest runtest,
OutputWindow **outwin);
gboolean add_test (gint window,
gchar *name,
gint num_params,
gchar *parameter_names[],
gchar *default_names[]);
void set_output_buffer (gchar *output);
gchar **tests_set (gint window,
int *count);
gchar *get_arg_of_func (gint window,
gchar *function_name,
gchar *arg_label);
int string_to_int (const char *the_string);
gboolean isVisibleDialog (void);

View File

@ -1,140 +0,0 @@
#include <string.h>
#include <gtk/gtk.h>
#include "testlib.h"
/*
* This module is used to test the accessible implementation for menu items
*
* 1) When a menu item is clicked in testgtk, the action for the
* item is performed.
* 2) The name of the keybinding for the 'activate" action for a menu item
* is output, if it exists.
* 3) Execute the action for a menu item programatically
*/
#define NUM_VALID_ROLES 1
static void _create_event_watcher (void);
static void _check_object (AtkObject *obj);
static gint _do_menu_item_action (gpointer data);
static void
_check_object (AtkObject *obj)
{
AtkRole role;
static const char *name = NULL;
static gboolean first_time = TRUE;
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME)
/*
* Find the specified menu item
*/
{
AtkRole valid_roles[NUM_VALID_ROLES];
AtkObject *atk_menu_item;
GtkWidget *widget;
if (name == NULL)
{
valid_roles[0] = ATK_ROLE_MENU_ITEM;
name = g_getenv ("TEST_ACCESSIBLE_NAME");
if (name == NULL)
name = "foo";
}
atk_menu_item = find_object_by_accessible_name_and_role (obj, name,
valid_roles, NUM_VALID_ROLES);
if (atk_menu_item == NULL)
{
g_print ("Object not found for %s\n", name);
return;
}
g_assert (GTK_IS_ACCESSIBLE (atk_menu_item));
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_menu_item));
g_assert (GTK_IS_MENU_ITEM (widget));
if (first_time)
first_time = FALSE;
else
return;
/*
* This action opens the menu whose name is "foo" or whatever
* was specified in the environment variable TEST_ACCESSIBLE_NAME
*/
atk_action_do_action (ATK_ACTION (atk_menu_item), 0);
}
else if ((role == ATK_ROLE_MENU_ITEM) ||
(role == ATK_ROLE_CHECK_MENU_ITEM) ||
(role == ATK_ROLE_RADIO_MENU_ITEM) ||
(role == ATK_ROLE_TEAR_OFF_MENU_ITEM))
{
const char *keybinding;
const char *accessible_name;
accessible_name = atk_object_get_name (obj);
if (accessible_name)
g_print ("Name: %s\n", accessible_name);
g_print ("Action: %s\n", atk_action_get_name (ATK_ACTION (obj), 0));
keybinding = atk_action_get_keybinding (ATK_ACTION (obj), 0);
if (keybinding)
g_print ("KeyBinding: %s\n", keybinding);
/*
* Do the action associated with the menu item once, otherwise
* we get into a loop
*/
if (strcmp (name, accessible_name) == 0)
{
if (first_time)
first_time = FALSE;
else
return;
if (g_getenv ("TEST_ACCESSIBLE_AUTO"))
{
g_idle_add (_do_menu_item_action, obj);
}
}
}
else
{
const char *accessible_name;
accessible_name = atk_object_get_name (obj);
if (accessible_name)
g_print ("Name: %s\n", accessible_name);
else if (GTK_IS_ACCESSIBLE (obj))
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
g_print ("Type: %s\n", g_type_name (G_OBJECT_TYPE (widget)));
}
}
}
static gint _do_menu_item_action (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
atk_action_do_action (ATK_ACTION (obj), 0);
return FALSE;
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_object);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testmenuitem Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,224 +0,0 @@
#include <stdio.h>
#include <glib.h>
#include <atk/atk.h>
#include <gtk/gtk.h>
#include "testlib.h"
#define NUM_VALID_ROLES 1
static void _print_type (AtkObject *obj);
static void _do_selection (AtkObject *obj);
static gint _finish_selection (gpointer data);
static gint _remove_page (gpointer data);
static void _print_type (AtkObject *obj)
{
const gchar *typename = NULL;
const gchar *name = NULL;
const gchar *description = NULL;
AtkRole role;
if (GTK_IS_ACCESSIBLE (obj))
{
GtkWidget* widget = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
typename = g_type_name (G_OBJECT_TYPE (widget));
g_print ("\tWidget type name: %s\n", typename ? typename : "NULL");
}
typename = g_type_name (G_OBJECT_TYPE (obj));
g_print ("\tAccessible type name: %s\n", typename ? typename : "NULL");
name = atk_object_get_name (obj);
g_print("\tAccessible Name: %s\n", (name) ? name : "NULL");
role = atk_object_get_role(obj);
g_print ("\tAccessible Role: %d\n", role);
description = atk_object_get_description (obj);
g_print ("\tAccessible Description: %s\n", (description) ? description : "NULL");
if (role == ATK_ROLE_PAGE_TAB)
{
AtkObject *parent, *child;
gint x, y, width, height;
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (obj), &x, &y, &width, &height,
ATK_XY_SCREEN);
g_print ("obj: x: %d y: %d width: %d height: %d\n", x, y, width, height);
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (obj), &x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("obj: x: %d y: %d width: %d height: %d\n", x, y, width, height);
parent = atk_object_get_parent (obj);
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (parent), &x, &y, &width, &height,
ATK_XY_SCREEN);
g_print ("parent: x: %d y: %d width: %d height: %d\n", x, y, width, height);
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (parent), &x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("parent: x: %d y: %d width: %d height: %d\n", x, y, width, height);
child = atk_object_ref_accessible_child (obj, 0);
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (child), &x, &y, &width, &height,
ATK_XY_SCREEN);
g_print ("child: x: %d y: %d width: %d height: %d\n", x, y, width, height);
x = y = width = height = 0;
atk_component_get_extents (ATK_COMPONENT (child), &x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("child: x: %d y: %d width: %d height: %d\n", x, y, width, height);
g_object_unref (child);
}
}
static void
_do_selection (AtkObject *obj)
{
gint i;
gint n_children;
AtkRole role;
AtkObject *selection_obj;
static gboolean done_selection = FALSE;
if (done_selection)
return;
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME)
{
AtkRole roles[NUM_VALID_ROLES];
roles[0] = ATK_ROLE_PAGE_TAB_LIST;
selection_obj = find_object_by_role (obj, roles, NUM_VALID_ROLES);
if (selection_obj)
{
done_selection = TRUE;
}
else
return;
}
else
{
return;
}
g_print ("*** Start do_selection ***\n");
n_children = atk_object_get_n_accessible_children (selection_obj);
g_print ("*** Number of notebook pages: %d\n", n_children);
for (i = 0; i < n_children; i++)
{
if (atk_selection_is_child_selected (ATK_SELECTION (selection_obj), i))
{
g_print ("%d page selected\n", i);
}
else
{
g_print ("%d page not selected\n", i);
}
}
/*
* Should not be able to select all items in a notebook.
*/
atk_selection_select_all_selection (ATK_SELECTION (selection_obj));
i = atk_selection_get_selection_count (ATK_SELECTION (selection_obj));
if ( i != 1)
{
g_print ("Unexpected selection count: %d, expected 1\n", i);
g_print ("\t value of i is: %d\n", i);
return;
}
for (i = 0; i < n_children; i++)
{
atk_selection_add_selection (ATK_SELECTION (selection_obj), i);
if (atk_selection_is_child_selected (ATK_SELECTION (selection_obj), i))
{
g_print ("Page %d: successfully selected\n", i);
_finish_selection (selection_obj);
}
else
{
g_print ("ERROR: child %d: selection failed\n", i);
}
}
g_print ("*** End _do_selection ***\n");
g_timeout_add (5000, _remove_page, selection_obj);
}
static gint _remove_page (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
GtkWidget *widget = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), 4);
return FALSE;
}
static gint _finish_selection (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
AtkObject *selected;
AtkObject *parent_object;
GtkWidget *parent_widget;
gint i, index;
g_print ("\t*** Start Finish selection ***\n");
i = atk_selection_get_selection_count (ATK_SELECTION (obj));
if (i != 1)
{
g_print ("\tUnexpected selection count: %d, expected 1\n", i);
return FALSE;
}
selected = atk_selection_ref_selection (ATK_SELECTION (obj), 0);
g_return_val_if_fail (selected != NULL, FALSE);
g_print ("\t*** Selected Item ***\n");
index = atk_object_get_index_in_parent (selected);
g_print ("\tIndex in parent is: %d\n", index);
parent_object = atk_object_get_parent (selected);
g_return_val_if_fail (ATK_IS_OBJECT (parent_object), FALSE);
g_return_val_if_fail (parent_object == obj, FALSE);
parent_widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent_object));
g_return_val_if_fail (GTK_IS_NOTEBOOK (parent_widget), FALSE);
_print_type (selected);
i = atk_selection_get_selection_count (ATK_SELECTION (obj));
g_return_val_if_fail (i == 1, FALSE);
g_object_unref (selected);
g_print ("\t*** End Finish selection ***\n");
return FALSE;
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_do_selection);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testnotebook Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,339 +0,0 @@
#include <gtk/gtk.h>
#include "testlib.h"
static void _print_accessible (AtkObject *obj);
static void _print_type (AtkObject *obj);
static void _print_states (AtkObject *obj);
static void _check_children (AtkObject *obj);
static void _check_relation (AtkObject *obj);
static void _create_event_watcher (void);
static void _focus_handler (AtkObject *obj, gboolean focus_in);
static gboolean _children_changed (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static guint id;
static void _print_states (AtkObject *obj)
{
AtkStateSet *state_set;
gint i;
state_set = atk_object_ref_state_set (obj);
g_print ("*** Start states ***\n");
for (i = 0; i < 64; i++)
{
AtkStateType one_state;
const gchar *name;
if (atk_state_set_contains_state (state_set, i))
{
one_state = i;
name = atk_state_type_get_name (one_state);
if (name)
g_print("%s\n", name);
}
}
g_object_unref (state_set);
g_print ("*** End states ***\n");
}
static void _print_type (AtkObject *obj)
{
const gchar * typename = NULL;
const gchar * name = NULL;
AtkRole role;
static gboolean in_print_type = FALSE;
if (GTK_IS_ACCESSIBLE (obj))
{
GtkWidget* widget = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
typename = g_type_name (G_OBJECT_TYPE (widget));
g_print ("Widget type name: %s\n", typename ? typename : "NULL");
}
typename = g_type_name (G_OBJECT_TYPE (obj));
g_print ("Accessible type name: %s\n", typename ? typename : "NULL");
name = atk_object_get_name (obj);
g_print("Accessible Name: %s\n", (name) ? name : "NULL");
role = atk_object_get_role (obj);
g_print ("Accessible Role: %s\n", atk_role_get_name (role));
if (ATK_IS_COMPONENT (obj))
{
gint x, y, width, height;
AtkStateSet *states;
_print_states (obj);
states = atk_object_ref_state_set (obj);
if (atk_state_set_contains_state (states, ATK_STATE_VISIBLE))
{
AtkObject *parent;
atk_component_get_extents (ATK_COMPONENT (obj),
&x, &y, &width, &height,
ATK_XY_SCREEN);
g_print ("ATK_XY_SCREEN: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
atk_component_get_extents (ATK_COMPONENT (obj),
&x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("ATK_XY_WINDOW: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
if (atk_state_set_contains_state (states, ATK_STATE_SHOWING) &&
ATK_IS_TEXT (obj))
{
gint offset;
atk_text_get_character_extents (ATK_TEXT (obj), 1,
&x, &y, &width, &height,
ATK_XY_WINDOW);
g_print ("Character extents : %d %d %d %d\n",
x, y, width, height);
if (width != 0 && height != 0)
{
offset = atk_text_get_offset_at_point (ATK_TEXT (obj),
x, y,
ATK_XY_WINDOW);
if (offset != 1)
{
g_print ("Wrong offset returned (%d) %d\n", 1, offset);
}
}
}
if (in_print_type)
return;
parent = atk_object_get_parent (obj);
if (!ATK_IS_COMPONENT (parent))
{
/* Assume toplevel */
g_object_unref (G_OBJECT (states));
return;
}
#if 0
obj1 = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
x, y, ATK_XY_WINDOW);
if (obj != obj1)
{
g_print ("Inconsistency between object and ref_accessible_at_point\n");
in_print_type = TRUE;
_print_type (obj1);
in_print_type = FALSE;
}
#endif
}
g_object_unref (G_OBJECT (states));
}
}
static void _print_accessible (AtkObject *obj)
{
GtkWidget* widget = NULL;
AtkObject* parent_atk;
AtkObject* ref_obj;
AtkRole role;
static gboolean first_time = TRUE;
if (first_time)
{
first_time = FALSE;
atk_add_global_event_listener (_children_changed,
"Atk:AtkObject:children_changed");
}
/*
* Check that the object returned by the atk_implementor_ref_accessible()
* for a widget is the same as the accessible object
*/
if (GTK_IS_ACCESSIBLE (obj))
{
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
ref_obj = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (widget));
g_assert (ref_obj == obj);
g_object_unref (G_OBJECT (ref_obj));
}
/*
* Add a focus handler so we see focus out events as well
*/
if (ATK_IS_COMPONENT (obj))
atk_component_add_focus_handler (ATK_COMPONENT (obj), _focus_handler);
g_print ("Object:\n");
_print_type (obj);
_print_states (obj);
/*
* Get the parent object
*/
parent_atk = atk_object_get_parent (obj);
if (parent_atk)
{
g_print ("Parent Object:\n");
_print_type (parent_atk);
parent_atk = atk_object_get_parent (parent_atk);
if (parent_atk)
{
g_print ("Grandparent Object:\n");
_print_type (parent_atk);
}
}
else
{
g_print ("No parent\n");
}
role = atk_object_get_role (obj);
if ((role == ATK_ROLE_FRAME) || (role == ATK_ROLE_DIALOG))
{
_check_children (obj);
}
}
static void _check_relation (AtkObject *obj)
{
AtkRelationSet* relation_set = atk_object_ref_relation_set (obj);
gint n_relations, i;
g_return_if_fail (relation_set);
n_relations = atk_relation_set_get_n_relations (relation_set);
for (i = 0; i < n_relations; i++)
{
AtkRelation* relation = atk_relation_set_get_relation (relation_set, i);
g_print ("Index: %d Relation type: %d Number: %d\n", i,
atk_relation_get_relation_type (relation),
atk_relation_get_target (relation)->len);
}
g_object_unref (relation_set);
}
static void _check_children (AtkObject *obj)
{
gint n_children, i;
AtkLayer layer;
AtkRole role;
g_print ("Start Check Children\n");
n_children = atk_object_get_n_accessible_children (obj);
g_print ("Number of children: %d\n", n_children);
role = atk_object_get_role (obj);
if (ATK_IS_COMPONENT (obj))
{
atk_component_add_focus_handler (ATK_COMPONENT (obj), _focus_handler);
layer = atk_component_get_layer (ATK_COMPONENT (obj));
if (role == ATK_ROLE_MENU)
g_assert (layer == ATK_LAYER_POPUP);
else
g_print ("Layer: %d\n", layer);
}
for (i = 0; i < n_children; i++)
{
AtkObject *child;
AtkObject *parent;
int j;
child = atk_object_ref_accessible_child (obj, i);
parent = atk_object_get_parent (child);
j = atk_object_get_index_in_parent (child);
_print_type (child);
_check_relation (child);
_check_children (child);
if (obj != parent)
{
g_print ("*** Inconsistency between atk_object_get_parent() and "
"atk_object_ref_accessible_child() ***\n");
_print_type (child);
_print_type (obj);
if (parent)
_print_type (parent);
}
g_object_unref (G_OBJECT (child));
if (j != i)
g_print ("*** Inconsistency between parent and children %d %d ***\n",
i, j);
}
g_print ("End Check Children\n");
}
static gboolean
_children_changed (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
guint index;
gpointer target;
const gchar *target_name = "NotAtkObject";
object = g_value_get_object (param_values + 0);
index = g_value_get_uint (param_values + 1);
target = g_value_get_pointer (param_values + 2);
if (G_IS_OBJECT (target))
{
if (ATK_IS_OBJECT (target))
{
target_name = atk_object_get_name (target);
}
if (!target_name)
target_name = g_type_name (G_OBJECT_TYPE (G_OBJECT (target)));
}
else
{
if (!target)
{
AtkObject *child;
child = atk_object_ref_accessible_child (ATK_OBJECT (object), index);
if (child)
{
target_name = g_type_name (G_OBJECT_TYPE (G_OBJECT (child)));
g_object_unref (child);
}
}
}
g_print ("_children_watched: %s %s %s index: %d\n",
g_type_name (G_OBJECT_TYPE (object)),
g_quark_to_string (ihint->detail),
target_name, index);
return TRUE;
}
static void
_create_event_watcher (void)
{
/*
* _print_accessible() will be called for an accessible object when its
* widget receives focus.
*/
id = atk_add_focus_tracker (_print_accessible);
}
static void
_focus_handler (AtkObject *obj, gboolean focus_in)
{
g_print ("In _focus_handler focus_in: %s\n", focus_in ? "true" : "false");
_print_type (obj);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testobject Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,130 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <testlib.h>
static gint _test_paned (gpointer data);
static void _check_paned (AtkObject *obj);
static void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values);
#define NUM_VALID_ROLES 1
static gint last_position;
static void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values)
{
const gchar *type_name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
const gchar *name = atk_object_get_name (obj);
g_print ("_property_change_handler: Accessible Type: %s\n",
type_name ? type_name : "NULL");
g_print ("_property_change_handler: Accessible name: %s\n",
name ? name : "NULL");
g_print ("_property_change_handler: PropertyName: %s\n",
values->property_name ? values->property_name: "NULL");
if (strcmp (values->property_name, "accessible-value") == 0)
{
GValue *value, val;
int position;
value = &val;
memset (value, 0, sizeof (GValue));
atk_value_get_current_value (ATK_VALUE (obj), value);
g_return_if_fail (G_VALUE_HOLDS_INT (value));
position = g_value_get_int (value);
g_print ("Position is %d previous position was %d\n",
position, last_position);
last_position = position;
atk_value_get_minimum_value (ATK_VALUE (obj), value);
g_return_if_fail (G_VALUE_HOLDS_INT (value));
position = g_value_get_int (value);
g_print ("Minimum Value is %d\n", position);
atk_value_get_maximum_value (ATK_VALUE (obj), value);
g_return_if_fail (G_VALUE_HOLDS_INT (value));
position = g_value_get_int (value);
g_print ("Maximum Value is %d\n", position);
}
}
static gint _test_paned (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
AtkRole role = atk_object_get_role (obj);
static gint times = 0;
if (role == ATK_ROLE_SPLIT_PANE)
{
GValue *value, val;
int position;
value = &val;
memset (value, 0, sizeof (GValue));
atk_value_get_current_value (ATK_VALUE (obj), value);
g_return_val_if_fail (G_VALUE_HOLDS_INT (value), FALSE);
position = g_value_get_int (value);
g_print ("Position is : %d\n", position);
last_position = position;
position *= 2;
g_value_set_int (value, position);
atk_value_set_current_value (ATK_VALUE (obj), value);
times++;
}
if (times < 4)
return TRUE;
else
return FALSE;
}
static void _check_paned (AtkObject *obj)
{
static gboolean done_paned = FALSE;
AtkRole role;
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME)
{
AtkRole roles[NUM_VALID_ROLES];
AtkObject *paned_obj;
if (done_paned)
return;
roles[0] = ATK_ROLE_SPLIT_PANE;
paned_obj = find_object_by_role (obj, roles, NUM_VALID_ROLES);
if (paned_obj)
{
if (!done_paned)
{
done_paned = TRUE;
}
atk_object_connect_property_change_handler (paned_obj,
(AtkPropertyChangeHandler*) _property_change_handler);
g_timeout_add (2000, _test_paned, paned_obj);
}
return;
}
if (role != ATK_ROLE_COMBO_BOX)
return;
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_paned);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testpaned Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,220 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <atk/atk.h>
#include <gtk/gtk.h>
#include <testlib.h>
static void _traverse_children (AtkObject *obj);
static void _add_handler (AtkObject *obj);
static void _check_properties (AtkObject *obj);
static void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values);
static void _state_changed (AtkObject *obj,
const gchar *name,
gboolean set);
static void _selection_changed (AtkObject *obj);
static void _visible_data_changed (AtkObject *obj);
static void _model_changed (AtkObject *obj);
static void _create_event_watcher (void);
static guint id;
static void
_state_changed (AtkObject *obj,
const gchar *name,
gboolean set)
{
g_print ("_state_changed: %s: state %s %s\n",
g_type_name (G_OBJECT_TYPE (obj)),
set ? "is" : "was", name);
}
static void
_selection_changed (AtkObject *obj)
{
gchar *type;
if (ATK_IS_TEXT (obj))
type = "text";
else if (ATK_IS_SELECTION (obj))
type = "child selection";
else
{
g_assert_not_reached();
return;
}
g_print ("In selection_changed signal handler for %s, object type: %s\n",
type, g_type_name (G_OBJECT_TYPE (obj)));
}
static void
_visible_data_changed (AtkObject *obj)
{
g_print ("In visible_data_changed signal handler, object type: %s\n",
g_type_name (G_OBJECT_TYPE (obj)));
}
static void
_model_changed (AtkObject *obj)
{
g_print ("In model_changed signal handler, object type: %s\n",
g_type_name (G_OBJECT_TYPE (obj)));
}
static void
_property_change_handler (AtkObject *obj,
AtkPropertyValues *values)
{
const gchar *type_name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
const gchar *name = atk_object_get_name (obj);
g_print ("_property_change_handler: Accessible Type: %s\n",
type_name ? type_name : "NULL");
g_print ("_property_change_handler: Accessible name: %s\n",
name ? name : "NULL");
g_print ("_property_change_handler: PropertyName: %s\n",
values->property_name ? values->property_name: "NULL");
if (G_VALUE_HOLDS_STRING (&values->new_value))
g_print ("_property_change_handler: PropertyValue: %s\n",
g_value_get_string (&values->new_value));
else if (strcmp (values->property_name, "accessible-child") == 0)
{
if (G_IS_VALUE (&values->old_value))
{
g_print ("Child is removed: %s\n",
g_type_name (G_TYPE_FROM_INSTANCE (g_value_get_pointer (&values->old_value))));
}
if (G_IS_VALUE (&values->new_value))
{
g_print ("Child is added: %s\n",
g_type_name (G_TYPE_FROM_INSTANCE (g_value_get_pointer (&values->new_value))));
}
}
else if (strcmp (values->property_name, "accessible-parent") == 0)
{
if (G_IS_VALUE (&values->old_value))
{
g_print ("Parent is removed: %s\n",
g_type_name (G_TYPE_FROM_INSTANCE (g_value_get_pointer (&values->old_value))));
}
if (G_IS_VALUE (&values->new_value))
{
g_print ("Parent is added: %s\n",
g_type_name (G_TYPE_FROM_INSTANCE (g_value_get_pointer (&values->new_value))));
}
}
else if (strcmp (values->property_name, "accessible-value") == 0)
{
if (G_VALUE_HOLDS_DOUBLE (&values->new_value))
{
g_print ("Value now is (double) %f\n",
g_value_get_double (&values->new_value));
}
}
}
static void
_traverse_children (AtkObject *obj)
{
gint n_children, i;
AtkRole role;
role = atk_object_get_role (obj);
if ((role == ATK_ROLE_TABLE) ||
(role == ATK_ROLE_TREE_TABLE))
return;
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);
_add_handler (child);
_traverse_children (child);
g_object_unref (G_OBJECT (child));
}
}
static void
_add_handler (AtkObject *obj)
{
static GPtrArray *obj_array = NULL;
gboolean found = FALSE;
gint i;
/*
* We create a property handler for each object if one was not associated
* with it already.
*
* We add it to our array of objects which have property handlers; if an
* object is destroyed it remains in the array.
*/
if (obj_array == NULL)
obj_array = g_ptr_array_new ();
for (i = 0; i < obj_array->len; i++)
{
if (obj == g_ptr_array_index (obj_array, i))
{
found = TRUE;
break;
}
}
if (!found)
{
atk_object_connect_property_change_handler (obj,
(AtkPropertyChangeHandler*) _property_change_handler);
g_signal_connect (obj, "state-change",
(GCallback) _state_changed, NULL);
if (ATK_IS_SELECTION (obj))
g_signal_connect (obj, "selection_changed",
(GCallback) _selection_changed, NULL);
g_signal_connect (obj, "visible_data_changed",
(GCallback) _visible_data_changed, NULL);
if (ATK_IS_TABLE (obj))
g_signal_connect (obj, "model_changed",
(GCallback) _model_changed, NULL);
g_ptr_array_add (obj_array, obj);
}
}
static void
_check_properties (AtkObject *obj)
{
AtkRole role;
g_print ("Start of _check_properties: %s\n",
g_type_name (G_OBJECT_TYPE (obj)));
_add_handler (obj);
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME ||
role == ATK_ROLE_DIALOG)
{
/*
* Add handlers to all children.
*/
_traverse_children (obj);
}
g_print ("End of _check_properties\n");
}
static void
_create_event_watcher (void)
{
id = atk_add_focus_tracker (_check_properties);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testprops Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,198 +0,0 @@
#include <string.h>
#include <atk/atk.h>
#include <gtk/gtk.h>
/*
* This module tests the selection interface on menu items.
* To use this module run the test program testgtk and use the menus
* option.
*/
static void _do_selection (AtkObject *obj);
static gint _finish_selection (gpointer data);
static AtkObject* _find_object (AtkObject* obj, AtkRole role);
static void _print_type (AtkObject *obj);
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 void _print_type (AtkObject *obj)
{
const gchar * typename = NULL;
const gchar * name = NULL;
AtkRole role;
if (GTK_IS_ACCESSIBLE (obj))
{
GtkWidget* widget = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
typename = g_type_name (G_OBJECT_TYPE (widget));
g_print ("Widget type name: %s\n", typename ? typename : "NULL");
}
typename = g_type_name (G_OBJECT_TYPE (obj));
g_print ("Accessible type name: %s\n", typename ? typename : "NULL");
name = atk_object_get_name (obj);
g_print("Accessible Name: %s\n", (name) ? name : "NULL");
role = atk_object_get_role(obj);
g_print ("Accessible Role: %d\n", role);
}
static void
_do_selection (AtkObject *obj)
{
gint i;
AtkObject *selected;
AtkRole role;
AtkObject *selection_obj;
role = atk_object_get_role (obj);
if ((role == ATK_ROLE_FRAME) &&
(strcmp (atk_object_get_name (obj), "menus") == 0))
{
selection_obj = _find_object (obj, ATK_ROLE_MENU_BAR);
if (selection_obj)
{
g_object_unref (selection_obj);
}
}
else if (role == ATK_ROLE_COMBO_BOX)
{
selection_obj = obj;
}
else
return;
g_print ("*** Start do_selection ***\n");
if (!selection_obj)
{
g_print ("no selection_obj\n");
return;
}
i = atk_selection_get_selection_count (ATK_SELECTION (selection_obj));
if (i != 0)
{
for (i = 0; i < atk_object_get_n_accessible_children (selection_obj); i++)
{
if (atk_selection_is_child_selected (ATK_SELECTION (selection_obj), i))
{
g_print ("%d child selected\n", i);
}
else
{
g_print ("%d child not selected\n", i);
}
}
}
/*
* Should not be able to select all items on a menu bar
*/
atk_selection_select_all_selection (ATK_SELECTION (selection_obj));
i = atk_selection_get_selection_count (ATK_SELECTION (selection_obj));
if ( i != 0)
{
g_print ("Unexpected selection count: %d, expected 0\n", i);
return;
}
/*
* There should not be any items selected
*/
selected = atk_selection_ref_selection (ATK_SELECTION (selection_obj), 0);
if ( selected != NULL)
{
g_print ("Unexpected selection: %d, expected 0\n", i);
}
atk_selection_add_selection (ATK_SELECTION (selection_obj), 1);
g_timeout_add (2000, _finish_selection, selection_obj);
g_print ("*** End _do_selection ***\n");
}
static gint _finish_selection (gpointer data)
{
AtkObject *obj = ATK_OBJECT (data);
AtkObject *selected;
gint i;
gboolean is_selected;
g_print ("*** Start Finish selection ***\n");
/*
* If being run for for menus, at this point menu item foo should be
* selected which means that its submenu should be visible.
*/
i = atk_selection_get_selection_count (ATK_SELECTION (obj));
if (i != 1)
{
g_print ("Unexpected selection count: %d, expected 1\n", i);
return FALSE;
}
selected = atk_selection_ref_selection (ATK_SELECTION (obj), 0);
g_return_val_if_fail (selected != NULL, FALSE);
g_print ("*** Selected Item ***\n");
_print_type (selected);
g_object_unref (selected);
is_selected = atk_selection_is_child_selected (ATK_SELECTION (obj), 1);
g_return_val_if_fail (is_selected, FALSE);
is_selected = atk_selection_is_child_selected (ATK_SELECTION (obj), 0);
g_return_val_if_fail (!is_selected, FALSE);
selected = atk_selection_ref_selection (ATK_SELECTION (obj), 1);
g_return_val_if_fail (selected == NULL, FALSE);
atk_selection_remove_selection (ATK_SELECTION (obj), 0);
i = atk_selection_get_selection_count (ATK_SELECTION (obj));
g_return_val_if_fail (i == 0, FALSE);
selected = atk_selection_ref_selection (ATK_SELECTION (obj), 0);
g_return_val_if_fail (selected == NULL, FALSE);
g_print ("*** End Finish selection ***\n");
return FALSE;
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_do_selection);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testselection Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,127 +0,0 @@
#include <string.h>
#include <glib-object.h>
#include <atk/atk.h>
/*
* To use this test module, run the test program testgtk and click on
* statusbar
*/
static void _check_statusbar (AtkObject *obj);
static AtkObject* _find_object (AtkObject* obj, AtkRole role);
static void _notify_handler (GObject *obj, GParamSpec *pspec);
static void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values);
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 void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values)
{
const gchar *type_name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
const gchar *name = atk_object_get_name (obj);
g_print ("_property_change_handler: Accessible Type: %s\n",
type_name ? type_name : "NULL");
g_print ("_property_change_handler: Accessible name: %s\n",
name ? name : "NULL");
g_print ("_property_change_handler: PropertyName: %s\n",
values->property_name ? values->property_name: "NULL");
if (G_VALUE_HOLDS_STRING (&values->new_value))
g_print ("_property_change_handler: PropertyValue: %s\n",
g_value_get_string (&values->new_value));
}
static void _check_statusbar (AtkObject *obj)
{
AtkRole role;
AtkObject *statusbar, *label;
role = atk_object_get_role (obj);
if (role != ATK_ROLE_FRAME)
return;
statusbar = _find_object (obj, ATK_ROLE_STATUSBAR);
if (!statusbar)
return;
g_print ("_check_statusbar\n");
label = atk_object_ref_accessible_child (statusbar, 0);
g_return_if_fail (label == NULL);
/*
* We get notified of changes to the label
*/
g_signal_connect_closure_by_id (statusbar,
g_signal_lookup ("notify",
G_OBJECT_TYPE (statusbar)),
0,
g_cclosure_new (G_CALLBACK (_notify_handler),
NULL, NULL),
FALSE);
atk_object_connect_property_change_handler (statusbar,
(AtkPropertyChangeHandler*) _property_change_handler);
}
static void
_notify_handler (GObject *obj, GParamSpec *pspec)
{
AtkObject *atk_obj = ATK_OBJECT (obj);
const gchar *name;
g_print ("_notify_handler: property: %s\n", pspec->name);
if (strcmp (pspec->name, "accessible-name") == 0)
{
name = atk_object_get_name (atk_obj);
g_print ("_notify_handler: value: |%s|\n", name ? name : "<NULL>");
}
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_statusbar);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("teststatusbar Module loaded\n");
_create_event_watcher();
return 0;
}

View File

@ -1,940 +0,0 @@
#include <string.h>
#include "testtextlib.h"
#define NUM_ROWS_TO_LOOP 30
typedef struct
{
GtkWidget *tb_others;
GtkWidget *tb_ref_selection;
GtkWidget *tb_ref_at;
GtkWidget *tb_ref_accessible_child;
GtkWidget *child_entry;
GtkWidget *row_entry;
GtkWidget *col_entry;
GtkWidget *index_entry;
}TestChoice;
static void _check_table (AtkObject *in_obj);
void table_runtest(AtkObject *);
static void other_runtest(AtkObject *obj);
static void ref_at_runtest(AtkObject *obj, gint row, gint col);
static void ref_accessible_child_runtest(AtkObject *obj, gint childno);
static void ref_selection_runtest (AtkObject *obj, gint index);
static void _selection_tests(AtkObject *obj);
static void _display_header_info(gchar *type,
AtkObject *header_obj, gint header_num);
static void _process_child(AtkObject *child_obj);
static void _notify_table_row_inserted (GObject *obj,
gint start_offset, gint length);
static void _notify_table_column_inserted (GObject *obj,
gint start_offset, gint length);
static void _notify_table_row_deleted (GObject *obj,
gint start_offset, gint length);
static void _notify_table_column_deleted (GObject *obj,
gint start_offset, gint length);
static void _notify_table_row_reordered (GObject *obj);
static void _notify_table_column_reordered (GObject *obj);
static void _notify_table_child_added (GObject *obj,
gint index, AtkObject *child);
static void _notify_table_child_removed (GObject *obj,
gint index, AtkObject *child);
static void _property_signal_connect (AtkObject *obj);
static void _property_change_handler (AtkObject *obj,
AtkPropertyValues *values);
static gboolean tested_set_headers = FALSE;
static void test_choice_gui (AtkObject **obj);
static void nogui_runtest (AtkObject *obj);
static void nogui_ref_at_runtest (AtkObject *obj);
static void nogui_process_child (AtkObject *obj);
static TestChoice *tc;
static gint g_visibleGUI = 0;
static AtkTable *g_table = NULL;
static AtkObject *current_obj = NULL;
gboolean g_done = FALSE;
gboolean g_properties = TRUE;
/*
* destroy
*
* Destroy Callback
*
*/
static void destroy (GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}
static void choicecb (GtkWidget *widget, gpointer data)
{
AtkObject **ptr_to_obj = (AtkObject **)data;
AtkObject *obj = *ptr_to_obj;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tc->tb_others)))
{
other_runtest(obj);
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tc->tb_ref_selection)))
{
const gchar *indexstr;
gint index;
indexstr = gtk_entry_get_text(GTK_ENTRY(tc->index_entry));
index = string_to_int((gchar *)indexstr);
ref_selection_runtest(obj, index);
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tc->tb_ref_at)))
{
const gchar *rowstr, *colstr;
gint row, col;
rowstr = gtk_entry_get_text(GTK_ENTRY(tc->row_entry));
colstr = gtk_entry_get_text(GTK_ENTRY(tc->col_entry));
row = string_to_int((gchar *)rowstr);
col = string_to_int((gchar *)colstr);
ref_at_runtest(obj, row, col);
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tc->tb_ref_accessible_child)))
{
const gchar *childstr;
gint childno;
childstr = gtk_entry_get_text(GTK_ENTRY(tc->child_entry));
childno = string_to_int((gchar *)childstr);
ref_accessible_child_runtest(obj, childno);
}
}
static void _check_table (AtkObject *in_obj)
{
AtkObject *obj = NULL;
const char *no_properties;
const char *no_gui;
no_properties = g_getenv ("TEST_ACCESSIBLE_NO_PROPERTIES");
no_gui = g_getenv ("TEST_ACCESSIBLE_NO_GUI");
if (no_properties != NULL)
g_properties = FALSE;
if (no_gui != NULL)
g_visibleGUI = 1;
obj = find_object_by_type(in_obj, "GailTreeView");
if (obj != NULL)
g_print("Found GailTreeView table in child!\n");
else
{
obj = find_object_by_type(in_obj, "GailCList");
if (obj != NULL)
g_print("Found GailCList in child!\n");
else
{
g_print("No object found %s\n", g_type_name (G_OBJECT_TYPE (in_obj)));
return;
}
}
g_print ("In _check_table\n");
if (!already_accessed_atk_object(obj))
{
/* Set up signal handlers */
g_print ("Adding signal handler\n");
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("column_inserted", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_column_inserted),
NULL, NULL),
FALSE);
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("row_inserted", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_row_inserted),
NULL, NULL),
FALSE);
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("column_deleted", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_column_deleted),
NULL, NULL),
FALSE);
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("row_deleted", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_row_deleted),
NULL, NULL),
FALSE);
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("column_reordered", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_column_reordered),
NULL, NULL),
FALSE);
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("row_reordered", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_table_row_reordered),
NULL, NULL),
FALSE);
g_signal_connect_closure (obj, "children_changed::add",
g_cclosure_new (G_CALLBACK (_notify_table_child_added),
NULL, NULL),
FALSE);
g_signal_connect_closure (obj, "children_changed::remove",
g_cclosure_new (G_CALLBACK (_notify_table_child_removed),
NULL, NULL),
FALSE);
}
g_table = ATK_TABLE(obj);
atk_object_connect_property_change_handler (obj,
(AtkPropertyChangeHandler*) _property_change_handler);
current_obj = obj;
/*
* The use of &current_obj allows us to change the object being processed
* in the GUI.
*/
if (g_visibleGUI != 1)
test_choice_gui(&current_obj);
else if (no_gui != NULL)
nogui_runtest(obj);
}
static
void other_runtest(AtkObject *obj)
{
AtkObject *header_obj;
AtkObject *out_obj;
const gchar *out_string;
GString *out_desc;
gint n_cols, n_rows;
gint rows_to_loop = NUM_ROWS_TO_LOOP;
gint i, j;
out_desc = g_string_sized_new(256);
n_cols = atk_table_get_n_columns(ATK_TABLE(obj));
n_rows = atk_table_get_n_rows(ATK_TABLE(obj));
g_print ("Number of columns is %d\n", n_cols);
g_print ("Number of rows is %d\n", n_rows);
/* Loop NUM_ROWS_TO_LOOP rows if possible */
if (n_rows < NUM_ROWS_TO_LOOP)
rows_to_loop = n_rows;
g_print ("\n");
/* Caption */
out_obj = atk_table_get_caption(ATK_TABLE(obj));
if (out_obj != NULL)
{
out_string = atk_object_get_name (out_obj);
if (out_string)
g_print("Caption Name is <%s>\n", out_string);
else
g_print("Caption has no name\n");
}
else
g_print("No caption\n");
/* Column descriptions and headers */
g_print ("\n");
for (i=0; i < n_cols; i++)
{
/* check default */
out_string = atk_table_get_column_description(ATK_TABLE(obj), i);
if (out_string != NULL)
g_print("%d: Column description is <%s>\n", i, out_string);
else
g_print("%d: Column description is <NULL>\n", i);
/* check setting a new value */
g_string_printf(out_desc, "new column description %d", i);
if (out_string == NULL || strcmp (out_string, out_desc->str) != 0)
{
g_print("%d, Setting the column description to <%s>\n",
i, out_desc->str);
atk_table_set_column_description(ATK_TABLE(obj), i, out_desc->str);
out_string = atk_table_get_column_description(ATK_TABLE(obj), i);
if (out_string != NULL)
g_print("%d: Column description is <%s>\n", i, out_string);
else
g_print("%d: Column description is <NULL>\n", i);
}
/* Column header */
header_obj = atk_table_get_column_header(ATK_TABLE(obj), i);
_display_header_info("Column", header_obj, i);
}
/* Row description */
g_print ("\n");
for (i=0; i < rows_to_loop; i++)
{
out_string = atk_table_get_row_description(ATK_TABLE(obj), i);
if (out_string != NULL)
g_print("%d: Row description is <%s>\n", i, out_string);
else
g_print("%d: Row description is <NULL>\n", i);
g_string_printf(out_desc, "new row description %d", i);
if (out_string == NULL || strcmp (out_string, out_desc->str) != 0)
{
g_print("%d: Setting the row description to <%s>\n",
i, out_desc->str);
atk_table_set_row_description(ATK_TABLE(obj), i, out_desc->str);
out_string = atk_table_get_row_description(ATK_TABLE(obj), i);
if (out_string != NULL)
g_print("%d: Row description is <%s>\n", i, out_string);
else
g_print("%d: Row description is <NULL>\n", i);
}
header_obj = atk_table_get_row_header(ATK_TABLE(obj), i);
_display_header_info("Row", header_obj, i);
for (j=0; j <n_cols; j++)
{
gint index = atk_table_get_index_at(ATK_TABLE(obj), i, j);
gint row, column;
column = atk_table_get_column_at_index (ATK_TABLE (obj), index);
g_return_if_fail (column == j);
row = atk_table_get_row_at_index (ATK_TABLE (obj), index);
g_return_if_fail (row == i);
if(atk_selection_is_child_selected(ATK_SELECTION(obj), index))
g_print("atk_selection_is_child_selected,index = %d returns TRUE\n", index);
/* Generic cell tests */
/* Just test setting column headers once. */
if (!tested_set_headers)
{
tested_set_headers = TRUE;
/* Hardcode to 1,1 for now */
g_print(
"Testing set_column_header for column %d, to table\n",
(n_cols - 1));
atk_table_set_column_header(ATK_TABLE(obj), (n_cols - 1), obj);
g_print("Testing set_row_header for row %d, to table\n", n_rows);
atk_table_set_row_header(ATK_TABLE(obj), n_rows, obj);
}
}
}
/* row/column extents */
g_print("\n");
g_print("Row extents at 1,1 is %d\n",
atk_table_get_row_extent_at(ATK_TABLE(obj), 1, 1));
g_print("Column extents at 1,1 is %d\n",
atk_table_get_column_extent_at(ATK_TABLE(obj), 1, 1));
}
static
void ref_accessible_child_runtest(AtkObject *obj, gint child)
{
AtkObject *child_obj;
/* ref_child */
g_print ("Accessing child %d\n", child);
child_obj = atk_object_ref_accessible_child (obj, child);
_property_signal_connect(child_obj);
if (child_obj != NULL)
_process_child(child_obj);
}
static
void ref_selection_runtest (AtkObject *obj, gint index)
{
AtkObject *child_obj;
/* use atk_selection_ref_selection just once to check it works */
child_obj = atk_selection_ref_selection(ATK_SELECTION(obj), index);
if (child_obj)
{
g_print("child_obj gotten from atk_selection_ref_selection\n");
g_object_unref (child_obj);
}
else
g_print("NULL returned by atk_selection_ref_selection\n");
_selection_tests(obj);
}
static
void ref_at_runtest(AtkObject *obj, gint row, gint col)
{
AtkObject *child_obj;
/* ref_at */
g_print("Testing ref_at row %d column %d\n", row, col);
child_obj = atk_table_ref_at(ATK_TABLE(obj), row, col);
_property_signal_connect(child_obj);
g_print("Row is %d, col is %d\n", row, col);
_process_child(child_obj);
if (child_obj)
g_object_unref (child_obj);
}
/**
* process_child
**/
static void
_process_child(AtkObject *child_obj)
{
if (child_obj != NULL)
{
if (ATK_IS_TEXT(child_obj))
{
add_handlers(child_obj);
setup_gui(child_obj, runtest);
}
else
{
g_print("Interface is not text!\n");
}
/*
if (ATK_IS_ACTION(child_obj))
{
gint i, j;
gchar *action_name;
gchar *action_description;
gchar *action_keybinding;
AtkAction *action = ATK_ACTION(child_obj);
i = atk_action_get_n_actions (action);
g_print ("Supports AtkAction with %d actions.\n", i);
for (j = 0; j < i; j++)
{
g_print ("Action %d:\n", j);
action_name = atk_action_get_name (action, j);
if (action_name)
g_print (" Name = %s\n", action_name);
action_description = atk_action_get_description (action, j);
if (action_description)
g_print (" Description = %s\n", action_description);
action_keybinding = atk_action_get_keybinding (action, j);
if (action_keybinding)
g_print (" Keybinding = %s\n", action_keybinding);
action_description = "new description";
g_print (" Setting description to %s\n", action_description);
atk_action_set_description (action, j, action_description);
action_description = atk_action_get_description (action, j);
if (action_description)
g_print (" New description is now %s\n", action_description);
}
}
*/
}
else
{
g_print("Child is NULL!\n");
}
}
/**
* Combined tests on AtkTable and AtkSelection on individual rows rather than
* all of them
**/
static void
_selection_tests(AtkObject *obj)
{
gint n_rows = 0;
gint n_cols = 0;
gint selection_count = 0;
gint i = 0;
gint *selected = NULL;
AtkTable *table;
table = ATK_TABLE (obj);
n_rows = atk_table_get_selected_rows(table, &selected);
for (i = 0; i < n_rows; i++)
{
g_print("atk_table_get_selected_row returns : %d\n",
selected[i]);
if (!atk_table_is_row_selected (table, selected[i]))
g_print("atk_table_is_row_selected returns false for selected row %d\n",
selected[i]);
}
g_free (selected);
selected = NULL;
n_cols = atk_table_get_selected_columns(table, &selected);
for (i = 0; i < n_cols; i++)
g_print("atk_table_get_selected_columns returns : %d\n", selected[i]);
g_free (selected);
selection_count = atk_selection_get_selection_count(ATK_SELECTION(obj));
g_print("atk_selection_get_selection_count returns %d\n", selection_count);
if (atk_table_is_row_selected(table, 2))
{
g_print("atk_table_is_row_selected (table, 2) returns TRUE\n");
atk_selection_clear_selection (ATK_SELECTION (obj));
if (atk_table_add_row_selection(table, 4))
g_print("atk_table_add_row_selection: selected row 4\n");
if (!atk_table_is_row_selected (table, 4))
g_print("atk_table_is_row_selected returns false for row 2\n");
if (atk_table_is_row_selected (table, 2))
g_print("atk_table_is_row_selected gives false positive for row 2\n");
}
if (atk_table_is_row_selected(table, 3))
{
if (atk_table_remove_row_selection(table, 3))
g_print("atk_table_remove_row_selection unselected row 3\n");
}
if (atk_table_is_selected(table, 5, 4))
{
atk_selection_clear_selection(ATK_SELECTION(obj));
g_print("atk_selection_clear_selection: just cleared all selected\n");
}
if (atk_table_is_column_selected(table, 2))
{
g_print("atk_table_is_column_selected(obj, 2) returns TRUE\n");
if (atk_table_add_column_selection(table, 4))
g_print("atk_table_add_column_selection: selected column 4\n");
g_print("atk_table_is_column_selected(obj, 2) returns TRUE\n");
}
if (atk_table_is_column_selected(table, 3))
{
if (atk_table_remove_column_selection(table, 3))
g_print("atk_table_remove_column_selection: unselected column 3\n");
}
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_table);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("TestTable Module loaded\n");
_create_event_watcher();
return 0;
}
static void
_notify_table_row_inserted (GObject *obj, gint start_offset, gint length)
{
g_print ("SIGNAL - Row inserted at position %d, num of rows inserted %d!\n",
start_offset, length);
}
static void
_notify_table_column_inserted (GObject *obj, gint start_offset, gint length)
{
g_print ("SIGNAL - Column inserted at position %d, num of columns inserted %d!\n",
start_offset, length);
}
static void
_notify_table_row_deleted (GObject *obj, gint start_offset, gint length)
{
g_print ("SIGNAL - Row deleted at position %d, num of rows deleted %d!\n",
start_offset, length);
}
static void
_notify_table_column_deleted (GObject *obj, gint start_offset, gint length)
{
g_print ("SIGNAL - Column deleted at position %d, num of columns deleted %d!\n",
start_offset, length);
}
static void
_notify_table_row_reordered (GObject *obj)
{
g_print ("SIGNAL - Row reordered!\n");
}
static void
_notify_table_column_reordered (GObject *obj)
{
g_print ("SIGNAL - Column reordered!\n");
}
static void _notify_table_child_added (GObject *obj,
gint index, AtkObject *child)
{
g_print ("SIGNAL - Child added - index %d\n", index);
}
static void _notify_table_child_removed (GObject *obj,
gint index, AtkObject *child)
{
g_print ("SIGNAL - Child removed - index %d\n", index);
}
static void
_display_header_info(gchar *type, AtkObject *header_obj, gint header_num)
{
if (header_obj != NULL)
{
AtkRole role;
role = atk_object_get_role(header_obj);
if (role == ATK_ROLE_PUSH_BUTTON)
{
g_print ("%d: %s header is a push button!\n", header_num, type);
}
else if (role == ATK_ROLE_LABEL)
{
g_print ("%d: %s header is a label!\n", header_num, type);
}
else if (ATK_IS_TEXT(header_obj))
{
gchar *header_text;
header_text = atk_text_get_text (ATK_TEXT (header_obj), 0, 3);
if (header_text != NULL)
{
g_print("%d: %s header is a text value <%s>\n", header_num,
type, header_text);
}
else
{
g_print("%d: %s header is a text value <NULL>\n", header_num,
type);
}
}
else
{
g_print ("%d: %s header is of type %s!\n", header_num,
type, atk_role_get_name (role));
}
}
else
{
g_print ("%d: %s header object is NULL!\n", header_num, type);
}
}
static void _property_signal_connect (AtkObject *obj)
{
if (g_properties && obj != NULL)
{
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("property_change", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_property_change_handler),
NULL, NULL),
FALSE);
}
}
static void
_property_change_handler (AtkObject *obj,
AtkPropertyValues *values)
{
gchar *obj_text;
const gchar *name;
if (g_table != NULL)
{
gint index = atk_object_get_index_in_parent(obj);
if (index >= 0)
g_print("Index is %d, row is %d, col is %d\n", index,
atk_table_get_row_at_index(g_table, index),
atk_table_get_column_at_index(g_table, index));
else
g_print ("index: %d for %s\n", index, g_type_name (G_OBJECT_TYPE (obj)));
}
if (ATK_IS_TEXT(obj))
{
obj_text = atk_text_get_text (ATK_TEXT (obj), 0, 15);
if (obj_text == NULL)
g_print(" Cell text is <NULL>\n");
else
g_print(" Cell text is <%s>\n", obj_text);
}
g_print(" PropertyName <%s>\n",
values->property_name ? values->property_name: "NULL");
g_print(" - ");
if (&values->old_value != NULL && G_IS_VALUE (&values->old_value))
{
GType old_type = G_VALUE_TYPE (&values->old_value);
switch (old_type)
{
case G_TYPE_INT:
g_print("value was <%d>\n", g_value_get_int (&values->old_value));
break;
case G_TYPE_STRING:
name = g_value_get_string (&values->old_value);
if (name != NULL)
g_print ("value was <%s>\n", name);
else
g_print ("value was <NULL>\n");
break;
default:
g_print("value was <unknown type>\n");
break;
}
}
else
{
g_print("value was <not a value>\n");
}
g_print(" - ");
if (&values->new_value != NULL && G_IS_VALUE (&values->new_value))
{
GType new_type = G_VALUE_TYPE (&values->new_value);
switch (new_type)
{
case G_TYPE_INT:
g_print("value is <%d>\n", g_value_get_int (&values->new_value));
break;
case G_TYPE_STRING:
name = g_value_get_string (&values->new_value);
if (name != NULL)
g_print ("value is <%s>\n", name);
else
g_print ("value is <NULL>\n");
break;
default:
g_print("value is <unknown type>\n");
break;
}
}
else
{
g_print("value is <not a value>\n");
}
}
static
void test_choice_gui(AtkObject **obj)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *child_label;
GtkWidget *row_label;
GtkWidget *col_label;
GtkWidget *index_label;
GtkWidget *hseparator;
GtkWidget *hbuttonbox;
GtkWidget *button;
tc = (TestChoice *) g_malloc (sizeof(TestChoice));
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Test to run");
g_signal_connect(window, "destroy",
G_CALLBACK (destroy), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
gtk_box_set_spacing(GTK_BOX(vbox), 10);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing(GTK_BOX(hbox), 10);
tc->tb_ref_selection = gtk_toggle_button_new_with_label("ref_selection");
gtk_box_pack_start (GTK_BOX (hbox), tc->tb_ref_selection, TRUE, TRUE, 0);
index_label = gtk_label_new("index: ");
gtk_box_pack_start (GTK_BOX (hbox), index_label, TRUE, TRUE, 0);
tc->index_entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(tc->index_entry), "1");
gtk_box_pack_start (GTK_BOX (hbox), tc->index_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing(GTK_BOX(hbox), 10);
tc->tb_ref_at = gtk_toggle_button_new_with_label("ref_at");
gtk_box_pack_start (GTK_BOX (hbox), tc->tb_ref_at, TRUE, TRUE, 0);
row_label = gtk_label_new("row:");
gtk_box_pack_start (GTK_BOX (hbox), row_label, TRUE, TRUE, 0);
tc->row_entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(tc->row_entry), "1");
gtk_box_pack_start (GTK_BOX (hbox), tc->row_entry, TRUE, TRUE, 0);
col_label = gtk_label_new("column:");
gtk_box_pack_start (GTK_BOX (hbox), col_label, TRUE, TRUE, 0);
tc->col_entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(tc->col_entry), "1");
gtk_box_pack_start (GTK_BOX (hbox), tc->col_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing(GTK_BOX(hbox), 10);
tc->tb_ref_accessible_child = gtk_toggle_button_new_with_label("ref_accessible_child");
gtk_box_pack_start (GTK_BOX (hbox), tc->tb_ref_accessible_child, TRUE, TRUE, 0);
child_label = gtk_label_new("Child no:");
gtk_box_pack_start (GTK_BOX (hbox), child_label, TRUE, TRUE, 0);
tc->child_entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(tc->child_entry), "1");
gtk_box_pack_start (GTK_BOX (hbox), tc->child_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
tc->tb_others = gtk_toggle_button_new_with_label("others");
gtk_box_pack_start (GTK_BOX (vbox), tc->tb_others, TRUE, TRUE, 0);
hseparator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
gtk_box_pack_start (GTK_BOX (vbox), hseparator, TRUE, TRUE, 0);
button = gtk_button_new_with_mnemonic("_Run Test");
hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox),
GTK_BUTTONBOX_SPREAD);
gtk_box_pack_end (GTK_BOX (hbuttonbox), GTK_WIDGET (button), TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (vbox), hbuttonbox, TRUE, TRUE, 0);
g_signal_connect(button, "clicked", G_CALLBACK (choicecb), obj);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show(vbox);
gtk_widget_show(window);
gtk_widget_show_all(GTK_WIDGET(window));
g_visibleGUI = 1;
}
void static
nogui_runtest (AtkObject *obj)
{
g_print ("Running non-GUI tests...\n");
other_runtest (obj);
nogui_ref_at_runtest (obj);
}
static void
nogui_ref_at_runtest (AtkObject *obj)
{
AtkObject *child_obj;
gint i, j;
gint n_cols;
gint rows_to_loop = 5;
n_cols = atk_table_get_n_columns (ATK_TABLE(obj));
if (atk_table_get_n_rows(ATK_TABLE(obj)) < rows_to_loop)
rows_to_loop = atk_table_get_n_rows (ATK_TABLE(obj));
for (i=0; i < rows_to_loop; i++)
{
/* Just the first rows_to_loop rows */
for (j=0; j < n_cols; j++)
{
gint index = atk_table_get_index_at(ATK_TABLE(obj), i, j);
if(atk_selection_is_child_selected(ATK_SELECTION(obj), index))
g_print("atk_selection_is_child_selected,index = %d returns TRUE\n", index);
g_print("Testing ref_at row %d column %d\n", i, j);
if (i == 3 && j == 0)
{
g_print("child_obj gotten from atk_selection_ref_selection\n");
/* use atk_selection_ref_selection just once to check it works */
child_obj = atk_selection_ref_selection(ATK_SELECTION(obj), index );
}
else
{
child_obj = atk_table_ref_at(ATK_TABLE(obj), i, j);
}
_property_signal_connect(child_obj);
g_print("Index is %d, row is %d, col is %d\n", index,
atk_table_get_row_at_index(ATK_TABLE(obj), index),
atk_table_get_column_at_index(ATK_TABLE(obj), index));
nogui_process_child (child_obj);
/* Generic cell tests */
/* Just test setting column headers once. */
if (!tested_set_headers)
{
tested_set_headers = TRUE;
g_print("Testing set_column_header for column %d, to cell value %d,%d\n",
j, i, j);
atk_table_set_column_header(ATK_TABLE(obj), j, child_obj);
g_print("Testing set_row_header for row %d, to cell value %d,%d\n",
i, i, j);
atk_table_set_row_header(ATK_TABLE(obj), i, child_obj);
}
if (child_obj)
g_object_unref (child_obj);
}
}
}
static void
nogui_process_child (AtkObject *obj)
{
gchar default_val[5] = "NULL";
if (ATK_IS_TEXT(obj))
{
gchar *current_text;
current_text = atk_text_get_text (ATK_TEXT(obj), 0, -1);
g_print ("Child supports text interface.\nCurrent text is %s\n", current_text);
}
if (ATK_IS_ACTION(obj))
{
AtkAction *action = ATK_ACTION(obj);
gint n_actions, i;
const gchar *name, *description;
n_actions = atk_action_get_n_actions (action);
g_print ("Child supports %d actions.\n", n_actions);
for (i = 0; i < n_actions; i++)
{
name = atk_action_get_name (action, i);
description = atk_action_get_description (action, i);
if (name == NULL)
name = default_val;
if (description == NULL)
description = default_val;
g_print (" %d: name = <%s>\n", i, name);
g_print (" description = <%s>\n", description);
}
}
}

View File

@ -1,131 +0,0 @@
#include <atk/atk.h>
#include "testtextlib.h"
#define NUM_VALID_ROLES 6
static void _create_event_watcher (void);
static void _check_text (AtkObject *obj);
void runtest(AtkObject *, gint);
static guint id1 = 0;
static guint win_count = 0;
static void _check_text (AtkObject *in_obj)
{
AtkObject *obj = NULL;
AtkRole role;
gchar* title;
AtkRole valid_roles[NUM_VALID_ROLES];
if (g_getenv("TEST_ACCESSIBLE_DELAY") != NULL)
{
int max_cnt = string_to_int(g_getenv("TEST_ACCESSIBLE_DELAY"));
win_count++;
if (win_count <= max_cnt)
return;
}
/* Set Up */
valid_roles[0] = ATK_ROLE_TEXT;
valid_roles[1] = ATK_ROLE_LABEL;
valid_roles[2] = ATK_ROLE_ACCEL_LABEL;
valid_roles[3] = ATK_ROLE_PASSWORD_TEXT;
valid_roles[4] = ATK_ROLE_TABLE_CELL;
valid_roles[5] = ATK_ROLE_PANEL;
/* The following if/else grabs the windows name, or sets title to NULL if none. */
if (in_obj->name)
{
title = in_obj->name;
}
else
{
GtkWidget *toplevel;
GtkWidget* widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (in_obj));
if (widget == NULL)
title = NULL;
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (toplevel))
title = (gchar *) gtk_window_get_title (GTK_WINDOW (toplevel));
else
title = NULL;
}
/* If no window name, do nothing */
if (title == NULL)
return;
/*
* If testtext test program, find obj just by role since only one child
* with no name
*/
else if (g_ascii_strncasecmp(title, "testtext", 7) == 0)
{
obj = find_object_by_role(in_obj, valid_roles, NUM_VALID_ROLES);
}
/*
* Otherwise, get obj by name and role so you can specify exactly which
* obj to run tests on
*/
else
{
const gchar *test_accessible_name = g_getenv ("TEST_ACCESSIBLE_NAME");
if (test_accessible_name != NULL)
{
obj = find_object_by_accessible_name_and_role(in_obj,
test_accessible_name, valid_roles, NUM_VALID_ROLES);
}
if (obj != NULL)
{
if (atk_object_get_role (obj) == ATK_ROLE_PANEL)
{
/* Get the child and check whether it is a label */
obj = atk_object_ref_accessible_child (obj, 0);
g_assert (atk_object_get_role (obj) == ATK_ROLE_LABEL);
g_object_unref (obj);
}
g_print("Found valid name and role in child!\n");
}
else
{
obj = find_object_by_role(in_obj, valid_roles, NUM_VALID_ROLES - 1);
if (obj != NULL)
g_print("Found valid role in child\n");
}
}
if (obj == NULL)
{
g_print("Object not found\n");
return;
}
role = atk_object_get_role(obj);
g_print("_check_text - Found role type %s!\n\n", atk_role_get_name (role));
add_handlers(obj);
if (!(isVisibleDialog()))
setup_gui(obj, runtest);
atk_remove_focus_tracker (id1);
}
static void
_create_event_watcher (void)
{
id1 = atk_add_focus_tracker (_check_text);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testtext Module loaded.\n");
_create_event_watcher();
return 0;
}

View File

@ -1,740 +0,0 @@
#include <string.h>
#include <stdio.h>
#include "testtextlib.h"
static AtkAttributeSet *attrib = NULL;
static char result_string[2][6] = {"FALSE", "TRUE"};
/**
* setup_gui:
* @obj: An @AtkObject
* @test: The callback to be run when the "Run Tests" button
* in the GUI is clicked.
*
* Sets up the GUI windows.
*
* Returns: the window number, or -1 if failure.
**/
gint setup_gui(AtkObject *obj, TLruntest test)
{
gchar *paramnames[MAX_PARAMS];
gchar *defaults[MAX_PARAMS];
static OutputWindow *tow = NULL;
gint window;
if (tow)
window = create_windows(obj, test, &tow);
else
window = create_windows(obj, test, &tow);
if (window == -1)
return -1;
/* Get Text [at|after|before] Offset Tests */
paramnames[0] = "offset";
defaults[0] = "1";
add_test(window, "atk_text_get_text_after_offset", 1, paramnames, defaults);
add_test(window, "atk_text_get_text_before_offset", 1, paramnames, defaults);
add_test(window, "atk_text_get_text_at_offset",1 , paramnames, defaults);
/* Get Character Count Test */
add_test(window, "atk_text_get_character_count", 0, NULL, NULL);
/* Get Character At Offset Test */
paramnames[0] = "offset";
defaults[0] = "1";
add_test(window, "atk_text_get_character_at_offset", 1, paramnames, defaults);
/* Get Text Test */
paramnames[0] = "position 1";
paramnames[1] = "position 2";
defaults[0] = "0";
defaults[1] = "5";
add_test(window, "atk_text_get_text", 2, paramnames, defaults);
/* Caret Tests */
add_test(window, "atk_text_get_caret_offset", 0, NULL, NULL);
paramnames[0] = "offset";
defaults[0] = "1";
add_test(window, "atk_text_set_caret_offset", 1, paramnames, defaults);
/* Selection Tests */
add_test(window, "atk_text_get_n_selections", 0, NULL, NULL);
paramnames[0] = "selection no";
defaults[0] = "0";
add_test(window, "atk_text_get_selection", 1, paramnames, defaults);
paramnames[0] = "start";
paramnames[1] = "end";
defaults[0] = "3";
defaults[1] = "8";
add_test(window, "atk_text_add_selection", 2, paramnames, defaults);
paramnames[0] = "selection no";
paramnames[1] = "start";
paramnames[2] = "end";
defaults[0] = "0";
defaults[1] = "5";
defaults[2] = "7";
add_test(window, "atk_text_set_selection", 3, paramnames, defaults);
paramnames[0] = "selection no";
defaults[0] = "0";
add_test(window, "atk_text_remove_selection", 1, paramnames, defaults);
paramnames[0] = "offset";
defaults[0] = "36";
add_test(window, "atk_text_get_run_attributes", 1, paramnames, defaults);
add_test(window, "atk_text_get_default_attributes", 0, paramnames, defaults);
paramnames[0] = "offset";
paramnames[1] = "coord mode";
defaults[0] = "0";
defaults[1] = "ATK_XY_SCREEN";
add_test(window, "atk_text_get_character_extents", 2, paramnames, defaults);
paramnames[0] = "x";
paramnames[1] = "y";
paramnames[2] = "coord mode";
defaults[0] = "106";
defaults[1] = "208";
defaults[2] = "ATK_XY_SCREEN";
add_test(window, "atk_text_get_offset_at_point", 3, paramnames, defaults);
/* Editable Text Tests */
if (ATK_IS_EDITABLE_TEXT(obj))
{
paramnames[0] = "start";
paramnames[1] = "end";
defaults[0] = "20";
defaults[1] = "27";
add_test(window, "atk_editable_text_set_run_attributes", 2, paramnames, defaults);
paramnames[0] = "start";
paramnames[1] = "end";
defaults[0] = "3";
defaults[1] = "5";
add_test(window, "atk_editable_text_cut_text", 2, paramnames, defaults);
paramnames[0] = "position";
defaults[0] = "8";
add_test(window, "atk_editable_text_paste_text", 1, paramnames, defaults);
paramnames[0] = "start";
paramnames[1] = "end";
defaults[0] = "15";
defaults[1] = "20";
add_test(window, "atk_editable_text_delete_text", 2, paramnames, defaults);
paramnames[0] = "start";
paramnames[1] = "end";
defaults[0] = "5";
defaults[1] = "20";
add_test(window, "atk_editable_text_copy_text", 2, paramnames, defaults);
paramnames[0] = "insert text";
paramnames[1] = "position";
defaults[0] = "this is my insert";
defaults[1] = "15";
add_test(window, "atk_editable_text_insert_text", 2, paramnames, defaults);
}
return window;
}
/**
* add_handlers:
* @obj: An #AtkObject
*
* Sets up text signal handlers.
*
**/
void add_handlers(AtkObject *obj)
{
if (!already_accessed_atk_object(obj))
{
/* Set up signal handlers */
g_print ("Adding signal handler\n");
g_signal_connect_closure_by_id (obj,
g_signal_lookup ("text_caret_moved", G_OBJECT_TYPE (obj)),
0,
g_cclosure_new (G_CALLBACK (_notify_caret_handler),
NULL, NULL),
FALSE);
g_signal_connect_closure (obj, "text_changed::insert",
g_cclosure_new (G_CALLBACK (_notify_text_insert_handler),
NULL, NULL),
FALSE);
g_signal_connect_closure (obj, "text_changed::delete",
g_cclosure_new (G_CALLBACK (_notify_text_delete_handler),
NULL, NULL),
FALSE);
}
}
/**
* notify_text_insert_handler:
* @obj: A #Gobject
* @start_offset: Start offset of insert
* @end_offset: End offset of insert.
*
* Text inserted singal handler
**/
void
_notify_text_insert_handler (GObject *obj, int start_offset, int end_offset)
{
g_print ("SIGNAL - Text inserted at position %d, length %d!\n",
start_offset, end_offset);
}
/**
* notify_text_delete_handler:
* @obj: A #Gobject
* @start_offset: Start offset of delete
* @end_offset: End offset of delete.
*
* Text deleted singal handler
**/
void
_notify_text_delete_handler (GObject *obj, int start_offset, int end_offset)
{
g_print ("SIGNAL - Text deleted at position %d, length %d!\n",
start_offset, end_offset);
}
/**
* notify_caret_handler:
* @obj: A #Gobject
* @position: Caret position
*
* Caret (cursor) moved signal handler.
**/
void
_notify_caret_handler (GObject *obj, int position)
{
g_print ("SIGNAL - The caret moved to position %d!\n", position);
}
/**
* runtest:
* @obj: An #AtkObject
* @win_val: The window number
*
* The callback to run when the "Run Tests" button on the
* Test GUI is clicked.
**/
void
runtest(AtkObject *obj, gint win_val)
{
gint i, size;
gunichar uni_char;
gchar output[MAX_LINE_SIZE];
gchar **testsOn;
testsOn = tests_set(win_val, &size);
for(i = 0; i < size; i++)
{
gint param_int1, param_int2, start, end, j, x, y, height, width;
gchar *param_string1, *param_string2, *param_string3, *text;
gboolean result;
gint index;
if (strcmp(testsOn[i], "atk_text_get_text_at_offset") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_text_at_offset", "offset");
param_int1 = string_to_int(param_string1);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
_run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_CHAR);
}
if (strcmp(testsOn[i], "atk_text_get_text_after_offset") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_text_after_offset", "offset");
param_int1 = string_to_int(param_string1);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
_run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_CHAR);
}
if (strcmp(testsOn[i], "atk_text_get_text_before_offset") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_text_before_offset", "offset");
param_int1 = string_to_int(param_string1);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
_run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_CHAR);
}
if (strcmp(testsOn[i], "atk_text_get_character_count") == 0)
{
param_int1 = atk_text_get_character_count (ATK_TEXT (obj));
sprintf(output, "\nText character count: %d\n", param_int1);
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_character_at_offset") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_character_at_offset",
"offset");
uni_char = atk_text_get_character_at_offset (ATK_TEXT(obj),
string_to_int(param_string1));
sprintf(output, "\nCharacter at offset %d: |%x|\n",
string_to_int(param_string1), uni_char);
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_text", "position 1");
param_string2 = get_arg_of_func(win_val, "atk_text_get_text", "position 2");
text = atk_text_get_text (ATK_TEXT (obj), string_to_int(param_string1),
string_to_int(param_string2));
sprintf(output, "\nText %d, %d: %s\n", string_to_int(param_string1),
string_to_int(param_string2), text);
g_free (text);
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_caret_offset") == 0)
{
param_int1 = atk_text_get_caret_offset (ATK_TEXT (obj));
if (param_int1 == -1)
sprintf(output, "\nCaret offset: |Not Supported|\n");
else
sprintf(output, "\nCaret offset: %d\n", param_int1);
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_set_caret_offset") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_set_caret_offset", "offset");
atk_text_set_caret_offset(ATK_TEXT(obj), string_to_int(param_string1));
sprintf(output, "\nPutting caret at offset: |%d|\n",
string_to_int(param_string1));
param_int1 = atk_text_get_caret_offset (ATK_TEXT (obj));
if (param_int1 == -1)
sprintf(output, "\nCaret offset: |Not Supported|\n");
else
sprintf(output, "\nCaret offset was set at: |%d|\n", param_int1);
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_n_selections") == 0)
{
param_int1 = atk_text_get_n_selections(ATK_TEXT(obj));
if (param_int1 == -1)
{
sprintf(output, "\nNo selected regions\n");
set_output_buffer(output);
}
for (j = 0; j < param_int1; j++)
{
sprintf(output, "\nNumber of selected text regions is: |%d|\n", j);
set_output_buffer(output);
text = atk_text_get_selection(ATK_TEXT(obj), j, &start, &end);
if (text != NULL)
{
sprintf(output, "\nSelected text for region %d is: |%s|\n", j, text);
set_output_buffer(output);
sprintf(output,
"\nStart selection bounds: %d\tEnd selection bounds: %d\n",
start, end);
}
else
{
sprintf(output, "\nNo selected region %d\n", j);
}
set_output_buffer(output);
}
}
if (strcmp(testsOn[i], "atk_text_add_selection") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_add_selection", "start");
param_string2 = get_arg_of_func(win_val, "atk_text_add_selection", "end");
result = atk_text_add_selection(ATK_TEXT(obj),
string_to_int(param_string1), string_to_int(param_string2));
sprintf(output, "\nSet selection bounds between %d, and %d: %s",
string_to_int(param_string1), string_to_int(param_string2),
result_string[result]);
set_output_buffer(output);
param_int1 = atk_text_get_n_selections(ATK_TEXT(obj));
for (j = 0; j < param_int1; j++)
{
sprintf(output, "\nNumber of selected text region is: %d\n", j);
set_output_buffer(output);
text = atk_text_get_selection(ATK_TEXT(obj), j, &start, &end);
if (text != NULL)
{
sprintf(output, "\nSelected text for region %d is: |%s|\n", j, text);
set_output_buffer(output);
sprintf(output,
"\nStart selection bounds: %d\tEnd selection bounds: %d\n",
start, end);
}
else
{
sprintf(output, "\nNo selected region %d\n", j);
}
set_output_buffer(output);
}
}
if (strcmp(testsOn[i], "atk_text_get_selection") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_get_selection", "selection no");
text = atk_text_get_selection(ATK_TEXT(obj),
string_to_int(param_string1), &start, &end);
if (text != NULL)
{
sprintf(output, "\nSelected text for region %d is: |%s|\n",
string_to_int(param_string1), text);
set_output_buffer(output);
sprintf(output,
"\nStart selection bounds: %d\t End selection bounds: %d\n",
start, end);
}
else
{
sprintf(output, "\nNo selected region %d\n", string_to_int(param_string1));
}
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_set_selection") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_set_selection", "selection no");
param_string2 = get_arg_of_func(win_val, "atk_text_set_selection", "start");
param_string3 = get_arg_of_func(win_val, "atk_text_set_selection", "end");
result = atk_text_set_selection(ATK_TEXT(obj), string_to_int(param_string1),
string_to_int(param_string2), string_to_int(param_string3));
sprintf(output, "Set selection %d's bounds between %d and %d: %s\n",
string_to_int(param_string1), string_to_int(param_string2),
string_to_int(param_string3), result_string[result]);
set_output_buffer(output);
text = atk_text_get_selection(ATK_TEXT(obj), string_to_int(param_string1),
&start, &end);
if (text != NULL)
{
sprintf(output, "Selected text for the reset region %d is: |%s|\n",
string_to_int(param_string1), text);
set_output_buffer(output);
sprintf(output,
"\nNew start selection bounds: %d\tNew end selection bounds: %d\n",
start, end);
}
else
{
sprintf(output, "\nNo selected region %d\n", string_to_int(param_string1));
}
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_remove_selection") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_text_remove_selection", "selection no");
result = atk_text_remove_selection(ATK_TEXT(obj), string_to_int(param_string1));
sprintf(output, "Remove selection for region %d: %s\n",
string_to_int(param_string1), result_string[result]);
set_output_buffer(output);
text = atk_text_get_selection(ATK_TEXT(obj),
string_to_int(param_string1), &start, &end);
if (text != NULL)
sprintf(output, "\nRemoved regions text should be empty instead of: %s", text);
else
sprintf(output, "\nRemoved regions text should be empty, this is: ||");
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_run_attributes") == 0)
{
gint test_int;
param_string1 = get_arg_of_func(win_val, "atk_text_get_run_attributes", "offset");
test_int = string_to_int(param_string1);
attrib = atk_text_get_run_attributes(ATK_TEXT(obj), test_int, &start, &end);
sprintf(output, "get_run_attributes at offset %i:\nStart: %i, End: %i\n", test_int,
start, end);
set_output_buffer(output);
if (attrib != NULL) {
GSList *node;
index = 0;
node = attrib;
while (node != NULL)
{
AtkAttribute* att = node->data;
sprintf(output, "List index: %i, Name: %s, Value: %s\n", index,
att->name, att->value);
set_output_buffer(output);
node = node->next;
index++;
}
atk_attribute_set_free (attrib);
}
}
if (strcmp(testsOn[i], "atk_text_get_default_attributes") == 0)
{
attrib = atk_text_get_default_attributes(ATK_TEXT(obj));
sprintf(output, "get_default_attributes\n");
set_output_buffer(output);
if (attrib != NULL) {
GSList *node;
index = 0;
node = attrib;
while (node != NULL)
{
AtkAttribute* att = node->data;
sprintf(output, "List index: %i, Name: %s, Value: %s\n", index,
att->name, att->value);
set_output_buffer(output);
node = node->next;
index++;
}
atk_attribute_set_free (attrib);
}
}
if (strcmp(testsOn[i], "atk_text_get_character_extents") == 0)
{
gint test_int;
param_string1 = get_arg_of_func(win_val, "atk_text_get_character_extents",
"offset");
param_string2 = get_arg_of_func(win_val, "atk_text_get_character_extents",
"coord mode");
test_int = string_to_int(param_string1);
if (strcmp(param_string2, "ATK_XY_SCREEN") == 0)
{
atk_text_get_character_extents(ATK_TEXT(obj), test_int, &x, &y, &width,
&height, ATK_XY_SCREEN);
sprintf(output,
"get_character_extents at offset %i, mode: SCREEN\nX: %i, Y: %i, width: %i, height: %i\n",
test_int, x, y, width, height);
}
else if (strcmp(param_string2, "ATK_XY_WINDOW") == 0)
{
atk_text_get_character_extents(ATK_TEXT(obj), test_int, &x, &y, &width,
&height, ATK_XY_WINDOW);
sprintf(output,
"get_character_extents at offset %i, mode: WIDGET_WINDOW\nX: %i, Y: %i, width: %i, height: %i\n",
test_int, x, y, width, height);
}
else
sprintf(output, "get_character_extents_at_offset: Invalid coord mode argument!");
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_text_get_offset_at_point") == 0)
{
gint test_int;
param_string1 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "x");
param_string2 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "y");
param_string3 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "coord mode");
param_int1 = string_to_int(param_string1);
param_int2 = string_to_int(param_string2);
if (strcmp(param_string3, "ATK_XY_SCREEN") == 0)
{
test_int = atk_text_get_offset_at_point(ATK_TEXT(obj), param_int1, param_int2,
ATK_XY_SCREEN);
if (test_int != -1)
sprintf(output, "get_offset_at_point %i,%i mode: SCREEN is %i\n", param_int1, param_int2, test_int);
else
sprintf(output, "Cannot get_offset_at_point\n");
}
else if (strcmp(param_string3, "ATK_XY_WINDOW") == 0)
{
test_int = atk_text_get_offset_at_point(ATK_TEXT(obj), param_int1, param_int2,
ATK_XY_WINDOW);
if (test_int != -1)
sprintf(output, "get_offset_at_point %i,%i mode: WIDGET_WINDOW is %i\n", param_int1, param_int2, test_int);
else
sprintf(output, "Cannot get_offset_at_point\n");
}
else
sprintf(output, "get_offset_at_point: Invalid coord mode argument!");
set_output_buffer(output);
}
if (ATK_IS_EDITABLE_TEXT(obj))
{
if (strcmp(testsOn[i], "atk_editable_text_set_run_attributes") == 0)
{
param_string1 = get_arg_of_func(win_val,
"atk_editable_text_set_run_attributes", "start");
param_string2 = get_arg_of_func(win_val,
"atk_editable_text_set_run_attributes", "end");
result = atk_editable_text_set_run_attributes(ATK_EDITABLE_TEXT(obj),
attrib, string_to_int(param_string1), string_to_int(param_string2));
if (result)
sprintf(output, "\nSetting attributes in range %d to %d...OK\n",
string_to_int(param_string1), string_to_int(param_string2));
else
sprintf(output, "\nSetting attributes in range %d to %d...Failed\n",
string_to_int(param_string1), string_to_int(param_string2));
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_editable_text_cut_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_editable_text_cut_text", "start");
param_string2 = get_arg_of_func(win_val, "atk_editable_text_cut_text", "end");
atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj),
string_to_int(param_string1), string_to_int(param_string2));
sprintf(output, "\nCutting text %d to %d...\n",
string_to_int(param_string1), string_to_int(param_string2));
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_editable_text_paste_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_editable_text_paste_text",
"position");
atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj),
string_to_int(param_string1));
sprintf(output, "\nPasting text to %d\n", string_to_int(param_string1));
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_editable_text_delete_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_editable_text_delete_text", "start");
param_string2 = get_arg_of_func(win_val, "atk_editable_text_delete_text", "end");
atk_editable_text_delete_text(ATK_EDITABLE_TEXT(obj),
string_to_int(param_string1), string_to_int(param_string2));
sprintf(output, "\nDeleting text %d to %d...\n",
string_to_int(param_string1), string_to_int(param_string2));
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_editable_text_copy_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_editable_text_copy_text", "start");
param_string2 = get_arg_of_func(win_val, "atk_editable_text_copy_text", "end");
atk_editable_text_copy_text(ATK_EDITABLE_TEXT(obj),
string_to_int(param_string1), string_to_int(param_string2));
sprintf(output, "\nCopying text %d to %d...\n",
string_to_int(param_string1), string_to_int(param_string2));
set_output_buffer(output);
}
if (strcmp(testsOn[i], "atk_editable_text_insert_text") == 0)
{
param_string1 = get_arg_of_func(win_val, "atk_editable_text_insert_text",
"insert text");
param_string2 = get_arg_of_func(win_val, "atk_editable_text_insert_text",
"position");
param_int2 = string_to_int(param_string2);
atk_editable_text_insert_text(ATK_EDITABLE_TEXT(obj),
param_string1, strlen(param_string1), &param_int2);
sprintf(output, "\nInserting text at %d...\n", param_int2);
set_output_buffer(output);
}
}
}
}
/**
* _run_offset_test:
* @obj: An #AtkObject
* @type: The type of test to run. Can be "at", "before", or "after".
* @offset: The offset into the text buffer.
* @boundary: The boundary type.
*
* Tests the following ATK_TEXT API functions:
* atk_text_get_text_at_offset
* atk_text_get_text_before_offseet
* atk_text_get_text_after_offset
**/
void _run_offset_test(AtkObject * obj, char * type, gint offset,
AtkTextBoundary boundary)
{
gchar output[MAX_LINE_SIZE];
gchar default_val[5] = "NULL";
gchar *text;
gint startOffset, endOffset;
if (strcmp(type, "at") == 0)
text = atk_text_get_text_at_offset (ATK_TEXT (obj),
offset, boundary, &startOffset, &endOffset);
else if (strcmp(type, "before") == 0)
text = atk_text_get_text_before_offset (ATK_TEXT (obj),
offset, boundary, &startOffset, &endOffset);
else if (strcmp(type, "after") == 0)
text = atk_text_get_text_after_offset (ATK_TEXT (obj),
offset, boundary, &startOffset, &endOffset);
else
text = NULL;
if (text == NULL)
text = g_strdup (default_val);
if (boundary == ATK_TEXT_BOUNDARY_CHAR)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_CHAR|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_WORD_START)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_WORD_START|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_WORD_END)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_WORD_END|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_SENTENCE_START)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_SENTENCE_START|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_SENTENCE_END)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_SENTENCE_END|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_LINE_START)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_LINE_START|\n",
type, text);
else if (boundary == ATK_TEXT_BOUNDARY_LINE_END)
sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_LINE_END|\n",
type, text);
else
sprintf(output, "\n|%s| Text |%s| Boundary |UNKNOWN|\n",
type, text);
g_free (text);
set_output_buffer(output);
sprintf(output, "Offset %d, startOffset %d, endOffset %d\n",
offset, startOffset, endOffset);
set_output_buffer(output);
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
#include <gtk/gtk.h>
#include <atk/atk.h>
#include "testlib.h"
void add_handlers (AtkObject *obj);
gint setup_gui (AtkObject *obj, TLruntest test);
void runtest(AtkObject *obj, gint win_num);
void _run_offset_test(AtkObject *obj, char * type, gint param_int1, AtkTextBoundary boundary);
void _notify_caret_handler (GObject *obj, int position);
void _notify_text_insert_handler (GObject *obj,
int start_offset, int end_offset);
void _notify_text_delete_handler (GObject *obj,
int start_offset, int end_offset);

View File

@ -1,127 +0,0 @@
#include <atk/atk.h>
#include <gtk/gtk.h>
#include "testlib.h"
static void _notify_toplevel_child_added (GObject *obj,
guint index, AtkObject *child, gpointer user_data);
static void _notify_toplevel_child_removed (GObject *obj,
guint index, AtkObject *child, gpointer user_data);
static gboolean _button_press_event_watcher (GSignalInvocationHint *ihint,
guint n_param_values, const GValue *param_values, gpointer data);
static guint id;
static gboolean g_register_listener = FALSE;
static guint g_signal_listener = 0;
static gint g_press_count = 0;
static void
_check_toplevel (AtkObject *obj)
{
AtkObject *root_obj;
const gchar *name_string, *version_string;
gint max_depth;
g_print ("Start of _check_toplevel\n");
root_obj = atk_get_root();
if (!already_accessed_atk_object(root_obj))
{
g_signal_connect_closure (root_obj, "children_changed::add",
g_cclosure_new (G_CALLBACK (_notify_toplevel_child_added),
NULL, NULL),
FALSE);
g_signal_connect_closure (root_obj, "children_changed::remove",
g_cclosure_new (G_CALLBACK (_notify_toplevel_child_removed),
NULL, NULL),
FALSE);
}
name_string = atk_get_toolkit_name();
version_string = atk_get_toolkit_version();
g_print ("Toolkit name <%s> version <%s>\n", name_string,
version_string);
if (g_getenv("TEST_ACCESSIBLE_DEPTH") != NULL)
max_depth = string_to_int(g_getenv("TEST_ACCESSIBLE_DEPTH"));
else
max_depth = 2;
display_children_to_depth(root_obj, max_depth, 0, 0);
g_print ("End of _check_toplevel\n");
if (!g_register_listener)
{
g_print("Adding global event listener on buttons\n");
g_register_listener = TRUE;
g_signal_listener = atk_add_global_event_listener(_button_press_event_watcher,
"Gtk:GtkButton:pressed");
}
}
static void
_create_event_watcher (void)
{
id = atk_add_focus_tracker (_check_toplevel);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testtoplevel Module loaded\n");
_create_event_watcher();
return 0;
}
static void _notify_toplevel_child_added (GObject *obj,
guint child_index, AtkObject *child, gpointer user_data)
{
g_print ("SIGNAL - Child added - index %d\n", child_index);
}
static void _notify_toplevel_child_removed (GObject *obj,
guint child_index, AtkObject *child, gpointer user_data)
{
g_print ("SIGNAL - Child removed - index %d\n", child_index);
}
static gboolean
_button_press_event_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
gchar * button_name = (gchar *) data;
object = g_value_get_object (param_values + 0);
if (ATK_IS_IMPLEMENTOR(object))
{
AtkObject * atk_obj =
atk_implementor_ref_accessible(ATK_IMPLEMENTOR(object));
g_print("Button <%s> pressed %d times!\n", button_name,
(g_press_count + 1));
g_print("Displaying children of Button pressed!\n");
display_children(atk_obj, 0, 0);
if (g_press_count >= 5)
{
g_print("Removing global event listener on buttons\n");
atk_remove_global_event_listener(g_signal_listener);
g_signal_listener = 0;
g_press_count = 0;
g_register_listener = FALSE;
}
else
{
g_press_count++;
}
}
return TRUE;
}

View File

@ -1,499 +0,0 @@
#include <stdlib.h>
#include <testlib.h>
/*
* This module is for use with the test program testtreeview
*/
static gboolean state_change_watch (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static void _check_table (AtkObject *in_obj);
static void _check_cell_actions (AtkObject *in_obj);
static gint _find_expander_column (AtkTable *table);
static void _check_expanders (AtkTable *table,
gint expander_column);
static void _runtest (AtkObject *obj);
static void _create_event_watcher (void);
static void row_inserted (AtkObject *obj,
gint row,
gint count);
static void row_deleted (AtkObject *obj,
gint row,
gint count);
static AtkObject *table_obj = NULL;
static gint expander_column = -1;
static gboolean editing_cell = FALSE;
static gboolean
state_change_watch (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
gboolean state_set;
const gchar *state_name;
AtkStateType state_type;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
state_name = g_value_get_string (param_values + 1);
state_set = g_value_get_boolean (param_values + 2);
g_print ("Object type: %s state: %s set: %d\n",
g_type_name (G_OBJECT_TYPE (object)), state_name, state_set);
state_type = atk_state_type_for_name (state_name);
if (state_type == ATK_STATE_EXPANDED)
{
AtkObject *parent = atk_object_get_parent (ATK_OBJECT (object));
if (ATK_IS_TABLE (parent))
_check_expanders (ATK_TABLE (parent), expander_column);
}
return TRUE;
}
static void
_check_table (AtkObject *in_obj)
{
AtkObject *obj;
AtkRole role[2];
AtkRole obj_role;
static gboolean emission_hook_added = FALSE;
if (!emission_hook_added)
{
emission_hook_added = TRUE;
g_signal_add_emission_hook (
g_signal_lookup ("state-change", ATK_TYPE_OBJECT),
/*
* To specify an emission hook for a particular state, e.g.
* ATK_STATE_EXPANDED, instead of 0 use
* g_quark_from_string (atk_state_type_get_name (ATK_STATE_EXPANDED))
*/
0,
state_change_watch, NULL, (GDestroyNotify) NULL);
}
role[0] = ATK_ROLE_TABLE;
role[1] = ATK_ROLE_TREE_TABLE;
g_print ("focus event for: %s\n", g_type_name (G_OBJECT_TYPE (in_obj)));
_check_cell_actions (in_obj);
obj_role = atk_object_get_role (in_obj);
if (obj_role == ATK_ROLE_TABLE_CELL)
obj = atk_object_get_parent (in_obj);
else
obj = find_object_by_role (in_obj, role, 2);
if (obj == NULL)
return;
editing_cell = FALSE;
if (obj != table_obj)
{
table_obj = obj;
g_print("Found %s table\n", g_type_name (G_OBJECT_TYPE (obj)));
g_signal_connect (G_OBJECT (obj),
"row_inserted",
G_CALLBACK (row_inserted),
NULL);
g_signal_connect (G_OBJECT (obj),
"row_deleted",
G_CALLBACK (row_deleted),
NULL);
/*
* Find expander column
*/
if (ATK_IS_TABLE (obj))
{
if (atk_object_get_role (obj) == ATK_ROLE_TREE_TABLE)
{
expander_column = _find_expander_column (ATK_TABLE (obj));
if (expander_column == -1)
{
g_warning ("Expander column not found\n");
return;
}
}
_runtest(obj);
}
else
g_warning ("Table does not support AtkTable interface\n");
}
else
{
/*
* We do not call these functions at the same time as we set the
* signals as the GtkTreeView may not be displayed yet.
*/
gint x, y, width, height, first_x, last_x, last_y;
gint first_row, last_row, first_column, last_column;
gint index;
AtkObject *first_child, *last_child, *header;
AtkComponent *component = ATK_COMPONENT (obj);
AtkTable *table = ATK_TABLE (obj);
atk_component_get_extents (component,
&x, &y, &width, &height, ATK_XY_WINDOW);
g_print ("WINDOW: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
atk_component_get_extents (component,
&x, &y, &width, &height, ATK_XY_SCREEN);
g_print ("SCREEN: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
last_x = x + width - 1;
last_y = y + height - 1;
first_x = x;
header = atk_table_get_column_header (table, 0);
if (header)
{
atk_component_get_extents (ATK_COMPONENT (header),
&x, &y, &width, &height, ATK_XY_SCREEN);
g_print ("Got column header: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
y += height;
}
first_child = atk_component_ref_accessible_at_point (component,
first_x, y, ATK_XY_SCREEN);
atk_component_get_extents (ATK_COMPONENT (first_child),
&x, &y, &width, &height, ATK_XY_SCREEN);
g_print ("first_child: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
index = atk_object_get_index_in_parent (ATK_OBJECT (first_child));
first_row = atk_table_get_row_at_index (table, index);
first_column = atk_table_get_column_at_index (table, index);
g_print ("first_row: %d first_column: %d index: %d\n",
first_row, first_column, index);
g_assert (index == atk_table_get_index_at (table, first_row, first_column));
last_child = atk_component_ref_accessible_at_point (component,
last_x, last_y, ATK_XY_SCREEN);
if (last_child == NULL)
{
/* The TreeView may be bigger than the data */
gint n_children;
n_children = atk_object_get_n_accessible_children (obj);
last_child = atk_object_ref_accessible_child (obj, n_children - 1);
}
atk_component_get_extents (ATK_COMPONENT (last_child),
&x, &y, &width, &height, ATK_XY_SCREEN);
g_print ("last_child: x: %d y: %d width: %d height: %d\n",
x, y, width, height);
index = atk_object_get_index_in_parent (ATK_OBJECT (last_child));
last_row = atk_table_get_row_at_index (table, index);
last_column = atk_table_get_column_at_index (table, index);
g_print ("last_row: %d last_column: %d index: %d\n",
last_row, last_column, index);
g_assert (index == atk_table_get_index_at (table, last_row, last_column));
g_object_unref (first_child);
g_object_unref (last_child);
if (expander_column >= 0)
{
gint n_rows, i;
gint x, y, width, height;
n_rows = atk_table_get_n_rows (table);
for (i = 0; i < n_rows; i++)
{
AtkObject *child_obj;
AtkStateSet *state_set;
gboolean showing;
child_obj = atk_table_ref_at (table, i, expander_column);
state_set = atk_object_ref_state_set (child_obj);
showing = atk_state_set_contains_state (state_set,
ATK_STATE_SHOWING);
g_object_unref (state_set);
atk_component_get_extents (ATK_COMPONENT (child_obj),
&x, &y, &width, &height,
ATK_XY_SCREEN);
g_object_unref (child_obj);
if (showing)
g_print ("Row: %d Column: %d x: %d y: %d width: %d height: %d\n",
i, expander_column, x, y, width, height);
}
}
}
}
static void
_check_cell_actions (AtkObject *in_obj)
{
AtkRole role;
AtkAction *action;
gint n_actions, i;
role = atk_object_get_role (in_obj);
if (role != ATK_ROLE_TABLE_CELL)
return;
if (!ATK_IS_ACTION (in_obj))
return;
if (editing_cell)
return;
action = ATK_ACTION (in_obj);
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
const gchar* name;
name = atk_action_get_name (action, i);
g_print ("Action %d is %s\n", i, name);
#if 0
if (strcmp (name, "edit") == 0)
{
editing_cell = TRUE;
atk_action_do_action (action, i);
}
#endif
}
return;
}
static gint
_find_expander_column (AtkTable *table)
{
gint n_columns, i;
gint retval = -1;
n_columns = atk_table_get_n_columns (table);
for (i = 0; i < n_columns; i++)
{
AtkObject *cell;
AtkRelationSet *relation_set;
cell = atk_table_ref_at (table, 0, i);
relation_set = atk_object_ref_relation_set (cell);
if (atk_relation_set_contains (relation_set,
ATK_RELATION_NODE_CHILD_OF))
retval = i;
g_object_unref (relation_set);
g_object_unref (cell);
if (retval >= 0)
break;
}
return retval;
}
static void
_check_expanders (AtkTable *table,
gint expander_column)
{
gint n_rows, i;
n_rows = atk_table_get_n_rows (table);
for (i = 0; i < n_rows; i++)
{
AtkObject *cell;
AtkRelationSet *relation_set;
AtkRelation *relation;
GPtrArray *target;
gint j;
cell = atk_table_ref_at (table, i, expander_column);
relation_set = atk_object_ref_relation_set (cell);
relation = atk_relation_set_get_relation_by_type (relation_set,
ATK_RELATION_NODE_CHILD_OF);
g_assert (relation);
target = atk_relation_get_target (relation);
g_assert (target->len == 1);
for (j = 0; j < target->len; j++)
{
AtkObject *target_obj;
AtkRole role;
gint target_index, target_row;
target_obj = g_ptr_array_index (target, j);
role = atk_object_get_role (target_obj);
switch (role)
{
case ATK_ROLE_TREE_TABLE:
g_print ("Row %d is top level\n", i);
break;
case ATK_ROLE_TABLE_CELL:
target_index = atk_object_get_index_in_parent (target_obj);
target_row = atk_table_get_row_at_index (table, target_index);
g_print ("Row %d has parent at %d\n", i, target_row);
break;
default:
g_assert_not_reached ();
}
}
g_object_unref (relation_set);
g_object_unref (cell);
}
}
static void
_create_event_watcher (void)
{
atk_add_focus_tracker (_check_table);
}
int
gtk_module_init (gint argc,
char *argv[])
{
g_print ("testtreetable Module loaded\n");
_create_event_watcher ();
return 0;
}
static void
_runtest (AtkObject *obj)
{
AtkObject *child_obj;
AtkTable *table;
AtkObject *caption;
gint i;
gint n_cols, n_rows, n_children;
table = ATK_TABLE (obj);
n_children = atk_object_get_n_accessible_children (ATK_OBJECT (obj));
n_cols = atk_table_get_n_columns (table);
n_rows = atk_table_get_n_rows (table);
g_print ("n_children: %d n_rows: %d n_cols: %d\n",
n_children, n_rows, n_cols);
for (i = 0; i < n_rows; i++)
{
gint index = atk_table_get_index_at (table, i, expander_column);
gint index_in_parent;
child_obj = atk_table_ref_at (table, i, expander_column);
index_in_parent = atk_object_get_index_in_parent (child_obj);
g_print ("index: %d %d row %d column %d\n", index, index_in_parent, i, expander_column);
g_object_unref (child_obj);
}
caption = atk_table_get_caption (table);
if (caption)
{
const gchar *caption_name = atk_object_get_name (caption);
g_print ("Caption: %s\n", caption_name ? caption_name : "<null>");
}
for (i = 0; i < n_cols; i++)
{
AtkObject *header;
header = atk_table_get_column_header (table, i);
g_print ("Header for column %d is %p\n", i, header);
if (header)
{
const gchar *name;
AtkRole role;
AtkObject *parent;
AtkObject *child;
gint index;
name = atk_object_get_name (header);
role = atk_object_get_role (header);
parent = atk_object_get_parent (header);
if (parent)
{
index = atk_object_get_index_in_parent (header);
g_print ("Parent: %s index: %d\n", G_OBJECT_TYPE_NAME (parent), index);
child = atk_object_ref_accessible_child (parent, 0);
g_print ("Child: %s %p\n", G_OBJECT_TYPE_NAME (child), child);
if (index >= 0)
{
child = atk_object_ref_accessible_child (parent, index);
g_print ("Index: %d child: %s\n", index, G_OBJECT_TYPE_NAME (child));
g_object_unref (child);
}
}
else
g_print ("Parent of header is NULL\n");
g_print ("%s %s %s\n", G_OBJECT_TYPE_NAME (header), name ? name: "<null>", atk_role_get_name (role));
}
}
}
static void
row_inserted (AtkObject *obj,
gint row,
gint count)
{
#if 0
GtkWidget *widget;
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
#endif
gint index;
g_print ("row_inserted: row: %d count: %d\n", row, count);
index = atk_table_get_index_at (ATK_TABLE (obj), row+1, 0);
g_print ("index for first column of next row is %d\n", index);
#if 0
widget = GTK_ACCESSIBLE (obj)->widget;
tree_view = GTK_TREE_VIEW (widget);
tree_model = gtk_tree_view_get_model (tree_view);
if (GTK_IS_TREE_STORE (tree_model))
{
GtkTreeStore *tree_store;
GtkTreePath *tree_path;
GtkTreeIter tree_iter;
tree_store = GTK_TREE_STORE (tree_model);
tree_path = gtk_tree_path_new_from_string ("3:0");
gtk_tree_model_get_iter (tree_model, &tree_iter, tree_path);
gtk_tree_path_free (tree_path);
gtk_tree_store_remove (tree_store, &tree_iter);
}
#endif
}
static void
row_deleted (AtkObject *obj,
gint row,
gint count)
{
#if 0
GtkWidget *widget;
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
#endif
gint index;
g_print ("row_deleted: row: %d count: %d\n", row, count);
index = atk_table_get_index_at (ATK_TABLE (obj), row+1, 0);
g_print ("index for first column of next row is %d\n", index);
#if 0
widget = GTK_ACCESSIBLE (obj)->widget;
tree_view = GTK_TREE_VIEW (widget);
tree_model = gtk_tree_view_get_model (tree_view);
if (GTK_IS_TREE_STORE (tree_model))
{
GtkTreeStore *tree_store;
GtkTreePath *tree_path;
GtkTreeIter tree_iter, new_iter;
tree_store = GTK_TREE_STORE (tree_model);
tree_path = gtk_tree_path_new_from_string ("2");
gtk_tree_model_get_iter (tree_model, &tree_iter, tree_path);
gtk_tree_path_free (tree_path);
gtk_tree_store_insert_before (tree_store, &new_iter, NULL, &tree_iter);
}
#endif
}

View File

@ -1,193 +0,0 @@
#include <string.h>
#include <atk/atk.h>
#include <gtk/gtk.h>
static void _traverse_children (AtkObject *obj);
static void _add_handler (AtkObject *obj);
static void _check_values (AtkObject *obj);
static void _value_change_handler (AtkObject *obj,
AtkPropertyValues *values);
static guint id;
static void _value_change_handler (AtkObject *obj,
AtkPropertyValues *values)
{
const gchar *type_name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
GValue *value_back, val;
value_back = &val;
if (!ATK_IS_VALUE (obj)) {
return;
}
if (strcmp (values->property_name, "accessible-value") == 0) {
g_print ("_value_change_handler: Accessible Type: %s\n",
type_name ? type_name : "NULL");
if(G_VALUE_HOLDS_DOUBLE (&values->new_value))
{
g_print( "adjustment value changed : new value: %f\n",
g_value_get_double (&values->new_value));
}
g_print("Now calling the AtkValue interface functions\n");
atk_value_get_current_value (ATK_VALUE(obj), value_back);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
g_print ("atk_value_get_current_value returns %f\n",
g_value_get_double (value_back) );
atk_value_get_maximum_value (ATK_VALUE (obj), value_back);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
g_print ("atk_value_get_maximum returns %f\n",
g_value_get_double (value_back));
atk_value_get_minimum_value (ATK_VALUE (obj), value_back);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
g_print ("atk_value_get_minimum returns %f\n",
g_value_get_double (value_back));
}
}
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);
_add_handler (child);
_traverse_children (child);
g_object_unref (G_OBJECT (child));
}
}
static void _add_handler (AtkObject *obj)
{
static GPtrArray *obj_array = NULL;
gboolean found = FALSE;
gint i;
/*
* We create a property handler for each object if one was not associated
* with it already.
*
* We add it to our array of objects which have property handlers; if an
* object is destroyed it remains in the array.
*/
if (obj_array == NULL)
obj_array = g_ptr_array_new ();
for (i = 0; i < obj_array->len; i++)
{
if (obj == g_ptr_array_index (obj_array, i))
{
found = TRUE;
break;
}
}
if (!found)
{
atk_object_connect_property_change_handler (obj,
(AtkPropertyChangeHandler*) _value_change_handler);
g_ptr_array_add (obj_array, obj);
}
}
static void _set_values (AtkObject *obj) {
GValue *value_back, val;
static gint count = 0;
gdouble double_value;
value_back = &val;
if(ATK_IS_VALUE(obj)) {
/* Spin button also inherits the text interfaces from GailEntry.
* Check when spin button recieves focus.
*/
if(ATK_IS_TEXT(obj) && ATK_IS_EDITABLE_TEXT(obj)) {
if(count == 0) {
gint x;
gchar* text;
count++;
x = atk_text_get_character_count (ATK_TEXT (obj));
text = atk_text_get_text (ATK_TEXT (obj), 0, x);
g_print("Text : %s\n", text);
text = "5.7";
atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj),text);
g_print("Set text to %s\n",text);
atk_value_get_current_value(ATK_VALUE(obj), value_back);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
g_print("atk_value_get_current_value returns %f\n",
g_value_get_double( value_back));
}
} else {
memset (value_back, 0, sizeof (GValue));
g_value_init (value_back, G_TYPE_DOUBLE);
g_value_set_double (value_back, 10.0);
if (atk_value_set_current_value (ATK_VALUE (obj), value_back))
{
double_value = g_value_get_double (value_back);
g_print("atk_value_set_current_value returns %f\n",
double_value);
}
}
}
}
static void _check_values (AtkObject *obj)
{
static gint calls = 0;
AtkRole role;
g_print ("Start of _check_values\n");
_set_values(obj);
_add_handler (obj);
if (++calls < 2)
{
/*
* Just do this on this on the first 2 objects visited
*/
atk_object_set_name (obj, "test123");
atk_object_set_description (obj, "test123");
}
role = atk_object_get_role (obj);
if (role == ATK_ROLE_FRAME || role == ATK_ROLE_DIALOG)
{
/*
* Add handlers to all children.
*/
_traverse_children (obj);
}
g_print ("End of _check_values\n");
}
static void
_create_event_watcher (void)
{
id = atk_add_focus_tracker (_check_values);
}
int
gtk_module_init(gint argc, char* argv[])
{
g_print("testvalues Module loaded\n");
_create_event_watcher();
return 0;
}