Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_layout_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailLayout
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailLayout
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("EailLayout")
19
20 static void
21 _do_test(AtkObject *object)
22 {
23    int child_count;
24
25    atk_object_set_description(object, "test");
26    g_assert_cmpstr(atk_object_get_description(object), ==, "test");
27
28    atk_object_set_name(object, "test name");
29    g_assert_cmpstr(atk_object_get_name(object), ==, "test name");
30
31    eailu_test_code_called++;
32    child_count = atk_object_get_n_accessible_children(object);
33    if (eailu_test_code_called == 1)
34      g_assert(2 == child_count);
35    else
36      g_assert(3 == child_count);
37
38    for(int i =0; i < child_count; i++)
39      {
40         AtkObject *child = atk_object_ref_accessible_child(object, i);
41         gboolean success = FALSE;
42         if (eailu_test_code_called == 1)
43           success = eailu_is_object_with_role(child, ATK_ROLE_ICON);
44         else
45           success = eailu_is_object_with_role(child, ATK_ROLE_PUSH_BUTTON);
46         g_object_unref(child);
47         g_assert(success);
48      }
49
50    g_assert(eailu_is_object_with_role(object, ATK_ROLE_FILLER));
51    g_assert(2 >= eailu_test_code_called);
52 }
53
54
55 static void
56 _init_layout(Evas_Object *win)
57 {
58    Evas_Object *box, *ly, *bt;
59    char buf[PATH_MAX];
60
61    box = elm_box_add(win);
62    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63    elm_win_resize_object_add(win, box);
64    evas_object_show(box);
65
66    ly = elm_layout_add(win);
67
68    if (!elm_layout_theme_set(
69            ly, "layout", "application", "titlebar"))
70      fprintf(stderr, "Failed to set layout");
71
72    elm_object_part_text_set(ly, "elm.text", "Some title");
73    evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74    evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
75    elm_box_pack_end(box, ly);
76    evas_object_show(ly);
77
78    bt = elm_icon_add(win);
79    elm_icon_standard_set(bt, "chat");
80    evas_object_size_hint_min_set(bt, 20, 20);
81    elm_layout_icon_set(ly, bt);
82
83    bt = elm_icon_add(win);
84    elm_icon_standard_set(bt, "close");
85    evas_object_size_hint_min_set(bt, 20, 20);
86    elm_layout_end_set(ly, bt);
87
88    ly = elm_layout_add(win);
89    g_snprintf(buf, sizeof(buf), "%s/test.edj","./data/");
90    elm_layout_file_set(ly, buf, "layout");
91    evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92    elm_box_pack_end(box, ly);
93    evas_object_show(ly);
94
95    bt = elm_button_add(win);
96    elm_object_text_set(bt, "Button 1");
97    elm_object_part_content_set(ly, "element1", bt);
98    evas_object_show(bt);
99
100    bt = elm_button_add(win);
101    elm_object_text_set(bt, "Button 2");
102    elm_object_part_content_set(ly, "element2", bt);
103    evas_object_show(bt);
104
105    bt = elm_button_add(win);
106    elm_object_text_set(bt, "Button 3");
107    elm_object_part_content_set(ly, "element3", bt);
108    evas_object_show(bt);
109
110    evas_object_show(win);
111 }
112
113 EAPI_MAIN int
114 elm_main(int argc, char **argv)
115 {
116    Evas_Object *win;
117
118    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
119    _init_layout(win);
120    elm_run();
121    elm_shutdown();
122
123    return 0;
124 }
125 ELM_MAIN()
126
127