OLD | NEW |
| (Empty) |
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 <WebKit2/WKPreferencesPrivate.h> | |
29 #include <WebKit2/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(WIN) | |
45 static const char* expectedStandardFontFamily = "Times New Roman"; | |
46 static const char* expectedFixedFontFamily = "Courier New"; | |
47 static const char* expectedSerifFontFamily = "Times New Roman"; | |
48 static const char* expectedSansSerifFontFamily = "Arial"; | |
49 static const char* expectedCursiveFontFamily = "Comic Sans MS"; | |
50 static const char* expectedFantasyFontFamily = "Comic Sans MS"; | |
51 static const char* expectedPictographFontFamily = "Times New Roman"; | |
52 #elif PLATFORM(MAC) | |
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 = "Apple Chancery"; | |
58 static const char* expectedFantasyFontFamily = "Papyrus"; | |
59 static const char* expectedPictographFontFamily = "Apple Color Emoji"; | |
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(WKPreferencesCopyStandar
dFontFamily(preference))); | |
83 EXPECT_WK_STREQ(expectedFixedFontFamily, adoptWK(WKPreferencesCopyFixedFontF
amily(preference))); | |
84 EXPECT_WK_STREQ(expectedSerifFontFamily, adoptWK(WKPreferencesCopySerifFontF
amily(preference))); | |
85 EXPECT_WK_STREQ(expectedSansSerifFontFamily, adoptWK(WKPreferencesCopySansSe
rifFontFamily(preference))); | |
86 EXPECT_WK_STREQ(expectedCursiveFontFamily, adoptWK(WKPreferencesCopyCursiveF
ontFamily(preference))); | |
87 EXPECT_WK_STREQ(expectedFantasyFontFamily, adoptWK(WKPreferencesCopyFantasyF
ontFamily(preference))); | |
88 EXPECT_WK_STREQ(expectedPictographFontFamily, adoptWK(WKPreferencesCopyPicto
graphFontFamily(preference))); | |
89 EXPECT_EQ(0u, WKPreferencesGetMinimumFontSize(preference)); | |
90 EXPECT_FALSE(WKPreferencesGetPrivateBrowsingEnabled(preference)); | |
91 EXPECT_FALSE(WKPreferencesGetDeveloperExtrasEnabled(preference)); | |
92 EXPECT_TRUE(WKPreferencesGetTextAreasAreResizable(preference)); | |
93 | |
94 #if PLATFORM(WIN) | |
95 EXPECT_EQ(kWKFontSmoothingLevelWindows, WKPreferencesGetFontSmoothingLevel(p
reference)); | |
96 #else | |
97 EXPECT_EQ(kWKFontSmoothingLevelMedium, WKPreferencesGetFontSmoothingLevel(pr
eference)); | |
98 #endif | |
99 | |
100 EXPECT_TRUE(WKPreferencesGetAcceleratedCompositingEnabled(preference)); | |
101 EXPECT_FALSE(WKPreferencesGetCompositingBordersVisible(preference)); | |
102 EXPECT_FALSE(WKPreferencesGetCompositingRepaintCountersVisible(preference)); | |
103 EXPECT_FALSE(WKPreferencesGetNeedsSiteSpecificQuirks(preference)); | |
104 EXPECT_EQ(kWKAllowAllStorage, WKPreferencesGetStorageBlockingPolicy(preferen
ce)); | |
105 EXPECT_FALSE(WKPreferencesGetTextAutosizingEnabled(preference)); | |
106 | |
107 WKRelease(preference); | |
108 } | |
109 | |
110 TEST(WebKit2, WKPreferencesCopying) | |
111 { | |
112 WKRetainPtr<WKStringRef> identifier(AdoptWK, WKStringCreateWithUTF8CString("
identifier")); | |
113 | |
114 WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreateWithId
entifier(identifier.get())); | |
115 WKPreferencesSetDefaultFontSize(preferences.get(), 36); | |
116 | |
117 WKRetainPtr<WKPreferencesRef> copy(AdoptWK, WKPreferencesCreateCopy(preferen
ces.get())); | |
118 | |
119 WKPreferencesSetDefaultFontSize(preferences.get(), 24); | |
120 EXPECT_EQ(24u, WKPreferencesGetDefaultFontSize(preferences.get())); | |
121 EXPECT_EQ(36u, WKPreferencesGetDefaultFontSize(copy.get())); | |
122 } | |
123 | |
124 } // namespace TestWebKitAPI | |
OLD | NEW |