Fixed a problem that remember popup does not disappear
[framework/web/webkit-efl.git] / TC / unit_test / webkit2 / utc_webkit2_ewk_context_web_database_path_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_context_web_database_path_set_func.c
24  * @author SangYong Park <sy302.park@samsung.com>
25  * @date 2012-06-20
26  * @brief Tests EWK function ewk_context_web_database_path_set()
27  */
28
29 /* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
30 #define TESTED_FUN_NAME ewk_context_web_database_path_set
31 #define POSITIVE_TEST_FUN_NUM 1
32 #define NEGATIVE_TEST_FUN_NUM 2
33
34 #include "utc_webkit2_ewk.h"
35 #include "utc_webkit2_ewk_context_web_database.h"
36
37 static const char* databasePath = "./tempDatabasePath";
38 Eina_Bool existPath;
39
40 /* Startup and cleanup functions */
41 static void startup(void)
42 {
43     g_type_init();
44     elm_init(0, NULL);
45
46     ewk_context_web_database_path_set(ewk_context_default_get(), databasePath);
47
48     utc_webkit2_ewk_test_init();
49
50     elm_shutdown();
51 }
52
53 static void cleanup(void)
54 {
55     utc_webkit2_ewk_test_end();
56 }
57
58 void webDatabaseOriginsGet(Eina_List* origins, void* data)
59 {
60     struct stat fileStat;
61
62     if (origins)
63         ewk_context_origins_free(origins);
64
65     if (!stat(databasePath, &fileStat) && (fileStat.st_mode & S_IFDIR) == S_IFDIR)
66         existPath = EINA_TRUE;
67
68     utc_webkit2_main_loop_quit();
69 }
70
71 static void addWebDatabaseFinished()
72 {
73     Ewk_Context* context = ewk_view_context_get(test_view.webview);
74     if (!ewk_context_web_database_origins_get(context, webDatabaseOriginsGet, 0))
75         utc_webkit2_main_loop_quit();
76 }
77
78 static void addWebDatabaseError()
79 {
80     utc_webkit2_main_loop_quit();
81 }
82
83 /**
84  * @brief Tests if can set web database path.
85  */
86 POS_TEST_FUN(1)
87 {
88     existPath = EINA_FALSE;
89
90     if (!addWebDatabase(addWebDatabaseFinished, addWebDatabaseError))
91         utc_fail();
92
93     utc_webkit2_main_loop_begin();
94
95     utc_check_eq(existPath, EINA_TRUE);
96 }
97
98 /**
99  * @brief Tests if returns false which context was null.
100  */
101 NEG_TEST_FUN(1)
102 {
103     utc_check_eq(ewk_context_web_database_path_set(0, databasePath), EINA_FALSE);
104 }
105
106 /**
107  * @brief Tests if returns false which path was null.
108  */
109 NEG_TEST_FUN(2)
110 {
111     Ewk_Context* context = ewk_view_context_get(test_view.webview);
112     utc_check_eq(ewk_context_web_database_path_set(context, 0), EINA_FALSE);
113 }