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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "content/browser/frame_host/navigation_handle_impl.h" | 6 #include "content/browser/frame_host/navigation_handle_impl.h" |
7 #include "content/public/browser/navigation_throttle.h" | 7 #include "content/public/browser/navigation_throttle.h" |
8 #include "content/test/test_render_frame_host.h" | 8 #include "content/test/test_render_frame_host.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Helper function to call WillStartRequest on |handle|. If this function | 95 // Helper function to call WillStartRequest on |handle|. If this function |
96 // returns DEFER, |callback_result_| will be set to the actual result of | 96 // returns DEFER, |callback_result_| will be set to the actual result of |
97 // the throttle checks when they are finished. | 97 // the throttle checks when they are finished. |
98 void SimulateWillStartRequest() { | 98 void SimulateWillStartRequest() { |
99 was_callback_called_ = false; | 99 was_callback_called_ = false; |
100 callback_result_ = NavigationThrottle::DEFER; | 100 callback_result_ = NavigationThrottle::DEFER; |
101 | 101 |
102 // It's safe to use base::Unretained since the NavigationHandle is owned by | 102 // It's safe to use base::Unretained since the NavigationHandle is owned by |
103 // the NavigationHandleImplTest. | 103 // the NavigationHandleImplTest. |
104 test_handle_->WillStartRequest( | 104 test_handle_->WillStartRequest( |
105 "GET", Referrer(), false, ui::PAGE_TRANSITION_LINK, false, | 105 "GET", nullptr, Referrer(), false, ui::PAGE_TRANSITION_LINK, false, |
106 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, | 106 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, |
107 base::Unretained(this))); | 107 base::Unretained(this))); |
108 } | 108 } |
109 | 109 |
110 // Helper function to call WillRedirectRequest on |handle|. If this function | 110 // Helper function to call WillRedirectRequest on |handle|. If this function |
111 // returns DEFER, |callback_result_| will be set to the actual result of the | 111 // returns DEFER, |callback_result_| will be set to the actual result of the |
112 // throttle checks when they are finished. | 112 // throttle checks when they are finished. |
113 // TODO(clamy): this should also simulate that WillStartRequest was called if | 113 // TODO(clamy): this should also simulate that WillStartRequest was called if |
114 // it has not been called before. | 114 // it has not been called before. |
115 void SimulateWillRedirectRequest() { | 115 void SimulateWillRedirectRequest() { |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); | 639 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
640 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 640 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
641 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 641 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
642 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); | 642 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
643 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 643 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
644 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 644 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
645 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); | 645 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
646 } | 646 } |
647 | 647 |
648 } // namespace content | 648 } // namespace content |
OLD | NEW |