| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 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 <wtf/RetainPtr.h> | |
| 28 | |
| 29 #import <WebKit/WebView.h> | |
| 30 #import <WebKit/WebPreferences.h> | |
| 31 | |
| 32 @interface WebView (WebViewOtherInternal) | |
| 33 + (WebCacheModel)_cacheModel; | |
| 34 @end | |
| 35 | |
| 36 namespace TestWebKitAPI { | |
| 37 | |
| 38 TEST(WebKit1, SetAndUpdateCacheModelInitialModel) | |
| 39 { | |
| 40 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 41 | |
| 42 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec
t(0, 0, 120, 200) frameName:nil groupName:nil]); | |
| 43 | |
| 44 EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]); | |
| 45 } | |
| 46 | |
| 47 TEST(WebKit1, SetAndUpdateCacheModelStandardPreferenceChange) | |
| 48 { | |
| 49 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 50 | |
| 51 WebPreferences *standardPreferences = [WebPreferences standardPreferences]; | |
| 52 EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]); | |
| 53 | |
| 54 [standardPreferences setCacheModel:WebCacheModelPrimaryWebBrowser]; | |
| 55 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 56 | |
| 57 [standardPreferences setCacheModel:WebCacheModelDocumentViewer]; | |
| 58 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 59 } | |
| 60 | |
| 61 TEST(WebKit1, SetAndUpdateCacheModelPreferencesChangeMix) | |
| 62 { | |
| 63 // On change, the cache model always take the highest value of any preferenc
e bound to a WebView. | |
| 64 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 65 | |
| 66 WebPreferences *standardPreferences = [WebPreferences standardPreferences]; | |
| 67 RetainPtr<WebPreferences> customPreferences(AdoptNS, [[WebPreferences alloc]
initWithIdentifier:@"SetAndUpdateCacheModelPreferencesChangeMix"]); | |
| 68 | |
| 69 // 1) The customPreferences is not set on a view. | |
| 70 EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]); | |
| 71 | |
| 72 [standardPreferences setCacheModel:WebCacheModelPrimaryWebBrowser]; | |
| 73 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 74 | |
| 75 [standardPreferences setCacheModel:WebCacheModelDocumentViewer]; | |
| 76 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 77 [customPreferences.get() setCacheModel:WebCacheModelPrimaryWebBrowser]; | |
| 78 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 79 | |
| 80 | |
| 81 // 2) The cache model should follow the highest value of cache model between
the two preferences. | |
| 82 RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRec
t(0, 0, 120, 200) frameName:nil groupName:nil]); | |
| 83 [webView.get() setPreferences:customPreferences.get()]; | |
| 84 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 85 | |
| 86 [customPreferences.get() setCacheModel:WebCacheModelDocumentBrowser]; | |
| 87 EXPECT_EQ((int)WebCacheModelDocumentBrowser, (int)[WebView _cacheModel]); | |
| 88 | |
| 89 [standardPreferences setCacheModel:WebCacheModelPrimaryWebBrowser]; | |
| 90 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 91 [customPreferences.get() setCacheModel:WebCacheModelDocumentViewer]; | |
| 92 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 93 | |
| 94 // 3) Resetting the view should fall back to standardPreferences. | |
| 95 [standardPreferences setCacheModel:WebCacheModelDocumentViewer]; | |
| 96 [customPreferences.get() setCacheModel:WebCacheModelPrimaryWebBrowser]; | |
| 97 EXPECT_EQ((int)WebCacheModelPrimaryWebBrowser, (int)[WebView _cacheModel]); | |
| 98 | |
| 99 webView.clear(); | |
| 100 EXPECT_EQ((int)WebCacheModelDocumentViewer, (int)[WebView _cacheModel]); | |
| 101 } | |
| 102 | |
| 103 } // namespace TestWebKitAPI | |
| OLD | NEW |