Commit 0068fa1b authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[Watch flakes]: Fix flakes from NetworkService.

This CL cause NetworkService::CreateForTesting to
use a mock NetworkChangeNotifier which does not observe network changes

Bug: 1011275
Change-Id: I6de34b7a5f6c5af5128cfc000ed63481f3351325
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864359
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: default avatarEric Orth <ericorth@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709257}
parent 2246e017
...@@ -329,8 +329,12 @@ std::unique_ptr<NetworkService> NetworkService::Create( ...@@ -329,8 +329,12 @@ std::unique_ptr<NetworkService> NetworkService::Create(
} }
std::unique_ptr<NetworkService> NetworkService::CreateForTesting() { std::unique_ptr<NetworkService> NetworkService::CreateForTesting() {
return std::make_unique<NetworkService>( auto network_service = std::make_unique<NetworkService>(
std::make_unique<service_manager::BinderRegistry>()); std::make_unique<service_manager::BinderRegistry>(), mojo::NullReceiver(),
true /* delay_initialization_until_set_client */);
network_service->Initialize(mojom::NetworkServiceParams::New(),
true /* mock_network_change_notifier */);
return network_service;
} }
void NetworkService::RegisterNetworkContext(NetworkContext* network_context) { void NetworkService::RegisterNetworkContext(NetworkContext* network_context) {
......
...@@ -86,8 +86,9 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkService ...@@ -86,8 +86,9 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkService
static std::unique_ptr<NetworkService> Create( static std::unique_ptr<NetworkService> Create(
mojo::PendingReceiver<mojom::NetworkService> receiver); mojo::PendingReceiver<mojom::NetworkService> receiver);
// Creates a testing instance of NetworkService not bound to an actual // Creates a testing instance of NetworkService not bound to an actual Service
// Service pipe. This instance must be driven by direct calls onto the // pipe. This will cause NetworkChangeNotifier, unless already created, to be
// mocked. This instance must be driven by direct calls onto the
// NetworkService object. // NetworkService object.
static std::unique_ptr<NetworkService> CreateForTesting(); static std::unique_ptr<NetworkService> CreateForTesting();
......
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