summaryrefslogtreecommitdiff
path: root/chromium/content/browser/loader/test_url_loader_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/loader/test_url_loader_client.cc')
-rw-r--r--chromium/content/browser/loader/test_url_loader_client.cc59
1 files changed, 53 insertions, 6 deletions
diff --git a/chromium/content/browser/loader/test_url_loader_client.cc b/chromium/content/browser/loader/test_url_loader_client.cc
index 035a050d28a..caa858312f4 100644
--- a/chromium/content/browser/loader/test_url_loader_client.cc
+++ b/chromium/content/browser/loader/test_url_loader_client.cc
@@ -4,7 +4,9 @@
#include "content/browser/loader/test_url_loader_client.h"
+#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -15,8 +17,31 @@ void TestURLLoaderClient::OnReceiveResponse(
const ResourceResponseHead& response_head) {
has_received_response_ = true;
response_head_ = response_head;
- if (quit_closure_for_on_received_response_)
- quit_closure_for_on_received_response_.Run();
+ if (quit_closure_for_on_receive_response_)
+ quit_closure_for_on_receive_response_.Run();
+}
+
+void TestURLLoaderClient::OnReceiveRedirect(
+ const net::RedirectInfo& redirect_info,
+ const ResourceResponseHead& response_head) {
+ EXPECT_FALSE(response_body_.is_valid());
+ EXPECT_FALSE(has_received_response_);
+ // Use ClearHasReceivedRedirect to accept more redirects.
+ EXPECT_FALSE(has_received_redirect_);
+ has_received_redirect_ = true;
+ redirect_info_ = redirect_info;
+ response_head_ = response_head;
+ if (quit_closure_for_on_receive_redirect_)
+ quit_closure_for_on_receive_redirect_.Run();
+}
+
+void TestURLLoaderClient::OnDataDownloaded(int64_t data_length,
+ int64_t encoded_data_length) {
+ has_data_downloaded_ = true;
+ download_data_length_ += data_length;
+ encoded_download_data_length_ += encoded_data_length;
+ if (quit_closure_for_on_data_downloaded_)
+ quit_closure_for_on_data_downloaded_.Run();
}
void TestURLLoaderClient::OnStartLoadingResponseBody(
@@ -34,8 +59,16 @@ void TestURLLoaderClient::OnComplete(
quit_closure_for_on_complete_.Run();
}
-mojom::URLLoaderClientPtr TestURLLoaderClient::CreateInterfacePtrAndBind() {
- return binding_.CreateInterfacePtrAndBind();
+void TestURLLoaderClient::ClearHasReceivedRedirect() {
+ has_received_redirect_ = false;
+}
+
+mojom::URLLoaderClientAssociatedPtrInfo
+TestURLLoaderClient::CreateRemoteAssociatedPtrInfo(
+ mojo::AssociatedGroup* associated_group) {
+ mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info;
+ binding_.Bind(&client_ptr_info, associated_group);
+ return client_ptr_info;
}
void TestURLLoaderClient::Unbind() {
@@ -45,9 +78,23 @@ void TestURLLoaderClient::Unbind() {
void TestURLLoaderClient::RunUntilResponseReceived() {
base::RunLoop run_loop;
- quit_closure_for_on_received_response_ = run_loop.QuitClosure();
+ quit_closure_for_on_receive_response_ = run_loop.QuitClosure();
+ run_loop.Run();
+ quit_closure_for_on_receive_response_.Reset();
+}
+
+void TestURLLoaderClient::RunUntilRedirectReceived() {
+ base::RunLoop run_loop;
+ quit_closure_for_on_receive_redirect_ = run_loop.QuitClosure();
+ run_loop.Run();
+ quit_closure_for_on_receive_redirect_.Reset();
+}
+
+void TestURLLoaderClient::RunUntilDataDownloaded() {
+ base::RunLoop run_loop;
+ quit_closure_for_on_data_downloaded_ = run_loop.QuitClosure();
run_loop.Run();
- quit_closure_for_on_received_response_.Reset();
+ quit_closure_for_on_data_downloaded_.Reset();
}
void TestURLLoaderClient::RunUntilResponseBodyArrived() {