2 * Tested interface: AtkObject
4 * Tested AtkObject: EailGengrid
6 * Description: Test AtkObject interface
8 * Test input: accessible object representing EailGengrid
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
18 INIT_TEST("EailGengrid")
20 typedef struct _Example_Item
25 static Elm_Gengrid_Item_Class *gic = NULL;
26 static Evas_Object *grid;
28 static const char *imgs[9] =
42 _grid_label_get(void *data, Evas_Object *obj, const char *part)
44 const Example_Item *it = data;
46 g_snprintf(buf, sizeof(buf), "Photo %s", it->path);
51 _grid_content_get(void *data, Evas_Object *obj, const char *part)
53 const Example_Item *it = data;
54 if (!strcmp(part, "elm.swallow.icon"))
56 Evas_Object *icon = elm_bg_add(obj);
58 g_snprintf(buf, sizeof(buf),"%s", it->path);
59 elm_bg_file_set(icon, buf, NULL);
60 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
61 evas_object_show(icon);
69 _grid_state_get(void *data, Evas_Object *obj, const char *part)
75 _grid_del(void *data, Evas_Object *obj)
77 Example_Item *it = data;
78 eina_stringshare_del(it->path);
83 _item_new(unsigned int index)
85 Example_Item *it = malloc(sizeof(*it));
87 it->path = eina_stringshare_add(imgs[index]);
89 it->path = eina_stringshare_add(imgs[0]);
93 void _on_selected(void *data, Evas_Object *obj, void *event_info)
95 _printf("selected item with handle: %p\n", event_info);
99 _print_object_info(AtkObject *obj)
101 AtkRole atk_role = atk_object_get_role(obj);
102 const char *name = atk_object_get_name(obj);
103 const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj));
104 const char *role_name = atk_role_get_name(atk_role);
106 _printf("atk_object_get_name: %s\n", name ? name : "NULL");
107 _printf("atk_object_get_role: %s\n", role_name ? role_name : "NULL");
108 _printf("atk_object_get_type_name: %s\n", type_name ? type_name : "NULL");
112 _do_test(AtkObject *obj)
114 int child_count = atk_object_get_n_accessible_children(obj);
116 g_assert(ATK_IS_OBJECT(obj));
118 atk_object_set_description(obj, "test");
119 g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
121 atk_object_set_name(obj, "test name");
122 g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
124 g_assert(atk_object_get_role(obj) == ATK_ROLE_TABLE);
126 for (int i = 0; i < child_count; i++)
128 AtkObject *child = atk_object_ref_accessible_child(obj, i);
129 _print_object_info(child);
131 g_object_unref(child);
134 eailu_test_code_called = 1;
136 static Ecore_Timer *timer_delay;
138 static Eina_Bool delay_test_run(void *data)
140 Eina_List *l, *list = elm_gengrid_realized_items_get(data);
143 Evas_Object *win = elm_object_parent_widget_get(data);
144 EINA_LIST_FOREACH(list, l, it)
147 elm_gengrid_item_pos_get(it, &x, &y);
150 _on_focus_in(NULL, win, NULL);
155 _init_gengrid(Evas_Object *win)
159 bg = elm_bg_add(win);
160 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
161 elm_win_resize_object_add(win, bg);
162 evas_object_show(bg);
163 grid = elm_gengrid_add(win);
165 elm_gengrid_item_size_set(grid, 200, 200);
166 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
167 elm_win_resize_object_add(win, grid);
168 evas_object_smart_callback_add(grid, "selected", _on_selected, NULL);
169 elm_gengrid_horizontal_set(grid, EINA_FALSE);
170 elm_gengrid_multi_select_set(grid, EINA_TRUE);
171 evas_object_show(grid);
175 gic = elm_gengrid_item_class_new();
176 gic->item_style = "default";
177 gic->func.text_get = _grid_label_get;
178 gic->func.content_get = _grid_content_get;
179 gic->func.state_get = _grid_state_get;
180 gic->func.del = _grid_del;
181 } // we only create the first time its needed. we dont unref/free
183 elm_gengrid_item_append(grid, gic, _item_new(0), NULL, NULL);
184 elm_gengrid_item_append(grid, gic, _item_new(1), NULL, NULL);
185 elm_gengrid_item_append(grid, gic, _item_new(2), NULL, NULL);
186 elm_gengrid_item_append(grid, gic, _item_new(3), NULL, NULL);
187 elm_gengrid_item_append(grid, gic, _item_new(4), NULL, NULL);
188 elm_gengrid_item_append(grid, gic, _item_new(5), NULL, NULL);
189 elm_gengrid_item_append(grid, gic, _item_new(6), NULL, NULL);
190 elm_gengrid_item_append(grid, gic, _item_new(7), NULL, NULL);
191 elm_gengrid_item_append(grid, gic, _item_new(8), NULL, NULL);
192 evas_object_resize(win, 800, 600);
196 elm_main(int argc, char **argv)
200 win = eailu_create_test_window_with_glib_init(_on_done, NULL);
202 evas_object_show(win);
204 timer_delay = ecore_timer_add(1, delay_test_run, grid);