Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_naviframe_tc2.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailNaviframe
5  *
6  * Description: Test AtkAction interface
7  *
8  * Test input: accessible object representing EailNaviframe
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 INIT_TEST("EailNaviframe")
19
20 #include "eail_test_utils.h"
21
22 #define BUTTON_TEXT_SET(BT, TEXT) \
23    elm_object_text_set((BT), (TEXT)); \
24    elm_object_tooltip_text_set((BT), (TEXT)); \
25    elm_object_tooltip_window_mode_set((BT), EINA_TRUE)
26
27 #define PACKAGE_DATA_DIR "./data"
28
29 static const char *img1 = PACKAGE_DATA_DIR "/whiterabbit01.jpg";
30 static const char *img2 = PACKAGE_DATA_DIR "/01.jpg";
31 static const char *img3 = PACKAGE_DATA_DIR "/02.jpg";
32 static const char *img4 = PACKAGE_DATA_DIR "/03.jpg";
33 static const char *img5 = PACKAGE_DATA_DIR "/04.jpg";
34 static const char *img8 = PACKAGE_DATA_DIR "/small-01.jpg";
35
36 static int action_test_passed;
37
38 Evas_Object *
39 _content_new(Evas_Object *parent, const char *img)
40 {
41    Evas_Object *photo = elm_photo_add(parent);
42    elm_photo_file_set(photo, img);
43    elm_photo_fill_inside_set(photo, EINA_TRUE);
44    elm_object_style_set(photo, "shadow");
45    return photo;
46 }
47
48 static void
49 _page5(Evas_Object *nf)
50 {
51    Evas_Object *bt, *bt2, *content;
52    Elm_Object_Item *it;
53
54    bt = elm_button_add(nf);
55    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
56    BUTTON_TEXT_SET(bt, "Page 4");
57
58    bt2 = elm_button_add(nf);
59    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
60    BUTTON_TEXT_SET(bt2, "Page 1");
61
62    content = _content_new(nf, img5);
63    it = elm_naviframe_item_insert_after(nf,
64                                         elm_naviframe_top_item_get(nf),
65                                         "Page 5",
66                                         bt,
67                                         bt2,
68                                         content,
69                                         NULL);
70    elm_object_item_part_text_set(it, "subtitle",
71                                  "This page is inserted without transition");
72
73    evas_object_data_set(nf, "page5", it);
74    elm_naviframe_item_promote(it);
75 }
76
77 static void
78 _page4(Evas_Object *nf)
79 {
80    Evas_Object *bt, *ic, *content;
81    char buf[PATH_MAX];
82    Elm_Object_Item *it;
83
84    ic = elm_icon_add(nf);
85    elm_icon_standard_set(ic, "arrow_right");
86
87    bt = elm_button_add(nf);
88    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
89    elm_layout_content_set(bt, "icon", ic);
90
91    content = _content_new(nf, img4);
92
93    it = elm_naviframe_item_push(nf,
94                                 "Page 4",
95                                 NULL,
96                                 bt,
97                                 content,
98                                 NULL);
99    elm_object_item_part_text_set(it, "subtitle", "Title area visibility test");
100
101    ic = elm_icon_add(nf);
102    g_snprintf(buf, sizeof(buf), "%s",
103             img8);
104    elm_image_file_set(ic, buf, NULL);
105    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
106    elm_object_item_part_content_set(it, "icon", ic);
107    elm_naviframe_item_title_visible_set(it, EINA_FALSE);
108
109    evas_object_data_set(nf, "page4", it);
110 }
111
112 static void
113 _page3(Evas_Object *nf)
114 {
115    Evas_Object *bt2, *ic, *content;
116    char buf[PATH_MAX];
117    Elm_Object_Item *it;
118
119    bt2 = elm_button_add(nf);
120    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
121    BUTTON_TEXT_SET(bt2, "Next");
122
123    content = _content_new(nf, img3);
124
125    it = elm_naviframe_item_push(nf,
126                                 "Page 3",
127                                 NULL,
128                                 bt2,
129                                 content,
130                                 NULL);
131    ic = elm_icon_add(nf);
132    g_snprintf(buf, sizeof(buf), "%s", img8);
133    elm_image_file_set(ic, buf, NULL);
134    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
135
136    elm_object_item_part_content_set(it, "icon", ic);
137
138    evas_object_data_set(nf, "page3", it);
139 }
140
141 static void
142 _page2(Evas_Object *nf)
143 {
144    Evas_Object *bt, *content, *ic;
145    Elm_Object_Item *it;
146
147    bt = elm_button_add(nf);
148    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
149
150    ic = elm_icon_add(nf);
151    elm_icon_standard_set(ic, "arrow_right");
152    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
153    elm_layout_content_set(bt, "icon", ic);
154
155    content = _content_new(nf, img2);
156
157    it = elm_naviframe_item_push(nf, "Page 2 - Long Title Here",
158                                 NULL, bt, content,  NULL);
159    elm_object_item_part_text_set(it, "subtitle", "Here is sub-title part!");
160    evas_object_data_set(nf, "page2", it);
161
162 }
163
164 static void
165 _page1(Evas_Object *nf)
166 {
167    Evas_Object *btn, *content;
168    Elm_Object_Item *it;
169
170    btn = elm_button_add(nf);
171    evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
172    BUTTON_TEXT_SET(btn, "Next");
173    evas_object_show(btn);
174
175    content = _content_new(nf, img1);
176    it = elm_naviframe_item_push(nf, "Page 1", NULL, btn, content, NULL);
177    evas_object_data_set(nf, "page1", it);
178 }
179
180 static void
181 _title_clicked(void *data, Evas_Object *obj, void *event_info)
182 {
183    _printf("Title Clicked!\n");
184    ++action_test_passed;
185 }
186
187 static void
188 _do_test(AtkObject *obj)
189 {
190    AtkAction *action;
191    const char *action_name, *desc;
192    gboolean result;
193    int actions_n;
194
195    g_assert(ATK_IS_ACTION(obj));
196    action = ATK_ACTION(obj);
197    actions_n = atk_action_get_n_actions(action);
198    _printf("action count %d\n", atk_action_get_n_actions(action));
199    g_assert(actions_n == 1);
200    action_name = atk_action_get_name(action, 0);
201    g_assert(!strcmp("click", action_name));
202    result = atk_action_set_description(action, 0, "click_title description");
203    g_assert(result);
204    desc = atk_action_get_description(action, 0);
205    g_assert(!strcmp(desc, "click_title description"));
206    result = atk_action_do_action(action, 0);
207    g_assert(result);
208
209    g_object_unref(obj);
210    g_assert(action_test_passed);
211
212    eailu_test_code_called = 1;
213 }
214
215 static void
216 _init_naviframe(Evas_Object *win)
217 {
218     Evas_Object *nf;
219
220    nf = elm_naviframe_add(win);
221    evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
222    elm_win_resize_object_add(win, nf);
223    evas_object_show(nf);
224    evas_object_smart_callback_add(nf, "title,clicked", _title_clicked, 0);
225
226    _page1(nf);
227    _page2(nf);
228    _page3(nf);
229    _page4(nf);
230    _page5(nf);
231
232    evas_object_resize(win, 800, 600);
233 }
234
235 EAPI_MAIN int
236 elm_main(int argc, char **argv)
237 {
238    Evas_Object *win;
239    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
240    _init_naviframe(win);
241    evas_object_show(win);
242
243    elm_run();
244    elm_shutdown();
245
246    return 0;
247 }
248 ELM_MAIN()