initial import
[vuplus_webkit] / 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 <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 #endif
61
62     WKPreferencesRef preference = WKPreferencesCreate();
63
64     EXPECT_TRUE(WKPreferencesGetJavaScriptEnabled(preference));
65     EXPECT_TRUE(WKPreferencesGetLoadsImagesAutomatically(preference));
66     EXPECT_FALSE(WKPreferencesGetOfflineWebApplicationCacheEnabled(preference));
67     EXPECT_TRUE(WKPreferencesGetLocalStorageEnabled(preference));
68     EXPECT_TRUE(WKPreferencesGetXSSAuditorEnabled(preference));
69     EXPECT_FALSE(WKPreferencesGetFrameFlatteningEnabled(preference));
70     EXPECT_TRUE(WKPreferencesGetPluginsEnabled(preference));
71     EXPECT_TRUE(WKPreferencesGetJavaEnabled(preference));
72     EXPECT_TRUE(WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(preference));
73     EXPECT_TRUE(WKPreferencesGetHyperlinkAuditingEnabled(preference));
74     EXPECT_WK_STREQ(expectedStandardFontFamily, adoptWK(WKPreferencesCopyStandardFontFamily(preference)));
75     EXPECT_WK_STREQ(expectedFixedFontFamily, adoptWK(WKPreferencesCopyFixedFontFamily(preference)));
76     EXPECT_WK_STREQ(expectedSerifFontFamily, adoptWK(WKPreferencesCopySerifFontFamily(preference)));
77     EXPECT_WK_STREQ(expectedSansSerifFontFamily, adoptWK(WKPreferencesCopySansSerifFontFamily(preference)));
78     EXPECT_WK_STREQ(expectedCursiveFontFamily, adoptWK(WKPreferencesCopyCursiveFontFamily(preference)));
79     EXPECT_WK_STREQ(expectedFantasyFontFamily, adoptWK(WKPreferencesCopyFantasyFontFamily(preference)));
80     EXPECT_WK_STREQ(expectedPictographFontFamily, adoptWK(WKPreferencesCopyPictographFontFamily(preference)));
81     EXPECT_EQ(0u, WKPreferencesGetMinimumFontSize(preference));
82     EXPECT_FALSE(WKPreferencesGetPrivateBrowsingEnabled(preference));
83     EXPECT_FALSE(WKPreferencesGetDeveloperExtrasEnabled(preference));
84     EXPECT_TRUE(WKPreferencesGetTextAreasAreResizable(preference));
85
86 #if PLATFORM(WIN)
87     EXPECT_EQ(kWKFontSmoothingLevelWindows, WKPreferencesGetFontSmoothingLevel(preference));
88 #else
89     EXPECT_EQ(kWKFontSmoothingLevelMedium, WKPreferencesGetFontSmoothingLevel(preference));
90 #endif
91
92     EXPECT_TRUE(WKPreferencesGetAcceleratedCompositingEnabled(preference));
93     EXPECT_FALSE(WKPreferencesGetCompositingBordersVisible(preference));
94     EXPECT_FALSE(WKPreferencesGetCompositingRepaintCountersVisible(preference));
95     EXPECT_FALSE(WKPreferencesGetNeedsSiteSpecificQuirks(preference));
96
97     WKRelease(preference);
98 }
99
100 } // namespace TestWebKitAPI