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

Side by Side Diff: content/public/test/navigation_simulator.cc

Issue 2820933002: [subresource_filter] add //chrome level unit test harness (Closed)
Patch Set: remove dep Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/public/test/navigation_simulator.h" 5 #include "content/public/test/navigation_simulator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/frame_host/navigation_handle_impl.h" 10 #include "content/browser/frame_host/navigation_handle_impl.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 } 162 }
163 163
164 void NavigationSimulator::Redirect(const GURL& new_url) { 164 void NavigationSimulator::Redirect(const GURL& new_url) {
165 CHECK(state_ <= STARTED) << "NavigationSimulator::Redirect should be " 165 CHECK(state_ <= STARTED) << "NavigationSimulator::Redirect should be "
166 "called before Fail or Commit"; 166 "called before Fail or Commit";
167 CHECK_EQ(0, num_did_finish_navigation_called_) 167 CHECK_EQ(0, num_did_finish_navigation_called_)
168 << "NavigationSimulator::Redirect cannot be called after the " 168 << "NavigationSimulator::Redirect cannot be called after the "
169 "navigation has finished"; 169 "navigation has finished";
170 170
171 if (state_ == INITIALIZATION) 171 if (state_ == INITIALIZATION) {
172 Start(); 172 Start();
173 if (state_ == FAILED)
174 return;
175 }
173 176
174 navigation_url_ = new_url; 177 navigation_url_ = new_url;
175 178
176 int previous_num_will_redirect_request_called = 179 int previous_num_will_redirect_request_called =
177 num_will_redirect_request_called_; 180 num_will_redirect_request_called_;
178 int previous_did_redirect_navigation_called = 181 int previous_did_redirect_navigation_called =
179 num_did_redirect_navigation_called_; 182 num_did_redirect_navigation_called_;
180 183
181 PrepareCompleteCallbackOnHandle(); 184 PrepareCompleteCallbackOnHandle();
182 if (IsBrowserSideNavigationEnabled()) { 185 if (IsBrowserSideNavigationEnabled()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 221 }
219 222
220 void NavigationSimulator::Commit() { 223 void NavigationSimulator::Commit() {
221 CHECK_LE(state_, STARTED) << "NavigationSimulator::Commit can only be " 224 CHECK_LE(state_, STARTED) << "NavigationSimulator::Commit can only be "
222 "called once, and cannot be called after " 225 "called once, and cannot be called after "
223 "NavigationSimulator::Fail"; 226 "NavigationSimulator::Fail";
224 CHECK_EQ(0, num_did_finish_navigation_called_) 227 CHECK_EQ(0, num_did_finish_navigation_called_)
225 << "NavigationSimulator::Commit cannot be called after the " 228 << "NavigationSimulator::Commit cannot be called after the "
226 "navigation has finished"; 229 "navigation has finished";
227 230
228 if (state_ == INITIALIZATION) 231 if (state_ == INITIALIZATION) {
229 Start(); 232 Start();
233 if (state_ == FAILED)
234 return;
235 }
230 236
231 PrepareCompleteCallbackOnHandle(); 237 PrepareCompleteCallbackOnHandle();
232 if (IsBrowserSideNavigationEnabled() && 238 if (IsBrowserSideNavigationEnabled() &&
233 render_frame_host_->frame_tree_node()->navigation_request()) { 239 render_frame_host_->frame_tree_node()->navigation_request()) {
234 render_frame_host_->PrepareForCommit(); 240 render_frame_host_->PrepareForCommit();
235 // Synchronous failure can cause the navigation to finish here. 241 // Synchronous failure can cause the navigation to finish here.
236 if (!handle_) { 242 if (!handle_) {
237 state_ = FAILED; 243 state_ = FAILED;
238 return; 244 return;
239 } 245 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 base::Bind(&NavigationSimulator::OnThrottleChecksComplete, 565 base::Bind(&NavigationSimulator::OnThrottleChecksComplete,
560 weak_factory_.GetWeakPtr())); 566 weak_factory_.GetWeakPtr()));
561 } 567 }
562 568
563 RenderFrameHost* NavigationSimulator::GetFinalRenderFrameHost() { 569 RenderFrameHost* NavigationSimulator::GetFinalRenderFrameHost() {
564 CHECK_EQ(state_, FINISHED); 570 CHECK_EQ(state_, FINISHED);
565 return render_frame_host_; 571 return render_frame_host_;
566 } 572 }
567 573
568 } // namespace content 574 } // namespace content
OLDNEW
« no previous file with comments | « components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698