summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2014-05-28 17:12:34 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-05-28 17:12:34 +0900
commitab9dfa4e04c094a9b0da6092fe9d549f59783cb3 (patch)
tree21d7c96345a7bf846c699a6a9d6d6d2368537e55
parent84c2351bc339eca22acb79c86acbee7a1322f8c0 (diff)
atspi: add accessible default relations and attributes
Summary: Tests added for accessibile interface Differential Revision: https://phab.enlightenment.org/D900
-rw-r--r--src/lib/elm_atspi_app_object.c29
-rw-r--r--src/lib/elm_atspi_app_object.eo4
-rw-r--r--src/lib/elm_atspi_bridge.c29
-rw-r--r--src/lib/elm_interface_atspi_accessible.c21
-rw-r--r--src/lib/elm_interface_atspi_accessible.eo16
-rw-r--r--src/lib/elm_interface_atspi_accessible.h46
-rw-r--r--src/lib/elm_interface_atspi_component.c4
-rw-r--r--src/lib/elm_interface_atspi_widget.c50
-rw-r--r--src/lib/elm_interface_atspi_widget.eo2
-rw-r--r--src/tests/Makefile.am1
-rw-r--r--src/tests/elm_suite.c1
-rw-r--r--src/tests/elm_suite.h1
-rw-r--r--src/tests/elm_test_atspi.c419
13 files changed, 607 insertions, 16 deletions
diff --git a/src/lib/elm_atspi_app_object.c b/src/lib/elm_atspi_app_object.c
index 0f9d5e718..60a448587 100644
--- a/src/lib/elm_atspi_app_object.c
+++ b/src/lib/elm_atspi_app_object.c
@@ -16,8 +16,21 @@ extern Eina_List *_elm_win_list;
16static Eo *_atspi_root; 16static Eo *_atspi_root;
17static int _init; 17static int _init;
18 18
19typedef struct _Elm_Atspi_App_Object_Data Elm_Atspi_App_Object_Data;
20
21struct _Elm_Atspi_App_Object_Data
22{
23 const char *descr;
24};
25
26EOLIAN static void
27_elm_atspi_app_object_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd)
28{
29 if (_pd->descr) eina_stringshare_del(_pd->descr);
30}
31
19EOLIAN static Eina_List* 32EOLIAN static Eina_List*
20_elm_atspi_app_object_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 33_elm_atspi_app_object_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd EINA_UNUSED)
21{ 34{
22 Eina_List *l, *accs = NULL; 35 Eina_List *l, *accs = NULL;
23 Evas_Object *win; 36 Evas_Object *win;
@@ -33,19 +46,25 @@ _elm_atspi_app_object_elm_interface_atspi_accessible_children_get(Eo *obj EINA_U
33} 46}
34 47
35EOLIAN static const char* 48EOLIAN static const char*
36_elm_atspi_app_object_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 49_elm_atspi_app_object_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd EINA_UNUSED)
37{ 50{
38 return elm_app_name_get(); 51 return elm_app_name_get();
39} 52}
40 53
41EOLIAN static const char* 54EOLIAN static const char*
42_elm_atspi_app_object_elm_interface_atspi_accessible_description_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 55_elm_atspi_app_object_elm_interface_atspi_accessible_description_get(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd)
56{
57 return _pd->descr;
58}
59
60EOLIAN static void
61_elm_atspi_app_object_elm_interface_atspi_accessible_description_set(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd EINA_UNUSED, const char *descr)
43{ 62{
44 return NULL; 63 eina_stringshare_replace(&_pd->descr, descr);
45} 64}
46 65
47EOLIAN static Elm_Atspi_Role 66EOLIAN static Elm_Atspi_Role
48_elm_atspi_app_object_elm_interface_atspi_accessible_role_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 67_elm_atspi_app_object_elm_interface_atspi_accessible_role_get(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd EINA_UNUSED)
49{ 68{
50 return ELM_ATSPI_ROLE_APPLICATION; 69 return ELM_ATSPI_ROLE_APPLICATION;
51} 70}
diff --git a/src/lib/elm_atspi_app_object.eo b/src/lib/elm_atspi_app_object.eo
index 0cdfccdb7..8a9b12270 100644
--- a/src/lib/elm_atspi_app_object.eo
+++ b/src/lib/elm_atspi_app_object.eo
@@ -1,9 +1,11 @@
1class Elm_Atspi_App_Object (Eo_Base, Elm_Interface_Atspi_Accessible) 1class Elm_Atspi_App_Object (Eo_Base, Elm_Interface_Atspi_Accessible)
2{ 2{
3 data: null; 3 data: Elm_Atspi_App_Object_Data;
4 implements { 4 implements {
5 Eo_Base::destructor;
5 Elm_Interface_Atspi_Accessible::name::get; 6 Elm_Interface_Atspi_Accessible::name::get;
6 Elm_Interface_Atspi_Accessible::description::get; 7 Elm_Interface_Atspi_Accessible::description::get;
8 Elm_Interface_Atspi_Accessible::description::set;
7 Elm_Interface_Atspi_Accessible::role::get; 9 Elm_Interface_Atspi_Accessible::role::get;
8 Elm_Interface_Atspi_Accessible::children::get; 10 Elm_Interface_Atspi_Accessible::children::get;
9 } 11 }
diff --git a/src/lib/elm_atspi_bridge.c b/src/lib/elm_atspi_bridge.c
index a488c6283..157041a9a 100644
--- a/src/lib/elm_atspi_bridge.c
+++ b/src/lib/elm_atspi_bridge.c
@@ -435,6 +435,33 @@ _accessible_get_application(const Eldbus_Service_Interface *iface EINA_UNUSED, c
435 return ret; 435 return ret;
436} 436}
437 437
438static Eldbus_Message *
439_accessible_attributes_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
440{
441 Eina_List *attrs, *l;
442 Elm_Atspi_Attribute *attr;
443 Eldbus_Message_Iter *iter, *iter_array;
444
445 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
446 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
447
448 const char *obj_path = eldbus_service_object_path_get(iface);
449 Eo *obj = _access_object_from_path(obj_path);
450
451 eo_do(obj, attrs = elm_interface_atspi_accessible_attributes_get());
452
453 iter = eldbus_message_iter_get(ret);
454 iter_array = eldbus_message_iter_container_new(iter, 'a', "ss");
455
456 EINA_LIST_FOREACH(attrs, l, attr)
457 eldbus_message_iter_arguments_get(iter_array, "ss", attr->key, attr->value);
458
459 eldbus_message_iter_container_close(iter, iter_array);
460 elm_atspi_attributes_list_free(attrs);
461
462 return ret;
463}
464
438static uint64_t 465static uint64_t
439_elm_atspi_state_set_to_atspi_state_set(Elm_Atspi_State_Set states) 466_elm_atspi_state_set_to_atspi_state_set(Elm_Atspi_State_Set states)
440{ 467{
@@ -552,7 +579,7 @@ static const Eldbus_Method accessible_methods[] = {
552 { "GetLocalizedRoleName", NULL, ELDBUS_ARGS({"s", "LocalizedName"}), _accessible_get_localized_role_name, 0}, 579 { "GetLocalizedRoleName", NULL, ELDBUS_ARGS({"s", "LocalizedName"}), _accessible_get_localized_role_name, 0},
553 { "GetState", NULL, ELDBUS_ARGS({"au", NULL}), _accessible_get_state, 0}, 580 { "GetState", NULL, ELDBUS_ARGS({"au", NULL}), _accessible_get_state, 0},
554 { "GetApplication", NULL, ELDBUS_ARGS({"(so)", NULL}), _accessible_get_application, 0}, 581 { "GetApplication", NULL, ELDBUS_ARGS({"(so)", NULL}), _accessible_get_application, 0},
555 //{ "GetAttributes", NULL, ELDBUS_ARGS({"a{ss}", NULL}), NULL, 0}, 582 { "GetAttributes", NULL, ELDBUS_ARGS({"a{ss}", NULL}), _accessible_attributes_get, 0},
556 { NULL, NULL, NULL, NULL, 0 } 583 { NULL, NULL, NULL, NULL, 0 }
557}; 584};
558 585
diff --git a/src/lib/elm_interface_atspi_accessible.c b/src/lib/elm_interface_atspi_accessible.c
index 1670b4ca5..9a5fe75e2 100644
--- a/src/lib/elm_interface_atspi_accessible.c
+++ b/src/lib/elm_interface_atspi_accessible.c
@@ -166,11 +166,12 @@ _elm_interface_atspi_accessible_parent_set(Eo *obj, void *priv EINA_UNUSED, Eo *
166 eo_class_name_get(eo_class_get(obj))); 166 eo_class_name_get(eo_class_get(obj)));
167} 167}
168 168
169EOLIAN void 169EOLIAN Eina_List*
170_elm_interface_atspi_accessible_attributes_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED) 170_elm_interface_atspi_accessible_attributes_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
171{ 171{
172 WRN("The %s object does not implement the \"accessible_attributes_set\" function.", 172 WRN("The %s object does not implement the \"accessible_attributes_set\" function.",
173 eo_class_name_get(eo_class_get(obj))); 173 eo_class_name_get(eo_class_get(obj)));
174 return NULL;
174} 175}
175 176
176EOLIAN static Elm_Atspi_Role 177EOLIAN static Elm_Atspi_Role
@@ -264,4 +265,22 @@ _elm_interface_atspi_accessible_state_set_get(Eo *obj EINA_UNUSED, void *pd EINA
264 return ret; 265 return ret;
265} 266}
266 267
268EOLIAN Eina_List*
269_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
270{
271 WRN("The %s object does not implement the \"accessible_relation_set\" function.",
272 eo_class_name_get(eo_class_get(obj)));
273 return NULL;
274}
275
276void elm_atspi_attributes_list_free(Eina_List *list)
277{
278 Elm_Atspi_Attribute *attr;
279 EINA_LIST_FREE(list, attr)
280 {
281 eina_stringshare_del(attr->key);
282 eina_stringshare_del(attr->value);
283 }
284}
285
267#include "elm_interface_atspi_accessible.eo.c" 286#include "elm_interface_atspi_accessible.eo.c"
diff --git a/src/lib/elm_interface_atspi_accessible.eo b/src/lib/elm_interface_atspi_accessible.eo
index 2b0f0340d..6f9b2e197 100644
--- a/src/lib/elm_interface_atspi_accessible.eo
+++ b/src/lib/elm_interface_atspi_accessible.eo
@@ -24,7 +24,11 @@ mixin Elm_Interface_Atspi_Accessible ()
24 } 24 }
25 protected relation_set { 25 protected relation_set {
26 get { 26 get {
27 /*@ Gets an string describing ATSPI widget role name. */ 27 /*@ Gets an string describing ATSPI widget role name. Lists and
28 * elements Should be free by a user. */
29 }
30 values {
31 Eina_List *relations;
28 } 32 }
29 } 33 }
30 protected role { 34 protected role {
@@ -56,8 +60,11 @@ mixin Elm_Interface_Atspi_Accessible ()
56 } 60 }
57 protected attributes { 61 protected attributes {
58 get { 62 get {
59 /*@ Gets human-readable string indentifying widget accessibility 63 /*@ Gets key-value pairs indentifying widget extra
60 * role. */ 64 * attributes. Must be free by a user. */
65 }
66 values {
67 Eina_List *attributes;
61 } 68 }
62 } 69 }
63 protected index_in_parent { 70 protected index_in_parent {
@@ -99,9 +106,6 @@ mixin Elm_Interface_Atspi_Accessible ()
99 } 106 }
100 } 107 }
101 } 108 }
102 implements {
103 virtual::relation_set::get;
104 }
105 events { 109 events {
106 property,changed (const char *); 110 property,changed (const char *);
107 children,changed (Elm_Atspi_Event_Children_Changed_Data); 111 children,changed (Elm_Atspi_Event_Children_Changed_Data);
diff --git a/src/lib/elm_interface_atspi_accessible.h b/src/lib/elm_interface_atspi_accessible.h
index e0c01ff2c..88c38560f 100644
--- a/src/lib/elm_interface_atspi_accessible.h
+++ b/src/lib/elm_interface_atspi_accessible.h
@@ -186,6 +186,31 @@ enum _Elm_Atspi_State_Type
186 ELM_ATSPI_STATE_LAST_DEFINED, 186 ELM_ATSPI_STATE_LAST_DEFINED,
187}; 187};
188 188
189typedef enum _Elm_Atspi_Relation_Type Elm_Atspi_Relation_Type;
190
191enum _Elm_Atspi_Relation_Type {
192 ELM_ATSPI_RELATION_NULL,
193 ELM_ATSPI_RELATION_LABEL_FOR,
194 ELM_ATSPI_RELATION_LABELLED_BY,
195 ELM_ATSPI_RELATION_CONTROLLER_FOR,
196 ELM_ATSPI_RELATION_CONTROLLED_BY,
197 ELM_ATSPI_RELATION_MEMBER_OF,
198 ELM_ATSPI_RELATION_TOOLTIP_FOR,
199 ELM_ATSPI_RELATION_NODE_CHILD_OF,
200 ELM_ATSPI_RELATION_NODE_PARENT_OF,
201 ELM_ATSPI_RELATION_EXTENDED,
202 ELM_ATSPI_RELATION_FLOWS_TO,
203 ELM_ATSPI_RELATION_FLOWS_FROM,
204 ELM_ATSPI_RELATION_SUBWINDOW_OF,
205 ELM_ATSPI_RELATION_EMBEDS,
206 ELM_ATSPI_RELATION_EMBEDDED_BY,
207 ELM_ATSPI_RELATION_POPUP_FOR,
208 ELM_ATSPI_RELATION_PARENT_WINDOW_OF,
209 ELM_ATSPI_RELATION_DESCRIPTION_FOR,
210 ELM_ATSPI_RELATION_DESCRIBED_BY,
211 ELM_ATSPI_RELATION_LAST_DEFINED,
212};
213
189 214
190typedef struct _Elm_Atspi_Event_State_Changed_Data Elm_Atspi_Event_State_Changed_Data; 215typedef struct _Elm_Atspi_Event_State_Changed_Data Elm_Atspi_Event_State_Changed_Data;
191 216
@@ -203,6 +228,27 @@ struct _Elm_Atspi_Event_Children_Changed_Data
203 Eo *child; 228 Eo *child;
204}; 229};
205 230
231typedef struct _Elm_Atspi_Attribute Elm_Atspi_Attribute;
232
233struct _Elm_Atspi_Attribute
234{
235 const char *key;
236 const char *value;
237};
238
239typedef struct _Elm_Atspi_Relation Elm_Atspi_Relation;
240
241struct _Elm_Atspi_Relation
242{
243 Elm_Atspi_Relation_Type type;
244 const Eo *obj;
245};
246
247/**
248 * Free Elm_Atspi_Attributes_List
249 */
250void elm_atspi_attributes_list_free(Eina_List *list);
251
206/** 252/**
207 * Emits ATSPI 'StateChanged' dbus signal. 253 * Emits ATSPI 'StateChanged' dbus signal.
208 */ 254 */
diff --git a/src/lib/elm_interface_atspi_component.c b/src/lib/elm_interface_atspi_component.c
index 6783ede5d..8817e012d 100644
--- a/src/lib/elm_interface_atspi_component.c
+++ b/src/lib/elm_interface_atspi_component.c
@@ -34,11 +34,11 @@ _elm_interface_atspi_component_position_set(Eo *obj EINA_UNUSED, void *_pd EINA_
34EOLIAN static Eina_Bool 34EOLIAN static Eina_Bool
35_elm_interface_atspi_component_size_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, int w, int h) 35_elm_interface_atspi_component_size_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, int w, int h)
36{ 36{
37 Eina_Bool ret = EINA_FALSE; 37 Eina_Bool ret;
38 int c_x = 0, c_y = 0; 38 int c_x = 0, c_y = 0;
39 39
40 eo_do(obj, elm_interface_atspi_component_extents_get(EINA_FALSE, &c_x, &c_y, NULL, NULL)); 40 eo_do(obj, elm_interface_atspi_component_extents_get(EINA_FALSE, &c_x, &c_y, NULL, NULL));
41 eo_do(obj, elm_interface_atspi_component_extents_set(EINA_FALSE, c_x, c_y, w, h)); 41 eo_do(obj, ret = elm_interface_atspi_component_extents_set(EINA_FALSE, c_x, c_y, w, h));
42 return ret; 42 return ret;
43} 43}
44 44
diff --git a/src/lib/elm_interface_atspi_widget.c b/src/lib/elm_interface_atspi_widget.c
index 5f2c3eef7..a8a814383 100644
--- a/src/lib/elm_interface_atspi_widget.c
+++ b/src/lib/elm_interface_atspi_widget.c
@@ -155,4 +155,54 @@ _elm_interface_atspi_widget_elm_interface_atspi_accessible_state_set_get(Eo *obj
155 return states; 155 return states;
156} 156}
157 157
158EOLIAN static Eina_List*
159_elm_interface_atspi_widget_elm_interface_atspi_accessible_attributes_get(Eo *obj, Elm_Interface_Atspi_Widget_Data *pd EINA_UNUSED)
160{
161 Eina_List *ret = NULL;
162 Elm_Atspi_Attribute *attr = calloc(1, sizeof(Elm_Atspi_Attribute));
163 if (!attr) return NULL;
164
165 attr->key = eina_stringshare_add("type");
166 attr->value = eina_stringshare_add(evas_object_type_get(obj));
167
168 ret = eina_list_append(ret, attr);
169 return ret;
170}
171
172static Elm_Atspi_Relation*
173_relation_new(Elm_Atspi_Relation_Type type, Eo *obj)
174{
175 Elm_Atspi_Relation *rel = calloc(1, sizeof(Elm_Atspi_Relation));
176 if (!rel) return NULL;
177
178 rel->type = type;
179 rel->obj = obj;
180
181 return rel;
182}
183
184EOLIAN static Eina_List*
185_elm_interface_atspi_widget_elm_interface_atspi_accessible_relation_set_get(Eo *obj, Elm_Interface_Atspi_Widget_Data *pd EINA_UNUSED)
186{
187 Eina_List *list = NULL;
188 Elm_Atspi_Relation *rel;
189 Evas_Object *rel_obj;
190
191 rel_obj = elm_object_focus_next_object_get(obj, ELM_FOCUS_NEXT);
192 if (eo_isa(rel_obj, ELM_INTERFACE_ATSPI_ACCESSIBLE_CLASS))
193 {
194 rel = _relation_new(ELM_ATSPI_RELATION_FLOWS_TO, rel_obj);
195 list = eina_list_append(list, rel);
196 }
197
198 rel_obj = elm_object_focus_next_object_get(obj, ELM_FOCUS_PREVIOUS);
199 if (eo_isa(rel_obj, ELM_INTERFACE_ATSPI_ACCESSIBLE_CLASS))
200 {
201 rel = _relation_new(ELM_ATSPI_RELATION_FLOWS_FROM, rel_obj);
202 list = eina_list_append(list, rel);
203 }
204
205 return list;
206}
207
158#include "elm_interface_atspi_widget.eo.c" 208#include "elm_interface_atspi_widget.eo.c"
diff --git a/src/lib/elm_interface_atspi_widget.eo b/src/lib/elm_interface_atspi_widget.eo
index d5b0e6c67..2d2294a18 100644
--- a/src/lib/elm_interface_atspi_widget.eo
+++ b/src/lib/elm_interface_atspi_widget.eo
@@ -12,6 +12,8 @@ mixin Elm_Interface_Atspi_Widget (Elm_Interface_Atspi_Accessible, Elm_Interface_
12 Elm_Interface_Atspi_Accessible::role::set; 12 Elm_Interface_Atspi_Accessible::role::set;
13 Elm_Interface_Atspi_Accessible::state_set::get; 13 Elm_Interface_Atspi_Accessible::state_set::get;
14 Elm_Interface_Atspi_Accessible::children::get; 14 Elm_Interface_Atspi_Accessible::children::get;
15 Elm_Interface_Atspi_Accessible::attributes::get;
16 Elm_Interface_Atspi_Accessible::relation_set::get;
15 Elm_Interface_Atspi_Component::focus_grab; 17 Elm_Interface_Atspi_Component::focus_grab;
16 } 18 }
17} 19}
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 200ada7fa..4fbbd68da 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -6,6 +6,7 @@ TESTS = elm_suite
6check_PROGRAMS = elm_suite 6check_PROGRAMS = elm_suite
7elm_suite_SOURCES = \ 7elm_suite_SOURCES = \
8 elm_suite.c \ 8 elm_suite.c \
9 elm_test_atspi.c \
9 elm_test_check.c \ 10 elm_test_check.c \
10 elm_test_colorselector.c \ 11 elm_test_colorselector.c \
11 elm_test_entry.c \ 12 elm_test_entry.c \
diff --git a/src/tests/elm_suite.c b/src/tests/elm_suite.c
index f5868335b..6072ebbd6 100644
--- a/src/tests/elm_suite.c
+++ b/src/tests/elm_suite.c
@@ -18,6 +18,7 @@ static const Elementary_Test_Case etc[] = {
18 { "elm_check", elm_test_check }, 18 { "elm_check", elm_test_check },
19 { "elm_colorselector", elm_test_colorselector }, 19 { "elm_colorselector", elm_test_colorselector },
20 { "elm_entry", elm_test_entry}, 20 { "elm_entry", elm_test_entry},
21 { "elm_atspi", elm_test_atspi},
21 { NULL, NULL } 22 { NULL, NULL }
22}; 23};
23 24
diff --git a/src/tests/elm_suite.h b/src/tests/elm_suite.h
index bac0a5692..30c3a929b 100644
--- a/src/tests/elm_suite.h
+++ b/src/tests/elm_suite.h
@@ -7,5 +7,6 @@ void elm_test_init(TCase *tc);
7void elm_test_check(TCase *tc); 7void elm_test_check(TCase *tc);
8void elm_test_colorselector(TCase *tc); 8void elm_test_colorselector(TCase *tc);
9void elm_test_entry(TCase *tc); 9void elm_test_entry(TCase *tc);
10void elm_test_atspi(TCase *tc);
10 11
11#endif /* _ELM_SUITE_H */ 12#endif /* _ELM_SUITE_H */
diff --git a/src/tests/elm_test_atspi.c b/src/tests/elm_test_atspi.c
new file mode 100644
index 000000000..7ff6712bc
--- /dev/null
+++ b/src/tests/elm_test_atspi.c
@@ -0,0 +1,419 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_INTERNAL_API_ARGESFSDFEFC
6
7#include <Elementary.h>
8#include "elm_priv.h"
9#include "elm_suite.h"
10
11#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
12#include "elm_interface_atspi_accessible.h"
13#include "elm_interface_atspi_accessible.eo.h"
14
15#define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
16#include "elm_interface_atspi_component.eo.h"
17
18static Evas_Object *g_win, *g_btn, *g_bg;
19
20Eo* generate_app(void)
21{
22 g_win = elm_win_add(NULL, "Title", ELM_WIN_BASIC);
23 evas_object_geometry_set(g_win, 100, 100, 100, 100);
24
25 g_bg = elm_bg_add(g_win);
26
27 g_btn = elm_button_add(g_win);
28
29 evas_object_show(g_btn);
30 evas_object_show(g_bg);
31 evas_object_show(g_win);
32
33 Eo *obj = NULL;
34
35 _elm_atspi_init();
36
37 obj = _elm_atspi_root_get();
38
39 return obj;
40}
41
42START_TEST (elm_atspi_root_get)
43{
44 elm_init(0, NULL);
45
46 Eo* obj = generate_app();
47
48 ck_assert(obj != NULL);
49
50 elm_shutdown();
51}
52END_TEST
53
54START_TEST (elm_atspi_name_get)
55{
56 elm_init(0, NULL);
57
58 Eo* obj = generate_app();
59
60 const char *ret = NULL;
61
62 elm_app_name_set("Test name");
63
64 eo_do(obj, ret = elm_interface_atspi_accessible_name_get());
65
66 ck_assert_str_eq(ret, "Test name");
67
68 elm_shutdown();
69}
70END_TEST
71
72START_TEST (elm_atspi_role_get)
73{
74 elm_init(0, NULL);
75
76 Eo *obj = generate_app();
77
78 Elm_Atspi_Role role;
79
80 eo_do(obj, role = elm_interface_atspi_accessible_role_get());
81
82 ck_assert(role == ELM_ATSPI_ROLE_APPLICATION);
83
84 elm_shutdown();
85}
86END_TEST
87
88
89START_TEST (elm_atspi_role_name_get)
90{
91 elm_init(0, NULL);
92
93 Eo *obj = generate_app();
94
95 const char *ret = NULL;
96
97 eo_do(obj, ret = elm_interface_atspi_accessible_role_name_get());
98
99 ck_assert(ret != NULL);
100
101 elm_shutdown();
102}
103END_TEST
104
105START_TEST (elm_atspi_localized_role_name_get)
106{
107 elm_init(0, NULL);
108
109 Eo *obj = generate_app();
110
111 const char *ret = NULL;
112
113 eo_do(obj, ret = elm_interface_atspi_accessible_localized_role_name_get());
114
115 ck_assert(ret != NULL);
116
117 elm_shutdown();
118}
119END_TEST
120
121START_TEST (elm_atspi_description_set)
122{
123 elm_init(0, NULL);
124
125 Eo *obj = generate_app();
126
127 const char *ret = NULL;
128
129 const char *desc = "Test description";
130
131 eo_do(obj, ret = elm_interface_atspi_accessible_description_get());
132
133 ck_assert(ret == NULL);
134
135 eo_do(obj, elm_interface_atspi_accessible_description_set(desc));
136
137 eo_do(obj, ret = elm_interface_atspi_accessible_description_get());
138
139 ck_assert(ret != NULL);
140 ck_assert_str_eq(ret, "Test description");
141
142 elm_shutdown();
143}
144END_TEST
145
146START_TEST (elm_atspi_children_and_parent)
147{
148 elm_init(0, NULL);
149
150 Eo *root = generate_app();
151
152 Eina_List *child_list = NULL;
153
154 eo_do(root, child_list = elm_interface_atspi_accessible_children_get());
155
156 //eo_do(eina_list_nth(child_list, 0), bg_child_list = elm_interface_atspi_accessible_children_get());
157
158 ck_assert(eina_list_count(child_list) == 1);
159
160 Eo *win = NULL;
161
162 win = eina_list_nth(child_list, 0);
163
164 ck_assert(win != NULL);
165 ck_assert(win == g_win);
166
167 Eo *win_parent = NULL;
168
169 eo_do(win, win_parent = elm_interface_atspi_accessible_parent_get());
170
171 ck_assert(root == win_parent);
172
173 elm_shutdown();
174}
175END_TEST
176
177START_TEST (elm_atspi_component_position)
178{
179 Eina_List *child_list = NULL;
180 elm_init(0, NULL);
181
182 Eo *root = generate_app();
183
184 Eo *win = NULL;
185
186 eo_do(root, child_list = elm_interface_atspi_accessible_children_get());
187
188 win = eina_list_nth(child_list, 0);
189
190 Eina_Bool ret = EINA_FALSE;
191
192 eo_do(win, ret = elm_interface_atspi_component_position_set(EINA_TRUE, 100, 100));
193
194 ck_assert(ret == EINA_TRUE);
195
196 int x, y;
197
198 eo_do(win, elm_interface_atspi_component_position_get(EINA_TRUE, &x, &y));
199
200 ck_assert((x == 100) && (y == 100));
201
202 elm_shutdown();
203}
204END_TEST
205
206START_TEST (elm_atspi_component_size)
207{
208 Eina_List *child_list = NULL;
209 elm_init(0, NULL);
210
211 Eo *root = generate_app();
212
213 Eo *win = NULL;
214
215 eo_do(root, child_list = elm_interface_atspi_accessible_children_get());
216
217 win = eina_list_nth(child_list, 0);
218
219 Eina_Bool ret = EINA_FALSE;
220
221 eo_do(win, ret = elm_interface_atspi_component_size_set(100, 100));
222
223 ck_assert(ret == EINA_TRUE);
224
225 int w, h;
226
227 eo_do(win, elm_interface_atspi_component_size_get(&w, &h));
228
229 ck_assert((w == 100) && (h == 100));
230
231 elm_shutdown();
232}
233END_TEST
234
235START_TEST (elm_atspi_component_focus)
236{
237 Eina_List *child_list = NULL;
238 elm_init(0, NULL);
239
240 Eo *root = generate_app();
241
242 Eo *win = NULL;
243
244 eo_do(root, child_list = elm_interface_atspi_accessible_children_get());
245
246 win = eina_list_nth(child_list, 0);
247
248 Eina_Bool ret = EINA_FALSE;
249
250 eo_do(win, ret = elm_interface_atspi_component_focus_grab());
251
252 ck_assert(ret == EINA_TRUE);
253
254 elm_shutdown();
255}
256END_TEST
257
258START_TEST (elm_test_atspi_object_children_get)
259{
260 elm_init(0, NULL);
261
262 Eo *root = _elm_atspi_root_get();
263
264 Eina_List *children = NULL;
265 eo_do(root, children = elm_interface_atspi_accessible_children_get());
266
267 ck_assert(children == NULL);
268
269 eina_list_free(children);
270
271 elm_shutdown();
272}
273END_TEST
274
275START_TEST (elm_test_atspi_obj_index_in_parent_get)
276{
277 elm_init(0, NULL);
278
279 Eo *root = generate_app();
280
281 int ret = 0;
282
283 Eina_List *children = NULL;
284 eo_do(root, children = elm_interface_atspi_accessible_children_get());
285
286 Evas_Object *win = eina_list_nth(children, 0);
287 ck_assert(win != NULL);
288
289 eo_do(win, ret = elm_interface_atspi_accessible_index_in_parent_get());
290
291 ck_assert(ret == 0);
292
293 elm_shutdown();
294}
295END_TEST
296
297START_TEST (elm_atspi_component_z_order)
298{
299 elm_init(0, NULL);
300
301 Eo *root = generate_app();
302
303 Eo *win = NULL;
304
305 Eina_List *children;
306 eo_do(root, children = elm_interface_atspi_accessible_children_get());
307
308 win = eina_list_nth(children, 0);
309 int z_order = -1;
310
311 eo_do(win, z_order = elm_interface_atspi_component_z_order_get());
312
313 ck_assert(z_order != -1);
314
315 elm_shutdown();
316}
317END_TEST
318
319START_TEST (elm_atspi_component_layer)
320{
321 elm_init(0, NULL);
322
323 Eo *root = generate_app();
324
325 Eo *win = NULL;
326
327 Eina_List *children;
328 eo_do(root, children = elm_interface_atspi_accessible_children_get());
329
330 win = eina_list_nth(children, 0);
331
332 int layer = -1;
333
334 eo_do(win, layer = elm_interface_atspi_component_layer_get());
335
336 ck_assert(layer != -1);
337
338 elm_shutdown();
339}
340END_TEST
341
342START_TEST (elm_atspi_component_alpha)
343{
344 elm_init(0, NULL);
345
346 Eo *root = generate_app();
347
348 Eo *win = NULL;
349
350 Eina_List *children;
351 eo_do(root, children = elm_interface_atspi_accessible_children_get());
352 win = eina_list_nth(children, 0);
353
354 double alpha = -1.0;
355
356 eo_do(win, alpha = elm_interface_atspi_component_alpha_get());
357
358 ck_assert(alpha >= 0.0);
359 ck_assert(alpha <= 1.0);
360
361 elm_shutdown();
362}
363END_TEST
364
365START_TEST (elm_atspi_children_and_parent2)
366{
367 elm_init(0, NULL);
368
369 Eo *root = generate_app();
370
371 Eo *win = NULL;
372
373 Eina_List *root_children;
374 eo_do(root, root_children = elm_interface_atspi_accessible_children_get());
375 win = eina_list_nth(root_children, 0);
376
377 Eina_List *win_children;
378 eo_do(win, win_children = elm_interface_atspi_accessible_children_get());
379
380 ck_assert(eina_list_count(win_children) == 2);
381
382 Eo *btn = NULL;
383
384 btn = eina_list_nth(win_children, 1);
385 ck_assert(btn != NULL);
386 ck_assert(btn == g_btn);
387
388 elm_shutdown();
389}
390END_TEST
391
392void elm_test_atspi(TCase *tc)
393{
394 tcase_add_test(tc, elm_atspi_root_get);
395 tcase_add_test(tc, elm_atspi_name_get);
396 tcase_add_test(tc, elm_atspi_role_get);
397 tcase_add_test(tc, elm_atspi_role_name_get);
398 tcase_add_test(tc, elm_atspi_localized_role_name_get);
399 tcase_add_test(tc, elm_atspi_description_set);
400 tcase_add_test(tc, elm_atspi_children_and_parent);
401 tcase_add_test(tc, elm_atspi_component_position);
402 tcase_add_test(tc, elm_atspi_component_size);
403 tcase_add_test(tc, elm_atspi_component_focus);
404 tcase_add_test(tc, elm_test_atspi_object_children_get);
405 tcase_add_test(tc, elm_test_atspi_obj_index_in_parent_get);
406 tcase_add_test(tc, elm_atspi_component_z_order);
407 tcase_add_test(tc, elm_atspi_component_layer);
408 tcase_add_test(tc, elm_atspi_component_alpha);
409 tcase_add_test(tc, elm_atspi_children_and_parent2);
410}
411
412/*
413 * TO DO
414 * elm_interface_atspi_accessible_relation_set_get
415 * elm_interface_atspi_accessible_relation_set_set
416 * elm_interface_atspi_accessible_state_get
417 * elm_interface_atspi_accessible_attributes_get
418 * elm_interface_atspi_component_contains
419*/