Remove Windows WebKit2 code from TestWebKitAPI
[WebKit-https.git] / Tools / TestWebKitAPI / Tests / WebKit2 / WKPreferences.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
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 #include "PlatformUtilities.h"
28 #include <WebKit/WKPreferencesRefPrivate.h>
29 #include <WebKit/WKRetainPtr.h>
30
31 namespace TestWebKitAPI {
32
33 TEST(WebKit2, WKPreferencesBasic)
34 {
35     WKPreferencesRef preference = WKPreferencesCreate();
36
37     EXPECT_EQ(WKPreferencesGetTypeID(), WKGetTypeID(preference));
38
39     WKRelease(preference);
40 }
41
42 TEST(WebKit2, WKPreferencesDefaults)
43 {
44 #if PLATFORM(MAC)
45     static const char* expectedStandardFontFamily = "Times";
46     static const char* expectedFixedFontFamily = "Courier";
47     static const char* expectedSerifFontFamily = "Times";
48     static const char* expectedSansSerifFontFamily = "Helvetica";
49     static const char* expectedCursiveFontFamily = "Apple Chancery";
50     static const char* expectedFantasyFontFamily = "Papyrus";
51     static const char* expectedPictographFontFamily = "Apple Color Emoji";
52 #elif PLATFORM(IOS)
53     static const char* expectedStandardFontFamily = "Times";
54     static const char* expectedFixedFontFamily = "Courier";
55     static const char* expectedSerifFontFamily = "Times";
56     static const char* expectedSansSerifFontFamily = "Helvetica";
57     static const char* expectedCursiveFontFamily = "Snell Roundhand";
58     static const char* expectedFantasyFontFamily = "Papyrus";
59     static const char* expectedPictographFontFamily = "AppleColorEmoji";
60 #elif PLATFORM(GTK) || PLATFORM(EFL)
61     static const char* expectedStandardFontFamily = "Times";
62     static const char* expectedFixedFontFamily = "Courier New";
63     static const char* expectedSerifFontFamily = "Times";
64     static const char* expectedSansSerifFontFamily = "Helvetica";
65     static const char* expectedCursiveFontFamily = "Comic Sans MS";
66     static const char* expectedFantasyFontFamily = "Impact";
67     static const char* expectedPictographFontFamily = "Times";
68 #endif
69
70     WKPreferencesRef preference = WKPreferencesCreate();
71
72     EXPECT_TRUE(WKPreferencesGetJavaScriptEnabled(preference));
73     EXPECT_TRUE(WKPreferencesGetLoadsImagesAutomatically(preference));
74     EXPECT_FALSE(WKPreferencesGetOfflineWebApplicationCacheEnabled(preference));
75     EXPECT_TRUE(WKPreferencesGetLocalStorageEnabled(preference));
76     EXPECT_TRUE(WKPreferencesGetXSSAuditorEnabled(preference));
77     EXPECT_FALSE(WKPreferencesGetFrameFlatteningEnabled(preference));
78     EXPECT_TRUE(WKPreferencesGetPluginsEnabled(preference));
79     EXPECT_TRUE(WKPreferencesGetJavaEnabled(preference));
80     EXPECT_TRUE(WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(preference));
81     EXPECT_TRUE(WKPreferencesGetHyperlinkAuditingEnabled(preference));
82     EXPECT_WK_STREQ(expectedStandardFontFamily, adoptWK(WKPreferencesCopyStandardFontFamily(preference)));
83     EXPECT_WK_STREQ(expectedFixedFontFamily, adoptWK(WKPreferencesCopyFixedFontFamily(preference)));
84     EXPECT_WK_STREQ(expectedSerifFontFamily, adoptWK(WKPreferencesCopySerifFontFamily(preference)));
85     EXPECT_WK_STREQ(expectedSansSerifFontFamily, adoptWK(WKPreferencesCopySansSerifFontFamily(preference)));
86     EXPECT_WK_STREQ(expectedCursiveFontFamily, adoptWK(WKPreferencesCopyCursiveFontFamily(preference)));
87     EXPECT_WK_STREQ(expectedFantasyFontFamily, adoptWK(WKPreferencesCopyFantasyFontFamily(preference)));
88     EXPECT_WK_STREQ(expectedPictographFontFamily, adoptWK(WKPreferencesCopyPictographFontFamily(preference)));
89     EXPECT_EQ(0u, WKPreferencesGetMinimumFontSize(preference));
90     EXPECT_FALSE(WKPreferencesGetPrivateBrowsingEnabled(preference));
91     EXPECT_FALSE(WKPreferencesGetDeveloperExtrasEnabled(preference));
92     EXPECT_TRUE(WKPreferencesGetTextAreasAreResizable(preference));
93
94     EXPECT_EQ(kWKFontSmoothingLevelMedium, WKPreferencesGetFontSmoothingLevel(preference));
95
96     EXPECT_TRUE(WKPreferencesGetAcceleratedCompositingEnabled(preference));
97     EXPECT_FALSE(WKPreferencesGetCompositingBordersVisible(preference));
98     EXPECT_FALSE(WKPreferencesGetCompositingRepaintCountersVisible(preference));
99     EXPECT_FALSE(WKPreferencesGetNeedsSiteSpecificQuirks(preference));
100     EXPECT_EQ(kWKAllowAllStorage, WKPreferencesGetStorageBlockingPolicy(preference));
101     EXPECT_FALSE(WKPreferencesGetTextAutosizingEnabled(preference));
102
103     WKRelease(preference);
104 }
105
106 TEST(WebKit2, WKPreferencesCopying)
107 {
108     WKRetainPtr<WKStringRef> identifier(AdoptWK, WKStringCreateWithUTF8CString("identifier"));
109
110     WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreateWithIdentifier(identifier.get()));
111     WKPreferencesSetDefaultFontSize(preferences.get(), 36);
112
113     WKRetainPtr<WKPreferencesRef> copy(AdoptWK, WKPreferencesCreateCopy(preferences.get()));
114
115     WKPreferencesSetDefaultFontSize(preferences.get(), 24);
116     EXPECT_EQ(24u, WKPreferencesGetDefaultFontSize(preferences.get()));
117     EXPECT_EQ(36u, WKPreferencesGetDefaultFontSize(copy.get()));
118 }
119
120 } // namespace TestWebKitAPI