summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-06-10 14:37:17 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-06-10 14:44:26 +0900
commit18eaa22d0126fd4f0ce3c384e626078b63918420 (patch)
treee4306005934961297d7eeb446566f05f4aaa7c42
parentc17b3d40a25f6a2202d15d278bc87e01246988dc (diff)
tests: Add test case for Grid.Static
This is copy of test_grid.c converted to EO.
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_grid_static.c199
3 files changed, 202 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 9034a8d068..eecee5b48e 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -795,6 +795,7 @@ bin/elementary/test_glview_simple.c \
795bin/elementary/test_glview.c \ 795bin/elementary/test_glview.c \
796bin/elementary/test_glview_manygears.c \ 796bin/elementary/test_glview_manygears.c \
797bin/elementary/test_grid.c \ 797bin/elementary/test_grid.c \
798bin/elementary/test_grid_static.c \
798bin/elementary/test_hover.c \ 799bin/elementary/test_hover.c \
799bin/elementary/test_hoversel.c \ 800bin/elementary/test_hoversel.c \
800bin/elementary/test_icon.c \ 801bin/elementary/test_icon.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 02d48c91ec..b43fad940e 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -239,6 +239,7 @@ void test_win_socket(void *data, Evas_Object *obj, void *event_info);
239void test_win_plug(void *data, Evas_Object *obj, void *event_info); 239void test_win_plug(void *data, Evas_Object *obj, void *event_info);
240void test_win_wm_rotation(void *data, Evas_Object *obj, void *event_info); 240void test_win_wm_rotation(void *data, Evas_Object *obj, void *event_info);
241void test_grid(void *data, Evas_Object *obj, void *event_info); 241void test_grid(void *data, Evas_Object *obj, void *event_info);
242void test_grid_static(void *data, Evas_Object *obj, void *event_info);
242void test_glview_simple(void *data, Evas_Object *obj, void *event_info); 243void test_glview_simple(void *data, Evas_Object *obj, void *event_info);
243void test_glview(void *data, Evas_Object *obj, void *event_info); 244void test_glview(void *data, Evas_Object *obj, void *event_info);
244void test_glview_manygears(void *data, Evas_Object *obj, void *event_info); 245void test_glview_manygears(void *data, Evas_Object *obj, void *event_info);
@@ -599,6 +600,7 @@ add_tests:
599 ADD_TEST(NULL, "New Containers", "Ui.Box", test_ui_box); 600 ADD_TEST(NULL, "New Containers", "Ui.Box", test_ui_box);
600 ADD_TEST(NULL, "New Containers", "Ui.Grid", test_ui_grid); 601 ADD_TEST(NULL, "New Containers", "Ui.Grid", test_ui_grid);
601 ADD_TEST(NULL, "New Containers", "Ui.Grid Linear", test_ui_grid_linear); 602 ADD_TEST(NULL, "New Containers", "Ui.Grid Linear", test_ui_grid_linear);
603 ADD_TEST(NULL, "New Containers", "Ui.Grid.Static", test_grid_static);
602 604
603 //------------------------------// 605 //------------------------------//
604 ADD_TEST(NULL, "New Events", "Event Refeed", test_events); 606 ADD_TEST(NULL, "New Events", "Event Refeed", test_events);
diff --git a/src/bin/elementary/test_grid_static.c b/src/bin/elementary/test_grid_static.c
new file mode 100644
index 0000000000..f171cfc0af
--- /dev/null
+++ b/src/bin/elementary/test_grid_static.c
@@ -0,0 +1,199 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7struct _Api_Data
8{
9 Eo *grid;
10 Eo *child;
11};
12typedef struct _Api_Data Api_Data;
13
14struct _api_data
15{
16 unsigned int state; /* What state we are testing */
17 Api_Data data;
18};
19typedef struct _api_data api_data;
20
21enum _api_state
22{
23 GRID_PACK_SET,
24 GRID_UNPACK,
25 GRID_SIZE,
26 GRID_CLEAR,
27 API_STATE_LAST
28};
29typedef enum _api_state api_state;
30
31static void
32set_api_state(api_data *api)
33{
34 Api_Data *dt = &api->data;
35 int w, h;
36
37 switch(api->state)
38 { /* Put all api-changes under switch */
39 case GRID_PACK_SET: /* 0 */
40 efl_pack_grid(dt->grid, dt->child, 5, 15, 60, 40);
41 break;
42
43 case GRID_UNPACK: /* 1 */
44 elm_grid_unpack(dt->grid, dt->child);
45 eo_del(dt->child);
46 break;
47
48 case GRID_SIZE: /* 2 */
49 efl_pack_grid_size_get(dt->grid, &w, &h);
50 printf("size w=<%d> h=<%d>\n", w, h);
51 w = h = 100; /* grid size returns wrong values */
52 w += 30;
53 h += 10;
54
55 efl_pack_grid_size_set(dt->grid, w, h);
56 break;
57
58 case GRID_CLEAR: /* 3 */
59 efl_pack_clear(dt->grid);
60 break;
61
62 default:
63 return;
64 }
65}
66
67static Eina_Bool
68_api_bt_clicked(void *data, const Eo_Event *ev)
69{ /* Will add here a SWITCH command containing code to modify test-object */
70 /* in accordance a->state value. */
71 api_data *a = data;
72 char str[128];
73
74 printf("clicked event on API Button: api_state=<%d>\n", a->state);
75 set_api_state(a);
76 a->state++;
77 sprintf(str, "Next API function (%u)", a->state);
78 elm_object_text_set(ev->object, str);
79 elm_object_disabled_set(ev->object, a->state == API_STATE_LAST);
80 return 1;
81}
82
83static Eina_Bool
84_ch_grid(void *data, const Eo_Event *ev)
85{
86 Eo *gd = data;
87 int x, y, w, h;
88
89 // FIXME: old elm_grid API doesn't need grid object
90 //elm_grid_pack_get(obj, &x, &y, &w, &h);
91 //elm_grid_pack_set(obj, x - 1, y - 1, w + 2, h + 2);
92 efl_pack_grid_position_get(gd, ev->object, &x, &y, &w, &h);
93 efl_pack_grid(gd, ev->object, x - 1, y - 1, w + 2, h + 2);
94 return 1;
95}
96
97static Eina_Bool
98_win_del(void *data, const Eo_Event *ev EINA_UNUSED)
99{
100 free(data);
101 return 1;
102}
103
104void
105test_grid_static(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
106{
107 Eo *win, *gd, *bt, *rc, *en;
108 api_data *api = calloc(1, sizeof(*api));
109
110 win = eo_add(EFL_UI_WIN_STANDARD_CLASS, NULL,
111 efl_ui_win_name_set(eo_self, "grid"),
112 efl_text_set(eo_self, "Grid"),
113 efl_ui_win_autodel_set(eo_self, EINA_TRUE),
114 eo_event_callback_add(eo_self, EO_EVENT_DEL, _win_del, api));
115
116 gd = eo_add(EFL_UI_GRID_STATIC_CLASS, win,
117 efl_gfx_size_hint_weight_set(eo_self, 1, 1));
118 efl_pack(win, gd);
119 api->data.grid = gd;
120 efl_gfx_visible_set(gd, 1);
121
122 /* FIXME: EO-ify entry & button & test_set! */
123
124 en = elm_entry_add(win);
125 elm_entry_scrollable_set(en, EINA_TRUE);
126 elm_object_text_set(en, "Entry text");
127 elm_entry_single_line_set(en, EINA_TRUE);
128 efl_pack_grid(gd, en, 50, 10, 40, 10);
129 efl_gfx_visible_set(en, 1);
130
131 en = elm_entry_add(win);
132 elm_entry_scrollable_set(en, EINA_TRUE);
133 elm_object_text_set(en, "Entry text 2");
134 elm_entry_single_line_set(en, EINA_TRUE);
135 efl_pack_grid(gd, en, 60, 20, 30, 10);
136 efl_gfx_visible_set(en, 1);
137
138 bt = elm_button_add(win);
139 elm_object_text_set(bt, "Next API function");
140 eo_event_callback_add(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _api_bt_clicked, api);
141 efl_pack_grid(gd, bt, 30, 0, 40, 10);
142 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
143 efl_gfx_visible_set(bt, 1);
144
145 bt = elm_button_add(win);
146 elm_object_text_set(bt, "Button");
147 efl_pack_grid(gd, bt, 0, 0, 20, 20);
148 efl_gfx_visible_set(bt, 1);
149
150 bt = elm_button_add(win);
151 elm_object_text_set(bt, "Button");
152 efl_pack_grid(gd, bt, 10, 10, 40, 20);
153 api->data.child = bt;
154 efl_gfx_visible_set(bt, 1);
155
156 bt = elm_button_add(win);
157 elm_object_text_set(bt, "Button");
158 efl_pack_grid(gd, bt, 10, 30, 20, 50);
159 efl_gfx_visible_set(bt, 1);
160
161 bt = elm_button_add(win);
162 elm_object_text_set(bt, "Button");
163 efl_pack_grid(gd, bt, 80, 80, 20, 20);
164 efl_gfx_visible_set(bt, 1);
165
166 bt = elm_button_add(win);
167 elm_object_text_set(bt, "Change");
168 efl_pack_grid(gd, bt, 40, 40, 20, 20);
169 eo_event_callback_add(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _ch_grid, gd);
170 efl_gfx_visible_set(bt, 1);
171
172 rc = eo_add(EFL_CANVAS_RECTANGLE_CLASS, win);
173 efl_gfx_color_set(rc, 128, 0, 0, 128);
174 efl_pack_grid(gd, rc, 40, 70, 20, 10);
175 efl_gfx_visible_set(rc, 1);
176
177 rc = eo_add(EFL_CANVAS_RECTANGLE_CLASS, win);
178 efl_gfx_color_set(rc, 0, 128, 0, 128);
179 efl_pack_grid(gd, rc, 60, 70, 10, 10);
180 efl_gfx_visible_set(rc, 1);
181
182 rc = eo_add(EFL_CANVAS_RECTANGLE_CLASS, win);
183 efl_gfx_color_set(rc, 0, 0, 128, 128);
184 efl_pack_grid(gd, rc, 40, 80, 10, 10);
185 efl_gfx_visible_set(rc, 1);
186
187 rc = eo_add(EFL_CANVAS_RECTANGLE_CLASS, win);
188 efl_gfx_color_set(rc, 128, 0, 128, 128);
189 efl_pack_grid(gd, rc, 50, 80, 10, 10);
190 efl_gfx_visible_set(rc, 1);
191
192 rc = eo_add(EFL_CANVAS_RECTANGLE_CLASS, win);
193 efl_gfx_color_set(rc, 128, 64, 0, 128);
194 efl_pack_grid(gd, rc, 60, 80, 10, 10);
195 efl_gfx_visible_set(rc, 1);
196
197 efl_gfx_size_set(win, 480, 480);
198 efl_gfx_visible_set(win, 1);
199}