Skip to content

Commit

Permalink
Speculative fix for flaky leaks in gcm_unit_tests.
Browse files Browse the repository at this point in the history
This CL tries to fix the test flakiness in gcm_unit_tests by using
the mock NetworkChangeNotifier in tests, which avoids receiving real
network status changes.

Bug: 906769
Change-Id: I08227a6f303328fe2f44cecc84c0ea64bd145415
Tbr: rmcelrath@chromium.org
Tbr: dimich@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/1343592
Reviewed-by: Yuta Kitamura <yutak@chromium.org>
Commit-Queue: Yuta Kitamura <yutak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609632}
  • Loading branch information
yutak authored and Commit Bot committed Nov 20, 2018
1 parent 91a4c9a commit b6f5756
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions google_apis/gcm/base/socket_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class GCMSocketStreamTest : public testing::Test {

// net:: components.
net::AddressList address_list_;
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
std::unique_ptr<network::NetworkService> network_service_;
network::mojom::NetworkContextPtr network_context_ptr_;
net::MockClientSocketFactory socket_factory_;
Expand All @@ -104,6 +105,7 @@ class GCMSocketStreamTest : public testing::Test {
GCMSocketStreamTest::GCMSocketStreamTest()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO),
network_change_notifier_(net::NetworkChangeNotifier::CreateMock()),
network_service_(network::NetworkService::CreateForTesting()),
url_request_context_(true /* delay_initialization */) {
address_list_ = net::AddressList::CreateFromIPAddress(
Expand Down
2 changes: 2 additions & 0 deletions google_apis/gcm/engine/connection_factory_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class ConnectionFactoryImplTest
std::unique_ptr<base::RunLoop> run_loop_;

GURL connected_server_;
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
std::unique_ptr<network::NetworkService> network_service_;
network::mojom::NetworkContextPtr network_context_ptr_;
std::unique_ptr<network::NetworkContext> network_context_;
Expand All @@ -320,6 +321,7 @@ ConnectionFactoryImplTest::ConnectionFactoryImplTest()
base::Bind(&ConnectionFactoryImplTest::ConnectionsComplete,
base::Unretained(this))),
run_loop_(new base::RunLoop()),
network_change_notifier_(net::NetworkChangeNotifier::CreateMock()),
network_service_(network::NetworkService::CreateForTesting()) {
network::mojom::NetworkContextParamsPtr params =
network::mojom::NetworkContextParams::New();
Expand Down
2 changes: 2 additions & 0 deletions google_apis/gcm/engine/connection_handler_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class GCMConnectionHandlerImplTest : public testing::Test {
net::AddressList address_list_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<base::RunLoop> run_loop_;
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
std::unique_ptr<network::NetworkService> network_service_;
network::mojom::NetworkContextPtr network_context_ptr_;
net::MockClientSocketFactory socket_factory_;
Expand All @@ -205,6 +206,7 @@ GCMConnectionHandlerImplTest::GCMConnectionHandlerImplTest()
: last_error_(0),
scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO),
network_change_notifier_(net::NetworkChangeNotifier::CreateMock()),
network_service_(network::NetworkService::CreateForTesting()),
url_request_context_(true /* delay_initialization */) {
address_list_ = net::AddressList::CreateFromIPAddress(
Expand Down

0 comments on commit b6f5756

Please sign in to comment.