Remove more ENABLE(TEXT_AUTOSIZING) code
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / efl / tests / test_ewk2_settings.cpp
1 /*
2  * Copyright (C) 2012 Samsung Electronics
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. Redistributions 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27
28 #include "UnitTestUtils/EWK2UnitTestBase.h"
29
30 using namespace EWK2UnitTest;
31
32 extern EWK2UnitTestEnvironment* environment;
33
34 TEST_F(EWK2UnitTestBase, ewk_settings_fullscreen_enabled)
35 {
36     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
37
38 #if ENABLE(FULLSCREEN_API)
39     ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings));
40
41     ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE));
42     ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings));
43
44     ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE));
45     ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
46 #else
47     ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
48
49     ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE));
50     ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
51
52     ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE));
53     ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings));
54 #endif
55 }
56
57 TEST_F(EWK2UnitTestBase, ewk_settings_javascript_enabled)
58 {
59     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
60
61     ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, EINA_TRUE));
62     ASSERT_TRUE(ewk_settings_javascript_enabled_get(settings));
63
64     ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, 2));
65     ASSERT_TRUE(ewk_settings_javascript_enabled_get(settings));
66
67     ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, EINA_FALSE));
68     ASSERT_FALSE(ewk_settings_javascript_enabled_get(settings));
69 }
70
71 TEST_F(EWK2UnitTestBase, ewk_settings_loads_images_automatically)
72 {
73     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
74
75     ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, EINA_TRUE));
76     ASSERT_TRUE(ewk_settings_loads_images_automatically_get(settings));
77
78     ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, 2));
79     ASSERT_TRUE(ewk_settings_loads_images_automatically_get(settings));
80
81     ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, EINA_FALSE));
82     ASSERT_FALSE(ewk_settings_loads_images_automatically_get(settings));
83 }
84
85 TEST_F(EWK2UnitTestBase, ewk_settings_developer_extras_enabled)
86 {
87     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
88
89     ASSERT_TRUE(ewk_settings_developer_extras_enabled_set(settings, EINA_TRUE));
90     ASSERT_TRUE(ewk_settings_developer_extras_enabled_get(settings));
91
92     ASSERT_TRUE(ewk_settings_developer_extras_enabled_set(settings, 2));
93     ASSERT_TRUE(ewk_settings_developer_extras_enabled_get(settings));
94
95     ASSERT_TRUE(ewk_settings_developer_extras_enabled_set(settings, EINA_FALSE));
96     ASSERT_FALSE(ewk_settings_developer_extras_enabled_get(settings));
97 }
98
99 TEST_F(EWK2UnitTestBase, ewk_settings_file_access_from_file_urls_allowed)
100 {
101     CString testURL = environment->urlForResource("local_file_access.html");
102     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
103
104     ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
105
106     ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, true));
107     ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
108
109     // Check that file access from file:// URLs is allowed.
110     ewk_view_url_set(webView(), testURL.data());
111     ASSERT_TRUE(waitUntilTitleChangedTo("Frame loaded"));
112
113     ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, false));
114     ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
115
116     // Check that file access from file:// URLs is NOT allowed.
117     ewk_view_url_set(webView(), testURL.data());
118     ASSERT_TRUE(waitUntilTitleChangedTo("Frame NOT loaded"));
119 }
120
121 TEST_F(EWK2UnitTestBase, ewk_settings_frame_flattening_enabled_set)
122 {
123     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
124     ASSERT_TRUE(settings);
125
126     // The frame flattening is disabled by default.
127     ASSERT_FALSE(ewk_settings_frame_flattening_enabled_get(settings));
128     ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data());
129     waitUntilTitleChangedTo("200"); // width of iframe tag.
130     ASSERT_STREQ("200", ewk_view_title_get(webView()));
131
132     ASSERT_TRUE(ewk_settings_frame_flattening_enabled_set(settings, true));
133     ASSERT_TRUE(ewk_settings_frame_flattening_enabled_get(settings));
134     ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data());
135     waitUntilTitleChangedTo("600"); // width of frame_flattening_test_subframe.html
136     ASSERT_STREQ("600", ewk_view_title_get(webView()));
137
138     ASSERT_TRUE(ewk_settings_frame_flattening_enabled_set(settings, false));
139     ASSERT_FALSE(ewk_settings_frame_flattening_enabled_get(settings));
140     ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data());
141     waitUntilTitleChangedTo("200"); // width of iframe tag.
142     ASSERT_STREQ("200", ewk_view_title_get(webView()));
143 }
144
145 TEST_F(EWK2UnitTestBase, ewk_settings_dns_prefetching_enabled)
146 {
147     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
148
149     // DNS prefeching is disabled by default.
150     ASSERT_FALSE(ewk_settings_dns_prefetching_enabled_get(settings));
151     ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_set(settings, true));
152     ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_get(settings));
153
154     ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_set(settings, false));
155     ASSERT_FALSE(ewk_settings_dns_prefetching_enabled_get(settings));
156 }
157
158 TEST_F(EWK2UnitTestBase, ewk_settings_encoding_detector_enabled)
159 {
160     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
161
162     // The encoding detector is disabled by default.
163     ASSERT_FALSE(ewk_settings_encoding_detector_enabled_get(settings));
164
165     ASSERT_TRUE(ewk_settings_encoding_detector_enabled_set(settings, true));
166     ASSERT_TRUE(ewk_settings_encoding_detector_enabled_get(settings));
167
168     ASSERT_TRUE(ewk_settings_encoding_detector_enabled_set(settings, false));
169     ASSERT_FALSE(ewk_settings_encoding_detector_enabled_get(settings));
170 }
171
172 TEST_F(EWK2UnitTestBase, ewk_settings_default_text_encoding_name)
173 {
174     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
175
176     // The default encoding name is ISO-8859-1.
177     ASSERT_STREQ("ISO-8859-1", ewk_settings_default_text_encoding_name_get(settings));
178
179     ASSERT_TRUE(ewk_settings_default_text_encoding_name_set(settings, "UTF-8"));
180     ASSERT_STREQ("UTF-8", ewk_settings_default_text_encoding_name_get(settings));
181
182     ASSERT_TRUE(ewk_settings_default_text_encoding_name_set(settings, "ISO-8859-1"));
183     ASSERT_STREQ("ISO-8859-1", ewk_settings_default_text_encoding_name_get(settings));
184 }
185
186 TEST_F(EWK2UnitTestBase, ewk_settings_preferred_minimum_contents_width)
187 {
188     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
189
190     // 980 by default.
191     ASSERT_EQ(980, ewk_settings_preferred_minimum_contents_width_get(settings));
192
193     ASSERT_TRUE(ewk_settings_preferred_minimum_contents_width_set(settings, 0));
194     ASSERT_EQ(0, ewk_settings_preferred_minimum_contents_width_get(settings));
195 }
196
197 TEST_F(EWK2UnitTestBase, ewk_settings_offline_web_application_cache_enabled)
198 {
199     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
200
201     // The offline web application cache is enabled by default.
202     ASSERT_TRUE(ewk_settings_offline_web_application_cache_enabled_get(settings));
203
204     ASSERT_TRUE(ewk_settings_offline_web_application_cache_enabled_set(settings, false));
205     ASSERT_FALSE(ewk_settings_offline_web_application_cache_enabled_get(settings));
206
207     ASSERT_TRUE(ewk_settings_offline_web_application_cache_enabled_set(settings, true));
208     ASSERT_TRUE(ewk_settings_offline_web_application_cache_enabled_get(settings));
209 }
210
211 TEST_F(EWK2UnitTestBase, ewk_settings_scripts_can_open_windows)
212 {
213     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
214
215     // The scripts can open new windows by default.
216     ASSERT_TRUE(ewk_settings_scripts_can_open_windows_get(settings));
217
218     ASSERT_TRUE(ewk_settings_scripts_can_open_windows_set(settings, true));
219     ASSERT_TRUE(ewk_settings_scripts_can_open_windows_get(settings));
220
221     ASSERT_TRUE(ewk_settings_scripts_can_open_windows_set(settings, false));
222     ASSERT_FALSE(ewk_settings_scripts_can_open_windows_get(settings));
223 }
224
225 TEST_F(EWK2UnitTestBase, ewk_settings_local_storage_enabled)
226 {
227     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
228
229     // HTML5 local storage should be enabled by default.
230     ASSERT_TRUE(ewk_settings_local_storage_enabled_get(settings));
231
232     ASSERT_TRUE(ewk_settings_local_storage_enabled_set(settings, false));
233     ASSERT_FALSE(ewk_settings_local_storage_enabled_get(settings));
234
235     ASSERT_TRUE(ewk_settings_local_storage_enabled_set(settings, true));
236     ASSERT_TRUE(ewk_settings_local_storage_enabled_get(settings));
237 }
238
239 TEST_F(EWK2UnitTestBase, ewk_settings_plugins_enabled)
240 {
241     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
242
243     // Plug-ins support is enabled by default.
244     ASSERT_TRUE(ewk_settings_plugins_enabled_get(settings));
245
246     ASSERT_TRUE(ewk_settings_plugins_enabled_set(settings, true));
247     ASSERT_TRUE(ewk_settings_plugins_enabled_get(settings));
248
249     ASSERT_TRUE(ewk_settings_plugins_enabled_set(settings, false));
250     ASSERT_FALSE(ewk_settings_plugins_enabled_get(settings));
251 }
252
253 TEST_F(EWK2UnitTestBase, ewk_settings_default_font_size)
254 {
255     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
256
257     // 16 by default.
258     ASSERT_EQ(16, ewk_settings_default_font_size_get(settings));
259
260     ASSERT_TRUE(ewk_settings_default_font_size_set(settings, 10));
261     ASSERT_EQ(10, ewk_settings_default_font_size_get(settings));
262
263     ASSERT_TRUE(ewk_settings_default_font_size_set(settings, 20));
264     ASSERT_EQ(20, ewk_settings_default_font_size_get(settings));
265 }
266
267 TEST_F(EWK2UnitTestBase, ewk_settings_private_browsing_enabled)
268 {
269     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
270
271     // Private browsing is disabled by default.
272     ASSERT_FALSE(ewk_settings_private_browsing_enabled_get(settings));
273
274     ASSERT_TRUE(ewk_settings_private_browsing_enabled_set(settings, true));
275     ASSERT_TRUE(ewk_settings_private_browsing_enabled_get(settings));
276
277     ASSERT_TRUE(ewk_settings_private_browsing_enabled_set(settings, false));
278     ASSERT_FALSE(ewk_settings_private_browsing_enabled_get(settings));
279 }
280
281 TEST_F(EWK2UnitTestBase, ewk_settings_text_autosizing_enabled)
282 {
283     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
284
285     ASSERT_FALSE(ewk_settings_text_autosizing_enabled_get(settings));
286
287     ASSERT_FALSE(ewk_settings_text_autosizing_enabled_set(settings, false));
288     ASSERT_FALSE(ewk_settings_text_autosizing_enabled_get(settings));
289
290     ASSERT_FALSE(ewk_settings_text_autosizing_enabled_set(settings, true));
291     ASSERT_FALSE(ewk_settings_text_autosizing_enabled_get(settings));
292 }
293
294 TEST_F(EWK2UnitTestBase, ewk_settings_web_security_enabled)
295 {
296     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
297
298     // Web security should be enabled by default.
299     ASSERT_TRUE(ewk_settings_web_security_enabled_get(settings));
300
301     ASSERT_TRUE(ewk_settings_web_security_enabled_set(settings, false));
302     ASSERT_FALSE(ewk_settings_web_security_enabled_get(settings));
303
304     ASSERT_TRUE(ewk_settings_web_security_enabled_set(settings, true));
305     ASSERT_TRUE(ewk_settings_web_security_enabled_get(settings));
306 }
307
308 TEST_F(EWK2UnitTestBase, ewk_settings_spatial_navigation_enabled)
309 {
310     Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
311
312     // Spatial navigation is disabled by default.
313     ASSERT_FALSE(ewk_settings_spatial_navigation_enabled_get(settings));
314
315     ASSERT_TRUE(ewk_settings_spatial_navigation_enabled_set(settings, true));
316     ASSERT_TRUE(ewk_settings_spatial_navigation_enabled_get(settings));
317
318     ASSERT_TRUE(ewk_settings_spatial_navigation_enabled_set(settings, false));
319     ASSERT_FALSE(ewk_settings_spatial_navigation_enabled_get(settings));
320 }