2 * Tested interface: AtkObject
4 * Tested AtkObject: EailCtxpopup
6 * Description: Test AtkObject interface
8 * Test input: accessible object representing EailCtxpopup
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
18 INIT_TEST("EailCtxpopup")
21 _do_test(AtkObject *obj)
24 AtkObject *nested_obj;
25 AtkStateSet *state_set = NULL;
27 _printf("Testing ctxpopup instance....\n");
29 atk_object_set_description(obj, "test");
30 g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
32 atk_object_set_name(obj, "test name");
33 g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
35 child_amount = atk_object_get_n_accessible_children(obj);
36 /* we have to check if there is nested label in Notify */
37 g_assert(1 == child_amount);
39 /* test if ctxpopup child is list-type*/
40 nested_obj = atk_object_ref_accessible_child(obj, 0);
41 g_assert(eailu_is_object_with_type(nested_obj, "EailList"));
43 /* check if atk sees proper amount of list items in ctxpopup */
44 child_amount = atk_object_get_n_accessible_children(nested_obj);
45 g_assert(6 == child_amount);
47 /* NOTE: in ctxpopup object focus automatically goes to nested
49 atk_component_grab_focus(ATK_COMPONENT(obj));
50 state_set = atk_object_ref_state_set(nested_obj);
51 /* checking if nested label is now focused... */
52 g_assert(atk_state_set_contains_state(state_set, ATK_STATE_FOCUSED));
54 _printf("Tests passed successfully\n");
56 eailu_test_code_called = 1;
60 _ctxpopup_item_cb(void *data, Evas_Object *obj, void *event_info)
62 _printf("ctxpopup item selected: %s\n", elm_object_item_text_get(event_info));
65 Elm_Object_Item *item_new(Evas_Object *ctxpopup, const char * label, const char *icon)
67 Evas_Object *ic = elm_icon_add(ctxpopup);
68 elm_icon_standard_set(ic, icon);
69 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
70 return elm_ctxpopup_item_append(ctxpopup, label, ic, _ctxpopup_item_cb, NULL);
74 _init_ctxpopup(Evas_Object *win)
76 Evas_Object *ctxpopup, *box;
77 Elm_Object_Item *object_it;
79 box = elm_box_add(win);
80 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
81 elm_win_resize_object_add(win, box);
82 evas_object_show(box);
84 ctxpopup = elm_ctxpopup_add(win);
85 item_new(ctxpopup, "Go to home folder", "home");
86 item_new(ctxpopup, "Save file", "file");
87 item_new(ctxpopup, "Delete file", "delete");
88 object_it = item_new(ctxpopup, "Navigate to folder", "folder");
89 elm_object_item_disabled_set(object_it, EINA_TRUE);
90 item_new(ctxpopup, "Edit entry", "edit");
91 object_it = item_new(ctxpopup, "Set date and time", "clock");
93 evas_object_size_hint_weight_set(ctxpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
94 evas_object_show(ctxpopup);
95 elm_box_pack_end(box, ctxpopup);
99 elm_main(int argc, char **argv)
103 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
105 evas_object_show(win);