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_popup_menu_close_func.c
24 * @author Lukasz Gajowy <l.gajowy@samsung.com>
26 * @brief Tests EWK function ewk_view_popup_menu_close(Evas_Object *o)
29 #define TESTED_FUN_NAME "ewk_view_popup_menu_close"
30 #define POS_STRING_FAIL "failed in positive test case"
31 #define NEG_STRING_FAIL "failed in negative test case"
33 #include <Ecore_Evas.h>
35 #include <Elementary.h>
39 static Evas_Object* webview;
40 static Evas_Object* window;
41 static Evas_Smart* evasSmartClass;
42 static Ewk_View_Smart_Class ewkViewSmartClass;
43 static Ecore_Timer* timer;
45 static const unsigned xClick = 46;
46 static const unsigned yClick = 19;
47 static const double timeout = 2;
48 static const char selectHTML[] =
51 "<option>one</option>"
55 static void startup(void);
56 static void cleanup(void);
58 void (*tet_startup)(void) = startup;
59 void (*tet_cleanup)(void) = cleanup;
61 static void utcWebkit2EwkWiewPopupMenuClosePositive(void);
62 static void utcWebkit2EwkWiewPopupMenuCloseNegative(void);
69 struct tet_testlist tet_testlist[] = {
70 {utcWebkit2EwkWiewPopupMenuClosePositive, POSITIVE_TC_IDX},
71 {utcWebkit2EwkWiewPopupMenuCloseNegative, NEGATIVE_TC_IDX},
75 static Ewk_View_Smart_Class smartClass()
77 static Ewk_View_Smart_Class smart = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("tcwebkit2");
81 static void onLoadFinished(void* data, Evas_Object* obj, void* eventInfo)
83 tet_infoline("====== onLoadFinished ======\n");
84 ecore_main_loop_quit();
87 static void startup(void)
89 tet_infoline("====== startup ======\n");
94 elm_config_preferred_engine_set("opengl_x11");
96 window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
97 elm_win_title_set(window, "TC Launcher");
98 evas_object_show(window);
100 Evas *evas = evas_object_evas_get(window);
102 ewkViewSmartClass = smartClass();
103 ewk_view_smart_class_set(&ewkViewSmartClass);
104 evasSmartClass = evas_smart_class_new(&ewkViewSmartClass.sc);
105 Ewk_Context *context = ewk_context_default_get();
106 webview = ewk_view_smart_add(evas, evasSmartClass, context);
108 evas_object_resize(webview, 800, 600);
109 evas_object_show(webview);
111 evas_object_smart_callback_add(webview, "load,finished", onLoadFinished, 0);
114 static void cleanup(void)
116 evas_object_smart_callback_del(webview, "load,finished", onLoadFinished);
117 evas_smart_free(evasSmartClass);
118 evas_object_del(webview);
121 static void mouseClick(int x, int y)
123 Evas *evas = evas_object_evas_get(window);
124 evas_event_feed_mouse_move(evas, x, y, 0, 0);
125 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, 0);
126 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, 0);
129 static Eina_Bool onTimeout(void* data)
131 ecore_main_loop_quit();
132 return ECORE_CALLBACK_CANCEL;
135 static Eina_Bool popupMenuShow(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selected_index)
137 tet_infoline("====== popup_menu_show ======\n");
138 Eina_Bool result = ewk_view_popup_menu_close(webview);
139 dts_check_eq(TESTED_FUN_NAME, result, EINA_TRUE, POS_STRING_FAIL);
140 ecore_main_loop_quit();
141 ecore_timer_delete(timer);
146 * @brief Checking whether popup menu is closed properly.
148 static void utcWebkit2EwkWiewPopupMenuClosePositive(void)
150 ewkViewSmartClass.popup_menu_show = popupMenuShow;
151 ewk_view_html_string_load(webview, selectHTML, 0, 0);
152 ecore_main_loop_begin();
153 mouseClick(xClick, yClick);
154 timer = ecore_timer_add(timeout, onTimeout, 0);
155 ecore_main_loop_begin();
159 * @brief Checking whether function works properly in case of a null Evas_Object given as an argument.
161 static void utcWebkit2EwkWiewPopupMenuCloseNegative(void)
163 dts_check_eq(TESTED_FUN_NAME, ewk_view_popup_menu_close(0), EINA_FALSE, NEG_STRING_FAIL);