summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorRyuan Choi <ryuan.choi@gmail.com>2014-01-26 12:20:03 +0900
committerRyuan Choi <ryuan.choi@gmail.com>2014-01-26 12:26:13 +0900
commit3ba4e4f7a3ca2acb850cb22c7adf29f4abc7ac52 (patch)
tree9889e8afb7408390ad66d865edddfacfb39b7cd4 /src/bin
parent0e465290be2016f12adcbc8c8d74645b3e6a1d9a (diff)
test_web_ui: Added a button to test select tag and window.open()
elm_web provide UI compoents by extending ewebkit. This patch adds a button to test select tag and window.open()
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_web.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/bin/test_web.c b/src/bin/test_web.c
index ee2042091..cb6ecf156 100644
--- a/src/bin/test_web.c
+++ b/src/bin/test_web.c
@@ -345,6 +345,48 @@ _useragent_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
345} 345}
346 346
347static void 347static void
348_select_tag_test_cb(void *data, Evas_Object *obj, void *event_info)
349{
350 Web_Test *wt = data;
351 const char *selected = elm_object_item_text_get(event_info);
352 const char select_html[] = "<!doctype html><body>"
353 "<select>"
354 "<option>eina</option>"
355 "<option>ecore</option>"
356 "<option>evas</option>"
357 "<option>edje</option>"
358 "<option>eet</option>"
359 "<option>emotion</option>"
360 "<option>elementary</option>"
361 "</select>"
362 "</body>";
363
364 printf("selected test : %s\n", selected);
365 elm_object_text_set(obj, selected);
366
367 elm_web_html_string_load(wt->web, select_html, NULL, NULL);
368}
369
370static void
371_new_window_test_cb(void *data, Evas_Object *obj, void *event_info)
372{
373 Web_Test *wt = data;
374 const char *selected = elm_object_item_text_get(event_info);
375 const char new_window_html[] = "<!doctype html><body>"
376 "<script>"
377 "var open = function() {"
378 " window.open('http://www.enlightenment.org','','width=400,height=300');"
379 "};"
380 "</script>"
381 "<input type='button' onclick='open();' value='click to open new window'>"
382 "</body>";
383
384 printf("selected test : %s\n", selected);
385 elm_object_text_set(obj, selected);
386
387 elm_web_html_string_load(wt->web, new_window_html, NULL, NULL);
388}
389static void
348_main_web_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 390_main_web_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
349{ 391{
350 Web_Test *wt = data; 392 Web_Test *wt = data;
@@ -513,7 +555,7 @@ test_web(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info
513void 555void
514test_web_ui(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 556test_web_ui(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
515{ 557{
516 Evas_Object *win, *bx, *web; 558 Evas_Object *win, *bx, *web, *hoversel;
517 Web_Test *wt; 559 Web_Test *wt;
518 560
519 elm_need_web(); 561 elm_need_web();
@@ -528,15 +570,29 @@ test_web_ui(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
528 elm_win_resize_object_add(win, bx); 570 elm_win_resize_object_add(win, bx);
529 evas_object_show(bx); 571 evas_object_show(bx);
530 572
573 hoversel = elm_hoversel_add(bx);
574 elm_hoversel_hover_parent_set(hoversel, win);
575 elm_object_text_set(hoversel, "Test cases");
576
577 elm_hoversel_item_add(hoversel, "<select> tag", NULL, ELM_ICON_NONE,
578 _select_tag_test_cb, wt);
579 elm_hoversel_item_add(hoversel, "new window", NULL, ELM_ICON_NONE,
580 _new_window_test_cb, wt);
581 elm_box_pack_end(bx, hoversel);
582 evas_object_show(hoversel);
583
531 web = elm_web_add(win); 584 web = elm_web_add(win);
532 evas_object_size_hint_weight_set(web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 585 evas_object_size_hint_weight_set(web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
533 evas_object_size_hint_align_set(web, EVAS_HINT_FILL, EVAS_HINT_FILL); 586 evas_object_size_hint_align_set(web, EVAS_HINT_FILL, EVAS_HINT_FILL);
534 elm_box_pack_end(bx, web); 587 elm_box_pack_end(bx, web);
535 evas_object_show(web); 588 evas_object_show(web);
536 589
590 elm_web_window_create_hook_set(web, _new_window_hook, wt);
591
537 evas_object_event_callback_add(web, EVAS_CALLBACK_DEL, _main_web_del_cb, wt); 592 evas_object_event_callback_add(web, EVAS_CALLBACK_DEL, _main_web_del_cb, wt);
538 wt->web = web; 593 wt->web = web;
539 594
595
540 elm_web_html_string_load(wt->web, 596 elm_web_html_string_load(wt->web,
541 "<!doctype html><body>Hello, WebKit/Efl</body>", 597 "<!doctype html><body>Hello, WebKit/Efl</body>",
542 NULL, NULL); 598 NULL, NULL);