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/public/common/request_context_type.h" | 8 #include "content/public/common/request_context_type.h" |
| 9 #include "content/public/common/ssl_status.h" |
9 #include "content/test/test_render_frame_host.h" | 10 #include "content/test/test_render_frame_host.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 // Test version of a NavigationThrottle. It will always return the current | 14 // Test version of a NavigationThrottle. It will always return the current |
14 // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the | 15 // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the |
15 // number of times WillStartRequest, WillRedirectRequest, and | 16 // number of times WillStartRequest, WillRedirectRequest, and |
16 // WillProcessResponse were called. | 17 // WillProcessResponse were called. |
17 class TestNavigationThrottle : public NavigationThrottle { | 18 class TestNavigationThrottle : public NavigationThrottle { |
18 public: | 19 public: |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // TODO(clamy): this should also simulate that WillStartRequest was called if | 135 // TODO(clamy): this should also simulate that WillStartRequest was called if |
135 // it has not been called before. | 136 // it has not been called before. |
136 void SimulateWillProcessResponse() { | 137 void SimulateWillProcessResponse() { |
137 was_callback_called_ = false; | 138 was_callback_called_ = false; |
138 callback_result_ = NavigationThrottle::DEFER; | 139 callback_result_ = NavigationThrottle::DEFER; |
139 | 140 |
140 // It's safe to use base::Unretained since the NavigationHandle is owned by | 141 // It's safe to use base::Unretained since the NavigationHandle is owned by |
141 // the NavigationHandleImplTest. | 142 // the NavigationHandleImplTest. |
142 test_handle_->WillProcessResponse( | 143 test_handle_->WillProcessResponse( |
143 main_test_rfh(), | 144 main_test_rfh(), |
144 scoped_refptr<net::HttpResponseHeaders>(), | 145 scoped_refptr<net::HttpResponseHeaders>(), SSLStatus(), |
145 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, | 146 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, |
146 base::Unretained(this))); | 147 base::Unretained(this))); |
147 } | 148 } |
148 | 149 |
149 // Returns the handle used in tests. | 150 // Returns the handle used in tests. |
150 NavigationHandleImpl* test_handle() const { return test_handle_.get(); } | 151 NavigationHandleImpl* test_handle() const { return test_handle_.get(); } |
151 | 152 |
152 // Whether the callback was called. | 153 // Whether the callback was called. |
153 bool was_callback_called() const { return was_callback_called_; } | 154 bool was_callback_called() const { return was_callback_called_; } |
154 | 155 |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); | 662 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
662 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 663 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
663 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 664 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
664 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); | 665 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
665 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 666 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
666 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 667 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
667 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); | 668 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
668 } | 669 } |
669 | 670 |
670 } // namespace content | 671 } // namespace content |
OLD | NEW |