Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_grid_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailGrid
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailGrid
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13
14 #include <Elementary.h>
15 #include <atk/atk.h>
16
17 #define DEBUG 1
18
19 #include "eail_test_utils.h"
20
21 INIT_TEST("EailGrid")
22
23 enum _slide_style
24 {
25    SLIDE_SHORT,
26    SLIDE_LONG,
27    SLIDE_BOUNCE,
28    SLIDE_STYLE_LAST
29 };
30
31 static void
32 _change_radio_cb(void *data, Evas_Object *obj, void *event)
33 {
34    Evas_Object *lb = (Evas_Object *)data;
35    int style = elm_radio_value_get((Evas_Object *)obj);
36
37    switch (style)
38      {
39       case SLIDE_SHORT:
40          _printf("change_radio: slide_short\n");
41          elm_object_style_set(lb, "slide_short");
42          break;
43
44       case SLIDE_LONG:
45          _printf("change_radio: slide_long\n");
46          elm_object_style_set(lb, "slide_long");
47          break;
48
49       case SLIDE_BOUNCE:
50          _printf("change_radio: slide_bounce\n");
51          elm_object_style_set(lb, "slide_bounce");
52          break;
53
54       default:
55          return;
56      }
57 }
58
59 static void
60 _change_slider_cb(void *data, Evas_Object *obj, void *event_info)
61 {
62    Evas_Object *lb = (Evas_Object *)data;
63    double val = elm_slider_value_get(obj);
64    elm_label_slide_duration_set(lb, val);
65 }
66
67 static void
68 _do_test(AtkObject *obj)
69 {
70    g_assert(ATK_IS_OBJECT(obj));
71    atk_object_set_description(obj, "test");
72    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
73
74    atk_object_set_name(obj, "test name");
75    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
76
77    g_assert(atk_object_get_role(obj) == ATK_ROLE_FILLER);
78    // test children
79    g_assert(8 == atk_object_get_n_accessible_children(obj));
80
81    eailu_test_code_called = 1;
82 }
83
84 static void
85 _init_grid(Evas_Object *win)
86 {
87    Evas_Object *bg, *gd, *lb, *rd, *rdg, *sl;
88
89    bg = elm_bg_add(win);
90    elm_win_resize_object_add(win, bg);
91    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92    evas_object_show(bg);
93
94    gd = elm_grid_add(win);
95    elm_grid_size_set(gd, 100, 100);
96    evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97    elm_win_resize_object_add(win, gd);
98    evas_object_show(gd);
99
100    lb = elm_label_add(win);
101    elm_object_text_set(lb, "Test Label Ellipsis:");
102    elm_grid_pack(gd, lb, 5, 5, 90, 10);
103    evas_object_show(lb);
104
105    lb = elm_label_add(win);
106    elm_object_text_set(lb,
107                        "This is a label set to ellipsis. "
108                        "If set ellipsis to true and the text doesn't fit "
109                        "in the label an ellipsis(\"...\") will be shown "
110                        "at the end of the widget."
111                       );
112
113    elm_label_ellipsis_set(lb, EINA_TRUE);
114    elm_grid_pack(gd, lb, 5, 15, 90, 10);
115    evas_object_show(lb);
116
117    lb = elm_label_add(win);
118    elm_object_text_set(lb, "Test Label Slide:");
119    elm_grid_pack(gd, lb, 5, 30, 90, 10);
120    evas_object_show(lb);
121
122    lb = elm_label_add(win);
123    elm_object_style_set(lb, "slide_short");
124    elm_object_text_set(lb,
125                        "This is a label set to slide. "
126                        "If set slide to true the text of the label "
127                        "will slide/scroll through the length of label."
128                        "This only works with the themes \"slide_short\", "
129                        "\"slide_long\" and \"slide_bounce\"."
130                       );
131    elm_grid_pack(gd, lb, 5, 40, 90, 10);
132    evas_object_show(lb);
133
134    rd = elm_radio_add(win);
135    elm_radio_state_value_set(rd, SLIDE_SHORT);
136    elm_object_text_set(rd, "slide_short");
137    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
138    evas_object_smart_callback_add(rd, "changed", _change_radio_cb, lb);
139    elm_grid_pack(gd, rd, 5, 50, 30, 10);
140    evas_object_show(rd);
141    rdg = rd;
142
143    rd = elm_radio_add(win);
144    elm_radio_state_value_set(rd, SLIDE_LONG);
145    elm_radio_group_add(rd, rdg);
146    elm_object_text_set(rd, "slide_long");
147    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
148    evas_object_smart_callback_add(rd, "changed", _change_radio_cb, lb);
149    elm_grid_pack(gd, rd, 35, 50, 30, 10);
150    evas_object_show(rd);
151
152    rd = elm_radio_add(win);
153    elm_radio_state_value_set(rd, SLIDE_BOUNCE);
154    elm_radio_group_add(rd, rdg);
155    elm_object_text_set(rd, "slide_bounce");
156    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
157    evas_object_smart_callback_add(rd, "changed", _change_radio_cb, lb);
158    elm_grid_pack(gd, rd, 65, 50, 30, 10);
159    evas_object_show(rd);
160
161    sl = elm_slider_add(win);
162    elm_object_text_set(sl, "Slide Duration");
163    elm_slider_unit_format_set(sl, "%1.1f units");
164    elm_slider_min_max_set(sl, 1, 20);
165    elm_slider_value_set(sl, 10);
166    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
167    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
168    evas_object_smart_callback_add(sl, "changed", _change_slider_cb, lb);
169    elm_grid_pack(gd, sl, 5, 60, 90, 10);
170    evas_object_show(sl);
171 }
172
173 EAPI_MAIN int
174 elm_main(int argc, char **argv)
175 {
176    Evas_Object *win;
177
178    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
179    g_assert(win);
180    _init_grid(win);
181    evas_object_show(win);
182    elm_run();
183    elm_shutdown();
184
185    return 0;
186 }
187 ELM_MAIN()