2 * Tested interface: AtkAction
4 * Tested AtkObject: EailSlideshow
6 * Description: Test AtkSelection interface
8 * Test input: accessible object representing EailSlideshow
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
18 INIT_TEST("EailSlideshow")
20 static Evas_Object *slideshow;
21 static Elm_Slideshow_Item_Class itc;
23 static char img1[256], img2[256], img3[256], img4[256], img5[256], img6[256],
24 img7[256], img8[256], img9[256];
26 /* get our images to make slideshow items */
31 Evas_Object *photo = elm_photo_add(obj);
32 elm_photo_file_set(photo, data);
33 elm_photo_fill_inside_set(photo, EINA_TRUE);
34 elm_object_style_set(photo, "shadow");
39 /* ordering alphabetically */
41 _cmp_func(const void *data1,
44 const char *img_path1, *img_path2;
46 const Elm_Object_Item *slide_it1 = data1;
47 const Elm_Object_Item *slide_it2 = data2;
49 img_path1 = elm_object_item_data_get(slide_it1);
50 img_path2 = elm_object_item_data_get(slide_it2);
52 return strcasecmp(img_path1, img_path2);
56 _do_test(AtkObject *obj)
58 int child_count, selection_count, action_count;
59 AtkObject *child, *selection;
61 const gchar *action_name, *action_description;
62 /*sometimes this is called several times*/
63 static int tested = 0;
64 if (tested > 0) return;
69 g_assert(eailu_is_object_with_role(obj, ATK_ROLE_DOCUMENT_PRESENTATION));
71 child_count = atk_object_get_n_accessible_children(obj);
72 g_assert(child_count == 9);
74 for (int i = 0; i < child_count; i++)
76 child = atk_object_ref_accessible_child(obj, i);
77 g_assert(eailu_is_object_with_role(child, ATK_ROLE_IMAGE));
78 g_object_unref(child);
81 /*test AtkSelectionIface*/
82 g_assert(ATK_IS_SELECTION(obj));
83 selection = atk_selection_ref_selection(ATK_SELECTION(obj), 0);
84 /*this may fail due to a problem with slideshow cache*/
85 g_assert(ATK_IS_OBJECT(selection));
86 g_assert(eailu_is_object_with_role(selection, ATK_ROLE_IMAGE));
87 g_object_unref(selection);
88 selection_count = atk_selection_get_selection_count(ATK_SELECTION(obj));
89 g_assert(selection_count == 1);
90 result = atk_selection_add_selection(ATK_SELECTION(obj), 5);
92 result = atk_selection_is_child_selected(ATK_SELECTION(obj), 5);
95 /*test AtkActionIface*/
96 g_assert(ATK_IS_ACTION(obj));
97 /* test set/get action description */
98 eailu_test_action_description_all(ATK_ACTION(obj));
99 action_count = atk_action_get_n_actions(ATK_ACTION(obj));
100 g_assert(4 == action_count);
101 action_name = atk_action_get_name(ATK_ACTION(obj), 0);
102 g_assert(!strcmp("next", action_name));
103 action_name = atk_action_get_name(ATK_ACTION(obj), 1);
104 g_assert(!strcmp("previous", action_name));
105 result = atk_action_set_description(ATK_ACTION(obj), 2,
106 "start the slideshow");
108 action_description = atk_action_get_description(ATK_ACTION(obj), 2);
109 g_assert(!strcmp("start the slideshow", action_description));
110 result = atk_action_do_action(ATK_ACTION(obj), 0);
112 result = atk_selection_is_child_selected(ATK_SELECTION(obj), 6);
115 eailu_test_atk_focus(obj, TRUE);
118 eailu_test_code_called = 1;
122 _init_slideshow(Evas_Object *win)
126 const char *data_dir;
129 g_snprintf(img1, sizeof(img1), "%s/01.jpg", data_dir);
130 g_snprintf(img2, sizeof(img2), "%s/02.jpg", data_dir);
131 g_snprintf(img3, sizeof(img3), "%s/03.jpg", data_dir);
132 g_snprintf(img4, sizeof(img4), "%s/04.jpg", data_dir);
133 g_snprintf(img5, sizeof(img5), "%s/05.jpg", data_dir);
134 g_snprintf(img6, sizeof(img6), "%s/06.jpg", data_dir);
135 g_snprintf(img7, sizeof(img7), "%s/07.jpg", data_dir);
136 g_snprintf(img8, sizeof(img8), "%s/08.jpg", data_dir);
137 g_snprintf(img9, sizeof(img9), "%s/09.jpg", data_dir);
139 evas_object_resize(win, 600, 400);
141 bg = elm_bg_add(win);
142 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 elm_win_resize_object_add(win, bg);
144 evas_object_show(bg);
146 slideshow = elm_slideshow_add(win);
147 elm_slideshow_loop_set(slideshow, EINA_TRUE);
148 elm_slideshow_cache_before_set(slideshow, 8);
149 elm_slideshow_cache_after_set(slideshow, 8);
150 evas_object_size_hint_weight_set(slideshow,
151 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
152 elm_win_resize_object_add(win, slideshow);
153 evas_object_show(slideshow);
158 elm_slideshow_item_sorted_insert(slideshow, &itc, img1, _cmp_func);
159 elm_slideshow_item_sorted_insert(slideshow, &itc, img2, _cmp_func);
160 elm_slideshow_item_sorted_insert(slideshow, &itc, img3, _cmp_func);
161 elm_slideshow_item_sorted_insert(slideshow, &itc, img4, _cmp_func);
162 elm_slideshow_item_sorted_insert(slideshow, &itc, img5, _cmp_func);
163 elm_slideshow_item_sorted_insert(slideshow, &itc, img6, _cmp_func);
164 elm_slideshow_item_sorted_insert(slideshow, &itc, img7, _cmp_func);
165 elm_slideshow_item_sorted_insert(slideshow, &itc, img8, _cmp_func);
166 elm_slideshow_item_sorted_insert(slideshow, &itc, img9, _cmp_func);
168 /*show last item, otherwise tests fail*/
169 it = elm_slideshow_item_nth_get(slideshow, 8);
170 elm_slideshow_item_show(it);
179 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
180 _init_slideshow(win);
182 evas_object_show(win);