OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/http/http_response_body_drainer.h" | 5 #include "net/http/http_response_body_drainer.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 TestOldCompletionCallback callback; | 248 TestOldCompletionCallback callback; |
249 int too_many_chunks = | 249 int too_many_chunks = |
250 HttpResponseBodyDrainer::kDrainBodyBufferSize / kMagicChunkSize; | 250 HttpResponseBodyDrainer::kDrainBodyBufferSize / kMagicChunkSize; |
251 too_many_chunks += 1; // Now it's too large. | 251 too_many_chunks += 1; // Now it's too large. |
252 | 252 |
253 mock_stream_->set_num_chunks(too_many_chunks); | 253 mock_stream_->set_num_chunks(too_many_chunks); |
254 drainer_->Start(session_); | 254 drainer_->Start(session_); |
255 EXPECT_TRUE(result_waiter_.WaitForResult()); | 255 EXPECT_TRUE(result_waiter_.WaitForResult()); |
256 } | 256 } |
257 | 257 |
| 258 TEST_F(HttpResponseBodyDrainerTest, StartBodyTooLarge) { |
| 259 TestOldCompletionCallback callback; |
| 260 int too_many_chunks = |
| 261 HttpResponseBodyDrainer::kDrainBodyBufferSize / kMagicChunkSize; |
| 262 too_many_chunks += 1; // Now it's too large. |
| 263 |
| 264 mock_stream_->set_num_chunks(0); |
| 265 drainer_->StartWithSize(session_, too_many_chunks * kMagicChunkSize); |
| 266 EXPECT_TRUE(result_waiter_.WaitForResult()); |
| 267 } |
| 268 |
| 269 TEST_F(HttpResponseBodyDrainerTest, StartWithNothingToDo) { |
| 270 TestOldCompletionCallback callback; |
| 271 mock_stream_->set_num_chunks(0); |
| 272 drainer_->StartWithSize(session_, 0); |
| 273 EXPECT_FALSE(result_waiter_.WaitForResult()); |
| 274 } |
| 275 |
258 } // namespace | 276 } // namespace |
259 | 277 |
260 } // namespace net | 278 } // namespace net |
OLD | NEW |