2 * Tested interface: AtkObject
4 * Tested AtkObject: EailNaviframePage
6 * Description: Test AtkAction interface
8 * Test input: accessible object representing EailNaviframePage
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
18 INIT_TEST("EailNaviframe")
20 #define BUTTON_TEXT_SET(BT, TEXT) \
21 elm_object_text_set((BT), (TEXT)); \
22 elm_object_tooltip_text_set((BT), (TEXT)); \
23 elm_object_tooltip_window_mode_set((BT), EINA_TRUE)
25 #define PACKAGE_DATA_DIR "./data"
27 static const char *img1 = PACKAGE_DATA_DIR "/whiterabbit01.jpg";
28 static const char *img2 = PACKAGE_DATA_DIR "/01.jpg";
29 static const char *img3 = PACKAGE_DATA_DIR "/02.jpg";
30 static const char *img4 = PACKAGE_DATA_DIR "/03.jpg";
31 static const char *img5 = PACKAGE_DATA_DIR "/04.jpg";
32 static const char *img8 = PACKAGE_DATA_DIR "/small-01.jpg";
35 _content_new(Evas_Object *parent, const char *img)
37 Evas_Object *photo = elm_photo_add(parent);
38 elm_photo_file_set(photo, img);
39 elm_photo_fill_inside_set(photo, EINA_TRUE);
40 elm_object_style_set(photo, "shadow");
45 _page5(Evas_Object *nf)
47 Evas_Object *bt, *bt2, *content;
50 bt = elm_button_add(nf);
51 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
52 BUTTON_TEXT_SET(bt, "Page 4");
54 bt2 = elm_button_add(nf);
55 evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
56 BUTTON_TEXT_SET(bt2, "Page 1");
58 content = _content_new(nf, img5);
59 it = elm_naviframe_item_insert_after(nf,
60 elm_naviframe_top_item_get(nf),
66 elm_object_item_part_text_set(it, "subtitle",
67 "This page is inserted without transition");
69 evas_object_data_set(nf, "page5", it);
70 elm_naviframe_item_promote(it);
74 _page4(Evas_Object *nf)
76 Evas_Object *bt, *ic, *content;
80 ic = elm_icon_add(nf);
81 elm_icon_standard_set(ic, "arrow_right");
83 bt = elm_button_add(nf);
84 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
85 elm_layout_content_set(bt, "icon", ic);
87 content = _content_new(nf, img4);
89 it = elm_naviframe_item_push(nf,
95 elm_object_item_part_text_set(it, "subtitle", "Title area visibility test");
97 ic = elm_icon_add(nf);
98 g_snprintf(buf, sizeof(buf), "%s",
100 elm_image_file_set(ic, buf, NULL);
101 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
102 elm_object_item_part_content_set(it, "icon", ic);
103 elm_naviframe_item_title_visible_set(it, EINA_FALSE);
105 evas_object_data_set(nf, "page4", it);
109 _page3(Evas_Object *nf)
111 Evas_Object *bt2, *ic, *content;
115 bt2 = elm_button_add(nf);
116 evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
117 BUTTON_TEXT_SET(bt2, "Next");
119 content = _content_new(nf, img3);
121 it = elm_naviframe_item_push(nf,
127 ic = elm_icon_add(nf);
128 g_snprintf(buf, sizeof(buf), "%s", img8);
129 elm_image_file_set(ic, buf, NULL);
130 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
132 elm_object_item_part_content_set(it, "icon", ic);
134 evas_object_data_set(nf, "page3", it);
138 _page2(Evas_Object *nf)
140 Evas_Object *bt, *content, *ic;
143 bt = elm_button_add(nf);
144 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
146 ic = elm_icon_add(nf);
147 elm_icon_standard_set(ic, "arrow_right");
148 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
149 elm_layout_content_set(bt, "icon", ic);
151 content = _content_new(nf, img2);
153 it = elm_naviframe_item_push(nf, "Page 2 - Long Title Here",
154 NULL, bt, content, NULL);
155 elm_object_item_part_text_set(it, "subtitle", "Here is sub-title part!");
156 evas_object_data_set(nf, "page2", it);
161 _page1(Evas_Object *nf)
163 Evas_Object *btn, *content;
166 btn = elm_button_add(nf);
167 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
168 BUTTON_TEXT_SET(btn, "Next");
169 evas_object_show(btn);
171 content = _content_new(nf, img1);
172 it = elm_naviframe_item_push(nf, "Page 1", NULL, btn, content, NULL);
173 evas_object_data_set(nf, "page1", it);
178 _test_naviframe_page(AtkObject *obj, int index)
180 int child_count = atk_object_get_n_accessible_children(obj);
182 atk_object_set_description(obj, "test");
183 g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
185 g_assert(child_count > 0);
186 AtkStateSet *state_set = atk_object_ref_state_set(obj);
189 AtkStateType states[3] = {ATK_STATE_SHOWING, ATK_STATE_VISIBLE,
191 /*we are showing last page*/
192 gboolean contains = atk_state_set_contains_states(state_set, states, 3);
195 g_object_unref(state_set);
197 int index_in_parent = atk_object_get_index_in_parent(obj);
198 g_assert(index_in_parent == index);
200 /*check if last child is naviframe page content*/
201 AtkObject *child = atk_object_ref_accessible_child(obj, child_count - 1);
202 g_assert(eailu_is_object_with_type(child, "EailPhoto"));
203 g_object_unref(child);
205 AtkObject *parent = atk_object_get_parent(obj);
206 g_object_ref(parent);
207 g_assert(ATK_IS_OBJECT(parent));
208 g_assert(eailu_is_object_with_type(parent, "EailNaviframe"));
209 g_object_unref(parent);
216 atk_component_get_extents(ATK_COMPONENT(obj),
222 g_assert(height > 0);
228 _do_test(AtkObject *obj)
233 child_count = atk_object_get_n_accessible_children(obj);
234 g_assert(child_count == 5);
236 for (int i = 0; i < child_count; i++)
238 AtkObject *child = atk_object_ref_accessible_child(obj, i);
239 g_assert(ATK_IS_OBJECT(child));
240 g_assert(eailu_is_object_with_type(child, "EailNaviframePage"));
241 g_assert(ATK_ROLE_PAGE_TAB == atk_object_get_role(child));
242 _test_naviframe_page(child, i);
243 g_object_unref(child);
247 eailu_test_code_called = 1;
251 _init_naviframe(Evas_Object *win)
255 nf = elm_naviframe_add(win);
256 evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257 elm_win_resize_object_add(win, nf);
258 evas_object_show(nf);
266 evas_object_resize(win, 800, 600);
270 elm_main(int argc, char **argv)
273 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
274 _init_naviframe(win);
275 evas_object_show(win);