OLD | NEW |
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 "base/memory/ptr_util.h" |
10 #include "ios/web/public/test/scoped_testing_web_client.h" | 11 #include "ios/web/public/test/scoped_testing_web_client.h" |
11 #include "ios/web/public/test/test_browser_state.h" | 12 #include "ios/web/public/test/test_browser_state.h" |
12 #include "ios/web/public/web_client.h" | 13 #include "ios/web/public/web_client.h" |
13 #import "ios/web/web_state/js/page_script_util.h" | 14 #import "ios/web/web_state/js/page_script_util.h" |
14 #import "ios/web/web_state/ui/crw_wk_script_message_router.h" | 15 #import "ios/web/web_state/ui/crw_wk_script_message_router.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/gtest_mac.h" | 17 #include "testing/gtest_mac.h" |
17 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
18 | 19 |
19 namespace web { | 20 namespace web { |
20 namespace { | 21 namespace { |
21 | 22 |
22 class WKWebViewConfigurationProviderTest : public PlatformTest { | 23 class WKWebViewConfigurationProviderTest : public PlatformTest { |
23 public: | 24 public: |
24 WKWebViewConfigurationProviderTest() | 25 WKWebViewConfigurationProviderTest() |
25 : web_client_(make_scoped_ptr(new web::WebClient)) {} | 26 : web_client_(base::WrapUnique(new web::WebClient)) {} |
26 | 27 |
27 protected: | 28 protected: |
28 // Returns WKWebViewConfigurationProvider associated with |browser_state_|. | 29 // Returns WKWebViewConfigurationProvider associated with |browser_state_|. |
29 WKWebViewConfigurationProvider& GetProvider() { | 30 WKWebViewConfigurationProvider& GetProvider() { |
30 return GetProvider(&browser_state_); | 31 return GetProvider(&browser_state_); |
31 } | 32 } |
32 // Returns WKWebViewConfigurationProvider for given |browser_state|. | 33 // Returns WKWebViewConfigurationProvider for given |browser_state|. |
33 WKWebViewConfigurationProvider& GetProvider( | 34 WKWebViewConfigurationProvider& GetProvider( |
34 BrowserState* browser_state) const { | 35 BrowserState* browser_state) const { |
35 return WKWebViewConfigurationProvider::FromBrowserState(browser_state); | 36 return WKWebViewConfigurationProvider::FromBrowserState(browser_state); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 NSArray* scripts = config.userContentController.userScripts; | 138 NSArray* scripts = config.userContentController.userScripts; |
138 EXPECT_EQ(1U, scripts.count); | 139 EXPECT_EQ(1U, scripts.count); |
139 NSString* early_script = GetEarlyPageScript(); | 140 NSString* early_script = GetEarlyPageScript(); |
140 // |earlyScript| is a substring of |userScripts|. The latter wraps the | 141 // |earlyScript| is a substring of |userScripts|. The latter wraps the |
141 // former with "if (!injected)" check to avoid double injections. | 142 // former with "if (!injected)" check to avoid double injections. |
142 EXPECT_LT(0U, [[scripts[0] source] rangeOfString:early_script].length); | 143 EXPECT_LT(0U, [[scripts[0] source] rangeOfString:early_script].length); |
143 } | 144 } |
144 | 145 |
145 } // namespace | 146 } // namespace |
146 } // namespace web | 147 } // namespace web |
OLD | NEW |