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

Side by Side Diff: components/navigation_interception/intercept_navigation_throttle_unittest.cc

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: … Created 4 years, 7 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 #include "components/navigation_interception/intercept_navigation_throttle.h"
6
7 #include <memory>
8
5 #include "base/bind.h" 9 #include "base/bind.h"
6 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/ptr_util.h"
8 #include "components/navigation_interception/intercept_navigation_throttle.h"
9 #include "components/navigation_interception/navigation_params.h" 12 #include "components/navigation_interception/navigation_params.h"
10 #include "content/public/browser/navigation_handle.h" 13 #include "content/public/browser/navigation_handle.h"
11 #include "content/public/browser/navigation_throttle.h" 14 #include "content/public/browser/navigation_throttle.h"
12 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
13 #include "content/public/test/test_renderer_host.h" 16 #include "content/public/test/test_renderer_host.h"
14 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
16 19
17 using content::NavigationThrottle; 20 using content::NavigationThrottle;
18 using testing::_; 21 using testing::_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // InterceptNavigationThrottleTest ------------------------------------ 54 // InterceptNavigationThrottleTest ------------------------------------
52 55
53 class InterceptNavigationThrottleTest 56 class InterceptNavigationThrottleTest
54 : public content::RenderViewHostTestHarness { 57 : public content::RenderViewHostTestHarness {
55 public: 58 public:
56 InterceptNavigationThrottleTest() 59 InterceptNavigationThrottleTest()
57 : mock_callback_receiver_(new MockInterceptCallbackReceiver()) {} 60 : mock_callback_receiver_(new MockInterceptCallbackReceiver()) {}
58 61
59 NavigationThrottle::ThrottleCheckResult 62 NavigationThrottle::ThrottleCheckResult
60 SimulateWillStart(const GURL& url, const GURL& sanitized_url, bool is_post) { 63 SimulateWillStart(const GURL& url, const GURL& sanitized_url, bool is_post) {
61 scoped_ptr<content::NavigationHandle> test_handle = 64 std::unique_ptr<content::NavigationHandle> test_handle =
62 content::NavigationHandle::CreateNavigationHandleForTesting( 65 content::NavigationHandle::CreateNavigationHandleForTesting(url,
63 url, main_rfh()); 66 main_rfh());
64 test_handle->RegisterThrottleForTesting( 67 test_handle->RegisterThrottleForTesting(
65 scoped_ptr<NavigationThrottle>(new InterceptNavigationThrottle( 68 base::WrapUnique(new InterceptNavigationThrottle(
66 test_handle.get(), 69 test_handle.get(),
67 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, 70 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation,
68 base::Unretained(mock_callback_receiver_.get())), 71 base::Unretained(mock_callback_receiver_.get())),
69 true))); 72 true)));
70 return test_handle->CallWillStartRequestForTesting( 73 return test_handle->CallWillStartRequestForTesting(
71 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); 74 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false);
72 } 75 }
73 76
74 NavigationThrottle::ThrottleCheckResult Simulate302() { 77 NavigationThrottle::ThrottleCheckResult Simulate302() {
75 scoped_ptr<content::NavigationHandle> test_handle = 78 std::unique_ptr<content::NavigationHandle> test_handle =
76 content::NavigationHandle::CreateNavigationHandleForTesting( 79 content::NavigationHandle::CreateNavigationHandleForTesting(
77 GURL(kTestUrl), main_rfh()); 80 GURL(kTestUrl), main_rfh());
78 test_handle->RegisterThrottleForTesting( 81 test_handle->RegisterThrottleForTesting(
79 scoped_ptr<NavigationThrottle>(new InterceptNavigationThrottle( 82 base::WrapUnique(new InterceptNavigationThrottle(
80 test_handle.get(), 83 test_handle.get(),
81 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, 84 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation,
82 base::Unretained(mock_callback_receiver_.get())), 85 base::Unretained(mock_callback_receiver_.get())),
83 true))); 86 true)));
84 test_handle->CallWillStartRequestForTesting( 87 test_handle->CallWillStartRequestForTesting(
85 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); 88 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false);
86 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, 89 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false,
87 GURL(), false); 90 GURL(), false);
88 } 91 }
89 92
90 scoped_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; 93 std::unique_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_;
91 }; 94 };
92 95
93 TEST_F(InterceptNavigationThrottleTest, 96 TEST_F(InterceptNavigationThrottleTest,
94 RequestDeferredAndResumedIfNavigationNotIgnored) { 97 RequestDeferredAndResumedIfNavigationNotIgnored) {
95 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _)) 98 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _))
96 .WillByDefault(Return(false)); 99 .WillByDefault(Return(false));
97 EXPECT_CALL( 100 EXPECT_CALL(
98 *mock_callback_receiver_, 101 *mock_callback_receiver_,
99 ShouldIgnoreNavigation(web_contents(), NavigationParamsUrlIsTest())); 102 ShouldIgnoreNavigation(web_contents(), NavigationParamsUrlIsTest()));
100 NavigationThrottle::ThrottleCheckResult result = 103 NavigationThrottle::ThrottleCheckResult result =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 ShouldIgnoreNavigation( 155 ShouldIgnoreNavigation(
153 _, AllOf(NavigationParamsUrlIsTest(), 156 _, AllOf(NavigationParamsUrlIsTest(),
154 Property(&NavigationParams::is_post, Eq(false))))) 157 Property(&NavigationParams::is_post, Eq(false)))))
155 .WillOnce(Return(false)); 158 .WillOnce(Return(false));
156 NavigationThrottle::ThrottleCheckResult result = Simulate302(); 159 NavigationThrottle::ThrottleCheckResult result = Simulate302();
157 160
158 EXPECT_EQ(NavigationThrottle::PROCEED, result); 161 EXPECT_EQ(NavigationThrottle::PROCEED, result);
159 } 162 }
160 163
161 } // namespace navigation_interception 164 } // namespace navigation_interception
OLDNEW
« no previous file with comments | « components/navigation_interception/intercept_navigation_delegate.cc ('k') | components/net_log/chrome_net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698