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_before_unload_confirm_panel_reply_func.c
24 * @author Krzysztof Czech <k.czech@samsung.com>
26 * @brief Tests EWK function ewk_view_before_unload_confirm_panel_reply
29 #define TESTED_FUN_NAME ewk_view_before_unload_confirm_panel_reply
30 #define POSITIVE_TEST_FUN_NUM 1
31 #define NEGATIVE_TEST_FUN_NUM 1
33 #include "utc_webkit2_ewk.h"
35 #define HTML_PAGE "/ewk_view/before_unload_test.html"
37 static Ecore_Timer* watchTimer;
38 static Eina_Bool result;
40 static void loadURL(const char* url)
42 char* full_path = generate_full_resource_path(url);
46 Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
53 static Eina_Bool onWatchTimerCallback(void* data)
55 utc_message("====== onWatchTimerCallback ======\n");
56 utc_webkit2_main_loop_quit();
57 return ECORE_CALLBACK_CANCEL;
60 static void onLoadFinished(void* data, Evas_Object* webview, void* event_info)
62 utc_message("===== onLoadFinished ======\n");
63 watchTimer = ecore_timer_add(20, onWatchTimerCallback, 0);
66 static void startup(void)
68 utc_webkit2_ewk_test_init();
69 evas_object_smart_callback_add(test_view.webview, "load,finished", onLoadFinished, NULL);
72 static void cleanup(void)
74 utc_webkit2_ewk_test_end();
75 evas_object_smart_callback_del(test_view.webview, "load,finished", onLoadFinished);
76 ecore_timer_del(watchTimer);
79 static Eina_Bool beforeUnloadCallback(Evas_Object* o, const char* message, void* userData)
81 utc_message("===== beforeUnloadCallback =====\n");
83 ewk_view_before_unload_confirm_panel_reply(test_view.webview, EINA_TRUE);
86 utc_webkit2_main_loop_quit();
90 * @brief Checks whether function works properly.
94 ewk_view_before_unload_confirm_panel_callback_set(test_view.webview, beforeUnloadCallback, 0);
97 utc_webkit2_main_loop_begin();
99 utc_check_eq(result, EINA_TRUE);
103 * @brief Checks whether function works correctly in case of null of a webview.
107 ewk_view_before_unload_confirm_panel_reply(0, EINA_FALSE);