Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_ctxpopup_tc2.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailCtxpopup
5  *
6  * Description: Test AtkAction interface
7  *
8  * Test input: accessible object representing EailCtxpopup
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13 #include <Elementary.h>
14 #include <atk/atk.h>
15
16 #include "eail_test_utils.h"
17
18 #define ACTIONS_NUMBER 1
19
20 INIT_TEST("EailCtxpopup")
21
22 static void
23 _do_test(AtkObject *obj)
24 {
25    _printf("Testing ctxpopup instance....\n");
26
27    g_assert(ATK_IS_ACTION(obj));
28    g_assert(ACTIONS_NUMBER == atk_action_get_n_actions(ATK_ACTION(obj)));
29    eailu_test_action_activate(ATK_ACTION(obj), "dismiss");
30    g_assert((eailu_get_action_number(ATK_ACTION(obj), "typo")) == -1);
31    eailu_test_action_description_all(ATK_ACTION(obj));
32
33    _printf("Tests passed successfully\n");
34
35    eailu_test_code_called = 1;
36 }
37
38 static void
39 _ctxpopup_item_cb(void *data, Evas_Object *obj, void *event_info)
40 {
41    _printf("ctxpopup item selected: %s\n", elm_object_item_text_get(event_info));
42 }
43
44 Elm_Object_Item *item_new(Evas_Object *ctxpopup, const char * label, const char *icon)
45 {
46    Evas_Object *ic = elm_icon_add(ctxpopup);
47    elm_icon_standard_set(ic, icon);
48    elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
49    return elm_ctxpopup_item_append(ctxpopup, label, ic, _ctxpopup_item_cb, NULL);
50 }
51
52 static void
53 _init_ctxpopup(Evas_Object *win)
54 {
55    Evas_Object *ctxpopup, *box;
56    Elm_Object_Item *object_it;
57
58    box = elm_box_add(win);
59    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60    elm_win_resize_object_add(win, box);
61    evas_object_show(box);
62
63    ctxpopup = elm_ctxpopup_add(win);
64    item_new(ctxpopup, "Go to home folder", "home");
65    item_new(ctxpopup, "Save file", "file");
66    item_new(ctxpopup, "Delete file", "delete");
67    object_it = item_new(ctxpopup, "Navigate to folder", "folder");
68    elm_object_item_disabled_set(object_it, EINA_TRUE);
69    item_new(ctxpopup, "Edit entry", "edit");
70    object_it = item_new(ctxpopup, "Set date and time", "clock");
71
72    evas_object_size_hint_weight_set(ctxpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73    evas_object_show(ctxpopup);
74    elm_box_pack_end(box, ctxpopup);
75 }
76
77 EAPI_MAIN int
78 elm_main(int argc, char **argv)
79 {
80    Evas_Object *win;
81
82    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
83    _init_ctxpopup(win);
84    evas_object_show(win);
85    elm_run();
86    elm_shutdown();
87
88    return 0;
89 }
90 ELM_MAIN()