summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-07-03 12:00:33 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-07-03 21:40:03 +0200
commit9622146c3d5ae6cc8f7810136f569575c17c4ec0 (patch)
tree98a99d2d200b98f339ec4b59c431d155e542840f
parenta9426e09ee03bc09492596dd0bad58b79780e677 (diff)
elementary: add test for edje external combobox
-rw-r--r--data/elementary/objects/test_external.edc36
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_external.c75
3 files changed, 113 insertions, 0 deletions
diff --git a/data/elementary/objects/test_external.edc b/data/elementary/objects/test_external.edc
index 27802f4047..3a77ef06a1 100644
--- a/data/elementary/objects/test_external.edc
+++ b/data/elementary/objects/test_external.edc
@@ -1177,4 +1177,40 @@ embryo script and from C code.";
1177 1177
1178 } 1178 }
1179 } 1179 }
1180
1181 group { name: "external/combobox";
1182 parts {
1183 COMMON_EXTERNAL_UNDER
1184 part { name: "combobox"; type: EXTERNAL;
1185 source: "elm/combobox";
1186 clip_to: "clip";
1187 description { state: "default" 0.0;
1188 rel2.relative: 1.0 0.0;
1189 align: 0.5 0.0;
1190 params {
1191 string: "guide" "Widgets";
1192 }
1193 }
1194 }
1195 part { name: "info"; type: TEXT;
1196 clip_to: "clip";
1197 description { state: "default" 0.;
1198 rel1 {
1199 to: "combobox";
1200 relative: 0.0 1.0;
1201 }
1202 text {
1203 text: "";
1204 font: "Sans";
1205 size: 24;
1206 align: 0.5 1.0;
1207 }
1208 }
1209 }
1210 COMMON_EXTERNAL_OVER
1211 }
1212 programs {
1213 COMMON_EXTERNAL_PROGRAM
1214 }
1215 }
1180} 1216}
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index f40de25af3..b884129bbe 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -264,6 +264,7 @@ void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
264void test_external_pbar(void *data, Evas_Object *obj, void *event_info); 264void test_external_pbar(void *data, Evas_Object *obj, void *event_info);
265void test_external_video(void *data, Evas_Object *obj, void *event_info); 265void test_external_video(void *data, Evas_Object *obj, void *event_info);
266void test_external_icon(void *data, Evas_Object *obj, void *event_info); 266void test_external_icon(void *data, Evas_Object *obj, void *event_info);
267void test_external_combobox(void *data, Evas_Object *obj, void *event_info);
267void test_config(void *data, Evas_Object *obj, void *event_info); 268void test_config(void *data, Evas_Object *obj, void *event_info);
268void test_video(void *data, Evas_Object *obj, void *event_info); 269void test_video(void *data, Evas_Object *obj, void *event_info);
269void test_eio(void *data, Evas_Object *obj, void *event_info); 270void test_eio(void *data, Evas_Object *obj, void *event_info);
@@ -680,6 +681,7 @@ add_tests:
680 ADD_TEST(NULL, "Edje External", "ExtSlider", test_external_slider); 681 ADD_TEST(NULL, "Edje External", "ExtSlider", test_external_slider);
681 ADD_TEST(NULL, "Edje External", "ExtVideo", test_external_video); 682 ADD_TEST(NULL, "Edje External", "ExtVideo", test_external_video);
682 ADD_TEST(NULL, "Edje External", "ExtIcon", test_external_icon); 683 ADD_TEST(NULL, "Edje External", "ExtIcon", test_external_icon);
684 ADD_TEST(NULL, "Edje External", "ExtCombobox", test_external_combobox);
683 685
684 //------------------------------// 686 //------------------------------//
685 ADD_TEST(NULL, "Toolbars", "Toolbar", test_toolbar); 687 ADD_TEST(NULL, "Toolbars", "Toolbar", test_toolbar);
diff --git a/src/bin/elementary/test_external.c b/src/bin/elementary/test_external.c
index 902458cbf7..cbd0c0774a 100644
--- a/src/bin/elementary/test_external.c
+++ b/src/bin/elementary/test_external.c
@@ -202,3 +202,78 @@ test_external_icon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
202 evas_object_resize(win, 320, 400); 202 evas_object_resize(win, 320, 400);
203 evas_object_show(win); 203 evas_object_show(win);
204} 204}
205
206static char *
207text_get_cb(void *data,
208 Evas_Object *obj EINA_UNUSED,
209 const char *part EINA_UNUSED)
210{
211 return strdup(data);
212}
213
214static void
215action_cb(void *data,
216 Evas_Object *obj EINA_UNUSED,
217 void *info)
218{
219 Evas_Object *const lay = data;
220 Elm_Object_Item *const item = info;
221
222 elm_layout_text_set(lay, "info", elm_object_item_data_get(item));
223}
224
225static void
226_cb_pressed_cb(void *data EINA_UNUSED,
227 Evas_Object *obj,
228 void *info)
229{
230 const char *txt;
231
232 txt = elm_object_item_text_get(info);
233 elm_object_text_set(obj, txt);
234 elm_combobox_hover_end(obj);
235 elm_entry_cursor_end_set(obj);
236}
237
238void
239test_external_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
240{
241 Evas_Object *win, *ly, *cb, *edj;
242 char buf[PATH_MAX];
243 Elm_Genlist_Item_Class *itc;
244 const char *info[] = {
245 "Label", "Button", "Combobox", "Icon", "Scroller", "Layout",
246 "Naviframe", "Bubble"
247 };
248 const unsigned int size = EINA_C_ARRAY_LENGTH(info);
249 unsigned int i;
250
251 win = elm_win_util_standard_add("ext_combobox", "Edje External Combobox");
252 elm_win_autodel_set(win, EINA_TRUE);
253
254 ly = elm_layout_add(win);
255 snprintf(buf, sizeof(buf), "%s/objects/test_external.edj", elm_app_data_dir_get());
256 elm_layout_file_set(ly, buf, "external/combobox");
257 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
258 elm_win_resize_object_add(win, ly);
259 evas_object_show(ly);
260
261 itc = elm_genlist_item_class_new();
262 itc->item_style = "default";
263 itc->func.text_get = text_get_cb;
264
265 edj = elm_layout_edje_get(ly);
266 cb = edje_object_part_external_object_get(edj, "combobox");
267 evas_object_smart_callback_add(cb, "item,pressed", _cb_pressed_cb, NULL);
268
269 for (i = 0; i < size; i++)
270 {
271 elm_genlist_item_append(cb, itc, info[i], NULL,
272 ELM_GENLIST_ITEM_NONE, action_cb, ly);
273 }
274
275 elm_genlist_item_class_free(itc);
276
277 evas_object_resize(win, 320, 400);
278 evas_object_show(win);
279}