From: Dhirendra Date: Thu, 14 Feb 2013 10:20:22 +0000 (+0900) Subject: Unit Test case for ewk_view_page_save function X-Git-Tag: 2.1_release~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc018a0504754dcca1a996eaa5643f4256855d8f;p=platform%2Fframework%2Fweb%2Fwebkit-efl.git Unit Test case for ewk_view_page_save function [Project] Tizen Browser [Title] Unit Test case for Offline page save ewk API [BinType] N/A [Customer] N/A [Issue#]: N/A [Solution]: N/A [Team] Browser(WCS) [Developer] Dhirendra Kumar(dhirendra.kr@samsung.com) Change-Id: I27eab19208a7ace23efb1cefebdc922339ffe1f0 --- diff --git a/TC/unit_test/webkit2/Makefile b/TC/unit_test/webkit2/Makefile index 8e42092..85dad7d 100644 --- a/TC/unit_test/webkit2/Makefile +++ b/TC/unit_test/webkit2/Makefile @@ -171,6 +171,7 @@ TARGETS = \ utc_webkit2_ewk_view_notification_closed_func \ utc_webkit2_ewk_view_orientation_send_func \ utc_webkit2_ewk_view_page_get_func \ + utc_webkit2_ewk_view_page_save_func \ utc_webkit2_ewk_view_page_visibility_state_set_func \ utc_webkit2_ewk_view_plain_text_get_func \ utc_webkit2_ewk_view_popup_menu_close_func \ diff --git a/TC/unit_test/webkit2/resources/ewk_view/page_save_test.html b/TC/unit_test/webkit2/resources/ewk_view/page_save_test.html new file mode 100644 index 0000000..073493c --- /dev/null +++ b/TC/unit_test/webkit2/resources/ewk_view/page_save_test.html @@ -0,0 +1,33 @@ + + + + Test-page + + + + +
+First Name : + +
+Last Name : + +
+Age : + +
+Email Id : + +
+WebSite : + +
+ +
+ + \ No newline at end of file diff --git a/TC/unit_test/webkit2/tslist b/TC/unit_test/webkit2/tslist index f858e66..1cc8b8d 100644 --- a/TC/unit_test/webkit2/tslist +++ b/TC/unit_test/webkit2/tslist @@ -168,6 +168,7 @@ /unit_test/webkit2/utc_webkit2_ewk_view_notification_closed_func /unit_test/webkit2/utc_webkit2_ewk_view_orientation_send_func /unit_test/webkit2/utc_webkit2_ewk_view_page_get_func +/unit_test/webkit2/utc_webkit2_ewk_view_page_save_func /unit_test/webkit2/utc_webkit2_ewk_view_page_visibility_state_set_func /unit_test/webkit2/utc_webkit2_ewk_view_plain_text_get_func /unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_close_func diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_page_save_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_page_save_func.c new file mode 100644 index 0000000..c10c943 --- /dev/null +++ b/TC/unit_test/webkit2/utc_webkit2_ewk_view_page_save_func.c @@ -0,0 +1,127 @@ +/* + * WebKit2 EFL + * + * Copyright (c) 2013 Samsung Electronics Co., Ltd. + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/** + * @file utc_webkit2_ewk_view_page_save_func.c + * @author Dhirendra Kumar + * @date 2013-01-31 + * @brief Tests EWK function ewk_view_page_save() + */ + +/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */ +#define TESTED_FUN_NAME ewk_view_page_save +#define POSITIVE_TEST_FUN_NUM 1 +#define NEGATIVE_TEST_FUN_NUM 3 + +#include "utc_webkit2_ewk.h" + +#define PATH "/opt/usr/apps/com.samsung.browser/data/offlinePageSave/" + +/*Callback for load finished */ +static void loadFinished(void *data, Evas_Object *webview, void *arg) +{ + utc_message("[loadFinished] :: \n"); + utc_webkit2_main_loop_quit(); +} + +/* Callback for load error */ +static void loadError(void* data, Evas_Object* webview, void* event_info) +{ + utc_message("[loadError] :: \n"); + utc_webkit2_main_loop_quit(); + + utc_fail(); +} + + +/* Startup and cleanup functions */ +static void startup(void) +{ + utc_webkit2_ewk_test_init(); + evas_object_smart_callback_add(test_view.webview, "load,finished", loadFinished, NULL); + evas_object_smart_callback_add(test_view.webview, "load,error", loadError, NULL); +} + +static void cleanup(void) +{ + evas_object_smart_callback_del(test_view.webview, "load,finished", loadFinished); + evas_object_smart_callback_del(test_view.webview, "load,error", loadError); + utc_webkit2_ewk_test_end(); +} + +/** + * @brief Tests if returns TRUE when page save start is triggered properly. + */ +POS_TEST_FUN(1) +{ + char* full_path = generate_full_resource_path("/ewk_view/page_save_test.html"); + if (!full_path) + utc_fail(); + + Eina_Bool result = ewk_view_url_set(test_view.webview, full_path); + if (!result) + utc_fail(); + free(full_path); + utc_webkit2_main_loop_begin(); + + result = ewk_view_page_save(test_view.webview, PATH); + if (!result) + utc_fail(); + + utc_check_eq(result, EINA_TRUE); +} + +/** + * @brief Tests if returns FALSE when view object and path both are NULL. + */ +NEG_TEST_FUN(1) +{ + Eina_Bool result = ewk_view_page_save(NULL, NULL); + if (result) + utc_fail(); + + utc_check_ne(result, EINA_TRUE); +} + +/** + * @brief Tests if returns FALSE when path is NULL. + */ +NEG_TEST_FUN(2) +{ + Eina_Bool result = ewk_view_page_save(test_view.webview, NULL); + if (result) + utc_fail(); + + utc_check_ne(result, EINA_TRUE); +} + +/** + * @brief Tests if returns FALSE when view object is NULL. + */ +NEG_TEST_FUN(3) +{ + Eina_Bool result = ewk_view_page_save(NULL, PATH); + if (result) + utc_fail(); + + utc_check_ne(result, EINA_TRUE); +} +