Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_file_selector_button_tc1.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailFileselector
5  *
6  * Description: Test AtkAction interface
7  *
8  * Test input: accessible object representing EailFileselector
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 3
19 #define EAIL_LABEL_FOR_FSB "File selector button"
20
21 static int action_test_passed;
22
23 INIT_TEST("EailButton")
24
25 static void
26 _on_click(void *data, Evas_Object *obj, void *event_info)
27 {
28    _printf("fileselector button click\n");
29    action_test_passed++;
30 }
31
32 static void
33 _on_press(void *data, Evas_Object *obj, void *event_info)
34 {
35    _printf("fileselector button press\n");
36    action_test_passed++;
37 }
38
39 static void
40 _on_release(void *data, Evas_Object *obj, void *event_info)
41 {
42    _printf("fileselector button release\n");
43    action_test_passed++;
44 }
45
46 static void
47 _do_test(AtkObject *obj)
48 {
49    _printf("Testing FileSelectorButton instance....\n");
50
51    g_assert(ATK_IS_OBJECT(obj));
52    g_assert(ATK_IS_ACTION(obj));
53
54    g_assert(ACTIONS_NUMBER == atk_action_get_n_actions(ATK_ACTION(obj)));
55    eailu_test_action_activate(ATK_ACTION(obj), "click");
56    eailu_test_action_activate(ATK_ACTION(obj), "press");
57    eailu_test_action_activate(ATK_ACTION(obj), "release");
58    g_assert((eailu_get_action_number(ATK_ACTION(obj), "typo")) == -1);
59
60    eailu_test_atk_focus(obj, TRUE);
61
62    _printf("DONE. All FileSelectorButton test passed successfully \n");
63
64    g_assert(action_test_passed == 3);
65
66    eailu_test_code_called = 1;
67 }
68
69 static void
70 _init_file_selector_button(Evas_Object *win)
71 {
72    Evas_Object *fs_button, *vbox, *icon;
73
74    vbox = elm_box_add(win);
75    elm_win_resize_object_add(win, vbox);
76    evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77    evas_object_show(vbox);
78
79    icon = elm_icon_add(win);
80    elm_icon_standard_set(icon, "file");
81    evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
82
83    /* file selector button */
84    fs_button = elm_fileselector_button_add(win);
85    elm_fileselector_button_path_set(fs_button, "/tmp");
86    elm_object_text_set(fs_button, EAIL_LABEL_FOR_FSB);
87    elm_object_part_content_set(fs_button, "icon", icon);
88    evas_object_smart_callback_add(fs_button, "clicked", _on_click, NULL);
89    evas_object_smart_callback_add(fs_button, "pressed", _on_press, NULL);
90    evas_object_smart_callback_add(fs_button, "unpressed", _on_release, NULL);
91
92    elm_box_pack_end(vbox, fs_button);
93    evas_object_show(fs_button);
94    evas_object_resize(win, 300, 300);
95 }
96
97 EAPI_MAIN int
98 elm_main(int argc, char **argv)
99 {
100    Evas_Object *win;
101
102    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
103    _init_file_selector_button(win);
104    evas_object_show(win);
105    elm_run();
106    elm_shutdown();
107
108    return 0;
109 }
110 ELM_MAIN()