Commit 51fa0ebf authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Migrate ResourceDispatcherHost unittests to MojoLoading

As a preparation step to deprecate resource_messages.h, this change
migrates ResourceDispatcherHostTest to LoadingWithMojo. This change
also removes some tests that are no longer needed.

Bug: 788241
Change-Id: I04ca5649fd621404a177d9c2571384a00a0d7741
Reviewed-on: https://chromium-review.googlesource.com/818925
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523957}
parent 737544e6
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,10 +23,9 @@ void TestURLLoaderClient::OnReceiveResponse(
has_received_response_ = true;
response_head_ = response_head;
ssl_info_ = ssl_info;
downloaded_file_ = std::move(downloaded_file);
if (quit_closure_for_on_receive_response_)
quit_closure_for_on_receive_response_.Run();
binding_.set_connection_error_handler(base::BindOnce(
&TestURLLoaderClient::OnConnectionError, base::Unretained(this)));
}
void TestURLLoaderClient::OnReceiveRedirect(
......@@ -109,6 +108,10 @@ void TestURLLoaderClient::OnComplete(
quit_closure_for_on_complete_.Run();
}
mojom::DownloadedTempFilePtr TestURLLoaderClient::TakeDownloadedTempFile() {
return std::move(downloaded_file_);
}
void TestURLLoaderClient::ClearHasReceivedRedirect() {
has_received_redirect_ = false;
}
......@@ -116,6 +119,8 @@ void TestURLLoaderClient::ClearHasReceivedRedirect() {
mojom::URLLoaderClientPtr TestURLLoaderClient::CreateInterfacePtr() {
mojom::URLLoaderClientPtr client_ptr;
binding_.Bind(mojo::MakeRequest(&client_ptr));
binding_.set_connection_error_handler(base::BindOnce(
&TestURLLoaderClient::OnConnectionError, base::Unretained(this)));
return client_ptr;
}
......@@ -188,6 +193,8 @@ void TestURLLoaderClient::RunUntilConnectionError() {
}
void TestURLLoaderClient::OnConnectionError() {
if (has_received_connection_error_)
return;
has_received_connection_error_ = true;
if (quit_closure_for_on_connection_error_)
quit_closure_for_on_connection_error_.Run();
......
......@@ -81,6 +81,7 @@ class TestURLLoaderClient final : public mojom::URLLoaderClient {
has_received_upload_progress_ = false;
}
mojom::DownloadedTempFilePtr TakeDownloadedTempFile();
void ClearHasReceivedRedirect();
// Creates an InterfacePtr, binds it to |*this| and returns it.
mojom::URLLoaderClientPtr CreateInterfacePtr();
......@@ -101,6 +102,7 @@ class TestURLLoaderClient final : public mojom::URLLoaderClient {
mojo::Binding<mojom::URLLoaderClient> binding_;
ResourceResponseHead response_head_;
base::Optional<net::SSLInfo> ssl_info_;
mojom::DownloadedTempFilePtr downloaded_file_;
net::RedirectInfo redirect_info_;
std::string cached_metadata_;
mojo::ScopedDataPipeConsumerHandle response_body_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment