2 * Tested interface: AtkText
4 * Tested AtkObject: EailPopup
6 * Description: Test AtkPopup interface
8 * Test input: accessible object representing EailPopup
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
17 #include "eail_test_utils.h"
19 #define EAIL_TYPE_FOR_POPUP "EailPopup"
20 #define EAIL_TEST_LABEL_TITTLE "Test popup obj"
21 #define EAIL_TEST_CONTENT_LABEL_TEXT "Test content label text"
22 #define EAIL_TEST_CONTENT_TEXT "seseeseese"
24 /* used to determine if test code has been successfully called
25 * (sometimes may happen that ATK object to test in hierarchy cannot be found)*/
26 static gboolean eail_test_code_called = FALSE;
29 _test_popup_object_with_text(AtkObject *obj);
32 _test_popup_object_with_label(AtkObject *obj);
34 static Evas_Object *popup = NULL;
37 _on_done(void *data, Evas_Object *obj, void *event_info)
43 _set_label_content_on_popup(Evas_Object *popup)
45 Evas_Object *label_content;
47 label_content = elm_label_add(popup);
48 elm_object_text_set(label_content, EAIL_TEST_CONTENT_LABEL_TEXT);
50 elm_object_content_set(popup, label_content);
54 on_focus_in(void *data, Evas_Object *obj, void *event_info)
56 AtkObject *aobj = atk_get_root();
59 /* testing popup with text content */
60 eailu_traverse_children_for_type_call_cb
61 (aobj, EAIL_TYPE_FOR_POPUP, _test_popup_object_with_text);
63 _set_label_content_on_popup(popup);
64 /* testing popup with label content */
65 eailu_traverse_children_for_type_call_cb
66 (aobj, EAIL_TYPE_FOR_POPUP, _test_popup_object_with_label);
68 g_assert(eail_test_code_called);
69 _on_done(NULL, obj, NULL);
73 _test_popup_object_with_text(AtkObject *obj)
75 AtkText *text_obj = NULL;
79 atk_object_set_name(obj, EAIL_TEST_CONTENT_TEXT);
80 g_assert_cmpstr(atk_object_get_name(obj), ==, EAIL_TEST_CONTENT_TEXT);
81 _printf("Testing popup instance with text....\n");
82 g_assert(ATK_IS_TEXT(obj));
83 text_obj = ATK_TEXT(obj);
84 text = atk_text_get_text(text_obj, 0, -1);
86 g_assert(strcmp(text, EAIL_TEST_CONTENT_TEXT) == 0);
87 g_assert((atk_text_get_character_count(text_obj)) ==
88 (g_utf8_strlen(EAIL_TEST_CONTENT_TEXT, -1)));
90 /* only 2 buttons should be listed as children when text content is set */
91 child_amount = atk_object_get_n_accessible_children(obj);
92 g_assert(1 == child_amount);
94 _printf("Tests passed successfully\n");
95 eail_test_code_called = TRUE;
99 _test_popup_object_with_label(AtkObject *obj)
101 AtkText *text_obj = NULL;
103 int child_amount = 0;
104 AtkObject *nested_obj;
105 atk_object_set_description(obj, "test");
106 g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
108 atk_object_set_name(obj, "test name");
109 g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
111 _printf("Testing popup instance with label....\n");
112 g_assert(ATK_IS_TEXT(obj));
113 text_obj = ATK_TEXT(obj);
114 text = atk_text_get_text(text_obj, 0, -1);
115 g_assert(NULL == text);
116 g_assert((atk_text_get_character_count(text_obj)) == 0);
118 /* only 2 buttons + one widget with content should be listed as childrens */
119 child_amount = atk_object_get_n_accessible_children(obj);
120 g_assert(2 == child_amount);
122 nested_obj = atk_object_ref_accessible_child(obj, 0);
123 g_assert(eailu_is_object_with_type(nested_obj, "EailLabel"));
124 g_assert(eailu_is_object_with_name
125 (nested_obj, EAIL_TEST_CONTENT_LABEL_TEXT));
127 _printf("Tests passed successfully\n");
131 _response_cb(void *data, Evas_Object *obj,
134 evas_object_hide(data);
138 _initialize_and_show_popup(Evas_Object *win)
140 Evas_Object *btn1, *btn2, *icon1;
143 popup = elm_popup_add(win);
145 icon1 = elm_icon_add(popup);
146 g_snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
147 elm_app_data_dir_get());
148 elm_image_file_set(icon1, buf, NULL );
150 /* Seting popup title-text */
151 elm_object_part_text_set(popup, "title,text", EAIL_TEST_LABEL_TITTLE);
153 elm_object_text_set(popup,EAIL_TEST_CONTENT_TEXT);
154 /* NOTE: RJ,list content of popup is not supported,
155 * so not adding list items. It is because there is no possibility to
156 * fetch those values from popup via popup API */
158 /* Creating the first action button */
159 btn1 = elm_button_add(popup);
160 elm_object_text_set(btn1, "OK");
162 /* NOTE: cannot add due to bug with popup inserting content for button3 */
164 /* Creating the second action button */
165 btn2 = elm_button_add(popup);
166 elm_object_text_set(btn2, "Cancel");
167 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
169 /* Appending the second action button */
170 elm_object_part_content_set(popup, "button1", btn2);
172 /* Display the popup object */
173 evas_object_show(popup);
177 elm_main(int argc, char **argv)
181 win = eailu_create_test_window_with_glib_init(_on_done, on_focus_in);
182 _initialize_and_show_popup(win);
184 evas_object_show(win);