Fixed a problem that remember popup does not disappear
[framework/web/webkit-efl.git] / TC / unit_test / webkit2 / utc_webkit2_ewk_view_stop_func.c
1 \r
2 /*\r
3  * WebKit2 EFL\r
4  *\r
5  * Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
6  *\r
7  * This library is free software; you can redistribute it and/or modify it under\r
8  * the terms of the GNU Lesser General Public License as published by the\r
9  * Free Software Foundation; either version 2.1 of the License, or (at your option)\r
10  * any later version.\r
11  *\r
12  * This library is distributed in the hope that it will be useful, but WITHOUT ANY\r
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\r
15  * License for more details.\r
16  *\r
17  * You should have received a copy of the GNU Lesser General Public License\r
18  * along with this library; if not, write to the Free Software Foundation, Inc., 51\r
19  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
20  *\r
21  */\r
22 \r
23 /* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */\r
24 \r
25 /**\r
26  * @file utc_webkit2_ewk_view_stop_func.c\r
27  * @author Rashmi Kulakarni <rashmi.vijay@samsung.com>\r
28  * @date 2012-06-11\r
29  * @brief Tests EWK function ewk_view_stop()\r
30  */\r
31 \r
32 #define TESTED_FUN_NAME ewk_view_stop\r
33 #define POSITIVE_TEST_FUN_NUM 1\r
34 #define NEGATIVE_TEST_FUN_NUM 1\r
35 \r
36 #include "utc_webkit2_ewk.h"\r
37 \r
38 #ifndef NULL\r
39 #define NULL    0x0\r
40 #endif\r
41 \r
42 #define SAMPLE_HTML_FILE        ("/common/sample.html")\r
43 #define SAMPLE1_HTML_FILE        ("/common/sample_1.html")\r
44 \r
45 static void loadFinished(void* data, Evas_Object* evas_object, void* event_info)\r
46 {\r
47     utc_message("[loadFinished] :: \n");\r
48     utc_webkit2_main_loop_quit();\r
49 }\r
50 /* Callback for load error */\r
51 static void loadError(void* data, Evas_Object* webview, void* event_info)\r
52 {\r
53     utc_message("[load_error] :: \n");\r
54     utc_webkit2_main_loop_quit();\r
55 \r
56     utc_fail();\r
57 }\r
58 \r
59 static void startup(void)\r
60 {\r
61     utc_webkit2_ewk_test_init();\r
62 \r
63     evas_object_smart_callback_add(test_view.webview, "load,finished", loadFinished, NULL);\r
64         evas_object_smart_callback_add(test_view.webview, "load,error", loadError, NULL);\r
65 }\r
66 \r
67 static void cleanup(void)\r
68 {\r
69     evas_object_smart_callback_del(test_view.webview, "load,finished", loadFinished);\r
70     evas_object_smart_callback_del(test_view.webview, "load,error", loadError);\r
71     utc_webkit2_ewk_test_end();\r
72 }\r
73 \r
74 static void loadURL(const char* url)\r
75 {\r
76     char* full_path = generate_full_resource_path(url);\r
77     if (!full_path)\r
78         utc_fail();\r
79 \r
80     Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);\r
81     free(full_path);\r
82 \r
83     if (!result)\r
84         utc_fail();\r
85 }\r
86 \r
87 /**\r
88  * @brief Positive  test case of ewk_view_stop()\r
89  * ewk_view_stop should return TRUE  as we are stopping the load with a valid url\r
90  */\r
91 POS_TEST_FUN(1)\r
92 {\r
93     loadURL(SAMPLE_HTML_FILE);\r
94     utc_webkit2_main_loop_begin();\r
95 \r
96     Eina_Bool result = ewk_view_stop(test_view.webview);\r
97     utc_check_eq(result, EINA_TRUE);\r
98 }\r
99 \r
100 /**\r
101  * @brief Negative  test case of ewk_view_stop()\r
102  * ewk_view_stop should return FALSE as we are stopping the load with NULL\r
103  */\r
104 NEG_TEST_FUN(1)\r
105 {\r
106     Eina_Bool result = ewk_view_stop(NULL);\r
107     utc_check_eq(result, EINA_FALSE);\r
108 }\r
109 \r
110 \r
111 \r
112 \r