6624373a1a377c6888d78f0d2d30c9df9c2b96de
[WebKit-https.git] / Source / WebKit / efl / tests / test_ewk_setting.cpp
1 /*
2  * Copyright (C) 2013 Cisco Systems, Inc. 
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1.  Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  * 2.  Red istributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ITS CONTRIBUTORS
14  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
17  * HOLDERS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27
28 #include "UnitTestUtils/EWKTestBase.h"
29 #include "UnitTestUtils/EWKTestConfig.h"
30 #include <EWebKit.h>
31
32 using namespace EWKUnitTests;
33
34 /**
35  * @brief Unit test for checking set/get of default quota for Web Database databases by ewk settings API.
36  */
37 TEST_F(EWKTestBase, ewk_settings_web_database_default_quota)
38 {
39     ASSERT_EQ(1 * 1024 * 1024, ewk_settings_web_database_default_quota_get());
40
41     ewk_settings_web_database_default_quota_set(2 * 1024 * 1024);
42     ASSERT_EQ(2 * 1024 * 1024, ewk_settings_web_database_default_quota_get());
43
44     ewk_settings_web_database_default_quota_set(3 * 1024 * 1024);
45     ASSERT_EQ(3 * 1024 * 1024, ewk_settings_web_database_default_quota_get());
46 }
47
48 /**
49  * @brief Unit test for checking set/get of directory path where Web Database databases is stored by ewk settings API.
50  */
51 TEST_F(EWKTestBase, ewk_settings_web_database_path)
52 {
53 #if ENABLE(SQL_DATABASE)
54     ASSERT_STREQ("~/.webkit", ewk_settings_web_database_path_get());
55 #else
56     ASSERT_STREQ(0, ewk_settings_web_database_path_get());
57 #endif
58
59     ewk_settings_web_database_path_set("~/data/webkitDB");
60 #if ENABLE(SQL_DATABASE)
61     ASSERT_STREQ("~/data/webkitDB", ewk_settings_web_database_path_get());
62 #else
63     ASSERT_STREQ(0, ewk_settings_web_database_path_get());
64 #endif
65
66     ewk_settings_web_database_path_set("~/tmp/webkit");
67 #if ENABLE(SQL_DATABASE)    
68     ASSERT_STREQ("~/tmp/webkit", ewk_settings_web_database_path_get());
69 #else
70     ASSERT_STREQ(0, ewk_settings_web_database_path_get());
71 #endif
72 }
73
74 /**
75  * @brief Unit test for checking set/get of directory path where the HTML5 local storage indexing database is stored by ewk settings API.
76  */
77 TEST_F(EWKTestBase, ewk_settings_local_storage_path)
78 {
79     ASSERT_STREQ("~/.webkit", ewk_settings_local_storage_path_get());
80
81     ewk_settings_local_storage_path_set("~/data/webkitDB");
82     ASSERT_STREQ("~/data/webkitDB", ewk_settings_local_storage_path_get());
83
84     ewk_settings_local_storage_path_set("~/tmp/webkit");
85     ASSERT_STREQ("~/tmp/webkit", ewk_settings_local_storage_path_get());
86 }
87
88 /**
89  * @brief Unit test for checking set/get of directory path where icon database is stored by ewk settings API.
90  */
91 TEST_F(EWKTestBase, ewk_settings_icon_database_path)
92 {
93     ASSERT_STREQ(0, ewk_settings_icon_database_path_get());
94
95     ASSERT_TRUE(ewk_settings_icon_database_path_set("/tmp"));
96     ASSERT_STREQ("/tmp", ewk_settings_icon_database_path_get());
97
98     ASSERT_TRUE(ewk_settings_icon_database_path_set(0));
99     ASSERT_STREQ(0, ewk_settings_icon_database_path_get());
100 }
101
102 /**
103  * @brief Unit test for checking set/get of path where the HTML5 application cache is stored by ewk settings API.
104  */
105 TEST_F(EWKTestBase, ewk_settings_application_cache_path)
106 {
107     ASSERT_STREQ(0, ewk_settings_application_cache_path_get());
108
109     ewk_settings_application_cache_path_set("~/data/webkitApp");
110     ASSERT_STREQ("~/data/webkitApp", ewk_settings_application_cache_path_get());
111
112     ewk_settings_application_cache_path_set("~/tmp/webkitApp");
113     ASSERT_STREQ("~/tmp/webkitApp", ewk_settings_application_cache_path_get());
114 }
115
116 /**
117  * @brief Unit test for checking set/get of maximum size of the application cache for HTML5 Offline Web Applications by ewk settings API.
118  */
119 TEST_F(EWKTestBase, ewk_settings_application_cache_max_quota)
120 {
121     ASSERT_EQ(std::numeric_limits<int64_t>::max(), ewk_settings_application_cache_max_quota_get());
122
123     ewk_settings_application_cache_max_quota_set(3 * 1024 * 1024);
124     ASSERT_EQ(3 * 1024 * 1024, ewk_settings_application_cache_max_quota_get());
125
126     ewk_settings_application_cache_max_quota_set(5 * 1024 * 1024);
127     ASSERT_EQ(5 * 1024 * 1024, ewk_settings_application_cache_max_quota_get());
128 }
129
130 /**
131  * @brief Unit test for checking set/get of in-memory object cache Enables/Disables status by ewk settings API.
132  */
133 TEST_F(EWKTestBase, ewk_settings_object_cache_enable)
134 {
135     ASSERT_TRUE(ewk_settings_object_cache_enable_get());
136
137     ewk_settings_object_cache_enable_set(false);
138     ASSERT_FALSE(ewk_settings_object_cache_enable_get());
139
140     ewk_settings_object_cache_enable_set(true);
141     ASSERT_TRUE(ewk_settings_object_cache_enable_get());
142 }
143
144 /**
145  * @brief Unit test for checking set/get of Shadow DOM functionality Enables/Disables status by ewk settings API.
146  */
147 TEST_F(EWKTestBase, ewk_settings_shadow_dom_enable)
148 {
149     ASSERT_FALSE(ewk_settings_shadow_dom_enable_get());
150
151     ewk_settings_shadow_dom_enable_set(true);
152     ASSERT_TRUE(ewk_settings_shadow_dom_enable_get());
153
154     ewk_settings_shadow_dom_enable_set(false);
155     ASSERT_FALSE(ewk_settings_shadow_dom_enable_get());
156 }
157
158 /**
159  * @brief Unit test for checking set/get of maximum number of pages in the memory page cache by ewk settings API.
160  */
161 TEST_F(EWKTestBase, ewk_settings_page_cache_capacity)
162 {
163     ASSERT_EQ(3, ewk_settings_page_cache_capacity_get());
164
165     ewk_settings_page_cache_capacity_set(5);
166     ASSERT_EQ(5, ewk_settings_page_cache_capacity_get());
167 }
168
169 /**
170  * @brief Unit test for checking set/get of css media type by ewk settings API.
171  */
172 TEST_F(EWKTestBase, ewk_settings_css_media_type)
173 {
174     ASSERT_STREQ(0, ewk_settings_css_media_type_get());
175
176     ewk_settings_css_media_type_set("handheld");
177     ASSERT_STREQ("handheld", ewk_settings_css_media_type_get());
178
179     ewk_settings_css_media_type_set("tv");
180     ASSERT_STREQ("tv", ewk_settings_css_media_type_get());
181
182     ewk_settings_css_media_type_set("screen");
183     ASSERT_STREQ("screen", ewk_settings_css_media_type_get());
184
185     ewk_settings_css_media_type_set(0);
186     ASSERT_STREQ(0, ewk_settings_css_media_type_get());
187 }