2 * Tested interface: AtkObject
4 * Tested AtkObject: EailMenu
6 * Description: Test whether accessible object is successfully registered
7 * in GObject type system and is visible in AtkObject tree. Test
8 * accessible children availability.
10 * Test input: accessible object representing EailMenu
12 * Expected test result: test should return 0 (success)
15 #include <Elementary.h>
18 #include "eail_test_utils.h"
20 #define EAIL_TYPE_FOR_MENU "EailMenu"
21 #define EAIL_TYPE_FOR_MENU_ITEM "EailMenuItem"
22 #define T_MENU_ITEM_WITH_NO_CHILD_NAME "first item"
23 #define T_SUBM_WITH_ICON_NAME "RJ Menu 1 with icon"
24 #define T_NESTED_BUTTON_NAME "button - delete items (2nd level)"
25 #define T_MENU_WITH_SUB_AND_ICON_NAME "second item"
26 #define T_CUSTOM_NAME_FOR_ITEM "Custom name set to nested button"
27 #define T_CUSTOM_DESCRIPTION "Description for testing"
32 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
34 Evas_Event_Mouse_Down *ev = event_info;
35 elm_menu_move(data, ev->canvas.x, ev->canvas.y);
36 evas_object_show(data);
40 _do_test(AtkObject *aobj)
42 AtkObject *found_obj = NULL;
45 found_obj = eailu_find_child_with_name(aobj, T_SUBM_WITH_ICON_NAME);
46 atk_object_set_description(aobj, "test");
47 g_assert_cmpstr(atk_object_get_description(aobj), ==, "test");
51 /* checking if nested button can be found */
52 found_obj = eailu_find_child_with_name(aobj, T_NESTED_BUTTON_NAME);
55 /* checking if menu with submenus AND nested icon can be found */
56 found_obj = eailu_find_child_with_name(aobj, T_MENU_WITH_SUB_AND_ICON_NAME);
58 eailu_test_atk_focus(found_obj, FALSE);
60 /* cheking if name/description change can be done for item */
61 atk_object_set_name(found_obj, T_CUSTOM_NAME_FOR_ITEM);
62 g_assert(0 == g_strcmp0
63 (T_CUSTOM_NAME_FOR_ITEM, atk_object_get_name(found_obj)));
64 atk_object_set_description(found_obj, T_CUSTOM_DESCRIPTION);
65 g_assert(0 == g_strcmp0
66 (T_CUSTOM_DESCRIPTION, atk_object_get_description(found_obj)));
68 /* submenu with icons should have 7 children - one for each of 5 submenus,
69 * plus 1 for separator, which is shown as MENU ITEM with empty name
70 * plus 1 for nested ICON */
71 child_amount = atk_object_get_n_accessible_children(found_obj);
72 g_assert(7 == child_amount);
74 eailu_test_code_called = TRUE;
79 _init_menu(Evas_Object *win)
81 Evas_Object *menu, *button;
82 Elm_Object_Item *menu_it, *menu_it1;
84 menu = elm_menu_add(win);
85 elm_object_tree_focus_allow_set(win, EINA_TRUE);
88 (menu, NULL, NULL, T_MENU_ITEM_WITH_NO_CHILD_NAME, NULL, NULL);
89 menu_it = elm_menu_item_add
90 (menu, NULL, "mail-reply-all", T_MENU_WITH_SUB_AND_ICON_NAME,
93 (menu, menu_it, "object-rotate-left", T_SUBM_WITH_ICON_NAME, NULL, NULL);
95 button = elm_button_add(win);
96 elm_object_text_set(button, T_NESTED_BUTTON_NAME);
97 menu_it1 = elm_menu_item_add(menu, menu_it, NULL, NULL, NULL, NULL );
98 elm_object_item_content_set(menu_it1, button);
100 /* separator by atk is treated as empty MENU ITEM */
101 elm_menu_item_separator_add(menu, menu_it);
102 elm_menu_item_add(menu, menu_it, NULL, "third item (2nd lev)", NULL, NULL);
103 elm_menu_item_add(menu, menu_it, NULL, "fourth item (2nd lev)", NULL, NULL);
105 (menu, menu_it, "window-new", "sub menu (2nd lev)", NULL, NULL );
107 menu_it = elm_menu_item_add(menu, NULL, NULL, "third item", NULL, NULL );
108 elm_object_item_disabled_set(menu_it, EINA_TRUE );
110 evas_object_event_callback_add(win, EVAS_CALLBACK_MOUSE_DOWN, _show, menu);
111 evas_object_show(menu);
115 elm_main(int argc, char **argv)
119 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
122 evas_object_show(win);