• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "Test.h"
27 
28 #include <WebKit2/WKPreferences.h>
29 #include <WebKit2/WKPreferencesPrivate.h>
30 #include <WebKit2/WKRetainPtr.h>
31 #include <WebKit2/WKString.h>
32 #include <wtf/Platform.h>
33 
34 namespace TestWebKitAPI {
35 
TEST(WebKit2,WKPreferencesBasic)36 TEST(WebKit2, WKPreferencesBasic)
37 {
38     WKPreferencesRef preference = WKPreferencesCreate();
39 
40     TEST_ASSERT(WKGetTypeID(preference) == WKPreferencesGetTypeID());
41 
42     WKRelease(preference);
43 }
44 
TEST(WebKit2,WKPreferencesDefaults)45 TEST(WebKit2, WKPreferencesDefaults)
46 {
47 #if PLATFORM(WIN)
48     static const char* expectedStandardFontFamily = "Times New Roman";
49     static const char* expectedFixedFontFamily = "Courier New";
50     static const char* expectedSerifFontFamily = "Times New Roman";
51     static const char* expectedSansSerifFontFamily = "Arial";
52     static const char* expectedCursiveFontFamily = "Comic Sans MS";
53     static const char* expectedFantasyFontFamily = "Comic Sans MS";
54 #elif PLATFORM(MAC)
55     static const char* expectedStandardFontFamily = "Times";
56     static const char* expectedFixedFontFamily = "Courier";
57     static const char* expectedSerifFontFamily = "Times";
58     static const char* expectedSansSerifFontFamily = "Helvetica";
59     static const char* expectedCursiveFontFamily = "Apple Chancery";
60     static const char* expectedFantasyFontFamily = "Papyrus";
61 #endif
62 
63     WKPreferencesRef preference = WKPreferencesCreate();
64 
65     TEST_ASSERT(WKPreferencesGetJavaScriptEnabled(preference) == true);
66     TEST_ASSERT(WKPreferencesGetLoadsImagesAutomatically(preference) == true);
67     TEST_ASSERT(WKPreferencesGetOfflineWebApplicationCacheEnabled(preference) == false);
68     TEST_ASSERT(WKPreferencesGetLocalStorageEnabled(preference) == true);
69     TEST_ASSERT(WKPreferencesGetXSSAuditorEnabled(preference) == true);
70     TEST_ASSERT(WKPreferencesGetFrameFlatteningEnabled(preference) == false);
71     TEST_ASSERT(WKPreferencesGetPluginsEnabled(preference) == true);
72     TEST_ASSERT(WKPreferencesGetJavaEnabled(preference) == true);
73     TEST_ASSERT(WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(preference) == true);
74     TEST_ASSERT(WKPreferencesGetHyperlinkAuditingEnabled(preference) == true);
75     WKRetainPtr<WKStringRef> standardFontFamily(AdoptWK, WKPreferencesCopyStandardFontFamily(preference));
76     TEST_ASSERT(WKStringIsEqualToUTF8CString(standardFontFamily.get(), expectedStandardFontFamily));
77     WKRetainPtr<WKStringRef> fixedFontFamily(AdoptWK, WKPreferencesCopyFixedFontFamily(preference));
78     TEST_ASSERT(WKStringIsEqualToUTF8CString(fixedFontFamily.get(), expectedFixedFontFamily));
79     WKRetainPtr<WKStringRef> serifFontFamily(AdoptWK, WKPreferencesCopySerifFontFamily(preference));
80     TEST_ASSERT(WKStringIsEqualToUTF8CString(serifFontFamily.get(), expectedSerifFontFamily));
81     WKRetainPtr<WKStringRef> sansSerifFontFamily(AdoptWK, WKPreferencesCopySansSerifFontFamily(preference));
82     TEST_ASSERT(WKStringIsEqualToUTF8CString(sansSerifFontFamily.get(), expectedSansSerifFontFamily));
83     WKRetainPtr<WKStringRef> cursiveFontFamily(AdoptWK, WKPreferencesCopyCursiveFontFamily(preference));
84     TEST_ASSERT(WKStringIsEqualToUTF8CString(cursiveFontFamily.get(), expectedCursiveFontFamily));
85     WKRetainPtr<WKStringRef> fantasyFontFamily(AdoptWK, WKPreferencesCopyFantasyFontFamily(preference));
86     TEST_ASSERT(WKStringIsEqualToUTF8CString(fantasyFontFamily.get(), expectedFantasyFontFamily));
87     TEST_ASSERT(WKPreferencesGetMinimumFontSize(preference) == 0);
88     TEST_ASSERT(WKPreferencesGetPrivateBrowsingEnabled(preference) == false);
89     TEST_ASSERT(WKPreferencesGetDeveloperExtrasEnabled(preference) == false);
90     TEST_ASSERT(WKPreferencesGetTextAreasAreResizable(preference) == true);
91     TEST_ASSERT(WKPreferencesGetFontSmoothingLevel(preference) == kWKFontSmoothingLevelMedium);
92     TEST_ASSERT(WKPreferencesGetAcceleratedCompositingEnabled(preference) == true);
93     TEST_ASSERT(WKPreferencesGetCompositingBordersVisible(preference) == false);
94     TEST_ASSERT(WKPreferencesGetCompositingRepaintCountersVisible(preference) == false);
95     TEST_ASSERT(WKPreferencesGetNeedsSiteSpecificQuirks(preference) == false);
96 
97     WKRelease(preference);
98 }
99 
100 } // namespace TestWebKitAPI
101