diff options
author | Patryk Kaczmarek <patryk.k@samsung.com> | 2015-03-06 10:58:16 +0100 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2015-03-06 19:52:28 -0600 |
commit | 8ecd9035032e52958834c36ec560263ad5046a5c (patch) | |
tree | 580eb7d30e8a8d7da23ef3d7647ee597f5b7aaf5 | |
parent | 2a2f521c24bd12928bea7832013c37477baaefd8 (diff) | |
download | at-spi2-atk-8ecd9035032e52958834c36ec560263ad5046a5c.tar.gz |
Component interface tests
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/README | 9 | ||||
-rw-r--r-- | tests/atk-object-xml-loader.c | 39 | ||||
-rw-r--r-- | tests/atk_suite.c | 8 | ||||
-rw-r--r-- | tests/atk_suite.h | 2 | ||||
-rw-r--r-- | tests/atk_test_component.c | 257 | ||||
-rw-r--r-- | tests/data/test-component.xml | 13 | ||||
-rw-r--r-- | tests/dummyatk/Makefile.am | 2 | ||||
-rw-r--r-- | tests/dummyatk/my-atk-action.c | 5 | ||||
-rw-r--r-- | tests/dummyatk/my-atk-component.c | 236 | ||||
-rw-r--r-- | tests/dummyatk/my-atk-component.h | 61 | ||||
-rw-r--r-- | tests/dummyatk/my-atk.h | 1 |
12 files changed, 630 insertions, 6 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index c03d3fe..6d388c9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,8 @@ atk_test_CPPFLAGS = -DTESTS_BUILD_DIR=\"$(top_builddir)/tests\" \ atk_test_SOURCES = atk_suite.c \ atk_test_accessible.c \ - atk_test_action.c + atk_test_action.c \ + atk_test_component.c app_test_CFLAGS = -I$(top_builddir) \ $(GLIB_CFLAGS) \ diff --git a/tests/README b/tests/README index b49f270..109cb18 100644 --- a/tests/README +++ b/tests/README @@ -80,3 +80,12 @@ AVAILABLE TESTS: -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 index 2174584..6f34ecd 100644 --- a/tests/atk-object-xml-loader.c +++ b/tests/atk-object-xml-loader.c @@ -30,10 +30,12 @@ #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") @@ -45,6 +47,13 @@ #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; @@ -56,6 +65,7 @@ create_atk_object_from_element (xmlNode *element) gpointer obj; gpointer child_obj; + gpointer child_obj2; AtkRelationSet *relation_set = NULL; AtkObject *array[1]; AtkRelation *relation; @@ -74,12 +84,15 @@ create_atk_object_from_element (xmlNode *element) 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; @@ -87,6 +100,9 @@ create_atk_object_from_element (xmlNode *element) 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, @@ -96,7 +112,8 @@ create_atk_object_from_element (xmlNode *element) 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_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); } @@ -130,6 +147,24 @@ create_atk_object_from_element (xmlNode *element) 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; diff --git a/tests/atk_suite.c b/tests/atk_suite.c index 0afb0ea..8b12d9a 100644 --- a/tests/atk_suite.c +++ b/tests/atk_suite.c @@ -42,6 +42,7 @@ struct _Atk_Test_Case { 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} }; @@ -62,6 +63,7 @@ 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[] = { @@ -103,6 +105,12 @@ main(int argc, char **argv) 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; diff --git a/tests/atk_suite.h b/tests/atk_suite.h index 2ac7e58..17aefcd 100644 --- a/tests/atk_suite.h +++ b/tests/atk_suite.h @@ -27,8 +27,10 @@ #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_component.c b/tests/atk_test_component.c new file mode 100644 index 0000000..8b85f5b --- /dev/null +++ b/tests/atk_test_component.c @@ -0,0 +1,257 @@ +/* + * 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/data/test-component.xml b/tests/data/test-component.xml new file mode 100644 index 0000000..80929b0 --- /dev/null +++ b/tests/data/test-component.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" ?> +<accessible description="Root of the accessible tree" name="root_object" role="accelerator label"> + <accessible_component description="second child" name="obj2" role="application"> + <component x="350" y="200" width="0" height="0" layer="2" zorder="1" alpha="1.5"/> + </accessible_component> + <accessible_component description="third child" name="obj3" role="push button"> + <component x="250" y="250" width="350" height="200" layer="3" zorder="2" alpha="2.5"/> + <accessible_component description="third child a" name="aobj3" role="push button"> + <component x="250" y="250" width="350" height="200" layer="4" zorder="3" alpha="3.5"/> + </accessible_component> + </accessible_component> + <accessible description="second child" name="obj2" role="application" /> +</accessible> diff --git a/tests/dummyatk/Makefile.am b/tests/dummyatk/Makefile.am index 631e986..32c9849 100644 --- a/tests/dummyatk/Makefile.am +++ b/tests/dummyatk/Makefile.am @@ -14,6 +14,8 @@ libdummyatk_la_LIBADD = $(ATK_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 index 3f02356..fec73d2 100644 --- a/tests/dummyatk/my-atk-action.c +++ b/tests/dummyatk/my-atk-action.c @@ -43,13 +43,12 @@ G_DEFINE_TYPE_WITH_CODE (MyAtkAction, my_atk_action, MY_TYPE_ATK_OBJECT, G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, - atk_action_interface_init)); + atk_action_interface_init)); #define MY_ATK_ACTION_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MY_TYPE_ATK_ACTION, MyAtkActionPrivate)) -struct _MyAtkActionPrivate -{ +struct _MyAtkActionPrivate { GQueue *action_queue; guint action_idle_handler; GList *action_list; diff --git a/tests/dummyatk/my-atk-component.c b/tests/dummyatk/my-atk-component.c new file mode 100644 index 0000000..53a1091 --- /dev/null +++ b/tests/dummyatk/my-atk-component.c @@ -0,0 +1,236 @@ +/* + * 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 <stdio.h> +#include <string.h> +#include <atk/atk.h> + +#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 new file mode 100644 index 0000000..229002f --- /dev/null +++ b/tests/dummyatk/my-atk-component.h @@ -0,0 +1,61 @@ +/* + * 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 <atk/atk.h> + +#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.h b/tests/dummyatk/my-atk.h index f617c9d..91fe29d 100644 --- a/tests/dummyatk/my-atk.h +++ b/tests/dummyatk/my-atk.h @@ -25,5 +25,6 @@ #include "my-atk-action.h" #include "my-atk-object.h" +#include "my-atk-component.h" #endif /*MY_ATK_H*/ |