OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/js/crw_js_early_script_manager.h" | 5 #import "ios/web/web_state/js/crw_js_early_script_manager.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #import "ios/web/public/test/crw_test_js_injection_receiver.h" | 9 #import "ios/web/public/test/crw_test_js_injection_receiver.h" |
9 #include "ios/web/public/test/scoped_testing_web_client.h" | 10 #include "ios/web/public/test/scoped_testing_web_client.h" |
10 #include "ios/web/public/web_client.h" | 11 #include "ios/web/public/web_client.h" |
11 #import "ios/web/web_state/js/page_script_util.h" | 12 #import "ios/web/web_state/js/page_script_util.h" |
12 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
13 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
14 | 15 |
15 namespace web { | 16 namespace web { |
16 namespace { | 17 namespace { |
17 | 18 |
18 class CRWJSEarlyScriptManagerTest : public PlatformTest { | 19 class CRWJSEarlyScriptManagerTest : public PlatformTest { |
19 public: | 20 public: |
20 CRWJSEarlyScriptManagerTest() : web_client_(make_scoped_ptr(new WebClient)) {} | 21 CRWJSEarlyScriptManagerTest() |
| 22 : web_client_(base::WrapUnique(new WebClient)) {} |
21 | 23 |
22 protected: | 24 protected: |
23 void SetUp() override { | 25 void SetUp() override { |
24 PlatformTest::SetUp(); | 26 PlatformTest::SetUp(); |
25 receiver_.reset([[CRWTestJSInjectionReceiver alloc] init]); | 27 receiver_.reset([[CRWTestJSInjectionReceiver alloc] init]); |
26 earlyScriptManager_.reset(static_cast<CRWJSEarlyScriptManager*>( | 28 earlyScriptManager_.reset(static_cast<CRWJSEarlyScriptManager*>( |
27 [[receiver_ instanceOfClass:[CRWJSEarlyScriptManager class]] retain])); | 29 [[receiver_ instanceOfClass:[CRWJSEarlyScriptManager class]] retain])); |
28 } | 30 } |
29 | 31 |
30 // Required for CRWJSEarlyScriptManager creation. | 32 // Required for CRWJSEarlyScriptManager creation. |
(...skipping 12 matching lines...) Expand all Loading... |
43 // |earlyScript| is a substring of |injectionContent|. The latter wraps the | 45 // |earlyScript| is a substring of |injectionContent|. The latter wraps the |
44 // former with "if (typeof __gCrWeb !== 'object')" check to avoid multiple | 46 // former with "if (typeof __gCrWeb !== 'object')" check to avoid multiple |
45 // injections. | 47 // injections. |
46 EXPECT_NE(NSNotFound, | 48 EXPECT_NE(NSNotFound, |
47 static_cast<NSInteger>( | 49 static_cast<NSInteger>( |
48 [injectionContent rangeOfString:earlyScript].location)); | 50 [injectionContent rangeOfString:earlyScript].location)); |
49 } | 51 } |
50 | 52 |
51 } // namespace | 53 } // namespace |
52 } // namespace web | 54 } // namespace web |
OLD | NEW |