| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/background_sync/background_sync_network_observer.h" | 5 #include "content/browser/background_sync/background_sync_network_observer.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/public/test/test_browser_thread_bundle.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
| 9 #include "net/base/network_change_notifier.h" | 9 #include "net/base/network_change_notifier.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class BackgroundSyncNetworkObserverTest : public testing::Test { | 14 class BackgroundSyncNetworkObserverTest : public testing::Test { |
| 15 protected: | 15 protected: |
| 16 BackgroundSyncNetworkObserverTest() | 16 BackgroundSyncNetworkObserverTest() |
| 17 : network_change_notifier(net::NetworkChangeNotifier::CreateMock()), | 17 : network_change_notifier(net::NetworkChangeNotifier::CreateMock()), |
| 18 network_observer_(new BackgroundSyncNetworkObserver( | 18 network_observer_(new BackgroundSyncNetworkObserver(base::BindRepeating( |
| 19 base::Bind(&BackgroundSyncNetworkObserverTest::OnNetworkChanged, | 19 &BackgroundSyncNetworkObserverTest::OnNetworkChanged, |
| 20 base::Unretained(this)))), | 20 base::Unretained(this)))), |
| 21 network_changed_count_(0) {} | 21 network_changed_count_(0) {} |
| 22 | 22 |
| 23 void SetNetwork(net::NetworkChangeNotifier::ConnectionType connection_type) { | 23 void SetNetwork(net::NetworkChangeNotifier::ConnectionType connection_type) { |
| 24 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( | 24 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( |
| 25 connection_type); | 25 connection_type); |
| 26 base::RunLoop().RunUntilIdle(); | 26 base::RunLoop().RunUntilIdle(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void OnNetworkChanged() { network_changed_count_++; } | 29 void OnNetworkChanged() { network_changed_count_++; } |
| 30 | 30 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 EXPECT_TRUE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); | 99 EXPECT_TRUE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); |
| 100 | 100 |
| 101 SetNetwork(net::NetworkChangeNotifier::CONNECTION_UNKNOWN); | 101 SetNetwork(net::NetworkChangeNotifier::CONNECTION_UNKNOWN); |
| 102 EXPECT_TRUE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); | 102 EXPECT_TRUE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); |
| 103 | 103 |
| 104 SetNetwork(net::NetworkChangeNotifier::CONNECTION_NONE); | 104 SetNetwork(net::NetworkChangeNotifier::CONNECTION_NONE); |
| 105 EXPECT_FALSE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); | 105 EXPECT_FALSE(network_observer_->NetworkSufficient(NETWORK_STATE_ONLINE)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace content | 108 } // namespace content |
| OLD | NEW |