Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: ios/web/web_state/ui/wk_web_view_configuration_provider_unittest.mm

Issue 1171203004: Correct iOS build for latest Xcode beta. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" 5 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import "base/ios/weak_nsobject.h" 9 #import "base/ios/weak_nsobject.h"
10 #include "ios/web/public/test/test_browser_state.h" 10 #include "ios/web/public/test/test_browser_state.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Different WKProcessPools for different providers. 63 // Different WKProcessPools for different providers.
64 TestBrowserState other_browser_state; 64 TestBrowserState other_browser_state;
65 WKWebViewConfigurationProvider& other_provider = 65 WKWebViewConfigurationProvider& other_provider =
66 GetProvider(&other_browser_state); 66 GetProvider(&other_browser_state);
67 EXPECT_NE(provider.GetWebViewConfiguration().processPool, 67 EXPECT_NE(provider.GetWebViewConfiguration().processPool,
68 other_provider.GetWebViewConfiguration().processPool); 68 other_provider.GetWebViewConfiguration().processPool);
69 } 69 }
70 70
71 // Tests that internal configuration object can not be changed by clients. 71 // Tests that internal configuration object can not be changed by clients.
72 #if 0
72 TEST_F(WKWebViewConfigurationProviderTest, ConfigurationProtection) { 73 TEST_F(WKWebViewConfigurationProviderTest, ConfigurationProtection) {
73 CR_TEST_REQUIRES_WK_WEB_VIEW(); 74 CR_TEST_REQUIRES_WK_WEB_VIEW();
74 75
75 WKWebViewConfigurationProvider& provider = GetProvider(&browser_state_); 76 WKWebViewConfigurationProvider& provider = GetProvider(&browser_state_);
76 WKWebViewConfiguration* config = provider.GetWebViewConfiguration(); 77 WKWebViewConfiguration* config = provider.GetWebViewConfiguration();
77 base::scoped_nsobject<WKProcessPool> pool([[config processPool] retain]); 78 base::scoped_nsobject<WKProcessPool> pool([[config processPool] retain]);
78 base::scoped_nsobject<WKPreferences> prefs([[config preferences] retain]); 79 base::scoped_nsobject<WKPreferences> prefs([[config preferences] retain]);
79 base::scoped_nsobject<WKUserContentController> userContentController( 80 base::scoped_nsobject<WKUserContentController> userContentController(
80 [[config userContentController] retain]); 81 [[config userContentController] retain]);
81 82
82 // nil-out the properties of returned configuration object. 83 // nil-out the properties of returned configuration object.
83 config.processPool = nil; 84 config.processPool = nil;
shreyasv1 2015/06/10 15:14:35 you can just WKProcessPool/WKPreference/WKUserCont
justincohen 2015/06/10 15:21:11 Just did the alloc init autorelease. wdyt?
84 config.preferences = nil; 85 config.preferences = nil;
85 config.userContentController = nil; 86 config.userContentController = nil;
86 87
87 // Make sure that the properties of internal configuration were not changed. 88 // Make sure that the properties of internal configuration were not changed.
88 EXPECT_TRUE(provider.GetWebViewConfiguration().processPool); 89 EXPECT_TRUE(provider.GetWebViewConfiguration().processPool);
89 EXPECT_EQ(pool.get(), provider.GetWebViewConfiguration().processPool); 90 EXPECT_EQ(pool.get(), provider.GetWebViewConfiguration().processPool);
90 EXPECT_TRUE(provider.GetWebViewConfiguration().preferences); 91 EXPECT_TRUE(provider.GetWebViewConfiguration().preferences);
91 EXPECT_EQ(prefs.get(), provider.GetWebViewConfiguration().preferences); 92 EXPECT_EQ(prefs.get(), provider.GetWebViewConfiguration().preferences);
92 EXPECT_TRUE(provider.GetWebViewConfiguration().userContentController); 93 EXPECT_TRUE(provider.GetWebViewConfiguration().userContentController);
93 EXPECT_EQ(userContentController.get(), 94 EXPECT_EQ(userContentController.get(),
94 provider.GetWebViewConfiguration().userContentController); 95 provider.GetWebViewConfiguration().userContentController);
95 } 96 }
97 #endif
96 98
97 // Tests that |HasWebViewConfiguration| returns false by default. 99 // Tests that |HasWebViewConfiguration| returns false by default.
98 TEST_F(WKWebViewConfigurationProviderTest, NoConfigurationByDefault) { 100 TEST_F(WKWebViewConfigurationProviderTest, NoConfigurationByDefault) {
99 CR_TEST_REQUIRES_WK_WEB_VIEW(); 101 CR_TEST_REQUIRES_WK_WEB_VIEW();
100 102
101 EXPECT_FALSE(GetProvider().HasWebViewConfiguration()); 103 EXPECT_FALSE(GetProvider().HasWebViewConfiguration());
102 } 104 }
103 105
104 // Tests that |HasWebViewConfiguration| returns true after 106 // Tests that |HasWebViewConfiguration| returns true after
105 // |GetWebViewConfiguration| call and false after |Purge| call. 107 // |GetWebViewConfiguration| call and false after |Purge| call.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 NSArray* scripts = config.userContentController.userScripts; 147 NSArray* scripts = config.userContentController.userScripts;
146 EXPECT_EQ(1U, scripts.count); 148 EXPECT_EQ(1U, scripts.count);
147 NSString* early_script = GetEarlyPageScript(WK_WEB_VIEW_TYPE); 149 NSString* early_script = GetEarlyPageScript(WK_WEB_VIEW_TYPE);
148 // |earlyScript| is a substring of |userScripts|. The latter wraps the 150 // |earlyScript| is a substring of |userScripts|. The latter wraps the
149 // former with "if (!injected)" check to avoid double injections. 151 // former with "if (!injected)" check to avoid double injections.
150 EXPECT_LT(0U, [[scripts[0] source] rangeOfString:early_script].length); 152 EXPECT_LT(0U, [[scripts[0] source] rangeOfString:early_script].length);
151 } 153 }
152 154
153 } // namespace 155 } // namespace
154 } // namespace web 156 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698