4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
6 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation; either version 2.1 of the License, or (at your option)
11 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @file utc_webkit2_ewk_view_popup_menu_multiple_select_func.c
24 * @author Krzysztof Czech <k.czech@samsung.com>
26 * @brief Tests EWK function ewk_view_popup_menu_multiple_select()
31 #include <Ecore_Evas.h>
32 #include <Elementary.h>
35 #define TESTED_FUN_NAME "ewk_view_popup_menu_multiple_select"
36 #define POS_STRING_FAIL "failed in positive test case"
37 #define NEG_STRING_FAIL "failed in negative test case"
39 static Evas_Object* webview;
40 static Evas_Object* window;
41 static Evas_Smart* evasSmartClass;
42 static Ewk_View_Smart_Class ewkViewSmartClass;
44 static void startup(void);
45 static void cleanup(void);
47 void (*tet_startup)(void) = startup;
48 void (*tet_cleanup)(void) = cleanup;
50 static void utc_webkit2_ewk_view_popup_menu_multiple_select_positive(void);
51 static void utc_webkit2_ewk_view_popup_menu_multiple_select_negative(void);
58 struct tet_testlist tet_testlist[] = {
59 {utc_webkit2_ewk_view_popup_menu_multiple_select_positive, POSITIVE_TC_IDX},
60 {utc_webkit2_ewk_view_popup_menu_multiple_select_negative, NEGATIVE_TC_IDX},
64 static Ewk_View_Smart_Class smartClass()
66 static Ewk_View_Smart_Class smart = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("tcwebkit2");
70 static void onLoadFinished(void* data, Evas_Object* obj, void* eventInfo)
72 tet_infoline("====== onLoadFinished ======\n");
73 ecore_main_loop_quit();
76 static void startup(void)
78 tet_infoline("====== startup ======\n");
83 elm_config_preferred_engine_set("opengl_x11");
87 window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
88 elm_win_title_set(window, "TC Launcher");
89 evas_object_show(window);
91 Evas *evas = evas_object_evas_get(window);
93 ewkViewSmartClass = smartClass();
94 ewk_view_smart_class_set(&ewkViewSmartClass);
95 evasSmartClass = evas_smart_class_new(&ewkViewSmartClass.sc);
96 Ewk_Context *context = ewk_context_default_get();
97 webview = ewk_view_smart_add(evas, evasSmartClass, context);
99 /*elements = eina_list_append(elements, eina_stringshare_add("one"));
100 elements = eina_list_append(elements, eina_stringshare_add("two"));
101 elements = eina_list_append(elements, eina_stringshare_add("three"));*/
103 evas_object_resize(webview, 800, 600);
104 evas_object_show(webview);
106 evas_object_smart_callback_add(webview, "load,finished", onLoadFinished, 0);
109 static void cleanup(void)
111 evas_object_smart_callback_del(webview, "load,finished", onLoadFinished);
112 evas_smart_free(evasSmartClass);
113 evas_object_del(webview);
117 static void mouseClick(int x, int y)
119 Evas *evas = evas_object_evas_get(window);
120 evas_event_feed_mouse_move(evas, x, y, 0, 0);
121 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, 0);
122 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, 0);
125 static Eina_Bool onTimeout(void* data)
127 ecore_main_loop_quit();
128 return ECORE_CALLBACK_CANCEL;
131 static Eina_Bool multiplePopupMenuShow(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items)
133 tet_infoline("====== multiple_popup_menu_show ======\n");
135 Eina_Inarray *inarr = eina_inarray_new(sizeof(int), 0);
137 eina_inarray_push(inarr, &index);
139 eina_inarray_push(inarr, &index);
141 Eina_Bool result = ewk_view_popup_menu_multiple_select(webview, inarr);
143 eina_inarray_free(inarr);
145 dts_check_eq(TESTED_FUN_NAME, result, EINA_TRUE, POS_STRING_FAIL);
151 * @brief Checking whether function works properly.
153 static void utc_webkit2_ewk_view_popup_menu_multiple_select_positive(void)
155 static const char selectHTML[] =
158 "<option>one</option>"
159 "<option>two</option>"
160 "<option>three</option>"
164 ewkViewSmartClass.multiple_popup_menu_show = multiplePopupMenuShow;
165 ewk_view_html_string_load(webview, selectHTML, 0, 0);
167 ecore_main_loop_begin();
169 static const unsigned x = 46;
170 static const unsigned y = 19;
173 static const double timeout = 2;
174 Ecore_Timer *timer = ecore_timer_add(timeout, onTimeout, 0);
175 ecore_main_loop_begin();
179 * @brief Checking whether function works properly.
181 static void utc_webkit2_ewk_view_popup_menu_multiple_select_negative(void)
183 dts_check_eq(TESTED_FUN_NAME, ewk_view_popup_menu_multiple_select(0, 0), EINA_FALSE, POS_STRING_FAIL);