4 * Copyright (c) 2012 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_context_menu.h
24 * @author Eunmi Lee <eunmi15.lee@samsung.com>
26 * @brief A header file to be used by context menu's unit test cases for WebKit2 EFL API
28 * This header file contains a common content for unit test cases, i.e.:
29 * it includes useful header files for context menu.
32 #ifndef UTC_WEBKIT2_EWK_CONTEXT_MENU_H
33 #define UTC_WEBKIT2_EWK_CONTEXT_MENU_H
35 #include "ewk_context_menu.h"
36 #include "utc_webkit2_ewk.h"
45 CUSTOM_CONTEXT_MENU_ITEM_BASE_TAG = EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG,
46 CUSTOM_CONTEXT_MENU_ITEM_TEST_TAG
49 static Eina_Bool is_failed = EINA_FALSE;
50 static Ecore_Timer* select_timer = 0;
52 static void feed_mouse_click(int button, int x, int y)
54 evas_event_feed_mouse_move(test_view.evas, x, y, ecore_time_get(), 0);
55 evas_event_feed_mouse_down(test_view.evas, button, EVAS_BUTTON_NONE, ecore_time_get(), 0);
56 evas_event_feed_mouse_up(test_view.evas, button, EVAS_BUTTON_NONE, ecore_time_get(), 0);
59 static Eina_Bool select_timer_callback(void* data)
61 utc_message("[select_timer_callback] :: \n");
62 feed_mouse_click(1, 50, 250);
63 return ECORE_CALLBACK_CANCEL;
66 static void select_item()
68 select_timer = ecore_timer_add(1, select_timer_callback, 0);
71 static void load_finished(void* data, Evas_Object* webview, void* event_info)
73 utc_message("[load_finished] :: \n");
74 feed_mouse_click(3, 100, 100);
77 static void load_error(void* data, Evas_Object* webview, void* event_info)
79 utc_message("[load_error] :: \n");
80 is_failed = EINA_TRUE;
81 utc_webkit2_main_loop_quit();
85 * Initiates context menu used in the test.
87 * This function should be _always_ called before the actual context menu's test starts.
88 * @see utc_webkit2_ewk_context_menu_test_end()
90 static void utc_webkit2_ewk_context_menu_test_init()
92 utc_webkit2_ewk_test_init();
94 /* Enable mouse events to feed events directly. */
95 ewk_view_mouse_events_enabled_set(test_view.webview, EINA_TRUE);
97 evas_object_smart_callback_add(test_view.webview, "load,finished", load_finished, 0);
98 evas_object_smart_callback_add(test_view.webview, "load,error", load_error, 0);
100 char* full_path = generate_full_resource_path("/ewk_context_menu/index.html");
102 is_failed = EINA_TRUE;
106 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
109 is_failed = EINA_TRUE;
115 * Frees context_menu's resources used during the test.
116 * This function should be _always_ called after the context menu's test is completed.
117 * @see utc_webkit2_ewk_context_menu_test_init()
119 static void utc_webkit2_ewk_context_menu_test_end()
121 evas_object_smart_callback_del(test_view.webview, "load,finished", load_finished);
122 evas_object_smart_callback_del(test_view.webview, "load,error", load_error);
125 ecore_timer_del(select_timer);
127 utc_webkit2_ewk_test_end();
134 #endif /* UTC_WEBKIT2_EWK_CONTEXT_MENU_H */