summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp')
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp
new file mode 100644
index 000000000..7971b0b27
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/WKPreferences.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include <WebKit/WKPreferencesRefPrivate.h>
+#include <WebKit/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+TEST(WebKit2, WKPreferencesBasic)
+{
+ WKPreferencesRef preference = WKPreferencesCreate();
+
+ EXPECT_EQ(WKPreferencesGetTypeID(), WKGetTypeID(preference));
+
+ WKRelease(preference);
+}
+
+TEST(WebKit2, WKPreferencesDefaults)
+{
+#if PLATFORM(GTK) || PLATFORM(EFL)
+ static const char* expectedStandardFontFamily = "Times";
+ static const char* expectedFixedFontFamily = "Courier New";
+ static const char* expectedSerifFontFamily = "Times";
+ static const char* expectedSansSerifFontFamily = "Helvetica";
+ static const char* expectedCursiveFontFamily = "Comic Sans MS";
+ static const char* expectedFantasyFontFamily = "Impact";
+ static const char* expectedPictographFontFamily = "Times";
+#elif WK_HAVE_C_SPI
+ static const char* expectedStandardFontFamily = "Times";
+ static const char* expectedFixedFontFamily = "Courier";
+ static const char* expectedSerifFontFamily = "Times";
+ static const char* expectedSansSerifFontFamily = "Helvetica";
+ static const char* expectedCursiveFontFamily = "Apple Chancery";
+ static const char* expectedFantasyFontFamily = "Papyrus";
+ static const char* expectedPictographFontFamily = "Apple Color Emoji";
+#elif PLATFORM(IOS)
+ static const char* expectedStandardFontFamily = "Times";
+ static const char* expectedFixedFontFamily = "Courier";
+ static const char* expectedSerifFontFamily = "Times";
+ static const char* expectedSansSerifFontFamily = "Helvetica";
+ static const char* expectedCursiveFontFamily = "Snell Roundhand";
+ static const char* expectedFantasyFontFamily = "Papyrus";
+ static const char* expectedPictographFontFamily = "AppleColorEmoji";
+#endif
+
+ WKPreferencesRef preference = WKPreferencesCreate();
+
+ EXPECT_TRUE(WKPreferencesGetJavaScriptEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetLoadsImagesAutomatically(preference));
+ EXPECT_FALSE(WKPreferencesGetOfflineWebApplicationCacheEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetLocalStorageEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetXSSAuditorEnabled(preference));
+ EXPECT_FALSE(WKPreferencesGetFrameFlatteningEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetPluginsEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetJavaEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(preference));
+ EXPECT_TRUE(WKPreferencesGetHyperlinkAuditingEnabled(preference));
+ EXPECT_WK_STREQ(expectedStandardFontFamily, adoptWK(WKPreferencesCopyStandardFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedFixedFontFamily, adoptWK(WKPreferencesCopyFixedFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedSerifFontFamily, adoptWK(WKPreferencesCopySerifFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedSansSerifFontFamily, adoptWK(WKPreferencesCopySansSerifFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedCursiveFontFamily, adoptWK(WKPreferencesCopyCursiveFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedFantasyFontFamily, adoptWK(WKPreferencesCopyFantasyFontFamily(preference)));
+ EXPECT_WK_STREQ(expectedPictographFontFamily, adoptWK(WKPreferencesCopyPictographFontFamily(preference)));
+ EXPECT_EQ(0u, WKPreferencesGetMinimumFontSize(preference));
+ EXPECT_FALSE(WKPreferencesGetPrivateBrowsingEnabled(preference));
+ EXPECT_FALSE(WKPreferencesGetDeveloperExtrasEnabled(preference));
+ EXPECT_TRUE(WKPreferencesGetTextAreasAreResizable(preference));
+
+ EXPECT_EQ(kWKFontSmoothingLevelMedium, WKPreferencesGetFontSmoothingLevel(preference));
+
+ EXPECT_TRUE(WKPreferencesGetAcceleratedCompositingEnabled(preference));
+ EXPECT_FALSE(WKPreferencesGetCompositingBordersVisible(preference));
+ EXPECT_FALSE(WKPreferencesGetCompositingRepaintCountersVisible(preference));
+ EXPECT_FALSE(WKPreferencesGetNeedsSiteSpecificQuirks(preference));
+ EXPECT_EQ(kWKAllowAllStorage, WKPreferencesGetStorageBlockingPolicy(preference));
+ EXPECT_FALSE(WKPreferencesGetTextAutosizingEnabled(preference));
+
+ WKRelease(preference);
+}
+
+TEST(WebKit2, WKPreferencesCopying)
+{
+ WKRetainPtr<WKStringRef> identifier(AdoptWK, WKStringCreateWithUTF8CString("identifier"));
+
+ WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreateWithIdentifier(identifier.get()));
+ WKPreferencesSetDefaultFontSize(preferences.get(), 36);
+
+ WKRetainPtr<WKPreferencesRef> copy(AdoptWK, WKPreferencesCreateCopy(preferences.get()));
+
+ WKPreferencesSetDefaultFontSize(preferences.get(), 24);
+ EXPECT_EQ(24u, WKPreferencesGetDefaultFontSize(preferences.get()));
+ EXPECT_EQ(36u, WKPreferencesGetDefaultFontSize(copy.get()));
+}
+
+} // namespace TestWebKitAPI
+
+#endif