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

Side by Side Diff: content/browser/loader/test_resource_handler.cc

Issue 2626663002: Update MimeSniffingResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Fix double-cancel tests Created 3 years, 11 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
« no previous file with comments | « content/browser/loader/mock_resource_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/loader/test_resource_handler.h" 5 #include "content/browser/loader/test_resource_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/loader/resource_controller.h" 8 #include "content/browser/loader/resource_controller.h"
9 #include "content/public/common/resource_response.h" 9 #include "content/public/common/resource_response.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, 125 bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
126 int* buf_size, 126 int* buf_size,
127 int min_size) { 127 int min_size) {
128 EXPECT_FALSE(canceled_); 128 EXPECT_FALSE(canceled_);
129 EXPECT_FALSE(expect_on_data_downloaded_); 129 EXPECT_FALSE(expect_on_data_downloaded_);
130 EXPECT_EQ(0, on_response_completed_called_); 130 EXPECT_EQ(0, on_response_completed_called_);
131 ScopedCallDepthTracker call_depth_tracker(&call_depth_); 131 ScopedCallDepthTracker call_depth_tracker(&call_depth_);
132 132
133 ++on_will_read_called_; 133 ++on_will_read_called_;
134 134
135 *buf = buffer_; 135 if (!on_will_read_result_) {
136 *buf_size = buffer_size_;
137 memset(buffer_->data(), '\0', buffer_size_);
138 if (!on_will_read_result_)
139 canceled_ = true; 136 canceled_ = true;
137 } else {
138 *buf = buffer_;
139 *buf_size = buffer_size_;
140 memset(buffer_->data(), '\0', buffer_size_);
mmenke 2017/01/10 19:20:34 This change is to meet MockResourceLoader's expect
141 }
142
140 return on_will_read_result_; 143 return on_will_read_result_;
141 } 144 }
142 145
143 bool TestResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { 146 bool TestResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
144 EXPECT_FALSE(canceled_); 147 EXPECT_FALSE(canceled_);
145 EXPECT_FALSE(expect_on_data_downloaded_); 148 EXPECT_FALSE(expect_on_data_downloaded_);
146 EXPECT_EQ(1, on_will_start_called_); 149 EXPECT_EQ(1, on_will_start_called_);
147 EXPECT_EQ(1, on_response_started_called_); 150 EXPECT_EQ(1, on_response_started_called_);
148 EXPECT_EQ(0, on_response_completed_called_); 151 EXPECT_EQ(0, on_response_completed_called_);
149 EXPECT_EQ(0, on_read_eof_); 152 EXPECT_EQ(0, on_read_eof_);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void TestResourceHandler::WaitUntilDeferred() { 224 void TestResourceHandler::WaitUntilDeferred() {
222 deferred_run_loop_->Run(); 225 deferred_run_loop_->Run();
223 deferred_run_loop_.reset(new base::RunLoop()); 226 deferred_run_loop_.reset(new base::RunLoop());
224 } 227 }
225 228
226 void TestResourceHandler::WaitUntilResponseComplete() { 229 void TestResourceHandler::WaitUntilResponseComplete() {
227 response_complete_run_loop_.Run(); 230 response_complete_run_loop_.Run();
228 } 231 }
229 232
230 } // namespace content 233 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mock_resource_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698