Merge "[Cherry-pick] Refactor WrapShape classes to BasicShape" into tizen_2.1
[framework/web/webkit-efl.git] / TC / unit_test / webkit2 / utc_webkit2_ewk_view_url_request_set_func.c
1 /*
2  * WebKit2 EFL
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5  *
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)
9  * any later version.
10  *
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.
15  *
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
19  *
20  */
21
22 /**
23  * @file utc_webkit2_ewk_view_url_request_set_func.c
24  * @author Yuni Jeong <yhnet.jung@samsung.com>
25  * @date 2012-06-21
26  * @brief Tests EWK function ewk_view_url_request_set()
27  */
28
29 /* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
30 #define TESTED_FUN_NAME ewk_view_url_request_set
31 #define POSITIVE_TEST_FUN_NUM 1
32 #define NEGATIVE_TEST_FUN_NUM 3
33
34 #include "utc_webkit2_ewk.h"
35
36 static Eina_Bool is_failed = EINA_FALSE;
37
38 #define URL "http://www.google.com"
39
40 static void load_finished(void* data, Evas_Object* webview, void* event_info)
41 {
42     utc_message("[load_finished] :: \n");
43     is_failed = EINA_FALSE;
44     utc_webkit2_main_loop_quit();
45 }
46
47 static void load_error(void* data, Evas_Object* webview, void* event_info)
48 {
49     utc_message("[load_error] :: \n");
50     is_failed = EINA_TRUE;
51     utc_webkit2_main_loop_quit();
52 }
53
54 /* Startup and cleanup functions */
55 static void startup(void)
56 {
57     utc_webkit2_ewk_test_init();
58
59     evas_object_smart_callback_add(test_view.webview, "load,finished", load_finished, NULL);
60     evas_object_smart_callback_add(test_view.webview, "load,error", load_error, NULL);
61 }
62
63 static void cleanup(void)
64 {
65     evas_object_smart_callback_del(test_view.webview, "load,finished", load_finished);
66     evas_object_smart_callback_del(test_view.webview, "load,error", load_error);
67
68     utc_webkit2_ewk_test_end();
69 }
70
71 /**
72  * @brief Tests if returns TRUE when uri is properly set.
73  */
74 POS_TEST_FUN(1)
75 {
76     Eina_Bool result = ewk_view_url_request_set(test_view.webview, URL, EWK_HTTP_METHOD_GET, NULL, NULL);
77     if (!result)
78         utc_fail();
79     utc_webkit2_main_loop_begin();
80
81     if (is_failed)
82         utc_fail();
83
84     utc_check_eq(result, EINA_TRUE);
85 }
86
87 /**
88  * @brief Checking whether function works properly in case of NULL of a webview.
89  */
90 NEG_TEST_FUN(1)
91 {
92     Eina_Bool result = ewk_view_url_request_set(NULL, URL, EWK_HTTP_METHOD_GET, NULL, NULL);
93     if (result)
94         utc_fail();
95
96     utc_check_ne(result, EINA_TRUE);
97 }
98
99 /**
100  * @brief Checking whether function works properly in case of NULL of a URL.
101  */
102 NEG_TEST_FUN(2)
103 {
104     Eina_Bool result = ewk_view_url_request_set(test_view.webview, NULL, EWK_HTTP_METHOD_GET, NULL, NULL);
105     if (result)
106         utc_fail();
107
108     utc_check_ne(result, EINA_TRUE);
109 }
110
111 /**
112  * @brief Checking whether function works properly in case that http method value is not within the scope of Ewk_Http_Method.
113  */
114 NEG_TEST_FUN(3)
115 {
116     Eina_Bool result = ewk_view_url_request_set(NULL, URL, 100, NULL, NULL);
117     if (result)
118         utc_fail();
119
120     utc_check_ne(result, EINA_TRUE);
121 }