summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-05-30 11:56:24 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-05-30 11:56:24 +0900
commit2a8e20c31a827dfe66a5de4accec902555b5dec4 (patch)
tree988dc4bd0193ad7a1f491331d3bfdd614ff0b5ca
parentd3ac2d8612f544cbd27f0eddb4da8e239f3a90e4 (diff)
atspi:AtspiSelection interface added
Reviewers: stanluk, m.jagiello, raster Differential Revision: https://phab.enlightenment.org/D810
-rw-r--r--src/lib/Makefile.am5
-rw-r--r--src/lib/elm_atspi_bridge.c246
-rw-r--r--src/lib/elm_interface_atspi_selection.c12
-rw-r--r--src/lib/elm_interface_atspi_selection.eo74
-rw-r--r--src/tests/Makefile.am1
-rw-r--r--src/tests/elm_test_list.c195
6 files changed, 533 insertions, 0 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index f012fb516..a2de0d87e 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -454,6 +454,7 @@ elm_interface_atspi_action.c \
454elm_interface_atspi_component.c \ 454elm_interface_atspi_component.c \
455elm_interface_atspi_image.c \ 455elm_interface_atspi_image.c \
456elm_interface_atspi_value.c \ 456elm_interface_atspi_value.c \
457elm_interface_atspi_selection.c \
457elm_interface_atspi_widget.c \ 458elm_interface_atspi_widget.c \
458elm_interface_atspi_widget_action.c \ 459elm_interface_atspi_widget_action.c \
459elm_interface_atspi_window.c \ 460elm_interface_atspi_window.c \
@@ -667,6 +668,8 @@ BUILT_SOURCES = \
667 elm_interface_atspi_widget.eo.h \ 668 elm_interface_atspi_widget.eo.h \
668 elm_interface_atspi_widget_action.eo.c \ 669 elm_interface_atspi_widget_action.eo.c \
669 elm_interface_atspi_widget_action.eo.h \ 670 elm_interface_atspi_widget_action.eo.h \
671 elm_interface_atspi_selection.eo.c \
672 elm_interface_atspi_selection.eo.h \
670 elm_interface_atspi_window.eo.c \ 673 elm_interface_atspi_window.eo.c \
671 elm_interface_atspi_window.eo.h \ 674 elm_interface_atspi_window.eo.h \
672 elm_interface_fileselector.eo.c \ 675 elm_interface_fileselector.eo.c \
@@ -794,6 +797,7 @@ elementaryeolianfiles_DATA = \
794 elm_interface_atspi_component.eo \ 797 elm_interface_atspi_component.eo \
795 elm_interface_atspi_image.eo \ 798 elm_interface_atspi_image.eo \
796 elm_interface_atspi_value.eo \ 799 elm_interface_atspi_value.eo \
800 elm_interface_atspi_selection.eo \
797 elm_interface_atspi_widget.eo \ 801 elm_interface_atspi_widget.eo \
798 elm_interface_atspi_widget_action.eo \ 802 elm_interface_atspi_widget_action.eo \
799 elm_interface_atspi_window.eo \ 803 elm_interface_atspi_window.eo \
@@ -887,6 +891,7 @@ nodist_includesunstable_HEADERS = \
887 elm_interface_atspi_component.eo.h \ 891 elm_interface_atspi_component.eo.h \
888 elm_interface_atspi_image.eo.h \ 892 elm_interface_atspi_image.eo.h \
889 elm_interface_atspi_value.eo.h \ 893 elm_interface_atspi_value.eo.h \
894 elm_interface_atspi_selection.eo.h \
890 elm_interface_atspi_widget.eo.h \ 895 elm_interface_atspi_widget.eo.h \
891 elm_interface_atspi_widget_action.eo.h \ 896 elm_interface_atspi_widget_action.eo.h \
892 elm_interface_atspi_window.eo.h \ 897 elm_interface_atspi_window.eo.h \
diff --git a/src/lib/elm_atspi_bridge.c b/src/lib/elm_atspi_bridge.c
index 157041a9a..c031c9247 100644
--- a/src/lib/elm_atspi_bridge.c
+++ b/src/lib/elm_atspi_bridge.c
@@ -7,6 +7,7 @@
7#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED 7#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED
8#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED 8#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
9#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED 9#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
10#define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED
10#include "atspi/atspi-constants.h" 11#include "atspi/atspi-constants.h"
11 12
12#include <stdint.h> 13#include <stdint.h>
@@ -21,6 +22,7 @@
21#include "elm_interface_atspi_action.eo.h" 22#include "elm_interface_atspi_action.eo.h"
22#include "elm_interface_atspi_value.eo.h" 23#include "elm_interface_atspi_value.eo.h"
23#include "elm_interface_atspi_image.eo.h" 24#include "elm_interface_atspi_image.eo.h"
25#include "elm_interface_atspi_selection.eo.h"
24 26
25/* 27/*
26 * Accessibility Bus info not defined in atspi-constants.h 28 * Accessibility Bus info not defined in atspi-constants.h
@@ -58,6 +60,7 @@ static Eina_Bool _state_changed_signal_send(void *data, Eo *obj, const Eo_Event_
58static Eina_Bool _property_changed_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info); 60static Eina_Bool _property_changed_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info);
59static Eina_Bool _children_changed_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info); 61static Eina_Bool _children_changed_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info);
60static Eina_Bool _window_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 62static Eina_Bool _window_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
63static Eina_Bool _selection_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
61static Eo * _access_object_from_path(const char *path); 64static Eo * _access_object_from_path(const char *path);
62static char * _path_from_access_object(Eo *eo); 65static char * _path_from_access_object(Eo *eo);
63static void _object_append_reference(Eldbus_Message_Iter *iter, Eo *obj); 66static void _object_append_reference(Eldbus_Message_Iter *iter, Eo *obj);
@@ -79,6 +82,10 @@ EO_CALLBACKS_ARRAY_DEFINE(_window_cb,
79 { ELM_INTERFACE_ATSPI_WINDOW_EVENT_WINDOW_DEACTIVATED, _window_signal_send} 82 { ELM_INTERFACE_ATSPI_WINDOW_EVENT_WINDOW_DEACTIVATED, _window_signal_send}
80); 83);
81 84
85EO_CALLBACKS_ARRAY_DEFINE(_selection_cb,
86 { ELM_INTERFACE_ATSPI_SELECTION_EVENT_SELECTION_CHANGED, _selection_signal_send}
87);
88
82enum _Atspi_Object_Child_Event_Type 89enum _Atspi_Object_Child_Event_Type
83{ 90{
84 ATSPI_OBJECT_CHILD_ADDED = 0, 91 ATSPI_OBJECT_CHILD_ADDED = 0,
@@ -584,6 +591,160 @@ static const Eldbus_Method accessible_methods[] = {
584}; 591};
585 592
586static Eldbus_Message * 593static Eldbus_Message *
594_selection_selected_child_get(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
595{
596 const char *obj_path = eldbus_service_object_path_get(iface);
597 Eo *obj = _access_object_from_path(obj_path);
598 Eo *child = NULL;
599
600 int idx;
601 Eldbus_Message *ret;
602 Eldbus_Message_Iter *iter;
603
604 if (!eldbus_message_arguments_get(msg, "i", &idx))
605 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
606
607 ret = eldbus_message_method_return_new(msg);
608 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
609
610 iter = eldbus_message_iter_get(ret);
611 eo_do(obj, child = elm_interface_atspi_selection_selected_child_get(idx));
612
613 _object_append_reference(iter, child);
614
615 return ret;
616}
617
618static Eldbus_Message *
619_selection_child_select(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
620{
621 const char *obj_path = eldbus_service_object_path_get(iface);
622 Eo *obj = _access_object_from_path(obj_path);
623 int idx;
624 Eldbus_Message *ret;
625 Eina_Bool result;
626
627 if (!eldbus_message_arguments_get(msg, "i", &idx))
628 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
629
630 ret = eldbus_message_method_return_new(msg);
631 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
632
633 eo_do(obj, result = elm_interface_atspi_selection_child_select(idx));
634 eldbus_message_arguments_append(ret, "b", result);
635
636 return ret;
637}
638
639static Eldbus_Message *
640_selection_selected_child_deselect(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
641{
642 const char *obj_path = eldbus_service_object_path_get(iface);
643 Eo *obj = _access_object_from_path(obj_path);
644 int idx;
645 Eldbus_Message *ret;
646 Eina_Bool result;
647
648 if (!eldbus_message_arguments_get(msg, "i", &idx))
649 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
650
651 ret = eldbus_message_method_return_new(msg);
652 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
653
654 eo_do(obj, result = elm_interface_atspi_selection_selected_child_deselect(idx));
655 eldbus_message_arguments_append(ret, "b", result);
656
657 return ret;
658}
659
660static Eldbus_Message *
661_selection_is_child_selected(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
662{
663 const char *obj_path = eldbus_service_object_path_get(iface);
664 Eo *obj = _access_object_from_path(obj_path);
665 int idx;
666 Eldbus_Message *ret;
667 Eina_Bool result;
668
669 if (!eldbus_message_arguments_get(msg, "i", &idx))
670 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
671
672 ret = eldbus_message_method_return_new(msg);
673 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
674
675 eo_do(obj, result = elm_interface_atspi_selection_is_child_selected(idx));
676 eldbus_message_arguments_append(ret, "b", result);
677
678 return ret;
679}
680
681static Eldbus_Message *
682_selection_all_children_select(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
683{
684 const char *obj_path = eldbus_service_object_path_get(iface);
685 Eo *obj = _access_object_from_path(obj_path);
686 Eldbus_Message *ret;
687 Eina_Bool result;
688
689 ret = eldbus_message_method_return_new(msg);
690 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
691
692 eo_do(obj, result = elm_interface_atspi_selection_all_children_select());
693 eldbus_message_arguments_append(ret, "b", result);
694
695 return ret;
696}
697
698static Eldbus_Message *
699_selection_clear(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
700{
701 const char *obj_path = eldbus_service_object_path_get(iface);
702 Eo *obj = _access_object_from_path(obj_path);
703 Eldbus_Message *ret;
704 Eina_Bool result;
705
706 ret = eldbus_message_method_return_new(msg);
707 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
708
709 eo_do(obj, result = elm_interface_atspi_selection_clear());
710 eldbus_message_arguments_append(ret, "b", result);
711
712 return ret;
713}
714
715static Eldbus_Message *
716_selection_child_deselect(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
717{
718 const char *obj_path = eldbus_service_object_path_get(iface);
719 Eo *obj = _access_object_from_path(obj_path);
720 int idx;
721 Eldbus_Message *ret;
722 Eina_Bool result;
723
724 if (!eldbus_message_arguments_get(msg, "i", &idx))
725 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
726
727 ret = eldbus_message_method_return_new(msg);
728 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
729
730 eo_do(obj, result = elm_interface_atspi_selection_child_deselect(idx));
731 eldbus_message_arguments_append(ret, "b", result);
732
733 return ret;
734}
735
736static const Eldbus_Method selection_methods[] = {
737 { "GetSelectedChild", ELDBUS_ARGS({"i", "selectedChildIndex"}), ELDBUS_ARGS({"(so)", "Accessible"}), _selection_selected_child_get, 0 },
738 { "SelectChild", ELDBUS_ARGS({"i", "childIndex"}), ELDBUS_ARGS({"b", "result"}), _selection_child_select, 0 },
739 { "DeselectSelectedChild", ELDBUS_ARGS({"i", "selectedChildIndex"}), ELDBUS_ARGS({"b", "result"}), _selection_selected_child_deselect, 0 },
740 { "IsChildSelected", ELDBUS_ARGS({"i", "childIndex"}), ELDBUS_ARGS({"b", "result"}), _selection_is_child_selected, 0 },
741 { "SelectAll", NULL, ELDBUS_ARGS({"b", "result"}), _selection_all_children_select, 0},
742 { "ClearSelection", NULL, ELDBUS_ARGS({"b", "result"}), _selection_clear, 0},
743 { "DeselectChild", ELDBUS_ARGS({"i", "childIndex"}), ELDBUS_ARGS({"b", "result"}), _selection_child_deselect, 0 },
744 { NULL, NULL, NULL, NULL, 0 }
745};
746
747static Eldbus_Message *
587_action_description_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 748_action_description_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
588{ 749{
589 const char *description, *obj_path = eldbus_service_object_path_get(iface); 750 const char *description, *obj_path = eldbus_service_object_path_get(iface);
@@ -893,6 +1054,26 @@ _accessible_property_get(const Eldbus_Service_Interface *interface, const char *
893} 1054}
894 1055
895static Eina_Bool 1056static Eina_Bool
1057_selection_property_get(const Eldbus_Service_Interface *interface, const char *property,
1058 Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED,
1059 Eldbus_Message **error EINA_UNUSED)
1060{
1061 int n;
1062 const char *obj_path = eldbus_service_object_path_get(interface);
1063 Eo *obj = _access_object_from_path(obj_path);
1064
1065 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1066
1067 if (!strcmp(property, "NSelectedChildren"))
1068 {
1069 eo_do(obj, n = elm_interface_atspi_selection_selected_children_count_get());
1070 eldbus_message_iter_basic_append(iter, 'i', n);
1071 return EINA_TRUE;
1072 }
1073 return EINA_FALSE;
1074}
1075
1076static Eina_Bool
896_action_property_get(const Eldbus_Service_Interface *interface, const char *property, 1077_action_property_get(const Eldbus_Service_Interface *interface, const char *property,
897 Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, 1078 Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED,
898 Eldbus_Message **error EINA_UNUSED) 1079 Eldbus_Message **error EINA_UNUSED)
@@ -1033,6 +1214,11 @@ static const Eldbus_Property image_properties[] = {
1033 { NULL, NULL, NULL, NULL, 0 } 1214 { NULL, NULL, NULL, NULL, 0 }
1034}; 1215};
1035 1216
1217static const Eldbus_Property selection_properties[] = {
1218 { "NSelectedChildren", "i", _selection_property_get, NULL, 0 },
1219 { NULL, NULL, NULL, NULL, 0 }
1220};
1221
1036static const Eldbus_Service_Interface_Desc accessible_iface_desc = { 1222static const Eldbus_Service_Interface_Desc accessible_iface_desc = {
1037 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL 1223 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL
1038}; 1224};
@@ -1057,6 +1243,10 @@ static const Eldbus_Service_Interface_Desc image_iface_desc = {
1057 ATSPI_DBUS_INTERFACE_IMAGE, image_methods, NULL, image_properties, _image_properties_get, NULL 1243 ATSPI_DBUS_INTERFACE_IMAGE, image_methods, NULL, image_properties, _image_properties_get, NULL
1058}; 1244};
1059 1245
1246static const Eldbus_Service_Interface_Desc selection_iface_desc = {
1247 ATSPI_DBUS_INTERFACE_SELECTION, selection_methods, NULL, selection_properties, NULL, NULL
1248};
1249
1060static void 1250static void
1061_object_append_reference(Eldbus_Message_Iter *iter, Eo *obj) 1251_object_append_reference(Eldbus_Message_Iter *iter, Eo *obj)
1062{ 1252{
@@ -1914,6 +2104,50 @@ _window_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc, void
1914 return EINA_TRUE; 2104 return EINA_TRUE;
1915} 2105}
1916 2106
2107static Eina_Bool
2108_selection_signal_send(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info EINA_UNUSED)
2109{
2110 const char *event_desc;
2111 Eldbus_Message *msg;
2112 Eldbus_Message_Iter *iter, *viter;
2113 Eldbus_Service_Interface *selection = data;
2114
2115 enum _Atspi_Object_Signals type;
2116 if (desc == ELM_INTERFACE_ATSPI_SELECTION_EVENT_SELECTION_CHANGED)
2117 {
2118 event_desc = "SelectionChanged";
2119 type = ATSPI_OBJECT_EVENT_SELECTION_CHANGED;
2120 }
2121 else
2122 {
2123 WRN("ATSPI Selection event not handled");
2124 return EINA_FALSE;
2125 }
2126
2127 if (!selection || !_a11y_bus)
2128 {
2129 ERR("A11Y connection closed. Unable to send ATSPI event.");
2130 return EINA_FALSE;
2131 }
2132
2133 msg = eldbus_service_signal_new(selection, type);
2134 EINA_SAFETY_ON_NULL_RETURN_VAL(msg, EINA_FALSE);
2135
2136 iter = eldbus_message_iter_get(msg);
2137 eldbus_message_iter_arguments_append(iter, "sii", event_desc, 0, 0);
2138
2139 viter = eldbus_message_iter_container_new(iter, 'v', "i");
2140 EINA_SAFETY_ON_NULL_RETURN_VAL(viter, EINA_FALSE);
2141
2142 eldbus_message_iter_arguments_append(viter, "i", 0);
2143 eldbus_message_iter_container_close(iter, viter);
2144
2145 _object_append_reference(iter, obj);
2146
2147 eldbus_service_signal_send(selection, msg);
2148 DBG("signal sent Selection:%s", event_desc);
2149 return EINA_TRUE;
2150}
1917static void 2151static void
1918_event_handlers_register(void) 2152_event_handlers_register(void)
1919{ 2153{
@@ -2032,6 +2266,13 @@ static void _object_register(Eo *obj, char *path)
2032 eldbus_service_interface_register(_a11y_bus, path, &value_iface_desc); 2266 eldbus_service_interface_register(_a11y_bus, path, &value_iface_desc);
2033 if (eo_isa(obj, ELM_INTERFACE_ATSPI_IMAGE_CLASS)) 2267 if (eo_isa(obj, ELM_INTERFACE_ATSPI_IMAGE_CLASS))
2034 eldbus_service_interface_register(_a11y_bus, path, &image_iface_desc); 2268 eldbus_service_interface_register(_a11y_bus, path, &image_iface_desc);
2269 if (eo_isa(obj, ELM_INTERFACE_ATSPI_SELECTION_CLASS))
2270 {
2271 infc = eldbus_service_interface_register(_a11y_bus, path, &selection_iface_desc);
2272 eo_do(obj, eo_key_data_set("selection_interface", infc, NULL));
2273 eo_do(obj, eo_event_callback_array_add(_selection_cb(), infc));
2274 }
2275
2035 } 2276 }
2036} 2277}
2037 2278
@@ -2056,6 +2297,11 @@ static void _object_unregister(void *obj)
2056 eo_do(obj, infc = eo_key_data_get("window_interface")); 2297 eo_do(obj, infc = eo_key_data_get("window_interface"));
2057 eo_do(obj, eo_event_callback_array_del(_window_cb(), infc)); 2298 eo_do(obj, eo_event_callback_array_del(_window_cb(), infc));
2058 } 2299 }
2300 if (eo_isa(obj, ELM_INTERFACE_ATSPI_SELECTION_CLASS))
2301 {
2302 eo_do(obj, infc = eo_key_data_get("selection_interface"));
2303 eo_do(obj, eo_event_callback_array_del(_selection_cb(), infc));
2304 }
2059} 2305}
2060 2306
2061void 2307void
diff --git a/src/lib/elm_interface_atspi_selection.c b/src/lib/elm_interface_atspi_selection.c
new file mode 100644
index 000000000..31519f48b
--- /dev/null
+++ b/src/lib/elm_interface_atspi_selection.c
@@ -0,0 +1,12 @@
1#ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_widget.h"
7#include "elm_priv.h"
8
9#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
10
11#include "elm_interface_atspi_selection.eo.h"
12#include "elm_interface_atspi_selection.eo.c"
diff --git a/src/lib/elm_interface_atspi_selection.eo b/src/lib/elm_interface_atspi_selection.eo
new file mode 100644
index 000000000..6ac62450c
--- /dev/null
+++ b/src/lib/elm_interface_atspi_selection.eo
@@ -0,0 +1,74 @@
1interface Elm_Interface_Atspi_Selection ()
2{
3 legacy_prefix: null;
4 eo_prefix: elm_interface_atspi_selection;
5 data: null;
6 properties {
7 protected selected_children_count {
8 get {
9 /* Gets the number of currently selected children */
10 return int;
11 }
12 }
13 protected selected_child {
14 /* Gets child for given child index */
15 get {
16 return Eo*;
17 }
18 keys {
19 int selected_child_index; /*@ index of selected child */
20 }
21 }
22 }
23 methods {
24 protected child_select {
25 /* Adds selection for given child index */
26 params {
27 @in int child_index;
28 }
29 return Eina_Bool;
30 }
31 protected selected_child_deselect {
32 /* Removes selection for given child index */
33 params {
34 @in int child_index;
35 }
36 return Eina_Bool;
37 }
38 protected is_child_selected {
39 /* Determines if child specified by index is selected */
40 params {
41 @in int child_index;
42 }
43 return Eina_Bool;
44 }
45 protected all_children_select {
46 /* Adds selection for all children */
47 return Eina_Bool;
48 }
49 protected clear {
50 /* Clears the current selection */
51 return Eina_Bool;
52 }
53 protected child_deselect {
54 /* Removes selection for given child index */
55 params {
56 @in int child_index;
57 }
58 return Eina_Bool;
59 }
60 }
61 events {
62 selection,changed; /*@ Called when selection has been changed. */
63 }
64 implements {
65 virtual::selected_children_count::get;
66 virtual::selected_child::get;
67 virtual::child_select;
68 virtual::selected_child_deselect;
69 virtual::is_child_selected;
70 virtual::all_children_select;
71 virtual::clear;
72 virtual::child_deselect;
73 }
74}
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 4fbbd68da..debb1847d 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -11,6 +11,7 @@ elm_suite_SOURCES = \
11 elm_test_colorselector.c \ 11 elm_test_colorselector.c \
12 elm_test_entry.c \ 12 elm_test_entry.c \
13 elm_test_init.c 13 elm_test_init.c
14 elm_test_list.c
14 15
15elm_suite_CPPFLAGS = \ 16elm_suite_CPPFLAGS = \
16 -DTESTS_BUILD_DIR=\"${top_builddir}/src/tests\" \ 17 -DTESTS_BUILD_DIR=\"${top_builddir}/src/tests\" \
diff --git a/src/tests/elm_test_list.c b/src/tests/elm_test_list.c
new file mode 100644
index 000000000..d16134247
--- /dev/null
+++ b/src/tests/elm_test_list.c
@@ -0,0 +1,195 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_suite.h"
7
8#define ELM_INTERFACE_ATSPI_TEXT_PROTECTED
9#include "elm_interface_atspi_selection.h"
10#include "elm_interface_atspi_selection.eo.h"
11
12
13START_TEST (elm_list_atspi_selection_selected_children_count_get)
14{
15 Evas_Object *win, *list;
16 Elm_Object_Item *item;
17 int val;
18
19 elm_init(1, NULL);
20 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
21
22 list = elm_list_add(win);
23 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
24
25 eo_do(list, val = elm_interface_atspi_selection_selected_children_count_get());
26 ck_assert(val == 0);
27
28 elm_list_item_selected_set(item, EINA_TRUE);
29 eo_do(list, val = elm_interface_atspi_selection_selected_children_count_get());
30 ck_assert(val == 1);
31
32 elm_list_item_selected_set(item, EINA_FALSE);
33 eo_do(list, val = elm_interface_atspi_selection_selected_children_count_get());
34 ck_assert(val == 0);
35
36 elm_shutdown();
37}
38END_TEST
39
40START_TEST (elm_list_atspi_selection_child_select)
41{
42 Evas_Object *win, *list;
43 Elm_Object_Item *item;
44 Eina_Bool val;
45
46 elm_init(1, NULL);
47 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
48
49 list = elm_list_add(win);
50 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
51
52 eo_do(list, val = elm_interface_atspi_selection_child_select(0));
53 ck_assert(val == EINA_TRUE);
54 ck_assert(EINA_TRUE == elm_list_item_selected_get(item));
55
56 elm_shutdown();
57}
58END_TEST
59
60START_TEST (elm_list_atspi_selection_selected_child_deselect)
61{
62 Evas_Object *win, *list;
63 Elm_Object_Item *item1, *item2;
64 Eina_Bool val;
65
66 elm_init(1, NULL);
67 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
68
69 list = elm_list_add(win);
70 elm_list_multi_select_set(list, EINA_TRUE);
71 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
72 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);
73
74 elm_list_item_selected_set(item2, EINA_TRUE);
75 eo_do(list, val = elm_interface_atspi_selection_selected_child_deselect(0));
76 ck_assert(val == EINA_TRUE);
77 ck_assert(EINA_FALSE == elm_list_item_selected_get(item2));
78
79 elm_shutdown();
80}
81END_TEST
82
83START_TEST (elm_list_atspi_selection_is_child_selected)
84{
85 Evas_Object *win, *list;
86 Elm_Object_Item *item;
87 Eina_Bool val;
88
89 elm_init(1, NULL);
90 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
91 Eina_Bool val;
92
93 list = elm_list_add(win);
94 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
95
96 eo_do(list, val = elm_interface_atspi_selection_is_child_selected(0));
97 ck_assert(val == EINA_FALSE);
98
99 elm_list_item_selected_set(item, EINA_TRUE);
100 eo_do(list, val = elm_interface_atspi_selection_is_child_selected(0));
101 ck_assert(val == EINA_TRUE);
102
103 elm_shutdown();
104}
105END_TEST
106
107START_TEST (elm_list_atspi_selection_all_children_select)
108{
109 Evas_Object *win, *list;
110 Elm_Object_Item *item1, *item2;
111 Eina_Bool val;
112
113 elm_init(1, NULL);
114 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
115 Eina_Bool val;
116
117 list = elm_list_add(win);
118
119 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
120 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);
121
122 eo_do(list, val = elm_interface_atspi_selection_all_children_select(0));
123 ck_assert(val == EINA_FALSE);
124
125 elm_list_multi_select_set(list, EINA_TRUE);
126 eo_do(list, val = elm_interface_atspi_selection_all_children_select(0));
127 ck_assert(val == EINA_TRUE);
128 ck_assert(EINA_TRUE == elm_list_item_selected_get(item1));
129 ck_assert(EINA_TRUE == elm_list_item_selected_get(item2));
130
131 elm_shutdown();
132}
133END_TEST
134
135
136START_TEST (elm_list_atspi_selection_child_clear)
137{
138 Evas_Object *win, *list;
139 Elm_Object_Item *item1, *item2;
140 Eina_Bool val;
141
142 elm_init(1, NULL);
143 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
144 Eina_Bool val;
145
146 list = elm_list_add(win);
147 elm_list_multi_select_set(list, EINA_TRUE);
148 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
149 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);
150 elm_list_item_selected_set(item1, EINA_TRUE);
151 elm_list_item_selected_set(item2, EINA_TRUE);
152
153
154 eo_do(list, val = elm_interface_atspi_selection_child_clear(0));
155 ck_assert(val == EINA_TRUE);
156 ck_assert(EINA_FALSE == elm_list_item_selected_get(item1));
157 ck_assert(EINA_FALSE == elm_list_item_selected_get(item2));
158
159 elm_shutdown();
160}
161END_TEST
162
163START_TEST (elm_list_atspi_selection_child_deselect)
164{
165 Evas_Object *win, *list;
166 Elm_Object_Item *item1, *item2;
167 Eina_Bool val;
168
169 elm_init(1, NULL);
170 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
171
172 list = elm_list_add(win);
173 elm_list_multi_select_set(list, EINA_TRUE);
174 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
175 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);
176
177 elm_list_item_selected_set(item2, EINA_TRUE);
178 eo_do(list, val = elm_interface_atspi_selection_selected_child_deselect(1));
179 ck_assert(val == EINA_TRUE);
180 ck_assert(EINA_FALSE == elm_list_item_selected_get(item2));
181
182 elm_shutdown();
183}
184END_TEST
185
186void elm_test_list(TCase *tc)
187{
188 tcase_add_test(tc, elm_list_atspi_selection_selected_children_count_get);
189 tcase_add_test(tc, elm_list_atspi_selection_child_select);
190 tcase_add_test(tc, elm_list_atspi_selection_selected_child_deselect);
191 tcase_add_test(tc, elm_list_atspi_selection_is_child_selected);
192 tcase_add_test(tc, elm_list_atspi_selection_all_children_select);
193 tcase_add_test(tc, elm_list_atspi_selection_clear);
194 tcase_add_test(tc, elm_list_atspi_selection_child_deselect);
195}