From: Tomasz Wozniak Date: Wed, 19 Oct 2016 09:17:04 +0000 (-0700) Subject: Revert "Merge remote-tracking branch 'origin/sandbox/mniesluchow/upstream_2_16' into... X-Git-Tag: submit/tizen/20161026.040418~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6db4799d4fc2d279eded25a3eb23a98f6c0b5852;p=platform%2Fupstream%2Fat-spi2-atk.git Revert "Merge remote-tracking branch 'origin/sandbox/mniesluchow/upstream_2_16' into 'origin/tizen'" This reverts commit a82723b503a3cc1aee214b36c365cb52472ceb11. Change-Id: Ie37dc1c3b1dce5ff4966c4415d4a903e7a2421ba --- diff --git a/Makefile.am b/Makefile.am index 889e76c..713fec5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,5 @@ SUBDIRS=droute atk-adaptor -if ATSPI_TESTS - -SUBDIRS += tests - -endif - gtk_modulesdir = $(libdir)/gnome-settings-daemon-3.0/gtk-modules/ gtk_modules_DATA = at-spi2-atk.desktop diff --git a/NEWS b/NEWS index d30499a..e601543 100644 --- a/NEWS +++ b/NEWS @@ -1,42 +1,3 @@ -What's new in at-spi2-atk 2.15.90: - -* Add roles for fractions, roots, subscripts, and superscripts. - -* Add action tests (bgo#743418). - -What's new in at-spi2-atk 2.15.4: - -* Don't parse non-existent signal arguments from atk. - -* Support ATK_STATE_HAS_TOOLTIP (bgo#738953). - -* Support ATK_STATE_READ_ONLY (bgo#690008). - -What's new in at-spi2-atk 2.15.3: - -* Add mapping between ATK_ROLE_STATIC and ATSPI_ROLE_STATIC - -What's new in at-spi2-atk 2.14.1: - -* Aggressively filter out children-changed signals for objects with - MANAGES_DESCENDANTS (bgo#728319). - -What's new in at-spi2-atk 2.13.4: - -* Fix typo in .pc file (bgo#721719). - -* Fix retrieving text attributes (bgo#731980). - -* Correctly remove the socket on exit (bgo#684076). - -What's new in at-spi2-atk 2.13.1: - -* Add an atexit handler to remove the D-Bus socket (bgo#684076). - -* Only send cache-related events for transients when explicitly requested. - Hopefully this will improve performance when we are flooded with them. - (bgo#728319). - What's new in at-spi2-atk 2.11.92: * Bump minimum libdbus version needed, since we use a function diff --git a/README b/README index 7a3449c..eb23e8a 100644 --- a/README +++ b/README @@ -60,13 +60,6 @@ as a module. These libraries depend on the at-spi2-core code that contains the daemon for registering applications, D-Bus helper libraries and the AT-SPI D-Bus specifications. -Tests ------ - -To run tests execute autogen.sh with '--with-tests=yes' parameter then -after 'make', type 'make check'. -Test result is available in tests/atk-test.log - Directory structure ------------------- @@ -91,8 +84,3 @@ The directories within this package are arranged as follows: It is also responsible for servicing requests from the registry to register handlers for specific event types. - - tests - - Contains tests for atspi. - More details in tests/README diff --git a/at-spi2-atk.doap b/at-spi2-atk.doap index 5b70365..52837e0 100644 --- a/at-spi2-atk.doap +++ b/at-spi2-atk.doap @@ -5,11 +5,9 @@ xmlns="http://usefulinc.com/ns/doap#"> at-spi2-atk - GTK+ module for bridging AT-SPI to ATK + Gtk module for bridging AT-SPI to Atk. - - C diff --git a/atk-adaptor/accessible-stateset.c b/atk-adaptor/accessible-stateset.c index f82910b..3ab35ca 100644 --- a/atk-adaptor/accessible-stateset.c +++ b/atk-adaptor/accessible-stateset.c @@ -135,10 +135,6 @@ spi_init_state_type_tables (void) atk_state_types[ATSPI_STATE_HAS_POPUP] = ATK_STATE_HAS_POPUP; accessible_state_types[ATK_STATE_CHECKABLE] = ATSPI_STATE_CHECKABLE; atk_state_types[ATSPI_STATE_CHECKABLE] = ATK_STATE_CHECKABLE; - accessible_state_types[ATK_STATE_HAS_TOOLTIP] = ATSPI_STATE_HAS_TOOLTIP; - atk_state_types[ATSPI_STATE_HAS_TOOLTIP] = ATK_STATE_HAS_TOOLTIP; - accessible_state_types[ATK_STATE_READ_ONLY] = ATSPI_STATE_READ_ONLY; - atk_state_types[ATSPI_STATE_READ_ONLY] = ATK_STATE_READ_ONLY; return TRUE; } diff --git a/atk-adaptor/adaptors/text-adaptor.c b/atk-adaptor/adaptors/text-adaptor.c index e80daf8..be10349 100644 --- a/atk-adaptor/adaptors/text-adaptor.c +++ b/atk-adaptor/adaptors/text-adaptor.c @@ -799,17 +799,16 @@ impl_GetAttributeRun (DBusConnection * bus, DBusMessage * message, return droute_invalid_arguments_error (message); } + attributes = + atk_text_get_run_attributes (text, offset, &intstart_offset, + &intend_offset); + if (includeDefaults) { attributes = g_slist_concat (attributes, atk_text_get_default_attributes (text)); } - attributes = g_slist_concat (attributes, - atk_text_get_run_attributes (text, offset, - &intstart_offset, - &intend_offset)); - reply = dbus_message_new_method_return (message); if (!reply) return NULL; diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index c40ef38..e542094 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -57,7 +57,6 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data); SpiBridge *spi_global_app_data = NULL; static gboolean inited = FALSE; -static gboolean atexit_added = FALSE; /*---------------------------------------------------------------------------*/ @@ -450,28 +449,6 @@ register_application (SpiBridge * app) /*---------------------------------------------------------------------------*/ -static void -remove_socket () -{ - if (!spi_global_app_data) - return; - - if (spi_global_app_data->app_bus_addr && - !strncmp (spi_global_app_data->app_bus_addr, "unix:path=", 10)) - { - unlink (spi_global_app_data->app_bus_addr + 10); - g_free (spi_global_app_data->app_bus_addr); - spi_global_app_data->app_bus_addr = NULL; - } - - if (spi_global_app_data->app_tmp_dir) - { - rmdir (spi_global_app_data->app_tmp_dir); - g_free (spi_global_app_data->app_tmp_dir); - spi_global_app_data->app_tmp_dir = NULL; - } -} - static void deregister_application (SpiBridge * app) { @@ -493,7 +470,19 @@ deregister_application (SpiBridge * app) if (message) dbus_message_unref (message); - remove_socket (); + if (app->app_bus_addr) + { + unlink (app->app_bus_addr); + g_free (app->app_bus_addr); + app->app_bus_addr = NULL; + } + + if (app->app_tmp_dir) + { + rmdir (app->app_tmp_dir); + g_free (app->app_tmp_dir); + app->app_tmp_dir = NULL; + } g_free (app->desktop_name); app->desktop_name = NULL; @@ -1106,10 +1095,6 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[]) else get_registered_event_listeners (spi_global_app_data); - if (!atexit_added) - atexit (remove_socket); - atexit_added = TRUE; - dbus_error_free (&error); return 0; } diff --git a/atk-adaptor/event.c b/atk-adaptor/event.c index 4d8ca22..0662664 100644 --- a/atk-adaptor/event.c +++ b/atk-adaptor/event.c @@ -376,8 +376,8 @@ append_properties (GArray *properties, event_data *evdata) } static gboolean -signal_is_needed (AtkObject *obj, const gchar *klass, const gchar *major, - const gchar *minor, GArray **properties) +signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor, + GArray **properties) { gchar *data [4]; event_data *evdata; @@ -403,18 +403,7 @@ signal_is_needed (AtkObject *obj, const gchar *klass, const gchar *major, !g_strcmp0 (data [2], "accessible-parent") || !g_strcmp0 (data [2], "accessible-role"))) || !g_strcmp0 (data [1], "StateChanged")) - { - if (minor && !g_strcmp0 (minor, "defunct")) - ret = TRUE; - else - { - AtkStateSet *set = atk_object_ref_state_set (obj); - AtkState state = ((!g_strcmp0 (data[1], "ChildrenChanged")) ? - ATK_STATE_MANAGES_DESCENDANTS : ATK_STATE_TRANSIENT); - ret = !atk_state_set_contains_state (set, state); - g_object_unref (set); - } - } + ret = TRUE; /* Hack: events such as "object::text-changed::insert:system" as generated by Gecko */ @@ -494,7 +483,7 @@ emit_event (AtkObject *obj, if (!minor) minor = ""; if (!type) type = "u"; - if (!signal_is_needed (obj, klass, major, minor, &properties)) + if (!signal_is_needed (klass, major, minor, &properties)) return; path = spi_register_object_to_path (spi_global_register, G_OBJECT (obj)); @@ -1027,6 +1016,7 @@ text_selection_changed_event_listener (GSignalInvocationHint * signal_hint, AtkObject *accessible; GSignalQuery signal_query; const gchar *name, *minor; + gint detail1 = 0, detail2 = 0; g_signal_query (signal_hint->signal_id, &signal_query); name = signal_query.signal_name; @@ -1034,7 +1024,13 @@ text_selection_changed_event_listener (GSignalInvocationHint * signal_hint, accessible = ATK_OBJECT (g_value_get_object (¶m_values[0])); minor = g_quark_to_string (signal_hint->detail); - emit_event (accessible, ITF_EVENT_OBJECT, name, minor, 0, 0, + if (G_VALUE_TYPE (¶m_values[1]) == G_TYPE_INT) + detail1 = g_value_get_int (¶m_values[1]); + + if (G_VALUE_TYPE (¶m_values[2]) == G_TYPE_INT) + detail2 = g_value_get_int (¶m_values[2]); + + emit_event (accessible, ITF_EVENT_OBJECT, name, minor, detail1, detail2, DBUS_TYPE_STRING_AS_STRING, "", append_basic); return TRUE; } @@ -1062,22 +1058,11 @@ children_changed_event_listener (GSignalInvocationHint * signal_hint, AtkObject *accessible, *ao=NULL; gpointer child; - AtkStateSet *set; - gboolean ret; g_signal_query (signal_hint->signal_id, &signal_query); name = signal_query.signal_name; - /* If the accessible is on STATE_MANAGES_DESCENDANTS state, - children-changed signal are not forwarded. */ accessible = ATK_OBJECT (g_value_get_object (¶m_values[0])); - set = atk_object_ref_state_set (accessible); - ret = atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS); - g_object_unref (set); - - if (ret) - return TRUE; - minor = g_quark_to_string (signal_hint->detail); detail1 = g_value_get_uint (param_values + 1); diff --git a/atk-adaptor/object.c b/atk-adaptor/object.c index bdc1625..404fb24 100644 --- a/atk-adaptor/object.c +++ b/atk-adaptor/object.c @@ -474,11 +474,6 @@ init_role_lookup_table (AtspiRole * role_table) role_table[ATK_ROLE_MATH] = ATSPI_ROLE_MATH; role_table[ATK_ROLE_RATING] = ATSPI_ROLE_RATING; role_table[ATK_ROLE_TIMER] = ATSPI_ROLE_TIMER; - role_table[ATK_ROLE_STATIC] = ATSPI_ROLE_STATIC; - role_table[ATK_ROLE_MATH_FRACTION] = ATSPI_ROLE_MATH_FRACTION; - role_table[ATK_ROLE_MATH_ROOT] = ATSPI_ROLE_MATH_ROOT; - role_table[ATK_ROLE_SUBSCRIPT] = ATSPI_ROLE_SUBSCRIPT; - role_table[ATK_ROLE_SUPERSCRIPT] = ATSPI_ROLE_SUPERSCRIPT; return TRUE; } diff --git a/atk-bridge-2.0.pc.in b/atk-bridge-2.0.pc.in index 449582f..6af5861 100644 --- a/atk-bridge-2.0.pc.in +++ b/atk-bridge-2.0.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: atk-bridge-2.0 Description: ATK/D-Bus Bridge Version: @VERSION@ -Requires.private: gobject-2.0 atspi-2 +Requires.Private: gobject-2.0 atspi-2 Libs: -L${libdir} -latk-bridge-2.0 Cflags: -I${includedir}/at-spi2-atk/2.0 diff --git a/configure.ac b/configure.ac index 87ee68f..d7f5c73 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([at-spi2-atk], [2.16.0], [accessibility-atspi@lists.linux-foundation.org]) +AC_INIT([at-spi2-atk], [2.12.0], [accessibility-atspi@lists.linux-foundation.org]) AC_CONFIG_AUX_DIR(config) AT_SPI_ATK_MAJOR_VERSION=0 @@ -47,46 +47,18 @@ PKG_CHECK_MODULES(GOBJ, [gobject-2.0 >= 2.0.0]) AC_SUBST(GOBJ_LIBS) AC_SUBST(GOBJ_CFLAGS) -PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.0.0]) +PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.0.0]) AC_SUBST(GMODULE_LIBS) AC_SUBST(GMODULE_CFLAGS) -PKG_CHECK_MODULES(ATK, [atk >= 2.15.4]) +PKG_CHECK_MODULES(ATK, [atk >= 2.11.90]) AC_SUBST(ATK_LIBS) AC_SUBST(ATK_CFLAGS) -PKG_CHECK_MODULES(ATSPI, [atspi-2 >= 2.15.5]) +PKG_CHECK_MODULES(ATSPI, [atspi-2 >= 2.11.2]) AC_SUBST(ATSPI_LIBS) AC_SUBST(ATSPI_CFLAGS) -AC_ARG_WITH([tests], - [AC_HELP_STRING([--with-tests=yes|no], - [choose if test should be enabled. - @<:@default=no@:>@])], - [build_tests=${withval}], - [build_tests=no]) - -want_tests="no" - -case "${build_tests}" in - yes) - want_tests="yes" - ;; - no*) - ;; - *) - AC_MSG_ERROR([Unknown build tests option: --with-tests=${build_tests}]) - ;; -esac - - -if test "${want_tests}" = "yes"; then - PKG_CHECK_MODULES(XML, [libxml-2.0 >= 2.9.1]) - AC_SUBST(XML_LIBS) - AC_SUBST(XML_CFLAGS) -fi -AM_CONDITIONAL([ATSPI_TESTS], [test "${want_tests}" = "yes"]) - GLIB_GSETTINGS AC_ARG_ENABLE(p2p, [ --enable-p2p Allow peer-to-peer DBus connections [default=yes]], enable_p2p="$enableval", enable_p2p=yes) @@ -121,14 +93,11 @@ fi AC_SUBST(P2P_CFLAGS) AC_CONFIG_FILES([Makefile - atk-bridge-2.0.pc - droute/Makefile - atk-adaptor/Makefile - atk-adaptor/adaptors/Makefile - atk-adaptor/gtk-2.0/Makefile - tests/Makefile - tests/dummyatk/Makefile - ]) - + atk-bridge-2.0.pc + droute/Makefile + atk-adaptor/Makefile + atk-adaptor/adaptors/Makefile + atk-adaptor/gtk-2.0/Makefile + ]) AC_OUTPUT diff --git a/packaging/at-spi2-atk.spec b/packaging/at-spi2-atk.spec index 556161b..4fa22af 100644 --- a/packaging/at-spi2-atk.spec +++ b/packaging/at-spi2-atk.spec @@ -1,11 +1,11 @@ Name: at-spi2-atk -Version: 2.16.0 +Version: 2.12.0 Release: 1 Summary: Assistive Technology Service Provider Interface - GTK+ module License: LGPL-2.0+ Group: System/Libraries Url: http://www.gnome.org/ -Source: http://download.gnome.org/sources/at-spi2-atk/2.16/%{name}-%{version}.tar.xz +Source: http://download.gnome.org/sources/at-spi2-atk/2.12/%{name}-%{version}.tar.xz Source1001: %{name}.manifest Requires: at-spi2-core BuildRequires: dbus-devel diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 7ec3435..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps/ -.libs/ -app-test -atk-test -*.log -*.o -*.la -*.lo diff --git a/tests/Makefile.am b/tests/Makefile.am index 6d388c9..741f850 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,69 +1 @@ -SUBDIRS = dummyatk - -noinst_PROGRAMS = atk-test app-test -TESTS = atk-test -lib_LTLIBRARIES =libxmlloader.la libtestutils.la - -atk_test_CFLAGS = $(DBUS_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(ATSPI_CFLAGS) \ - -I$(top_builddir)\ - -I$(top_srcdir)/tests/dummyatk/ \ - -I$(top_srcdir)/tests/dummyatk/.libs \ - -I$(top_srcdir)/tests/dummyatk/.deps \ - -I$(top_srcdir) - -atk_test_LDFLAGS = libxmlloader.la \ - libtestutils.la \ - $(GLIB_LIBS) \ - $(ATSPI_LIBS) \ - $(top_srcdir)/tests/dummyatk/libdummyatk.la - -atk_test_CPPFLAGS = -DTESTS_BUILD_DIR=\"$(top_builddir)/tests\" \ - -DTESTS_SRC_DIR=\"$(top_srcdir)/tests\" \ - -DTESTS_DATA_DIR=\"$(top_srcdir)/tests/data\" - -atk_test_SOURCES = atk_suite.c \ - atk_test_accessible.c \ - atk_test_action.c \ - atk_test_component.c - -app_test_CFLAGS = -I$(top_builddir) \ - $(GLIB_CFLAGS) \ - $(ATK_CFLAGS) \ - -I$(top_srcdir)/tests/dummyatk \ - -I$(top_srcdir)/atk-adaptor - -app_test_LDFLAGS = libxmlloader.la \ - libtestutils.la \ - $(GLIB_LIBS) \ - $(ATK_LIBS) \ - $(top_srcdir)/tests/dummyatk/libdummyatk.la \ - $(top_srcdir)/atk-adaptor/libatk-bridge-2.0.la - -app_test_SOURCES = test-application.c - -libxmlloader_la_CFLAGS = $(GLIB_CFLAGS) \ - $(GOBJ_CFLAGS) \ - $(XML_CFLAGS) \ - $(ATK_CFLAGS) \ - -I$(top_srcdir)/tests/dummyatk/ - -libxmlloader_la_LIBADD = $(GLIB_LIBS) \ - $(XML_LIBS) \ - $(GOBJ_LIBS) \ - $(top_srcdir)/tests/dummyatk/libdummyatk.la \ - $(ATK_LIBS) - -libxmlloader_la_SOURCES = atk-object-xml-loader.c\ - atk-object-xml-loader.h - -libtestutils_la_CFLAGS = -I$(top_builddir) \ - $(GLIB_CFLAGS) \ - $(ATSPI_CFLAGS) - -libtestutils_la_LIBADD = $(GLIB_LIBS) \ - $(ATSPI_LIBS) - -libtestutils_la_SOURCES = atk_test_util.c \ - atk_test_util.h +SUBDIRS = diff --git a/tests/README b/tests/README deleted file mode 100644 index 109cb18..0000000 --- a/tests/README +++ /dev/null @@ -1,91 +0,0 @@ - -Testing AT-SPI requires both a test application and an AT client. - -Test applications are built from xml files using xml loader module, -based on Dummy ATK implementation. - -Each test is built as a GTest object and packed into a single interface test suite. - -Test directory contains: - - * atk_suite - Generates a test suite, the main executable of all test suite, - help is shown when run with '-h' parameter. - - * atk-object-xml-loader - Generates dummy atk object from xml file. - - * test-application - Starts an application with atk object generated by atk-object-xml-loader - - * data/ - Folder which contains xml file from which dummy atk object is generated - - * dummyatk/ - Folder which contains dummy atk implementation - - -************************ -HOW TO CREATE NEW TESTS: - -1) Add atspi interface which will be tested to Atk_Test_Case in atk_suite.c and atk_suite.h, - then add proper test call in atk_suite_build function. -2) Prepare xml file which describes tested root object and descendants. - If any new fields in xml file appear, atk-object-xml-loader should be modifed. -3) Add test file named atk_test_TEST_NAME.c, where TEST_NAME is tested interface name: - a) Create function which runs tested application - b) Create get_root_obj function for tested interface - c) Create tested functions - d) Create function which calls all test functions, this function should be called in atk_suite.c file. - -************************* -AVAILABLE TESTS: - -- Accessible: - -accessible_get_name - -accessible_get_description - -accessible_get_child_count - -accessible_get_parent - -accessible_get_child_at_index - -accessible_get_index_in_parent - -accessible_get_relation_set_1 - -accessible_get_relation_set_2 - -accessible_get_role - -accessible_get_role_name - -accessible_get_localized_role_name - -accessible_get_state_set - -accessible_get_attributes - -accessible_get_attributes_as_array - -accessible_get_toolkit_name - -accessible_get_toolkit_version - -accessible_get_atspi_version - -accessible_get_id - -accessible_get_application - -accessible_get_action_iface - -accessible_get_collection_iface - -accessible_get_component_iface - -accessible_get_document_iface - -accessible_get_editable_text_iface - -accessible_get_hypertext_iface - -accessible_get_image_iface - -accessible_get_selection_iface - -accessible_get_table_iface - -accessible_get_text_iface - -accessible_get_value_iface - -accessible_get_interfaces - -accessible_get_object_locale - -accessible_set_cache_mask - -accessible_clear_cache - -accessible_get_process_id -- Action: - -get_action_interface - -action_get_action_description - -action_get_action_name - -action_get_n_actions - -action_get_key_binding - -action_get_localized_name - -action_do_action -- Component: - -component_contains - -component_get_accessible_at_point - -component_get_extents - -component_get_layer - -component_get_mdi_z_order - -component_grab_focus - -component_get_alpha - -component_set_extents diff --git a/tests/atk-object-xml-loader.c b/tests/atk-object-xml-loader.c deleted file mode 100644 index 6f34ecd..0000000 --- a/tests/atk-object-xml-loader.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include - -#include "my-atk.h" - -#define ACCESSIBLE_NODE ((const xmlChar *) "accessible") -#define ACC_ACTION_NODE ((const xmlChar *) "accessible_action") -#define ACC_COMPONENT_NODE ((const xmlChar *) "accessible_component") -#define ACTION_NODE ((const xmlChar *) "action") -#define INTERFACE_NODE ((const xmlChar *) "interface") -#define RELATION_NODE ((const xmlChar *) "relation") -#define STATE_NODE ((const xmlChar *) "state") -#define COMPONENT_NODE ((const xmlChar *) "component") - -#define NAME_ATTR ((const xmlChar *) "name") -#define DESC_ATTR ((const xmlChar *) "description") -#define ROLE_ATTR ((const xmlChar *) "role") -#define TYPE_ATTR ((const xmlChar *) "type") -#define RELATION_TYPE_ATTR ((const xmlChar *) "relation_type") -#define RELATION_TARGET_NAME_ATTR ((const xmlChar *) "target_name") -#define STATE_TYPE_ATTR ((const xmlChar *) "state_enum") -#define ACTION_NAME_ATTR ((const xmlChar *) "action_name") -#define ACTION_DES_ATTR ((const xmlChar *) "action_description") -#define ACTION_KEY_BIND_ATTR ((const xmlChar *) "key_binding") -#define COMP_X_ATTR ((const xmlChar *) "x") -#define COMP_Y_ATTR ((const xmlChar *) "y") -#define COMP_WIDTH_ATTR ((const xmlChar *) "width") -#define COMP_HEIGHT_ATTR ((const xmlChar *) "height") -#define COMP_LAYER_ATTR ((const xmlChar *) "layer") -#define COMP_ZORDER_ATTR ((const xmlChar *) "zorder") -#define COMP_ALPHA_ATTR ((const xmlChar *) "alpha") - -MyAtkObject *relation_target = NULL; - -static gpointer -create_atk_object_from_element (xmlNode *element) -{ - xmlNode *child_node; - xmlNode *child_node2; - - gpointer obj; - gpointer child_obj; - gpointer child_obj2; - AtkRelationSet *relation_set = NULL; - AtkObject *array[1]; - AtkRelation *relation; - AtkStateSet *state_set = NULL; - AtkStateType state_type; - AtkAction *action; - - xmlChar *name; - xmlChar *description; - xmlChar *type_text; - xmlChar *relation_type_text; - xmlChar *state_enum; - xmlChar *role; - gint relation_type; - xmlChar *relation_target_name; - xmlChar *action_name; - xmlChar *action_des; - xmlChar *action_key_bind; - gint x_extent, y_extent, w_extent, h_extent; - name = xmlGetProp (element, NAME_ATTR); - description = xmlGetProp (element, DESC_ATTR); - role = xmlGetProp (element, ROLE_ATTR); - type_text = xmlGetProp (element, TYPE_ATTR); - GType type = MY_TYPE_ATK_OBJECT; - gint layer; - gint zorder; - gdouble alpha; - - if (!xmlStrcmp (element->name, ACCESSIBLE_NODE)) - type = MY_TYPE_ATK_OBJECT; - - if (!xmlStrcmp (element->name, ACC_ACTION_NODE)) - type = MY_TYPE_ATK_ACTION; - - if (!xmlStrcmp (element->name, ACC_COMPONENT_NODE)) - type = MY_TYPE_ATK_COMPONENT; - - obj = g_object_new (type, - "accessible-name", name, - "accessible-description", description, - "accessible-role", atk_role_for_name (role), - NULL); - - child_node = element->xmlChildrenNode; - while (child_node != NULL) { - if (!xmlStrcmp (child_node->name, ACCESSIBLE_NODE) || - !xmlStrcmp (child_node->name, ACC_ACTION_NODE) || - !xmlStrcmp (child_node->name, ACC_COMPONENT_NODE)) { - child_obj = create_atk_object_from_element (child_node); - my_atk_object_add_child (obj, child_obj); - } - child_node2 = child_node->xmlChildrenNode; - while (child_node2 != NULL) { - if (!xmlStrcmp (child_node2->name, RELATION_NODE)) { - relation_type_text = xmlGetProp (child_node2, RELATION_TYPE_ATTR); - relation_type = atoi (relation_type_text); - relation_target_name = xmlGetProp (child_node2, RELATION_TARGET_NAME_ATTR); - relation_set = atk_object_ref_relation_set (ATK_OBJECT (child_obj)); - array[0] = ATK_OBJECT (obj); - relation = atk_relation_new (array, 1, relation_type); - atk_relation_new (array, 1, relation_type); - atk_relation_set_add (relation_set, relation); - g_object_unref (relation); - g_object_unref (relation_set); - xmlFree (relation_target_name); - xmlFree (relation_type_text); - } - if (!xmlStrcmp (child_node2->name, STATE_NODE)) { - state_set = atk_object_ref_state_set (ATK_OBJECT (child_obj)); - state_enum = xmlGetProp (child_node2, STATE_TYPE_ATTR); - state_type = atk_state_type_for_name (state_enum); - atk_state_set_add_state (state_set, state_type); - g_object_unref (state_set); - xmlFree (state_enum); - } - if (!xmlStrcmp (child_node2->name, ACTION_NODE)) { - action_name = xmlGetProp (child_node2, ACTION_NAME_ATTR); - action_des = xmlGetProp (child_node2, ACTION_DES_ATTR); - action_key_bind = xmlGetProp (child_node2, ACTION_KEY_BIND_ATTR); - my_atk_action_add_action (child_obj, action_name, action_des, action_key_bind); - } - if (!xmlStrcmp (child_node2->name, COMPONENT_NODE)) { - x_extent = atoi (xmlGetProp (child_node2, COMP_X_ATTR)); - y_extent = atoi (xmlGetProp (child_node2, COMP_Y_ATTR)); - w_extent = atoi (xmlGetProp (child_node2, COMP_WIDTH_ATTR)); - h_extent = atoi (xmlGetProp (child_node2, COMP_HEIGHT_ATTR)); - layer = atoi (xmlGetProp (child_node2, COMP_LAYER_ATTR)); - zorder = atoi (xmlGetProp (child_node2, COMP_ZORDER_ATTR)); - alpha = atof (xmlGetProp (child_node2, COMP_ALPHA_ATTR)); - atk_component_set_extents (ATK_COMPONENT (child_obj), - x_extent, - y_extent, - w_extent, - h_extent, - ATK_XY_SCREEN); - my_atk_component_set_layer (ATK_COMPONENT (child_obj), layer); - my_atk_component_set_mdi_zorder (ATK_COMPONENT (child_obj), zorder); - my_atk_component_set_alpha (ATK_COMPONENT (child_obj), alpha); - } - child_node2 = child_node2->next; - } - child_node = child_node->next; - } - return obj; -} - -/* - * Reads the XML from filename and uses it - * to create a tree of MyAtkObjects. - * - * returns: The root object of the tree. - */ -MyAtkObject * -atk_object_xml_parse (gchar *filename) -{ - xmlDoc *doc; - xmlNode *root_element; - MyAtkObject *new_atk_object = NULL; - - doc = xmlReadFile (filename, NULL, 0); - g_assert (doc != NULL); - - root_element = xmlDocGetRootElement (doc); - - if (!root_element) - return NULL; - - new_atk_object = create_atk_object_from_element (root_element); - - xmlFreeDoc (doc); - return new_atk_object; -} diff --git a/tests/atk-object-xml-loader.h b/tests/atk-object-xml-loader.h deleted file mode 100644 index 5d2768a..0000000 --- a/tests/atk-object-xml-loader.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef ATK_OBJECT_XML_LOADER_H -#define ATK_OBJECT_XML_LOADER_H - -#include -#include "my-atk.h" - -MyAtkObject * atk_object_xml_parse (gchar *filename); - -#endif /*ATK_OBJECT_XML_LOADER_H*/ diff --git a/tests/atk_suite.c b/tests/atk_suite.c deleted file mode 100644 index 8b12d9a..0000000 --- a/tests/atk_suite.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include "atk_suite.h" -#include "atk_test_util.h" - -static gchar *tdata_list = NULL; -static gchar *one_test = NULL; - -typedef struct _Atk_Test_Case Atk_Test_Case; - -struct _Atk_Test_Case { - const char *test_case; - void (*build)( void); -}; - -static const Atk_Test_Case atc[] = { - { ATK_TEST_PATH_ACCESSIBLE, atk_test_accessible }, - { ATK_TEST_PATH_ACTION, atk_test_action }, - { ATK_TEST_PATH_COMP, atk_test_component }, - { NULL, NULL} -}; - -static void -_list_tests (void) -{ - const Atk_Test_Case *itr; - - itr = atc; - g_print ("Available Test Cases:\n"); - for (; itr->test_case; itr++) - g_print ("\t%s\n", itr->test_case); -} - -static void -atk_suite_build (int argc, char **argv ) -{ - g_test_init (&argc, &argv, NULL); - atk_test_accessible (); - atk_test_action (); - atk_test_component (); -} - -static GOptionEntry optentries[] = { - {"list", 'l', 0, G_OPTION_ARG_NONE, &tdata_list, "Display all available test cases", NULL}, - {"separate", 0, 0, G_OPTION_ARG_STRING, &one_test, "Run only NAME test", "NAME"}, - {NULL} -}; - -int -main(int argc, char **argv) -{ - int test_result; - GOptionContext *opt; - opt = g_option_context_new (NULL); - g_option_context_add_main_entries (opt, optentries, NULL); - g_option_context_set_help_enabled (opt, TRUE); - g_option_context_set_ignore_unknown_options (opt, TRUE); - - if (!g_option_context_parse (opt, &argc, &argv, NULL)) - return EXIT_FAILURE; - - if (tdata_list) { - _list_tests(); - return EXIT_SUCCESS; - } - - clean_exit_on_fail (); - - if (one_test) { - if (!g_strcmp0 (one_test, "Accessible")) { - g_test_init (&argc, &argv, NULL); - atk_test_accessible (); - test_result = g_test_run (); - return (test_result == 0 ) ? 0 : 255; - } - if (!g_strcmp0 (one_test, "Action")) { - g_test_init (&argc, &argv, NULL); - atk_test_action (); - test_result = g_test_run (); - return (test_result == 0 ) ? 0 : 255; - } - if (!g_strcmp0(one_test, "Component")) { - g_test_init (&argc, &argv, NULL); - atk_test_component (); - test_result = g_test_run (); - return ( test_result == 0 ) ? 0 : 255; - } - g_print ("Unknown test name\n"); - _list_tests (); - return EXIT_SUCCESS; - } - atk_suite_build (argc, argv); - test_result = g_test_run (); - - return (test_result == 0 ) ? 0 : 255; - -} diff --git a/tests/atk_suite.h b/tests/atk_suite.h deleted file mode 100644 index 17aefcd..0000000 --- a/tests/atk_suite.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _ATK_SUITE_H -#define _ATK_SUITE_H - -#include - -#define ATK_TEST_PATH_ACCESSIBLE (const char *)"/Accessible" -#define ATK_TEST_PATH_ACTION (const char *)"/Action" -#define ATK_TEST_PATH_COMP (const char *)"/Component" - -void atk_test_accessible (void); -void atk_test_action (void); -void atk_test_component (void); - -#endif /* _ATK_SUITE_H */ diff --git a/tests/atk_test_accessible.c b/tests/atk_test_accessible.c deleted file mode 100644 index e6aeb2f..0000000 --- a/tests/atk_test_accessible.c +++ /dev/null @@ -1,445 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "atk_suite.h" -#include "atk_test_util.h" - -#define DATA_FILE TESTS_DATA_DIR"/test-accessible.xml" - -static void -teardown_accessible_test (gpointer fixture, gconstpointer user_data) -{ - kill (child_pid, SIGTERM); -} - -static void -atk_test_accessible_get_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object"); -} - -static void -atk_test_accessible_get_description (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - g_assert_cmpstr (atspi_accessible_get_description (obj, NULL), ==, "Root of the accessible tree" ); -} - -static void -atk_test_accessible_get_child_count (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gint child_c = atspi_accessible_get_child_count (obj, NULL); - g_assert_cmpint ( 3, ==, child_c ); -} - -static void -atk_test_accessible_get_parent (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL ); - AtspiAccessible *parent = atspi_accessible_get_parent (child, NULL ); - g_assert (parent == obj ); -} - -static void -atk_test_accessible_get_child_at_index (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL ); - g_assert_cmpstr (atspi_accessible_get_name (child, NULL), ==, "obj2"); -} - -static void -atk_test_accessible_get_index_in_parent (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 2, NULL); - int index = atspi_accessible_get_index_in_parent (child, NULL); - g_assert_cmpint (index, ==, 2); -} - -static void -atk_test_accessible_get_relation_set_1 (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child1 = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiAccessible *child = atspi_accessible_get_child_at_index (child1, 0, NULL); - GArray *rel_set = atspi_accessible_get_relation_set (child, NULL); - g_assert_cmpint (rel_set->len, == , 1); -} - -static void -atk_test_accessible_get_relation_set_2 (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *obj2 = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiAccessible *obj2_1 = atspi_accessible_get_child_at_index (obj2, 0, NULL); - GArray *rel_set = atspi_accessible_get_relation_set (obj2_1, NULL); - int i=0; - for (i = 0; i < rel_set->len; i++) { - AtspiRelation *a = g_array_index (rel_set, AtspiRelation *, i); - g_assert_cmpint (atspi_relation_get_relation_type (a), == , ATSPI_RELATION_CONTROLLER_FOR ); - g_assert_cmpint (atspi_relation_get_n_targets (a), ==, 1); - AtspiAccessible *target = atspi_relation_get_target (a, 0); - g_assert_cmpstr (atspi_accessible_get_name (target,NULL), == , "obj2"); - } -} - -static void -atk_test_accessible_get_role (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiRole root_role = atspi_accessible_get_role (obj, NULL); - g_assert_cmpint (root_role, ==, ATSPI_ROLE_ACCELERATOR_LABEL); -} - -static void -atk_test_accessible_get_role_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *root_role_name = atspi_accessible_get_role_name (obj, NULL); - g_assert_cmpstr (root_role_name, ==, "accelerator label"); -} - -static void -atk_test_accessible_get_localized_role_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *root_role_name = atspi_accessible_get_localized_role_name (obj, NULL); - g_assert_cmpstr (root_role_name, ==, "accelerator label"); -} - -static void -atk_test_accessible_get_state_set (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 0, NULL); - AtspiStateSet *states = atspi_accessible_get_state_set (child); - GArray *states_arr = atspi_state_set_get_states (states); - - AtspiStateType valid_states[] = { - ATSPI_STATE_MODAL, - ATSPI_STATE_MULTI_LINE, - }; - g_assert_cmpint (states_arr->len, ==, 2); - int i = 0; - for (i = 0; i < states_arr->len; ++i) { - g_assert_cmpint (valid_states[i], ==, g_array_index (states_arr, AtspiStateType, i)); - g_assert (atspi_state_set_contains (states, ATSPI_STATE_MODAL)); - g_assert (atspi_state_set_contains(states, ATSPI_STATE_MULTI_LINE)); - } -} - -static void -atk_test_accessible_get_attributes (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - GHashTable *attr_hash_tab = atspi_accessible_get_attributes (obj, NULL); - GHashTableIter iter; - gpointer key, value; - - gchar *valid_keys[] = { "atspi" }; - gchar *valid_values[] = { "test" }; - - g_hash_table_iter_init (&iter, attr_hash_tab ); - int i = 0; - while (g_hash_table_iter_next (&iter, &key, &value)) { - g_assert_cmpstr (valid_keys[i], ==, (gchar *)key ); - g_assert_cmpstr (valid_values[i], ==, (gchar *)value ); - ++i; - } -} - -static void -atk_test_accessible_get_attributes_as_array (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *valid_attr[] = { "atspi:test", NULL }; - GArray *attr_arr = atspi_accessible_get_attributes_as_array ( obj, NULL); - int i = 0; - g_assert (attr_arr->len == (sizeof(valid_attr)/sizeof(gchar *))-1); - for( i = 0; i < attr_arr->len; ++i) { - g_assert_cmpstr (valid_attr[i], ==, g_array_index (attr_arr, gchar *, i)); - } -} - -static void -atk_test_accessible_get_toolkit_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *toolkit_name = atspi_accessible_get_toolkit_name (obj, NULL); - - g_assert_cmpstr (toolkit_name, ==, "atspitesting-toolkit"); -} - -static void -atk_test_accessible_get_toolkit_version (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *toolkit_ver = atspi_accessible_get_toolkit_version (obj, NULL); - /* should be empty string, because no value is setted */ - g_assert_cmpstr (toolkit_ver, ==, ""); -} - -static void -atk_test_accessible_get_atspi_version (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *atspi_version = atspi_accessible_get_atspi_version (obj, NULL); - g_assert_cmpstr (atspi_version, ==, "2.0"); -} - -static void -atk_test_accessible_get_id (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gint app_id = atspi_accessible_get_id (obj, NULL); - g_assert_cmpint (app_id, !=, -1); -} - -static void -atk_test_accessible_get_application (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *app = atspi_accessible_get_application (obj, NULL); - g_assert (app != NULL); -} - -static void -atk_test_accessible_get_action_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAction *iface = atspi_accessible_get_action_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_collection_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiCollection *iface = atspi_accessible_get_collection_iface (obj); - g_assert (iface != NULL); -} - -static void -atk_test_accessible_get_component_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiComponent *iface = atspi_accessible_get_component_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_document_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiDocument *iface = atspi_accessible_get_document_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_editable_text_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_hypertext_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiHypertext *iface = atspi_accessible_get_hypertext_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_image_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiImage *iface = atspi_accessible_get_image_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_selection_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiSelection *iface = atspi_accessible_get_selection_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_table_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiTable *iface = atspi_accessible_get_table_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_text_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiText *iface = atspi_accessible_get_text_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_value_iface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiValue *iface = atspi_accessible_get_value_iface (obj); - g_assert (iface == NULL); -} - -static void -atk_test_accessible_get_interfaces (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - gchar *valid_obj_ifaces[] = { "Accessible", "Collection" }; - - GArray *ifaces = atspi_accessible_get_interfaces (obj); - g_assert (ifaces->len == 2); - int i = 0; - for (i = 0; i < ifaces->len; ++i) - g_assert_cmpstr (valid_obj_ifaces[i], ==, g_array_index (ifaces, gchar *, i)); -} - -static void -atk_test_accessible_get_object_locale (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - const gchar *obj_locale = atspi_accessible_get_object_locale (obj, NULL); - g_assert_cmpstr (obj_locale, ==, setlocale (LC_MESSAGES, NULL)); -} - -static void -atk_test_accessible_set_cache_mask (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiCache cache_mask = ATSPI_CACHE_ROLE; - atspi_accessible_set_cache_mask (obj, cache_mask); - g_assert_cmpint (obj->parent.app->cache, ==, cache_mask); -} - -static void -atk_test_check_cache_cleared (AtspiAccessible *obj) -{ - GList *l; - g_assert_cmpint (obj->cached_properties, ==, ATSPI_CACHE_NONE); - for (l = obj->children; l; l = l->next) - atk_test_check_cache_cleared( l->data); -} - -static void -atk_test_accessible_clear_cache (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - atspi_accessible_clear_cache (obj); - atk_test_check_cache_cleared (obj); -} - -static void -atk_test_accessible_get_process_id (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - guint proc_id = atspi_accessible_get_process_id (obj, NULL); - g_assert_cmpint (proc_id, ==, child_pid); -} - -void -atk_test_accessible(void ) -{ - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accesible_get_name", - 0, NULL, NULL, atk_test_accessible_get_name, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_description", - 0, NULL, NULL, atk_test_accessible_get_description, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_child_count", - 0, NULL, NULL, atk_test_accessible_get_child_count, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_parent", - 0, NULL, NULL, atk_test_accessible_get_parent, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_child_at_index", - 0, NULL, NULL, atk_test_accessible_get_child_at_index, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_index_in_parent", - 0, NULL, NULL, atk_test_accessible_get_index_in_parent, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_relation_set_1", - 0, NULL, NULL, atk_test_accessible_get_relation_set_1, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_relation_set_2", - 0, NULL, NULL, atk_test_accessible_get_relation_set_2, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_role", - 0, NULL, NULL, atk_test_accessible_get_role, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_role_name", - 0, NULL, NULL, atk_test_accessible_get_role_name, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_localized_role_name", - 0, NULL, NULL, atk_test_accessible_get_localized_role_name, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_state_set", - 0, NULL, NULL, atk_test_accessible_get_state_set, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_attributes", - 0, NULL, NULL, atk_test_accessible_get_attributes, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_attributes_as_array", - 0, NULL, NULL, atk_test_accessible_get_attributes_as_array, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_toolkit_name", - 0, NULL, NULL, atk_test_accessible_get_toolkit_name, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_toolkit_version", - 0, NULL, NULL, atk_test_accessible_get_toolkit_version, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_atspi_version", - 0, NULL, NULL, atk_test_accessible_get_atspi_version, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_id", - 0, NULL, NULL, atk_test_accessible_get_id, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_application", - 0, NULL, NULL, atk_test_accessible_get_application, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_action_iface", - 0, NULL, NULL, atk_test_accessible_get_action_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_collection_iface", - 0, NULL, NULL, atk_test_accessible_get_collection_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_component_iface", - 0, NULL, NULL, atk_test_accessible_get_component_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_document_iface", - 0, NULL, NULL, atk_test_accessible_get_document_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_editable_text_iface", - 0, NULL, NULL, atk_test_accessible_get_editable_text_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_hypertext_iface", - 0, NULL, NULL, atk_test_accessible_get_hypertext_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_image_iface", - 0, NULL, NULL, atk_test_accessible_get_image_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_selection_iface", - 0, NULL, NULL, atk_test_accessible_get_selection_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_table_iface", - 0, NULL, NULL, atk_test_accessible_get_table_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_text_iface", - 0, NULL, NULL, atk_test_accessible_get_text_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_value_iface", - 0, NULL, NULL, atk_test_accessible_get_value_iface, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_interfaces", - 0, NULL, NULL, atk_test_accessible_get_interfaces, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_object_locale", - 0, NULL, NULL, atk_test_accessible_get_object_locale, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_set_cache_mask", - 0, NULL, NULL, atk_test_accessible_set_cache_mask, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_clear_cache", - 0, NULL, NULL, atk_test_accessible_clear_cache, teardown_accessible_test ); - g_test_add_vtable (ATK_TEST_PATH_ACCESSIBLE "/atk_test_accessible_get_process_id", - 0, NULL, NULL, atk_test_accessible_get_process_id, teardown_accessible_test ); -} diff --git a/tests/atk_test_action.c b/tests/atk_test_action.c deleted file mode 100644 index fa79d1e..0000000 --- a/tests/atk_test_action.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "atk_suite.h" -#include "atk_test_util.h" - -#define DATA_FILE TESTS_DATA_DIR"/test-action.xml" - -static void -teardown_action_test (gpointer fixture, gconstpointer user_data) -{ - kill (child_pid, SIGTERM); -} - -static void -atk_test_action_sample_get_interface (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object"); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *iface = atspi_accessible_get_action_iface (child); - g_assert (iface != NULL); -} - -static void -atk_test_action_get_action_description (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert_cmpstr (atspi_action_get_action_description (action, 0, NULL), == ,"action1 description"); -} - -static void -atk_test_action_get_action_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert_cmpstr (atspi_action_get_action_name (action, 0, NULL), == ,"action1"); -} - -static void -atk_test_action_get_n_actions (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert_cmpint (atspi_action_get_n_actions (action, NULL), == , 2); -} - -static void -atk_test_action_get_key_binding (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert_cmpstr (atspi_action_get_key_binding (action, 0, NULL), == ,"action1 key binding"); -} - -static void -atk_test_action_get_localized_name (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert_cmpstr (atspi_action_get_localized_name (action, 0, NULL), == ,"action1"); -} - -static void -atk_test_action_do_action (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiAction *action = atspi_accessible_get_action_iface (child); - g_assert (action != NULL); - atspi_action_do_action (action, 0, NULL); - atspi_accessible_clear_cache (obj); - AtspiStateSet *s = atspi_accessible_get_state_set (child); - GArray *array = atspi_state_set_get_states (s); - g_assert_cmpint (array->len, ==, 1); -} - -void -atk_test_action (void) -{ - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_sample_get_interface", - 0, NULL, NULL, atk_test_action_sample_get_interface, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_get_action_description", - 0, NULL, NULL, atk_test_action_get_action_description, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_get_action_name", - 0, NULL, NULL, atk_test_action_get_action_name, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_get_n_actions", - 0, NULL, NULL, atk_test_action_get_n_actions, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_get_key_binding", - 0, NULL, NULL, atk_test_action_get_key_binding, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_get_localized_name", - 0, NULL, NULL, atk_test_action_get_localized_name, teardown_action_test); - g_test_add_vtable (ATK_TEST_PATH_ACTION "/atk_test_action_do_action", - 0, NULL, NULL, atk_test_action_do_action, teardown_action_test); -} diff --git a/tests/atk_test_component.c b/tests/atk_test_component.c deleted file mode 100644 index 8b85f5b..0000000 --- a/tests/atk_test_component.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "atk_suite.h" -#include "atk_test_util.h" - -#define DATA_FILE TESTS_DATA_DIR"/test-component.xml" - -static void -teardown_component_test (gpointer fixture, gconstpointer user_data) -{ - kill (child_pid, SIGTERM); -} - -static void -atk_test_component_sample (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object"); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); -} - -static void -atk_test_component_contains (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gboolean ret = atspi_component_contains (iface, 400, 300, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert (ret != FALSE); -} - -static void -atk_test_component_get_accessible_at_point (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiAccessible *r = atspi_component_get_accessible_at_point (iface, - 400, - 300, - ATSPI_COORD_TYPE_SCREEN, - NULL); - g_assert (r != NULL); -} - -static void -atk_test_component_get_extents (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiRect *r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert_cmpint (r->x, ==, 350); - g_assert_cmpint (r->y, ==, 200); - g_assert_cmpint (r->width, ==, 250); - g_assert_cmpint (r->height, ==, 250); - g_free (r); -} - -static void -atk_test_component_get_position (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiPoint *p = atspi_component_get_position (iface, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert_cmpint (p->x, ==, 350); - g_assert_cmpint (p->y, ==, 200); - g_free (p); -} - -static void -atk_test_component_get_size (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiPoint *p = atspi_component_get_size (iface, NULL); - g_assert (p != NULL); - g_assert_cmpint (p->x, ==, 350); - g_assert_cmpint (p->y, ==, 200); - g_free (p); -} - -static void -atk_test_component_get_layer (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiComponentLayer layer = atspi_component_get_layer (iface, NULL); - g_assert_cmpint (layer, ==, ATSPI_LAYER_WIDGET); -} - -static void -atk_test_component_get_mdi_z_order (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gshort ret = atspi_component_get_mdi_z_order (iface, NULL); - g_assert_cmpint (ret, ==, 2); -} - -static void -atk_test_component_grab_focus (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gboolean ret = atspi_component_grab_focus (iface, NULL); - g_assert (ret != FALSE); -} - -static void -atk_test_component_get_alpha (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gdouble ret = atspi_component_get_alpha (iface, NULL); - g_assert_cmpint (ret, ==, 2.5); -} - -static void -atk_test_component_set_extents (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - AtspiRect *r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert_cmpint (r->x, ==, 350); - g_assert_cmpint (r->y, ==, 200); - g_assert_cmpint (r->width, ==, 250); - g_assert_cmpint (r->height, ==, 250); - g_free (r); - - gboolean ret = atspi_component_set_extents (iface, 100, 100, 100, 100, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert (ret != FALSE); - - r = atspi_component_get_extents (iface, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert_cmpint (r->x, ==, 100); - g_assert_cmpint (r->y, ==, 100); - g_assert_cmpint (r->width, ==, 100); - g_assert_cmpint (r->height, ==, 100); - g_free (r); -} - -static void -atk_test_component_set_position (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gboolean ret = atspi_component_set_position (iface, 350, 250, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert (ret != FALSE); - - AtspiPoint *p = atspi_component_get_position (iface, ATSPI_COORD_TYPE_SCREEN, NULL); - g_assert (p != NULL ); - g_assert_cmpint (p->x, ==, 350); - g_assert_cmpint (p->y, ==, 200); - g_free (p); -} - -static void -atk_test_component_set_size (gpointer fixture, gconstpointer user_data) -{ - AtspiAccessible *obj = get_root_obj (DATA_FILE); - AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL); - AtspiComponent *iface = atspi_accessible_get_component_iface (child); - g_assert (iface != NULL); - - gboolean ret = atspi_component_set_size (iface, 350, 250, NULL); - g_assert (ret != FALSE); - - AtspiPoint *p = atspi_component_get_size (iface, NULL); - g_assert (p != NULL); - g_assert_cmpint (p->x, ==, 350); - g_assert_cmpint (p->y, ==, 200); - g_free (p); -} - -void -atk_test_component (void) -{ - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_sample", - 0, NULL, NULL, atk_test_component_sample, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_contains", - 0, NULL, NULL, atk_test_component_contains, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_accessible_at_point", - 0, NULL, NULL, atk_test_component_get_accessible_at_point, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_extents", - 0, NULL, NULL, atk_test_component_get_extents, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_layer", - 0, NULL, NULL, atk_test_component_get_layer, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_mdi_z_order", - 0, NULL, NULL, atk_test_component_get_mdi_z_order, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_grab_focus", - 0, NULL, NULL, atk_test_component_grab_focus, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_alpha", - 0, NULL, NULL, atk_test_component_get_alpha, teardown_component_test); - g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_set_extents", - 0, NULL, NULL, atk_test_component_set_extents, teardown_component_test); -// DEPRICATED -// g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_position", -// 0, NULL, NULL, atk_test_component_get_position, teardown_component_test); -// g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_get_size", -// 0, NULL, NULL, atk_test_component_get_size, teardown_component_test); -// g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_set_position", -// 0, NULL, NULL, atk_test_component_set_position, teardown_component_test); -// g_test_add_vtable (ATK_TEST_PATH_COMP "/atk_test_component_set_size", -// 0, NULL, NULL, atk_test_component_set_size, teardown_component_test); -} diff --git a/tests/atk_test_util.c b/tests/atk_test_util.c deleted file mode 100644 index 22c791d..0000000 --- a/tests/atk_test_util.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include "atk_test_util.h" - -static void assert_clean_exit (int sig) -{ - kill (child_pid, SIGTERM); -} - -void clean_exit_on_fail () -{ - signal (SIGABRT, assert_clean_exit); -} - -void -run_app (const char *file_name) -{ - int i=0; - child_pid = fork (); - if (child_pid == 0) { - execlp ("./app-test", - "./app-test", - "--test-data-file", - file_name, - NULL); - _exit (EXIT_SUCCESS); - } -} - -AtspiAccessible * get_root_obj (const char *file_name) -{ - int i; - AtspiAccessible *obj = NULL; - - run_app (file_name); - - /* sleep is needed to wait for fored test application*/ - sleep (1); - - obj = atspi_get_desktop (0); - gint child_count = atspi_accessible_get_child_count (obj, NULL); - if (child_count < 1) { - g_test_message ("Fail, test application not found\n"); - g_test_fail (); - kill (child_pid, SIGTERM); - return NULL; - } - - for (i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "atk_suite.h" - -pid_t child_pid; - -void run_app (const char *file_name); -AtspiAccessible *get_root_obj (const char *file_name); -void clean_exit_on_fail (); - -#endif /* _ATK_TEST_UTIL_H */ diff --git a/tests/cspi/Makefile.am b/tests/cspi/Makefile.am new file mode 100644 index 0000000..b5b8d05 --- /dev/null +++ b/tests/cspi/Makefile.am @@ -0,0 +1,19 @@ +noinst_PROGRAMS = key-listener-test keysynth-test simple-at test-simple + +key_listener_test_SOURCES = key-listener-test.c +keysynth_test_SOURCES = keysynth-test.c +simple_at_SOURCES = simple-at.c +test_simple_SOURCES = test-simple.c + +INCLUDES = -I$(top_srcdir) \ + -I$(top_builddir) \ + $(DBUS_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + $(ATK_CFLAGS) \ + $(DBIND_CFLAGS) \ + $(DEBUG_CFLAGS) + +LDADD = $(top_builddir)/common/libspicommon.la \ + $(top_builddir)/cspi/libcspi.la \ + $(TESTS_LIBS) $(XINPUT_LIBS) $(ATK_LIBS) $(GTK_LIBS) $(DBIND_LIBS) @EXTRA_SOCKET_LIBS@ diff --git a/tests/cspi/key-listener-test.c b/tests/cspi/key-listener-test.c new file mode 100644 index 0000000..b212a21 --- /dev/null +++ b/tests/cspi/key-listener-test.c @@ -0,0 +1,201 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "../../cspi/spi.h" + +static SPIBoolean report_command_key_event (const AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_ordinary_key_event (const AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_synchronous_key_event (const AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_tab_key_event (const AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_all_key_event (const AccessibleKeystroke *stroke, void *user_data); + +static AccessibleKeystrokeListener *command_key_listener; +static AccessibleKeystrokeListener *ordinary_key_listener; +static AccessibleKeystrokeListener *synchronous_key_listener; +static AccessibleKeystrokeListener *tab_key_listener; +static AccessibleKeystrokeListener *all_key_listener; +static AccessibleKeySet *command_keyset; +static AccessibleKeySet *async_keyset; +static AccessibleKeySet *sync_keyset; +static AccessibleKeySet *tab_keyset; + +int +main (int argc, char **argv) +{ + const char *tab_strings[1] = {"Tab"}; + short keycodes[] = {65, 64, 23}; + SPIBoolean retval = FALSE; + + SPI_init (); + + /* prepare the keyboard snoopers */ + command_key_listener = SPI_createAccessibleKeystrokeListener (report_command_key_event, NULL); + ordinary_key_listener = SPI_createAccessibleKeystrokeListener (report_ordinary_key_event, NULL); + synchronous_key_listener = SPI_createAccessibleKeystrokeListener (report_synchronous_key_event, NULL); + tab_key_listener = SPI_createAccessibleKeystrokeListener (report_tab_key_event, NULL); + all_key_listener = SPI_createAccessibleKeystrokeListener (report_all_key_event, NULL); + + command_keyset = SPI_createAccessibleKeySet (1, "q", NULL, NULL); + async_keyset = SPI_createAccessibleKeySet (3, NULL, keycodes, NULL); + sync_keyset = SPI_createAccessibleKeySet (3, "def", NULL, NULL); + tab_keyset = SPI_createAccessibleKeySet (1, NULL, NULL, tab_strings); + retval = SPI_registerAccessibleKeystrokeListener(command_key_listener, + command_keyset, + SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL, + (unsigned long) ( SPI_KEY_PRESSED ), + SPI_KEYLISTENER_ALL_WINDOWS); + fprintf (stderr, "Command key registry: result %s\n", retval ? "succeeded" : + "failed"); + retval = SPI_registerAccessibleKeystrokeListener(ordinary_key_listener, + async_keyset, + SPI_KEYMASK_UNMODIFIED, + (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), + SPI_KEYLISTENER_NOSYNC); + + retval = SPI_registerAccessibleKeystrokeListener(synchronous_key_listener, + sync_keyset, + SPI_KEYMASK_UNMODIFIED, + (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), + SPI_KEYLISTENER_CANCONSUME); + + retval = SPI_registerAccessibleKeystrokeListener(tab_key_listener, + tab_keyset, + SPI_KEYMASK_ALT, + (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), + SPI_KEYLISTENER_ALL_WINDOWS); + fprintf (stderr, "tab listener registry: %s\n", retval ? "succeeded" : "failed"); + + retval = SPI_registerAccessibleKeystrokeListener(all_key_listener, + SPI_KEYSET_ALL_KEYS, + SPI_KEYMASK_CONTROL | SPI_KEYMASK_SHIFT, + (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), + SPI_KEYLISTENER_ALL_WINDOWS); + + fprintf (stderr, "all key registry: %s\n", retval ? "succeeded" : "failed" ); + + SPI_registerAccessibleKeystrokeListener(all_key_listener, + SPI_KEYSET_ALL_KEYS, + SPI_KEYMASK_SHIFT, + (unsigned long) ( SPI_KEY_PRESSED ), + SPI_KEYLISTENER_NOSYNC | SPI_KEYLISTENER_CANCONSUME); + + SPI_event_main (); + + putenv ("AT_BRIDGE_SHUTDOWN=1"); + + return SPI_exit (); +} + +static void +simple_at_exit (void) +{ + SPI_deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); + AccessibleKeystrokeListener_unref (command_key_listener); + SPI_freeAccessibleKeySet (command_keyset); + +/* + SPI_deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); */ + AccessibleKeystrokeListener_unref (ordinary_key_listener); + SPI_freeAccessibleKeySet (async_keyset); + +/* SPI_deregisterAccessibleKeystrokeListener (synchronous_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); */ + AccessibleKeystrokeListener_unref (synchronous_key_listener); + SPI_freeAccessibleKeySet (sync_keyset); + + SPI_deregisterAccessibleKeystrokeListener (tab_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); + AccessibleKeystrokeListener_unref (tab_key_listener); + SPI_freeAccessibleKeySet (tab_keyset); + + SPI_event_quit (); +} + +static SPIBoolean +is_command_key (const AccessibleKeystroke *key) +{ + switch (key->keyID) + { + case 'Q': + case 'q': + simple_at_exit(); + return TRUE; /* not reached */ + default: + return FALSE; + } +} + +static void +print_key_event (const AccessibleKeystroke *key, char *prefix) +{ + fprintf (stderr, "%s KeyEvent %s%c (keycode %d); string=%s; time=%lx\n", + prefix, + (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"", + ((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))? + (char) toupper((int) key->keyID) : (char) tolower((int) key->keyID), + (int) key->keycode, + key->keystring, + (long int) key->timestamp); +} + +static SPIBoolean +report_command_key_event (const AccessibleKeystroke *key, void *user_data) +{ + print_key_event (key, "command"); + return is_command_key (key); +} + +static SPIBoolean +report_ordinary_key_event (const AccessibleKeystroke *key, void *user_data) +{ + print_key_event (key, "ordinary"); + return FALSE; +} + +static SPIBoolean +report_synchronous_key_event (const AccessibleKeystroke *key, void *user_data) +{ + /* consume 'd' key, let others pass through */ + print_key_event (key, "synchronous (consumable) "); + return ( key->keyID == 'd' ) ? TRUE : FALSE; +} + +static SPIBoolean +report_tab_key_event (const AccessibleKeystroke *key, void *user_data) +{ + print_key_event (key, "[TAB]"); + return FALSE; +} + +static SPIBoolean +report_all_key_event (const AccessibleKeystroke *key, void *user_data) +{ + fprintf(stderr, "(%ld)", key->keyID); + return FALSE; +} + diff --git a/tests/cspi/keysynth-test.c b/tests/cspi/keysynth-test.c new file mode 100644 index 0000000..73aa240 --- /dev/null +++ b/tests/cspi/keysynth-test.c @@ -0,0 +1,65 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include "../../cspi/spi-private.h" /* A hack for now */ +#include +#include +#include +#include +#include "common/spi-dbus.h" + +typedef struct { + long int val; + char *string; + AccessibleKeySynthType type; +} TextTest; + +static TextTest text[] = { + {65, NULL, SPI_KEY_PRESSRELEASE}, + {64, NULL, SPI_KEY_SYM}, + {0, "--hello!", SPI_KEY_STRING}, + {0, "StudlyCaps!", SPI_KEY_STRING} +}; + +static void +test_key_synthesis (void) +{ + int i; + for (i = 0; i < G_N_ELEMENTS (text); ++i) { + SPI_generateKeyboardEvent (text[i].val, text[i].string, text[i].type); + } +} + +int +main (int argc, char **argv) +{ + gtk_init (&argc, &argv); + SPI_init (); + + test_key_synthesis (); + + return SPI_exit (); +} + diff --git a/tests/cspi/simple-at.c b/tests/cspi/simple-at.c new file mode 100644 index 0000000..23cb0ec --- /dev/null +++ b/tests/cspi/simple-at.c @@ -0,0 +1,615 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#undef MAGNIFIER_ENABLED +#include "../../cspi/spi-private.h" /* A hack for now */ + +#define PRINT_TREE + +static void report_focus_event (const AccessibleEvent *event, void *user_data); +static void report_generic_event (const AccessibleEvent *event, void *user_data); +static void report_window_event (const AccessibleEvent *event, void *user_data); +static void report_text_event (const AccessibleEvent *event, void *user_data); +static void report_button_press (const AccessibleEvent *event, void *user_data); +static void check_property_change (const AccessibleEvent *event, void *user_data); +static SPIBoolean report_command_key_event (const AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_ordinary_key_event (const AccessibleKeystroke *stroke, void *user_data); +static void get_environment_vars (void); + +static int _festival_init (void); +static void _festival_say (const char *text, const char *voice, SPIBoolean shutup); +static void _festival_write (const char *buff, int fd); + +#ifdef PRINT_TREE +static void print_accessible_tree (Accessible *accessible, char *prefix); +#endif + +#ifdef MAGNIFIER_ENABLED +static SPIBoolean use_magnifier = FALSE; +#endif + +static SPIBoolean use_festival = FALSE; +static SPIBoolean festival_chatty = FALSE; +static SPIBoolean name_changed = FALSE; + +static AccessibleEventListener *focus_listener; +static AccessibleEventListener *property_listener; +static AccessibleEventListener *generic_listener; +static AccessibleEventListener *window_listener; +static AccessibleEventListener *button_listener; +static AccessibleEventListener *text_listener; +static AccessibleKeystrokeListener *command_key_listener; +static AccessibleKeystrokeListener *ordinary_key_listener; +static AccessibleKeySet *command_keyset; + +int +main (int argc, char **argv) +{ + int i, j; + int n_desktops; + int n_apps; + char *s; + Accessible *desktop; + Accessible *application; + const char *modules; + + if ((argc > 1) && (!strncmp (argv[1], "-h", 2))) + { + printf ("Usage: simple-at\n"); + printf ("\tEnvironment variables used:\n\t\tFESTIVAL\n\t\tMAGNIFIER\n\t\tFESTIVAL_CHATTY\n"); + exit (0); + } + + modules = g_getenv ("GTK_MODULES"); + if (!modules || modules [0] == '\0') + { + putenv ("GTK_MODULES="); + } + modules = NULL; + + SPI_init (); + + focus_listener = SPI_createAccessibleEventListener (report_focus_event, NULL); + property_listener = SPI_createAccessibleEventListener (check_property_change, NULL); + generic_listener = SPI_createAccessibleEventListener (report_generic_event, NULL); + window_listener = SPI_createAccessibleEventListener (report_window_event, NULL); + text_listener = SPI_createAccessibleEventListener (report_text_event, NULL); + button_listener = SPI_createAccessibleEventListener (report_button_press, NULL); + SPI_registerGlobalEventListener (focus_listener, "focus:"); + SPI_registerGlobalEventListener (property_listener, "object:property-change"); +/* :accessible-selection"); */ + SPI_registerGlobalEventListener (property_listener, "object:property-change:accessible-name"); + SPI_registerGlobalEventListener (generic_listener, "object:selection-changed"); + SPI_registerGlobalEventListener (generic_listener, "object:children-changed"); + SPI_registerGlobalEventListener (generic_listener, "object:visible-data-changed"); + SPI_registerGlobalEventListener (generic_listener, "object:text-selection-changed"); + SPI_registerGlobalEventListener (text_listener, "object:text-caret-moved"); + SPI_registerGlobalEventListener (text_listener, "object:text-changed"); + SPI_registerGlobalEventListener (button_listener, "Gtk:GtkWidget:button-press-event"); + SPI_registerGlobalEventListener (window_listener, "window:minimize"); + SPI_registerGlobalEventListener (window_listener, "window:activate"); + n_desktops = SPI_getDesktopCount (); + + for (i=0; i 0) + { + AccessibleText_getCharacterExtents (text, 0, &x0, &y0, &w0, &h0, + SPI_COORD_TYPE_SCREEN); + AccessibleText_getCharacterExtents (text, nchars-1, &xN, &yN, &wN, &hN, + SPI_COORD_TYPE_SCREEN); + x = MIN (x0, xN); + width = MAX (x0 + w0, xN + wN) - x; + fprintf (stderr, "Text bounding box: (%ld, %ld) ; (%ld, %ld)\n", + x, y, x+width, y+height); + } + } +#ifdef MAGNIFIER_ENABLED + if (use_magnifier) { + magnifier_set_roi ((short) 0, x, y, width, height); + } +#endif + } + + + if (Accessible_isValue (obj)) + { + AccessibleValue *value = Accessible_getValue (obj); + fprintf (stderr, "Current value = %f, min = %f; max = %f\n", + AccessibleValue_getCurrentValue (value), + AccessibleValue_getMinimumValue (value), + AccessibleValue_getMaximumValue (value)); + } + /* if this is a text object, speak the first sentence. */ + + if (Accessible_isText(obj)) + + { + AccessibleText *text_interface; + long start_offset, end_offset; + char *first_sentence = "empty"; + text_interface = Accessible_getText (obj); + first_sentence = AccessibleText_getTextAtOffset ( + text_interface, (long) 0, SPI_TEXT_BOUNDARY_SENTENCE_START, &start_offset, &end_offset); + if (first_sentence && use_festival) + { + _festival_say(first_sentence, "voice_don_diphone", FALSE); + SPI_freeString (first_sentence); + } + len = AccessibleText_getCharacterCount (text_interface); + s = AccessibleText_getText (text_interface, 0, len); + fprintf (stderr, "done reporting on focussed object, text=%s\n", s); + } +} + +void +report_focus_event (const AccessibleEvent *event, void *user_data) +{ + char *s; + + g_return_if_fail (event->source != NULL); + s = Accessible_getName (event->source); + if (s) + { + fprintf (stderr, "%s event from %s\n", event->type, s); + SPI_freeString (s); + report_focussed_accessible (event->source, TRUE); + } + Accessible_getParent (event->source); + name_changed = FALSE; +} + +void +report_generic_event (const AccessibleEvent *event, void *user_data) +{ + fprintf (stderr, "%s event received\n", event->type); +} + +void +report_window_event (const AccessibleEvent *event, void *user_data) +{ + fprintf (stderr, "%s event received\n", event->type); + if (!strcmp (event->type, "window:activate")) + { + print_accessible_tree (event->source, "window"); + } +} + +void +report_text_event (const AccessibleEvent *event, void *user_data) +{ + AccessibleText *text = Accessible_getText (event->source); + fprintf (stderr, "%s event received\n", event->type); +#ifdef MAGNIFIER_ENABLED + if (use_magnifier && strcmp (event->type, "object:text-changed")) + { + long offset = AccessibleText_getCaretOffset (text); + long x, y, w, h; + fprintf (stderr, "offset %d\n", (int) offset); + AccessibleText_getCharacterExtents (text, offset, &x, &y, &w, &h, + SPI_COORD_TYPE_SCREEN); + fprintf (stderr, "new roi %d %d %d %d\n", (int) x, (int) y, (int) w, (int) h); + magnifier_set_roi ((short) 0, x, y, w, h); + } +#endif + if (!strcmp (event->type, "object:text-changed")) + { + long start, end; + char *new_text = AccessibleText_getTextAtOffset (text, (long) event->detail1, SPI_TEXT_BOUNDARY_WORD_START, &start, &end); + _festival_say (new_text, "voice_kal_diphone", FALSE); + fprintf (stderr, "text changed: %s", new_text ? new_text : ""); + SPI_freeString (new_text); + } + else + { + long start, end; + char *word_text = AccessibleText_getTextAtOffset (text, (long) event->detail1, SPI_TEXT_BOUNDARY_WORD_START, &start, &end); + char *sentence_text = AccessibleText_getTextAtOffset (text, (long) event->detail1, SPI_TEXT_BOUNDARY_SENTENCE_START, &start, &end); + fprintf (stderr, "text changed: word %s; sentence %s at %ld", + (word_text ? word_text : ""), + (sentence_text ? sentence_text : ""), + event->detail1); + if (word_text) SPI_freeString (word_text); + if (sentence_text) SPI_freeString (sentence_text); + } +} + +void +report_button_press (const AccessibleEvent *event, void *user_data) +{ + char *s; + + g_return_if_fail (event->source != NULL); + + s = Accessible_getName (event->source); + + fprintf (stderr, "%s event from %s\n", event->type, s); + SPI_freeString (s); + s = Accessible_getDescription (event->source); + fprintf (stderr, "Object description %s\n", s); + SPI_freeString (s); +} + +void +check_property_change (const AccessibleEvent *event, void *user_data) +{ + AccessibleSelection *selection = Accessible_getSelection (event->source); + int n_selections; + int i; + char *s; + fprintf (stderr, "property change event!\n"); + if (selection) + { + n_selections = (int) AccessibleSelection_getNSelectedChildren (selection); + s = Accessible_getName (event->source); + fprintf (stderr, "(Property) %s event from %s, %d selected children\n", + event->type, s, n_selections); + SPI_freeString (s); + /* for now, speak entire selection set */ + for (i=0; itype, "object:property-change:accessible-name")) + { + name_changed = TRUE; + report_focussed_accessible (event->source, TRUE); + } + else + { + fprintf (stderr, "Property change %s received\n", event->type); + } +} + +static void +simple_at_exit (void) +{ + SPI_deregisterGlobalEventListenerAll (focus_listener); + AccessibleEventListener_unref (focus_listener); + + SPI_deregisterGlobalEventListenerAll (property_listener); + AccessibleEventListener_unref (property_listener); + + SPI_deregisterGlobalEventListenerAll (generic_listener); + AccessibleEventListener_unref (generic_listener); + + SPI_deregisterGlobalEventListenerAll (text_listener); + AccessibleEventListener_unref (text_listener); + + SPI_deregisterGlobalEventListenerAll (button_listener); + AccessibleEventListener_unref (button_listener); + + SPI_deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); + AccessibleKeystrokeListener_unref (command_key_listener); + SPI_freeAccessibleKeySet (command_keyset); + + SPI_deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_SHIFTLOCK); + AccessibleKeystrokeListener_unref (ordinary_key_listener); + + SPI_event_quit (); +} + +static SPIBoolean +is_command_key (const AccessibleKeystroke *key) +{ + switch (key->keyID) + { + case 'Q': + case 'q': + simple_at_exit(); + return TRUE; /* not reached */ +#ifdef MAGNIFIER_ENABLED + case 'M': + case 'm': + use_magnifier = ! use_magnifier; + fprintf (stderr, "%ssing magnifier\n", use_magnifier ? "U" : "Not u"); + return TRUE; +#endif + case 'F': + case 'f': + use_festival = ! use_festival; + fprintf (stderr, "%speech output\n", use_festival ? "S" : "No s"); + return TRUE; + default: + return FALSE; + } +} + +static SPIBoolean +report_command_key_event (const AccessibleKeystroke *key, void *user_data) +{ + fprintf (stderr, "Command KeyEvent %s%c (keycode %d); string=%s; time=%lx\n", + (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"", + ((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))? + (char) toupper((int) key->keyID) : (char) tolower((int) key->keyID), + (int) key->keycode, + key->keystring, + (long int) key->timestamp); + return is_command_key (key); +} + + +static SPIBoolean +report_ordinary_key_event (const AccessibleKeystroke *key, void *user_data) +{ + fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\tstring=\'%s\'\n\ttime %lx\n", + (long) key->keyID, + (unsigned int) key->modifiers, + (int) key->keycode, + key->keystring, + (long int) key->timestamp); + return FALSE; +} + +static int +_festival_init (void) +{ + int fd; + struct sockaddr_in name; + int tries = 2; + + name.sin_family = AF_INET; + name.sin_port = htons (1314); + name.sin_addr.s_addr = htonl(INADDR_ANY); + fd = socket (PF_INET, SOCK_STREAM, 0); + + while (connect(fd, (struct sockaddr *) &name, sizeof (name)) < 0) { + if (!tries--) { + perror ("connect"); + return -1; + } + } + + _festival_write ("(audio_mode'async)\n", fd); + _festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)\n", fd); + _festival_write ("(Parameter.set 'Duration_Stretch 0.75)\n", fd); + return fd; +} + +static void +_festival_say (const char *text, const char *voice, SPIBoolean shutup) +{ + static int fd = 0; + gchar *quoted; + gchar *p; + gchar prefix[50]; + static gchar voice_spec[32]; + + if (!fd) + { + fd = _festival_init (); + } + + fprintf (stderr, "saying text: %s\n", text); + + quoted = g_malloc(64+strlen(text)*2); + + sprintf (prefix, "(SayText \""); + + strncpy(quoted, prefix, 10); + p = quoted+strlen(prefix); + while (*text) { + if ( *text == '\\' || *text == '"' ) + *p = '\\'; + *p++ = *text++; + } + *p++ = '"'; + *p++ = ')'; + *p++ = '\n'; + *p = 0; + + if (shutup) _festival_write ("(audio_mode'shutup)\n", fd); + if (voice && (strncmp (voice, (char *) (voice_spec+1), strlen(voice)))) + { + snprintf (voice_spec, 32, "(%s)\n", voice); + _festival_write (voice_spec, fd); + _festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)\n", fd); + _festival_write ("(Parameter.set 'Duration_Stretch 0.75)\n", fd); + } + + _festival_write (quoted, fd); + + g_free(quoted); +} + +static void +_festival_write (const gchar *command_string, int fd) +{ + fprintf(stderr, command_string); + if (fd < 0) { + perror("socket"); + return; + } + write(fd, command_string, strlen(command_string)); +} + diff --git a/tests/cspi/test-simple.c b/tests/cspi/test-simple.c new file mode 100644 index 0000000..62bcb31 --- /dev/null +++ b/tests/cspi/test-simple.c @@ -0,0 +1,816 @@ +/* + * test-simple.c: A set of simple regression tests + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * ******** Do not copy this code as an example ********* + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "dbus/dbus.h" + +/* Known bugs */ +#define WHOLE_STRING -1 + +static void validate_accessible (Accessible *accessible, + gboolean has_parent, + gboolean recurse_down); + +#define WINDOW_MAGIC 0x123456a +#define TEST_STRING_A "A test string" +#define TEST_STRING_A_OBJECT "A_test_string_object" +#define TEST_STRING_B "Another test string" + +static int print_tree_depth = 0; +static gboolean print_tree = FALSE; +static gboolean do_poke = FALSE; +static gboolean key_press_received = FALSE; +static gboolean key_release_received = FALSE; + +typedef struct { + gulong magic; + GtkWidget *window; +} TestWindow; + +static gboolean +focus_me (GtkWidget *widget) +{ + AtkObject *aobject = atk_implementor_ref_accessible ( + ATK_IMPLEMENTOR (widget)); + + /* Force a focus event - even if the WM focused + * us before our at-bridge's idle handler registered + * our interest */ + if (!GTK_WIDGET_HAS_FOCUS (widget)) + gtk_widget_grab_focus (widget); +/* else: FIXME - gtk_widget_grab_focus should send a notify */ + atk_focus_tracker_notify (aobject); + + g_object_unref (G_OBJECT (aobject)); + + return FALSE; +} + +static void +test_window_add_and_show (GtkContainer *container, GtkWidget *widget) +{ + gtk_container_add (container, widget); + gtk_widget_show (widget); +} + +static GtkWidget * +create_tree (void) +{ + GtkWidget *widget; + GtkTreeIter iter; + GtkListStore *store; + GtkTreeViewColumn *column; + + store = gtk_list_store_new (1, G_TYPE_STRING); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, TEST_STRING_A, -1); + column = gtk_tree_view_column_new_with_attributes ("String", + gtk_cell_renderer_text_new (), "text", 0, NULL); + widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); + g_object_unref (G_OBJECT (store)); + gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); + + return widget; +} + +static TestWindow * +create_test_window (void) +{ + TestWindow *win = g_new0 (TestWindow, 1); + GtkWidget *widget, *vbox; + AtkObject *obj; + + win->magic = WINDOW_MAGIC; + win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + gtk_widget_show (win->window); + + vbox = gtk_vbox_new (0, 0); + gtk_container_add (GTK_CONTAINER (win->window), vbox); + gtk_widget_show (vbox); + + widget = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (widget), TEST_STRING_A); + obj = gtk_widget_get_accessible (widget); + atk_object_set_name (obj, TEST_STRING_A_OBJECT); + + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + widget = gtk_button_new_with_label ("_Foobar"); + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + widget = gtk_hseparator_new (); + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + widget = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, + GTK_ICON_SIZE_LARGE_TOOLBAR); + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + widget = g_object_new (GTK_TYPE_HSCALE, NULL); + gtk_range_set_range (GTK_RANGE (widget), 0.0, 100.0); + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + widget = create_tree (); + test_window_add_and_show (GTK_CONTAINER (vbox), widget); + + g_idle_add ((GSourceFunc) focus_me, win->window); + + return win; +} + +static void +test_window_destroy (TestWindow *win) +{ + gtk_widget_destroy (win->window); + g_free (win); +} + +static void +test_roles (void) +{ + int i; + + fprintf (stderr, "Testing roles...\n"); + for (i = -1; i < 1000; i++) + g_assert (AccessibleRole_getName (i) != NULL); + + g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_FILE_CHOOSER), "file-chooser")); + g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_RADIO_BUTTON), "radio-button")); + g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_TABLE), "table")); + g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_WINDOW), "window")); +} + +static void +test_action (AccessibleAction *action) +{ + gint n_actions, i; + gchar *s, *sd; + g_assert ((n_actions = AccessibleAction_getNActions (action)) >= 0); + + fprintf (stderr, "Testing actions..."); + for (i = 0; i < n_actions; ++i) + { + s = AccessibleAction_getName (action, i); + g_assert (s); + sd = AccessibleAction_getDescription (action, i); + g_assert (sd); + fprintf (stderr, "%d: %s (%s); ", i, s, sd); + SPI_freeString (s); + SPI_freeString (sd); + g_assert (AccessibleAction_doAction (action, i)); + } + fprintf (stderr, "\n"); +} + +static void +test_desktop (void) +{ + Accessible *desktop; + Accessible *application; + Accessible **list; + + fprintf (stderr, "Testing desktop...\n"); + + g_assert (SPI_getDesktop (-1) == NULL); + desktop = SPI_getDesktop (0); + g_assert (desktop != NULL); + + g_assert ((SPI_getDesktopList (&list)) > 0); + g_assert (list[0] == desktop); + SPI_freeDesktopList (list); + + validate_accessible (desktop, FALSE, FALSE); + + application = Accessible_getChildAtIndex (desktop, 0); + g_assert (application != NULL); + AccessibleApplication_unref (application); + + Accessible_unref (desktop); +} + +static void +test_application (Accessible *application) +{ + char *str; + + fprintf (stderr, "Testing application ...\n"); + g_assert (Accessible_isApplication (application)); + g_assert (Accessible_getApplication (application) == + application); + AccessibleApplication_unref (application); + + str = AccessibleApplication_getToolkitName (application); + g_assert (str != NULL); + g_assert (!strcmp (str, "GAIL")); + SPI_freeString (str); + + str = AccessibleApplication_getLocale (application, LC_MESSAGES); + g_assert (!strcmp (str, setlocale (LC_MESSAGES, NULL))); + SPI_freeString (str); + + str = AccessibleApplication_getVersion (application); + g_assert (str != NULL); + SPI_freeString (str); + + AccessibleApplication_getID (application); +} + +static void +test_editable_text (AccessibleEditableText *etext) +{ + char *str; + AccessibleText *text; + + fprintf (stderr, "Testing editable text ...\n"); + + g_assert (Accessible_isText (etext)); + text = Accessible_getText (etext); + + AccessibleEditableText_setTextContents ( + etext, TEST_STRING_B); + + str = AccessibleText_getText (text, 0, WHOLE_STRING); + g_assert (!strcmp (str, TEST_STRING_B)); + + SPI_freeString (str); + + /* FIXME: lots more editing here */ + + AccessibleEditableText_setTextContents ( + etext, TEST_STRING_A); + + AccessibleText_unref (text); +} + +static void +test_table (AccessibleTable *table) +{ + Accessible *header; + gint index; + gint rows, columns; + + fprintf (stderr, "Testing table ...\n"); + + rows = AccessibleTable_getNRows (table); + g_assert (rows > 0); + + columns = AccessibleTable_getNColumns (table); + g_assert (columns > 0); + + index = AccessibleTable_getIndexAt (table, rows - 1, columns - 1); + + g_assert (AccessibleTable_getRowAtIndex (table, index) == rows - 1); + + g_assert (AccessibleTable_getColumnAtIndex (table, index) == columns - 1); + + g_assert ((header = AccessibleTable_getColumnHeader (table, 0))); + Accessible_unref (header); + + AccessibleTable_isSelected (table, 0, 0); + + /* FIXME: lots more tests */ +} + +static void +test_text (AccessibleText *text) +{ + char *str; + + fprintf (stderr, "Testing text ...\n"); + + g_assert (AccessibleText_getCharacterCount (text) == + strlen (TEST_STRING_A)); + + str = AccessibleText_getText (text, 0, WHOLE_STRING); + g_assert (!strcmp (str, TEST_STRING_A)); + SPI_freeString (str); + + str = AccessibleText_getText (text, 0, 5); + g_assert (!strncmp (str, TEST_STRING_A, 5)); + SPI_freeString (str); + + AccessibleText_setCaretOffset (text, 7); + g_assert (AccessibleText_getCaretOffset (text) == 7); + + /* FIXME: lots more tests - selections etc. etc. */ +} + +static void +test_value (AccessibleValue *value) +{ + float original_value; + + fprintf (stderr, "Testing value ...\n"); + + original_value = AccessibleValue_getCurrentValue (value); + + g_assert (AccessibleValue_getCurrentValue (value) <= + AccessibleValue_getMaximumValue (value)); + + g_assert (AccessibleValue_getCurrentValue (value) >= + AccessibleValue_getMinimumValue (value)); + + AccessibleValue_setCurrentValue (value, + AccessibleValue_getMinimumValue (value)); + + g_assert (AccessibleValue_getCurrentValue (value) == + AccessibleValue_getMinimumValue (value)); + + AccessibleValue_setCurrentValue (value, + AccessibleValue_getMaximumValue (value)); + + g_assert (AccessibleValue_getCurrentValue (value) == + AccessibleValue_getMaximumValue (value)); + + AccessibleValue_setCurrentValue (value, original_value); + + g_assert (AccessibleValue_getCurrentValue (value) == original_value); +} + +static void +test_component (AccessibleComponent *component) +{ + long x, y, width, height; + + fprintf (stderr, "Testing component...\n"); + + AccessibleComponent_getExtents ( + component, &x, &y, &width, &height, SPI_COORD_TYPE_SCREEN); + + AccessibleComponent_getPosition ( + component, &x, &y, SPI_COORD_TYPE_SCREEN); + + AccessibleComponent_getSize (component, &width, &height); + + if (width > 0 && height > 0) { +#ifdef FIXME + Accessible *accessible, *componentb; +#endif + + g_assert (AccessibleComponent_contains ( + component, x, y, SPI_COORD_TYPE_SCREEN)); + + g_assert (AccessibleComponent_contains ( + component, x + width - 1, y, SPI_COORD_TYPE_SCREEN)); + + g_assert (AccessibleComponent_contains ( + component, x + width - 1, y + height - 1, + SPI_COORD_TYPE_SCREEN)); + +#ifdef FIXME + accessible = AccessibleComponent_getAccessibleAtPoint ( + component, x, y, SPI_COORD_TYPE_SCREEN); + + g_assert (Accessible_isComponent (accessible)); + componentb = Accessible_getComponent (accessible); + g_assert (componentb == component); + + AccessibleComponent_unref (componentb); + Accessible_unref (accessible); +#endif + } + + AccessibleComponent_getLayer (component); + AccessibleComponent_getMDIZOrder (component); +/* AccessibleComponent_grabFocus (component); */ +} + +static void +test_image (AccessibleImage *image) +{ + char *desc; + long int x = -1, y = -1, width = -1, height = -1; + + desc = AccessibleImage_getImageDescription (image); + g_assert (desc != NULL); + SPI_freeString (desc); + + AccessibleImage_getImagePosition (image, &x, &y, + SPI_COORD_TYPE_SCREEN); + AccessibleImage_getImageSize (image, &width, &height); + AccessibleImage_getImageExtents (image, &x, &y, &width, &height, + SPI_COORD_TYPE_WINDOW); +} + +static void +validate_tree (Accessible *accessible, + gboolean has_parent, + gboolean recurse_down) +{ + Accessible *parent; + long len, i; + + parent = Accessible_getParent (accessible); + if (has_parent) { + long index; + Accessible *child_at_index; + + g_assert (parent != NULL); + + index = Accessible_getIndexInParent (accessible); + g_assert (index >= 0); + + child_at_index = Accessible_getChildAtIndex (parent, index); + + g_assert (child_at_index == accessible); + + Accessible_unref (child_at_index); + Accessible_unref (parent); + } + + len = Accessible_getChildCount (accessible); + print_tree_depth++; + for (i = 0; i < len; i++) { + Accessible *child; + + child = Accessible_getChildAtIndex (accessible, i); +#ifdef ROPEY + if (!child) + fprintf (stderr, "Unusual - ChildGone at %ld\n", i); + + g_assert (Accessible_getIndexInParent (child) == i); + g_assert (Accessible_getParent (child) == accessible); +#endif + + if (recurse_down && child) + validate_accessible (child, has_parent, recurse_down); + + Accessible_unref (child); + } + print_tree_depth--; +} + +static void +validate_accessible (Accessible *accessible, + gboolean has_parent, + gboolean recurse_down) +{ + Accessible *tmp; + char *name, *descr; + AccessibleRole role; + AccessibleRelation **relations; + char *role_name; + GString *item_str = g_string_new (""); + int i; + + name = Accessible_getName (accessible); + g_assert (name != NULL); + + descr = Accessible_getDescription (accessible); + g_assert (descr != NULL); + + role = Accessible_getRole (accessible); + g_assert (role != SPI_ROLE_INVALID); + role_name = Accessible_getRoleName (accessible); + g_assert (role_name != NULL); + + relations = Accessible_getRelationSet (accessible); + g_assert (relations != NULL); + + for (i = 0; relations [i]; i++) { + AccessibleRelationType type; + int targets; + + fprintf (stderr, "relation %d\n", i); + + type = AccessibleRelation_getRelationType (relations [i]); + g_assert (type != SPI_RELATION_NULL); + + targets = AccessibleRelation_getNTargets (relations [i]); + g_assert (targets != -1); + + AccessibleRelation_unref (relations [i]); + relations [i] = NULL; + } + free (relations); + + if (print_tree) { + int i; + + for (i = 0; i < print_tree_depth; i++) + fputc (' ', stderr); + fputs ("|-> [ ", stderr); + } + + if (Accessible_isAction (accessible)) { + tmp = Accessible_getAction (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "At"); + else + test_action (tmp); + AccessibleAction_unref (tmp); + } + + if (Accessible_isApplication (accessible)) { + tmp = Accessible_getApplication (accessible); + if (print_tree) + fprintf (stderr, "Ap"); + else + test_application (tmp); + AccessibleApplication_unref (tmp); + } + + if (Accessible_isComponent (accessible)) { + tmp = Accessible_getComponent (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Co"); + else + test_component (tmp); + AccessibleComponent_unref (tmp); + } + + if (Accessible_isEditableText (accessible)) { + tmp = Accessible_getEditableText (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Et"); + else + test_editable_text (tmp); + AccessibleEditableText_unref (tmp); + } + + if (Accessible_isHypertext (accessible)) { + tmp = Accessible_getHypertext (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Ht"); + AccessibleHypertext_unref (tmp); + } + + if (Accessible_isImage (accessible)) { + tmp = Accessible_getImage (accessible); + g_assert (tmp != NULL); + if (print_tree) { + char *desc; + + fprintf (stderr, "Im"); + + desc = AccessibleImage_getImageDescription (tmp); + g_string_append_printf ( + item_str, " image descr: '%s'", desc); + SPI_freeString (desc); + } else + test_image (tmp); + + AccessibleImage_unref (tmp); + } + + if (Accessible_isSelection (accessible)) { + tmp = Accessible_getSelection (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Se"); + AccessibleSelection_unref (tmp); + } + + if (Accessible_isTable (accessible)) { + tmp = Accessible_getTable (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Ta"); + else + test_table (tmp); + AccessibleTable_unref (tmp); + } + + if (Accessible_isText (accessible)) { + tmp = Accessible_getText (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Te"); + else { + if (strcmp (name, TEST_STRING_A_OBJECT) == 0) + test_text (tmp); + } + AccessibleText_unref (tmp); + } + + if (Accessible_isValue (accessible)) { + tmp = Accessible_getValue (accessible); + g_assert (tmp != NULL); + if (print_tree) + fprintf (stderr, "Va"); + else + test_value (tmp); + AccessibleValue_unref (tmp); + } + + if (print_tree) + fprintf (stderr, " ] '%s' (%s) - %s: %s\n", + name, descr, role_name, item_str->str); + + SPI_freeString (name); + SPI_freeString (descr); + SPI_freeString (role_name); + g_string_free (item_str, TRUE); + + validate_tree (accessible, has_parent, recurse_down); +} + +static void +test_misc (void) +{ + fprintf (stderr, "Testing misc bits ...\n"); + + g_assert (!Accessible_isComponent (NULL)); + g_assert (Accessible_getComponent (NULL) == NULL); + SPI_freeString (NULL); +} + +static void +global_listener_cb (const AccessibleEvent *event, + void *user_data) +{ + TestWindow *win = user_data; + Accessible *desktop; + AccessibleApplication *application; + + g_assert (win->magic == WINDOW_MAGIC); + g_assert (!strcmp (event->type, "focus:")); + + fprintf (stderr, "Fielded focus event ...\n"); + + if (!do_poke) { + desktop = SPI_getDesktop (0); + application = Accessible_getChildAtIndex (desktop, 0); + g_assert (application != NULL); + Accessible_unref (desktop); + + test_application (application); + + AccessibleApplication_unref (application); + + print_tree = FALSE; + + validate_accessible (event->source, TRUE, TRUE); + + fprintf (stderr, "quitting mainloop.\n"); + gtk_main_quit (); + } + + print_tree = TRUE; + validate_accessible (event->source, TRUE, TRUE); +} + +static SPIBoolean +key_listener_cb (const AccessibleKeystroke *stroke, + void *user_data) +{ + AccessibleKeystroke *s = user_data; + + *s = *stroke; + if (stroke->keystring) s->keystring = g_strdup (stroke->keystring); + + if (s->type == SPI_KEY_PRESSED) + key_press_received = TRUE; + else if (s->type == SPI_KEY_RELEASED) + key_release_received = TRUE; + + return TRUE; +} + + +static void +test_keylisteners (void) +{ + int i; + AccessibleKeystroke stroke; + AccessibleKeystrokeListener *key_listener; + AccessibleKeySet *test_keyset; + + fprintf (stderr, "Testing keyboard listeners ...\n"); + + key_listener = SPI_createAccessibleKeystrokeListener ( + key_listener_cb, &stroke); + + test_keyset = SPI_createAccessibleKeySet (1, "=", NULL, NULL); + + g_assert (SPI_registerAccessibleKeystrokeListener ( + key_listener, + test_keyset, + 0, + SPI_KEY_PRESSED | SPI_KEY_RELEASED, + SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS)); + + for (i = 0; i < 3; i++) { + memset (&stroke, 0, sizeof (AccessibleKeystroke)); + g_assert (SPI_generateKeyboardEvent ('=', NULL, SPI_KEY_SYM)); + while (!(key_press_received)) + g_main_context_iteration (NULL, TRUE); + fprintf (stderr, "p [%s]", stroke.keystring); + g_assert (!strcmp (stroke.keystring, "=")); + while (!(key_release_received)) + g_main_context_iteration (NULL, TRUE); + fprintf (stderr, "r [%s]", stroke.keystring); + key_press_received = FALSE; + key_release_received = FALSE; + } + g_assert (SPI_deregisterAccessibleKeystrokeListener (key_listener, 0)); + SPI_freeAccessibleKeySet (test_keyset); + + fprintf (stderr, "\n"); + + AccessibleKeystrokeListener_unref (key_listener); + + g_assert (SPI_generateMouseEvent (100, 100, "rel")); + g_assert (SPI_generateMouseEvent (-50, -50, "rel")); + g_assert (SPI_generateMouseEvent (-50, -50, "rel")); + g_assert (SPI_generateMouseEvent (-1, -1, "b1c")); +} + +int +main (int argc, char **argv) +{ + int leaked, i; + TestWindow *win; + const char *modules; + AccessibleEventListener *global_listener; + + modules = g_getenv ("GTK_MODULES"); + if (!modules || modules [0] == '\0') + putenv ("GTK_MODULES=gail:atk-bridge"); + modules = NULL; + + for (i = 1; i < argc; i++) { + if (!g_strcasecmp (argv [i], "--poke")) + do_poke = TRUE; + } + + gtk_init (&argc, &argv); + + g_assert (!SPI_init ()); + g_assert (SPI_init ()); + g_assert (SPI_getDesktopCount () == 1); + + test_roles (); + test_misc (); + test_desktop (); + test_keylisteners (); + + win = create_test_window (); + + global_listener = SPI_createAccessibleEventListener (global_listener_cb, win); + + g_assert (SPI_registerGlobalEventListener (global_listener, "focus:")); + + fprintf (stderr, "Waiting for focus event ...\n"); + gtk_main (); + + g_assert (SPI_deregisterGlobalEventListenerAll (global_listener)); + AccessibleEventListener_unref (global_listener); + + test_window_destroy (win); + + /* Wait for any pending events from the registry */ + g_usleep (500*1000); + for (i = 0; i < 100; i++) + dbus_connection_read_write_dispatch (SPI_bus(), 5); + + if ((leaked = SPI_exit ())) + g_error ("Leaked %d SPI handles", leaked); + + g_assert (!SPI_exit ()); + + fprintf (stderr, "All tests passed\n"); + + if (g_getenv ("_MEMPROF_SOCKET")) { + fprintf (stderr, "Waiting for memprof\n"); + gtk_main (); + } + + putenv ("AT_BRIDGE_SHUTDOWN=1"); + + return 0; +} diff --git a/tests/data/test-accessible.xml b/tests/data/test-accessible.xml deleted file mode 100644 index 26728dd..0000000 --- a/tests/data/test-accessible.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/data/test-action.xml b/tests/data/test-action.xml deleted file mode 100644 index 41ddf00..0000000 --- a/tests/data/test-action.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/tests/data/test-component.xml b/tests/data/test-component.xml deleted file mode 100644 index 80929b0..0000000 --- a/tests/data/test-component.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/data/test.xml b/tests/data/test.xml deleted file mode 100644 index 26728dd..0000000 --- a/tests/data/test.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/dummyatk/Makefile.am b/tests/dummyatk/Makefile.am deleted file mode 100644 index 32c9849..0000000 --- a/tests/dummyatk/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -lib_LTLIBRARIES = libdummyatk.la - -libdummyatk_la_CFLAGS = $(ATK_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(GOBJ_CFLAGS) \ - -I$(top_srcdir) - -libdummyatk_la_LDFLAGS = -no-undefined - -libdummyatk_la_LIBADD = $(ATK_LIBS) \ - $(GLIB_LIBS) \ - $(GOBJ_LIBS) - -libdummyatk_la_SOURCES = \ - my-atk-action.c \ - my-atk-action.h \ - my-atk-component.c \ - my-atk-component.h \ - my-atk-object.c \ - my-atk-object.h \ - my-atk.h diff --git a/tests/dummyatk/my-atk-action.c b/tests/dummyatk/my-atk-action.c deleted file mode 100644 index fec73d2..0000000 --- a/tests/dummyatk/my-atk-action.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "my-atk-object.h" -#include "my-atk-action.h" - -typedef struct _MyAtkActionInfo MyAtkActionInfo; - -struct _MyAtkActionInfo { - gchar *name; - gchar *description; - gchar *keybinding; - - MyAtkActionFunc do_action_func; -}; - -static void atk_action_interface_init (AtkActionIface *iface); - -G_DEFINE_TYPE_WITH_CODE (MyAtkAction, - my_atk_action, - MY_TYPE_ATK_OBJECT, - G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, - atk_action_interface_init)); - -#define MY_ATK_ACTION_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MY_TYPE_ATK_ACTION, MyAtkActionPrivate)) - -struct _MyAtkActionPrivate { - GQueue *action_queue; - guint action_idle_handler; - GList *action_list; - GList *children; -}; - -static void -my_atk_action_initialize (AtkObject *obj, gpointer data) -{ -} - -static void -my_atk_action_init (MyAtkAction *action_obj) -{ - MyAtkActionPrivate *priv = MY_ATK_ACTION_GET_PRIVATE (action_obj); - action_obj->priv = priv; - priv->action_queue = NULL; - priv->action_idle_handler = 0; - priv->action_list = NULL; - priv->children = NULL; -} - -static void -my_atk_action_finalize (GObject *object) -{ -} - -static void -my_atk_action_class_init (MyAtkActionClass *my_class) -{ - AtkObjectClass *atk_class = ATK_OBJECT_CLASS (my_class); - GObjectClass *gobject_class = G_OBJECT_CLASS (my_class); - - gobject_class->finalize = my_atk_action_finalize; - - atk_class->initialize = my_atk_action_initialize; - - g_type_class_add_private (gobject_class, sizeof (MyAtkActionPrivate)); -} - -static MyAtkActionInfo * -_my_atk_action_get_action_info (MyAtkAction *action, gint i) -{ - MyAtkActionPrivate *priv = NULL; - MyAtkActionInfo *node_data = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - - priv = action->priv; - - if (priv->action_list == NULL) - return NULL; - - node_data = g_list_nth_data (priv->action_list, i); - - g_return_val_if_fail (node_data, NULL); - - return node_data; -} - -static const gchar* -my_atk_action_description_get (AtkAction *action, gint i) -{ - MyAtkAction *my_action = NULL; - MyAtkActionInfo *info = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - my_action = MY_ATK_ACTION (action); - - info = _my_atk_action_get_action_info (my_action, i); - - if (info == NULL) - return NULL; - - return strdup (info->description); -} - -static gboolean -my_atk_action_description_set (AtkAction *action, gint i, const char *des) -{ - MyAtkAction *my_action = NULL; - MyAtkActionInfo *info = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), FALSE); - my_action = MY_ATK_ACTION (action); - - info = _my_atk_action_get_action_info (my_action, i); - - if (info == NULL) - return FALSE; - - g_free (info->description); - info->description = g_strdup (des); - - return TRUE; -} - -static const gchar* -my_atk_action_name_get (AtkAction *action, gint i) -{ - MyAtkAction *my_action = NULL; - MyAtkActionInfo *info = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - my_action = MY_ATK_ACTION (action); - - info = _my_atk_action_get_action_info (my_action, i); - - if (info == NULL) - return NULL; - - return strdup (info->name); -} - -static const gchar* -my_atk_action_localized_name_get (AtkAction *action, gint i) -{ - MyAtkAction *my_action = NULL; - MyAtkActionInfo *info = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - my_action = MY_ATK_ACTION (action); - - info = _my_atk_action_get_action_info (my_action, i); - - if (info == NULL) - return NULL; - - return strdup (info->name); -} - -static gint -my_atk_action_get_n_actions (AtkAction *action) -{ - MyAtkAction *action_obj = NULL; - MyAtkActionPrivate *priv = NULL; - - action_obj = MY_ATK_ACTION (action); - priv = action_obj->priv; - - return g_list_length (priv->action_list); -} - -static const gchar * -my_atk_action_get_keybinding (AtkAction *action, gint i) -{ - MyAtkAction *my_action = NULL; - MyAtkActionInfo *info = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - my_action = MY_ATK_ACTION (action); - - info = _my_atk_action_get_action_info (my_action, i); - - if (info == NULL) - return NULL; - - return strdup (info->keybinding); -} - -void perform_action (AtkObject *obj) -{ - AtkStateSet *state_set1 = atk_object_ref_state_set (obj); - atk_state_set_add_state (state_set1, ATK_STATE_ACTIVE); -} - -static gboolean -my_atk_action_do_action (AtkAction *action, gint i) -{ - g_return_val_if_fail (MY_IS_ATK_ACTION (action), NULL); - - MyAtkAction *my_action = NULL; - MyAtkActionPrivate *priv = NULL; - - my_action = MY_ATK_ACTION (action); - priv = my_action->priv; - - perform_action (ATK_OBJECT (action)); - - return FALSE; -} - -guint my_atk_action_add_action (MyAtkAction *action, - const gchar *action_name, - const gchar *action_description, - const gchar *action_keybinding) -{ - MyAtkActionInfo *info = NULL; - MyAtkActionPrivate *priv = NULL; - - g_return_val_if_fail (MY_IS_ATK_ACTION (action), -1); - - priv = action->priv; - - info = g_slice_new (MyAtkActionInfo); - info->name = g_strdup (action_name); - info->description = g_strdup (action_description); - info->keybinding = g_strdup (action_keybinding); - - priv->action_list = g_list_append (priv->action_list, info); - - return g_list_length (priv->action_list); -} - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface); - - iface->do_action = my_atk_action_do_action; - - iface->get_n_actions = my_atk_action_get_n_actions; - iface->get_description = my_atk_action_description_get; - iface->get_keybinding = my_atk_action_get_keybinding; - iface->get_name = my_atk_action_name_get; - iface->set_description = my_atk_action_description_set; - iface->get_localized_name = my_atk_action_localized_name_get; -} diff --git a/tests/dummyatk/my-atk-action.h b/tests/dummyatk/my-atk-action.h deleted file mode 100644 index 8bdb4f8..0000000 --- a/tests/dummyatk/my-atk-action.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MY_ATK_ACTION_H -#define MY_ATK_ACTION_H - -#include -#include -#include - -#include "my-atk-object.h" - -#define MY_TYPE_ATK_ACTION (my_atk_action_get_type ()) -#define MY_ATK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_TYPE_ATK_ACTION, MyAtkAction)) -#define MY_ATK_ACTION_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), MY_TYPE_ATK_ACTION, MyAtkActionClass)) -#define MY_IS_ATK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_TYPE_ATK_ACTION)) -#define MY_IS_ATK_ACTION_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MY_TYPE_ATK_ACTION)) -#define MY_ATK_ACTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), MY_TYPE_ATK_ACTION, MyAtkActionClass)) - -typedef struct _MyAtkAction MyAtkAction; -typedef struct _MyAtkActionPrivate MyAtkActionPrivate; -typedef struct _MyAtkActionClass MyAtkActionClass; - -typedef void (* MyAtkActionFunc) (MyAtkAction *action); - -struct _MyAtkAction { - MyAtkObject parent; - MyAtkActionPrivate *priv; - gint last_performed_action;//this field is changed when action is performed - -}; - -struct _MyAtkActionClass { - MyAtkObjectClass parent; -}; - -GType my_atk_action_get_type (void); - -guint my_atk_action_add_action (MyAtkAction *action, - const gchar *action_name, - const gchar *action_description, - const gchar *action_keybinding); - -#endif /*MY_ATK_ACTION_H*/ diff --git a/tests/dummyatk/my-atk-component.c b/tests/dummyatk/my-atk-component.c deleted file mode 100644 index 53a1091..0000000 --- a/tests/dummyatk/my-atk-component.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "my-atk-object.h" -#include "my-atk-component.h" - -typedef struct _MyAtkComponentInfo MyAtkComponentInfo; - -static void atk_component_interface_init (AtkComponentIface *iface); - -G_DEFINE_TYPE_WITH_CODE (MyAtkComponent, - my_atk_component, - MY_TYPE_ATK_OBJECT, - G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, - atk_component_interface_init)); - -void -my_atk_component_set_layer (AtkComponent *component, - AtkLayer layer) -{ - g_return_if_fail (MY_IS_ATK_COMPONENT (component)); - - MyAtkComponent *self = MY_ATK_COMPONENT (component); - self->layer = layer; -} - -void -my_atk_component_set_mdi_zorder (AtkComponent *component, - gint mdi_zorder) -{ - g_return_if_fail (MY_IS_ATK_COMPONENT (component)); - - MyAtkComponent *self = MY_ATK_COMPONENT (component); - self->zorder = mdi_zorder; -} - -void -my_atk_component_set_alpha (AtkComponent *component, - gdouble alpha) -{ - - g_return_if_fail (MY_IS_ATK_COMPONENT (component)); - - MyAtkComponent *self = MY_ATK_COMPONENT (component); - self->alpha = alpha; -} - -static void -my_atk_component_get_extents (AtkComponent *component, - gint *width, - gint *height, - gint *x, - gint *y, - AtkCoordType coord_type) -{ - g_return_if_fail (MY_IS_ATK_COMPONENT (component)); - - MyAtkComponent *self = MY_ATK_COMPONENT (component); - *width = self->extent.width; - *height = self->extent.height; - *x = self->extent.x; - *y = self->extent.y; -} - -static gboolean -my_atk_component_set_extents (AtkComponent *component, - gint x, - gint y, - gint width, - gint height, - AtkCoordType coord_type) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), FALSE); - - MyAtkComponent *self = MY_ATK_COMPONENT (component); - - if (self->extent_may_change) { - self->extent.width = width; - self->extent.height = height; - self->extent.x = x; - self->extent.y = y; - return TRUE; - } - return FALSE; -} - -static gboolean -my_atk_component_contains (AtkComponent *component, - gint c_x, - gint c_y, - AtkCoordType coord_type) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), FALSE); - - gint x, y, w, h; - my_atk_component_get_extents (component, &x, &y, &w, &h, coord_type); - - if ((c_x >= x) && (c_y >= y) && (c_x < x + w) && (c_y < y + h)) - return TRUE; - else - return FALSE; -} - -static AtkObject * -my_atk_component_ref_accessible_at_point (AtkComponent *component, - gint x, - gint y, - AtkCoordType coord_type) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), NULL); - - gint count,i; - count = atk_object_get_n_accessible_children (ATK_OBJECT (component)); - - for (i = 0; i < count; i++) { - AtkObject *obj; - obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i); - - if (obj != NULL) { - if (atk_component_contains (ATK_COMPONENT (obj), x, y, coord_type)) - return obj; - else - g_object_unref (obj); - } - } - return NULL; -} - -static gboolean -my_atk_component_grab_focus (AtkComponent *component) -{ - return TRUE; -} - -static AtkLayer -my_atk_component_get_layer (AtkComponent *component) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1); - - return MY_ATK_COMPONENT (component)->layer; -} - -static gint -my_atk_component_get_mdi_zorder (AtkComponent *component) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1); - - return MY_ATK_COMPONENT (component)->zorder; -} - -static gdouble -my_atk_component_get_alpha (AtkComponent *component) -{ - g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1); - - return MY_ATK_COMPONENT (component)->alpha; -} - -static void -atk_component_interface_init (AtkComponentIface *iface) -{ - g_return_if_fail (iface); - - iface->add_focus_handler = NULL; - iface->contains = my_atk_component_contains; - iface->ref_accessible_at_point = my_atk_component_ref_accessible_at_point; - iface->get_extents = my_atk_component_get_extents; - iface->get_position = NULL; - iface->get_size = NULL; - iface->grab_focus = my_atk_component_grab_focus; - iface->remove_focus_handler = NULL; - iface->set_extents = my_atk_component_set_extents; - iface->set_position = NULL; - iface->set_size = NULL; - iface->get_layer = my_atk_component_get_layer; - iface->get_mdi_zorder = my_atk_component_get_mdi_zorder; - iface->bounds_changed = NULL; - iface->get_alpha = my_atk_component_get_alpha; -} - -static void -my_atk_component_initialize (AtkObject *obj, gpointer data) -{ -} - -static void -my_atk_component_finalize (GObject *object) -{ -} - -static void -my_atk_component_init(MyAtkComponent *obj) -{ - obj->extent.x = 0; - obj->extent.y = 0; - obj->extent.width = 0; - obj->extent.height = 0; - obj->extent_may_change = TRUE; - obj->layer = ATK_LAYER_BACKGROUND; - obj->zorder = -1; - obj->alpha = 1.0; -} - -static void -my_atk_component_class_init (MyAtkComponentClass *my_class) -{ - AtkObjectClass *atk_class = ATK_OBJECT_CLASS (my_class); - GObjectClass *gobject_class = G_OBJECT_CLASS (my_class); - - gobject_class->finalize = my_atk_component_finalize; - - atk_class->initialize = my_atk_component_initialize; -} diff --git a/tests/dummyatk/my-atk-component.h b/tests/dummyatk/my-atk-component.h deleted file mode 100644 index 229002f..0000000 --- a/tests/dummyatk/my-atk-component.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef MY_ATK_COMPONENT_H -#define MY_ATK_COMPONENT_H - -#include - -#define MY_TYPE_ATK_COMPONENT (my_atk_component_get_type ()) -#define MY_ATK_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_TYPE_ATK_COMPONENT, MyAtkComponent)) -#define MY_ATK_COMPONENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), MY_TYPE_ATK_COMPONENT, MyAtkComponentClass)) -#define MY_IS_ATK_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_TYPE_ATK_COMPONENT)) -#define MY_IS_ATK_COMPONENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MY_TYPE_ATK_COMPONENT)) -#define MY_ATK_COMPONENT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), MY_TYPE_ATK_COMPONENT, MyAtkComponentClass)) - -typedef struct _MyAtkComponent MyAtkComponent; -typedef struct _MyAtkComponentClass MyAtkComponentClass; - -typedef void (* MyAtkComponentFunc) (MyAtkComponent *component); - -struct _MyAtkComponent { - MyAtkObject parent; - AtkRectangle extent; - gboolean extent_may_change; - gboolean is_manage_descendants; - AtkLayer layer; - gint zorder; - gdouble alpha; -}; - -struct _MyAtkComponentClass { - MyAtkObjectClass parent; -}; - -GType my_atk_component_get_type (); - -void my_atk_component_set_layer (AtkComponent *component, AtkLayer layer); -void my_atk_component_set_mdi_zorder (AtkComponent *component, gint mdi_zorder); -void my_atk_component_set_alpha (AtkComponent *component, gdouble alpha); - -#endif /*MY_ATK_COMPONENT_H*/ diff --git a/tests/dummyatk/my-atk-object.c b/tests/dummyatk/my-atk-object.c deleted file mode 100644 index c0b3014..0000000 --- a/tests/dummyatk/my-atk-object.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "my-atk-object.h" - -GType my_atk_object_get_type (void); - -G_DEFINE_TYPE (MyAtkObject, - my_atk_object, - ATK_TYPE_OBJECT); - -void my_atk_object_add_child (MyAtkObject* parent, - MyAtkObject* child) -{ - g_ptr_array_add (parent->children, child); - g_object_ref_sink (child); - - atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (parent)); - - g_signal_emit_by_name (parent, "children-changed::add", - parent->children->len - 1, - child); -} - -void my_atk_object_remove_child (MyAtkObject* parent, - MyAtkObject* child) -{ - gint i; - for (i = parent->children->len - 1; i >= 0; i--) { - if (g_ptr_array_index (parent->children, i) == child) - break; - } - g_return_if_fail (i < 0); - g_ptr_array_remove_index (parent->children, i); - g_signal_emit_by_name (parent, "children-changed::remove", i, child); -} - -static void my_atk_object_set_parent(AtkObject *accessible, AtkObject *parent) -{ - MyAtkObject *self = MY_ATK_OBJECT (accessible); - AtkObject *parent_old = atk_object_get_parent (accessible); - - if (parent_old == parent) - return; - - AtkObjectClass *klass = ATK_OBJECT_CLASS (my_atk_object_parent_class); - klass->set_parent (accessible, parent); - - if (parent_old != NULL) - my_atk_object_remove_child (MY_ATK_OBJECT (parent_old), self); -} - -static gint my_atk_object_get_n_children (AtkObject *accessible) -{ - MyAtkObject *self = MY_ATK_OBJECT (accessible); - return self->children->len; -} - -static AtkObject* my_atk_object_ref_child (AtkObject *accessible, gint i) -{ - MyAtkObject *self = MY_ATK_OBJECT (accessible); - - g_return_val_if_fail (i >= 0 || i <= self->children->len, NULL); - - AtkObject* child = ATK_OBJECT (g_ptr_array_index (self->children, i)); - - return (child == NULL) ? NULL : g_object_ref (child); -} - -static gint my_atk_object_get_index_in_parent (AtkObject *accessible) -{ - AtkObject *parent = atk_object_get_parent (accessible); - if (parent == NULL) return -1; /*root object so no parent*/ - - MyAtkObject *parent_my = MY_ATK_OBJECT (parent); - - int i = parent_my->children->len; - for (; i>=0; i--) { - if (g_ptr_array_index (parent_my->children,i) == accessible) - break; - } - - g_return_val_if_fail (i>=0, -1); - - return i; -} - -static AtkRelationSet *my_atk_object_ref_relation_set (AtkObject* accessible) -{ - MyAtkObject *obj = MY_ATK_OBJECT (accessible); - if (obj->relation_set == NULL) - obj->relation_set = atk_relation_set_new (); - return g_object_ref (G_OBJECT (obj->relation_set)); -} - -static AtkStateSet *my_atk_object_ref_state_set (AtkObject *accessible) -{ - MyAtkObject *obj = MY_ATK_OBJECT (accessible); - if (obj->state_set == NULL) - obj->state_set = atk_state_set_new (); - return g_object_ref (G_OBJECT (obj->state_set)); -} - -static AtkAttributeSet *my_atk_object_get_attributes (AtkObject *accessible) -{ - AtkAttributeSet *attributes; - AtkAttribute *attr; - - attr = g_malloc (sizeof (AtkAttribute)); - attr->name = g_strdup ("atspi"); - attr->value = g_strdup ("test"); - - attributes = g_slist_append (NULL, attr); - - return attributes; -} - -static void my_atk_object_init (MyAtkObject *self) -{ - self->children = g_ptr_array_new_full (10, g_object_unref); -} - -static void my_atk_object_class_init (MyAtkObjectClass *my_class) -{ - AtkObjectClass *object_class = ATK_OBJECT_CLASS (my_class); - - object_class->set_parent = my_atk_object_set_parent; - object_class->get_n_children = my_atk_object_get_n_children; - object_class->ref_child = my_atk_object_ref_child; - object_class->get_index_in_parent = my_atk_object_get_index_in_parent; - object_class->ref_state_set = my_atk_object_ref_state_set; - object_class->get_attributes = my_atk_object_get_attributes; - object_class->ref_relation_set = my_atk_object_ref_relation_set; - -} diff --git a/tests/dummyatk/my-atk-object.h b/tests/dummyatk/my-atk-object.h deleted file mode 100644 index d4a1eec..0000000 --- a/tests/dummyatk/my-atk-object.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef MY_ATK_OBJECT_H -#define MY_ATK_OBJECT_H - -#include - -#define MY_TYPE_ATK_OBJECT (my_atk_object_get_type ()) -#define MY_ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_TYPE_ATK_OBJECT, MyAtkObject)) -#define MY_ATK_OBJECT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), MY_TYPE_ATK_OBJECT, MyAtkObjectClass)) -#define MY_IS_ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_TYPE_ATK_OBJECT)) -#define MY_IS_ATK_OBJECT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MY_TYPE_ATK_OBJECT)) -#define MY_ATK_OBJECT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), MY_TYPE_ATK_OBJECT, MyAtkObjectClass)) - -typedef struct _MyAtkObject MyAtkObject; -typedef struct _MyAtkObjectClass MyAtkObjectClass; - -struct _MyAtkObject { - AtkObject parent; - AtkStateSet *state_set; - AtkRelationSet *relation_set; - GPtrArray* children; - gint id; -}; - -struct _MyAtkObjectClass { - AtkObjectClass parent; -}; - -GType my_atk_object_get_type (); - -void my_atk_object_add_child (MyAtkObject* parent, - MyAtkObject* child); - -void my_atk_object_remove_child (MyAtkObject* parent, - MyAtkObject* child); - -#endif /*MY_ATK_OBJECT_H*/ diff --git a/tests/dummyatk/my-atk.h b/tests/dummyatk/my-atk.h deleted file mode 100644 index 91fe29d..0000000 --- a/tests/dummyatk/my-atk.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MY_ATK_H -#define MY_ATK_H - -#include "my-atk-action.h" -#include "my-atk-object.h" -#include "my-atk-component.h" - -#endif /*MY_ATK_H*/ diff --git a/tests/test-application.c b/tests/test-application.c deleted file mode 100644 index fe9527d..0000000 --- a/tests/test-application.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility) - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Testing AT-SPI requires both a test application and AT client. - * Test applications are built using the Dummy ATK implementation: MyAtk. - * This file contains the entry point for all test applications. - * The test will provide its own implementation of atk_get_root, - * and as such provide all the application state for the test. - */ - -#include -#include -#include -#include -#include -#include -#include "my-atk.h" -#include "atk-object-xml-loader.h" - -static AtkObject *root_accessible; - -static GMainLoop *mainloop; - -static gchar *tdata_path = NULL; - -void -test_init (gchar *path) -{ - gchar *td; - - if (path == NULL) { - g_print ("No test data file provided\n"); - exit (EXIT_FAILURE); - } - tdata_path = path; - - td = g_build_path (G_DIR_SEPARATOR_S, tdata_path, NULL, NULL); - root_accessible = ATK_OBJECT (atk_object_xml_parse (td)); - g_free (td); -} - -AtkObject * -test_get_root (void) -{ - return root_accessible; -} - -static AtkObject * -get_root (void) -{ - return test_get_root (); -} - -const gchar * -get_toolkit_name (void) -{ - return strdup ("atspitesting-toolkit"); -} - -static void -setup_atk_util (void) -{ - AtkUtilClass *klass; - - klass = g_type_class_ref (ATK_TYPE_UTIL); - klass->get_root = get_root; - klass->get_toolkit_name = get_toolkit_name; - g_type_class_unref (klass); -} - -static GOptionEntry optentries[] = { - {"test-data-file", 0, 0, G_OPTION_ARG_STRING, &tdata_path, "Path to file of test data", NULL}, - {NULL} -}; - -int main (int argc, char *argv[]) -{ - GOptionContext *opt; - GError *err = NULL; - opt = g_option_context_new (NULL); - g_option_context_add_main_entries (opt, optentries, NULL); - g_option_context_set_ignore_unknown_options (opt, TRUE); - - if (!g_option_context_parse (opt, &argc, &argv, &err)) - g_error("Option parsing failed: %s\n", err->message); - - setup_atk_util (); - test_init (tdata_path); - atk_bridge_adaptor_init (NULL, NULL); - - mainloop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (mainloop); - - return 0; -}