Commit 29941629 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Change the TwoPhaseUploaderTest's handling of the NetworkService

This test currently crashes when run in combination with other unit tests
because it creates a NetworkService. If another test has already created
a unit test and not destroyed it (e.g. through GetNetworkServiceImpl),
a DCHECK in the NetworkService constructor fails.

Bug: 940082
Change-Id: I74793b6e1c6b962307d14b32bb53f2cbf13738ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626516
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662859}
parent 58870e8c
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "chrome/browser/safe_browsing/local_two_phase_testserver.h" #include "chrome/browser/safe_browsing/local_two_phase_testserver.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -75,12 +76,12 @@ class TwoPhaseUploaderTest : public testing::Test { ...@@ -75,12 +76,12 @@ class TwoPhaseUploaderTest : public testing::Test {
network_service_client_ = network_service_client_ =
std::make_unique<network::TestNetworkServiceClient>( std::make_unique<network::TestNetworkServiceClient>(
mojo::MakeRequest(&network_service_client_ptr)); mojo::MakeRequest(&network_service_client_ptr));
network_service_ = network::NetworkService::CreateForTesting(); network::NetworkService* network_service = content::GetNetworkServiceImpl();
network_service_->SetClient(std::move(network_service_client_ptr), network_service->SetClient(std::move(network_service_client_ptr),
network::mojom::NetworkServiceParams::New()); network::mojom::NetworkServiceParams::New());
shared_url_loader_factory_ = shared_url_loader_factory_ =
base::MakeRefCounted<network::TestSharedURLLoaderFactory>( base::MakeRefCounted<network::TestSharedURLLoaderFactory>(
network_service_.get()); network_service);
} }
protected: protected:
...@@ -89,7 +90,6 @@ class TwoPhaseUploaderTest : public testing::Test { ...@@ -89,7 +90,6 @@ class TwoPhaseUploaderTest : public testing::Test {
base::CreateSequencedTaskRunnerWithTraits( base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}); {base::MayBlock(), base::TaskPriority::BEST_EFFORT});
std::unique_ptr<network::TestNetworkServiceClient> network_service_client_; std::unique_ptr<network::TestNetworkServiceClient> network_service_client_;
std::unique_ptr<network::NetworkService> network_service_;
scoped_refptr<network::TestSharedURLLoaderFactory> shared_url_loader_factory_; scoped_refptr<network::TestSharedURLLoaderFactory> shared_url_loader_factory_;
}; };
......
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