Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_list_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailList
5  *
6  * Description: Test whether accessible object is successfully registered
7  *    in GObject type system and is visible in AtkObject tree. Test
8  *    accessible children availability. Test focus.
9  *
10  * Test input: accessible object representing EailList
11  *
12  * Expected test result: test should return 0 (success)
13  */
14
15 #include <Elementary.h>
16 #include <atk/atk.h>
17
18 #include "eail_test_utils.h"
19
20 INIT_TEST("EailList")
21
22 static Evas_Object *glob_elm_list = NULL;
23
24 void
25 _do_test(AtkObject *aobj)
26 {
27    int child_amount = 0, i = 0;
28
29    g_assert(ATK_IS_OBJECT(aobj));
30
31    g_assert(atk_object_get_role(aobj) == ATK_ROLE_LIST);
32
33    child_amount = atk_object_get_n_accessible_children(aobj);
34    g_assert(7 == child_amount);
35
36    /* For list widget focusing work */
37    eailu_test_atk_focus(aobj, TRUE);
38
39    /* checking list items implementation */
40      for (i = 0; i < child_amount; i++)
41       {
42          AtkObject *child = atk_object_ref_accessible_child(aobj, i);
43          _printf("Child amount %d\n", atk_object_get_n_accessible_children(child));
44          g_assert(2 == atk_object_get_n_accessible_children(child));
45
46          g_object_unref(child);
47        }
48
49    eailu_test_code_called = 1;
50 }
51
52 void
53 _init_list(Evas_Object *win)
54 {
55    Evas_Object *box, *entry;
56    int i = 0;
57
58    static const char *lbl[] =
59       {
60          "Sunday",
61          "Monday",
62          "Tuesday",
63          "Wednesday",
64          "Thursday",
65          "Friday",
66          "Saturday"
67       };
68
69    box = elm_box_add(win);
70    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71    elm_win_resize_object_add(win, box);
72    evas_object_show(box);
73
74    glob_elm_list = elm_list_add(win);
75    evas_object_size_hint_weight_set(glob_elm_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
76    evas_object_size_hint_align_set(glob_elm_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
77    elm_object_tree_focus_allow_set(win, EINA_TRUE);
78
79    entry = elm_entry_add(win);
80    elm_entry_single_line_set(entry, EINA_TRUE);
81    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
82    evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
83    evas_object_show(entry);
84
85    for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
86      elm_list_item_append(glob_elm_list, lbl[i], entry, entry, NULL, NULL);
87
88    elm_box_pack_end(box, glob_elm_list);
89
90    elm_list_go(glob_elm_list);
91    evas_object_show(glob_elm_list);
92 }
93
94 EAPI_MAIN int
95 elm_main(int argc, char **argv)
96 {
97    Evas_Object *win;
98
99    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
100    _init_list(win);
101
102    /* and show the window */
103    evas_object_show(win);
104
105    elm_run();
106    elm_shutdown();
107
108    /* exit code */
109    return 0;
110 }
111 ELM_MAIN()