OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "google_apis/gcm/engine/connection_factory_impl.h" | 5 #include "google_apis/gcm/engine/connection_factory_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 EXPECT_FALSE(initial_backoff.is_null()); | 427 EXPECT_FALSE(initial_backoff.is_null()); |
428 | 428 |
429 factory()->SetDelayLogin(true); | 429 factory()->SetDelayLogin(true); |
430 factory()->SetConnectResult(net::OK); | 430 factory()->SetConnectResult(net::OK); |
431 factory()->OnNetworkChanged(net::NetworkChangeNotifier::CONNECTION_WIFI); | 431 factory()->OnNetworkChanged(net::NetworkChangeNotifier::CONNECTION_WIFI); |
432 WaitForConnections(); | 432 WaitForConnections(); |
433 EXPECT_FALSE(factory()->IsEndpointReachable()); | 433 EXPECT_FALSE(factory()->IsEndpointReachable()); |
434 | 434 |
435 // Pump the loop, to ensure the pending backoff retry has no effect. | 435 // Pump the loop, to ensure the pending backoff retry has no effect. |
436 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 436 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
437 FROM_HERE, | 437 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
438 base::MessageLoop::QuitClosure(), | |
439 base::TimeDelta::FromMilliseconds(1)); | 438 base::TimeDelta::FromMilliseconds(1)); |
440 WaitForConnections(); | 439 WaitForConnections(); |
441 } | 440 } |
442 | 441 |
443 // Fail after successful connection via signal reset. | 442 // Fail after successful connection via signal reset. |
444 TEST_F(ConnectionFactoryImplTest, FailViaSignalReset) { | 443 TEST_F(ConnectionFactoryImplTest, FailViaSignalReset) { |
445 factory()->SetConnectResult(net::OK); | 444 factory()->SetConnectResult(net::OK); |
446 factory()->Connect(); | 445 factory()->Connect(); |
447 EXPECT_TRUE(factory()->NextRetryAttempt().is_null()); | 446 EXPECT_TRUE(factory()->NextRetryAttempt().is_null()); |
448 | 447 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Now trigger force a re-connection. | 563 // Now trigger force a re-connection. |
565 factory()->SetConnectResult(net::OK); | 564 factory()->SetConnectResult(net::OK); |
566 factory()->Connect(); | 565 factory()->Connect(); |
567 WaitForConnections(); | 566 WaitForConnections(); |
568 | 567 |
569 // Re-connection should succeed. | 568 // Re-connection should succeed. |
570 EXPECT_TRUE(factory()->IsEndpointReachable()); | 569 EXPECT_TRUE(factory()->IsEndpointReachable()); |
571 } | 570 } |
572 | 571 |
573 } // namespace gcm | 572 } // namespace gcm |
OLD | NEW |