| 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 #include "components/navigation_interception/intercept_navigation_throttle.h" | 5 #include "components/navigation_interception/intercept_navigation_throttle.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 std::unique_ptr<content::NavigationHandle> test_handle = | 64 std::unique_ptr<content::NavigationHandle> test_handle = |
| 65 content::NavigationHandle::CreateNavigationHandleForTesting(url, | 65 content::NavigationHandle::CreateNavigationHandleForTesting(url, |
| 66 main_rfh()); | 66 main_rfh()); |
| 67 test_handle->RegisterThrottleForTesting( | 67 test_handle->RegisterThrottleForTesting( |
| 68 base::MakeUnique<InterceptNavigationThrottle>( | 68 base::MakeUnique<InterceptNavigationThrottle>( |
| 69 test_handle.get(), | 69 test_handle.get(), |
| 70 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, | 70 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, |
| 71 base::Unretained(mock_callback_receiver_.get())), | 71 base::Unretained(mock_callback_receiver_.get())), |
| 72 true)); | 72 true)); |
| 73 return test_handle->CallWillStartRequestForTesting( | 73 return test_handle->CallWillStartRequestForTesting( |
| 74 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); | 74 is_post, content::Referrer(), ui::PAGE_TRANSITION_LINK, false); |
| 75 } | 75 } |
| 76 | 76 |
| 77 NavigationThrottle::ThrottleCheckResult Simulate302() { | 77 NavigationThrottle::ThrottleCheckResult Simulate302() { |
| 78 std::unique_ptr<content::NavigationHandle> test_handle = | 78 std::unique_ptr<content::NavigationHandle> test_handle = |
| 79 content::NavigationHandle::CreateNavigationHandleForTesting( | 79 content::NavigationHandle::CreateNavigationHandleForTesting( |
| 80 GURL(kTestUrl), main_rfh()); | 80 GURL(kTestUrl), main_rfh()); |
| 81 test_handle->RegisterThrottleForTesting( | 81 test_handle->RegisterThrottleForTesting( |
| 82 base::MakeUnique<InterceptNavigationThrottle>( | 82 base::MakeUnique<InterceptNavigationThrottle>( |
| 83 test_handle.get(), | 83 test_handle.get(), |
| 84 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, | 84 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, |
| 85 base::Unretained(mock_callback_receiver_.get())), | 85 base::Unretained(mock_callback_receiver_.get())), |
| 86 true)); | 86 true)); |
| 87 test_handle->CallWillStartRequestForTesting( | 87 test_handle->CallWillStartRequestForTesting( |
| 88 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); | 88 true, content::Referrer(), ui::PAGE_TRANSITION_LINK, false); |
| 89 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, | 89 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, |
| 90 GURL(), false); | 90 GURL(), false); |
| 91 } | 91 } |
| 92 | 92 |
| 93 std::unique_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; | 93 std::unique_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 TEST_F(InterceptNavigationThrottleTest, | 96 TEST_F(InterceptNavigationThrottleTest, |
| 97 RequestDeferredAndResumedIfNavigationNotIgnored) { | 97 RequestDeferredAndResumedIfNavigationNotIgnored) { |
| 98 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _)) | 98 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _)) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ShouldIgnoreNavigation( | 155 ShouldIgnoreNavigation( |
| 156 _, AllOf(NavigationParamsUrlIsTest(), | 156 _, AllOf(NavigationParamsUrlIsTest(), |
| 157 Property(&NavigationParams::is_post, Eq(false))))) | 157 Property(&NavigationParams::is_post, Eq(false))))) |
| 158 .WillOnce(Return(false)); | 158 .WillOnce(Return(false)); |
| 159 NavigationThrottle::ThrottleCheckResult result = Simulate302(); | 159 NavigationThrottle::ThrottleCheckResult result = Simulate302(); |
| 160 | 160 |
| 161 EXPECT_EQ(NavigationThrottle::PROCEED, result); | 161 EXPECT_EQ(NavigationThrottle::PROCEED, result); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace navigation_interception | 164 } // namespace navigation_interception |
| OLD | NEW |