| OLD | NEW |
| 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_url_loader_client.h" | 5 #include "content/browser/loader/test_url_loader_client.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 quit_closure_for_on_receive_cached_metadata_.Run(); | 64 quit_closure_for_on_receive_cached_metadata_.Run(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) { | 67 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) { |
| 68 EXPECT_TRUE(has_received_response_); | 68 EXPECT_TRUE(has_received_response_); |
| 69 EXPECT_FALSE(has_received_completion_); | 69 EXPECT_FALSE(has_received_completion_); |
| 70 EXPECT_GT(transfer_size_diff, 0); | 70 EXPECT_GT(transfer_size_diff, 0); |
| 71 body_transfer_size_ += transfer_size_diff; | 71 body_transfer_size_ += transfer_size_diff; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void TestURLLoaderClient::OnUploadProgress(int64_t current_position, |
| 75 int64_t total_size, |
| 76 const base::Closure& ack_callback) { |
| 77 EXPECT_TRUE(ack_callback); |
| 78 EXPECT_FALSE(has_received_response_); |
| 79 EXPECT_FALSE(has_received_completion_); |
| 80 EXPECT_LT(0, current_position); |
| 81 EXPECT_LE(current_position, total_size); |
| 82 |
| 83 has_received_upload_progress_ = true; |
| 84 current_upload_position_ = current_position; |
| 85 total_upload_size_ = total_size; |
| 86 ack_callback.Run(); |
| 87 } |
| 88 |
| 74 void TestURLLoaderClient::OnStartLoadingResponseBody( | 89 void TestURLLoaderClient::OnStartLoadingResponseBody( |
| 75 mojo::ScopedDataPipeConsumerHandle body) { | 90 mojo::ScopedDataPipeConsumerHandle body) { |
| 76 EXPECT_TRUE(has_received_response_); | 91 EXPECT_TRUE(has_received_response_); |
| 77 EXPECT_FALSE(has_received_completion_); | 92 EXPECT_FALSE(has_received_completion_); |
| 78 response_body_ = std::move(body); | 93 response_body_ = std::move(body); |
| 79 if (quit_closure_for_on_start_loading_response_body_) | 94 if (quit_closure_for_on_start_loading_response_body_) |
| 80 quit_closure_for_on_start_loading_response_body_.Run(); | 95 quit_closure_for_on_start_loading_response_body_.Run(); |
| 81 } | 96 } |
| 82 | 97 |
| 83 void TestURLLoaderClient::OnComplete( | 98 void TestURLLoaderClient::OnComplete( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void TestURLLoaderClient::RunUntilComplete() { | 169 void TestURLLoaderClient::RunUntilComplete() { |
| 155 if (has_received_completion_) | 170 if (has_received_completion_) |
| 156 return; | 171 return; |
| 157 base::RunLoop run_loop; | 172 base::RunLoop run_loop; |
| 158 quit_closure_for_on_complete_ = run_loop.QuitClosure(); | 173 quit_closure_for_on_complete_ = run_loop.QuitClosure(); |
| 159 run_loop.Run(); | 174 run_loop.Run(); |
| 160 quit_closure_for_on_complete_.Reset(); | 175 quit_closure_for_on_complete_.Reset(); |
| 161 } | 176 } |
| 162 | 177 |
| 163 } // namespace content | 178 } // namespace content |
| OLD | NEW |