| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/invalidation/sync_system_resources.h" | 5 #include "components/invalidation/sync_system_resources.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class SyncSystemResourcesTest : public testing::Test { | 50 class SyncSystemResourcesTest : public testing::Test { |
| 51 protected: | 51 protected: |
| 52 SyncSystemResourcesTest() | 52 SyncSystemResourcesTest() |
| 53 : push_client_channel_( | 53 : push_client_channel_( |
| 54 scoped_ptr<notifier::PushClient>(new notifier::FakePushClient())), | 54 scoped_ptr<notifier::PushClient>(new notifier::FakePushClient())), |
| 55 sync_system_resources_(&push_client_channel_, &mock_state_writer_) {} | 55 sync_system_resources_(&push_client_channel_, &mock_state_writer_) {} |
| 56 | 56 |
| 57 virtual ~SyncSystemResourcesTest() {} | 57 ~SyncSystemResourcesTest() override {} |
| 58 | 58 |
| 59 void ScheduleShouldNotRun() { | 59 void ScheduleShouldNotRun() { |
| 60 { | 60 { |
| 61 // Owned by ScheduleImmediately. | 61 // Owned by ScheduleImmediately. |
| 62 MockClosure mock_closure; | 62 MockClosure mock_closure; |
| 63 base::Closure* should_not_run = mock_closure.CreateClosure(); | 63 base::Closure* should_not_run = mock_closure.CreateClosure(); |
| 64 EXPECT_CALL(mock_closure, Run()).Times(0); | 64 EXPECT_CALL(mock_closure, Run()).Times(0); |
| 65 sync_system_resources_.internal_scheduler()->Schedule( | 65 sync_system_resources_.internal_scheduler()->Schedule( |
| 66 invalidation::Scheduler::NoDelay(), should_not_run); | 66 invalidation::Scheduler::NoDelay(), should_not_run); |
| 67 } | 67 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 protected: | 205 protected: |
| 206 SyncNetworkChannelTest() | 206 SyncNetworkChannelTest() |
| 207 : last_invalidator_state_(DEFAULT_INVALIDATION_ERROR), | 207 : last_invalidator_state_(DEFAULT_INVALIDATION_ERROR), |
| 208 connected_(false) { | 208 connected_(false) { |
| 209 network_channel_.AddObserver(this); | 209 network_channel_.AddObserver(this); |
| 210 network_channel_.AddNetworkStatusReceiver( | 210 network_channel_.AddNetworkStatusReceiver( |
| 211 invalidation::NewPermanentCallback( | 211 invalidation::NewPermanentCallback( |
| 212 this, &SyncNetworkChannelTest::OnNetworkStatusChange)); | 212 this, &SyncNetworkChannelTest::OnNetworkStatusChange)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 virtual ~SyncNetworkChannelTest() { | 215 ~SyncNetworkChannelTest() override { network_channel_.RemoveObserver(this); } |
| 216 network_channel_.RemoveObserver(this); | |
| 217 } | |
| 218 | 216 |
| 219 void OnNetworkChannelStateChanged( | 217 void OnNetworkChannelStateChanged( |
| 220 InvalidatorState invalidator_state) override { | 218 InvalidatorState invalidator_state) override { |
| 221 last_invalidator_state_ = invalidator_state; | 219 last_invalidator_state_ = invalidator_state; |
| 222 } | 220 } |
| 223 | 221 |
| 224 void OnNetworkStatusChange(bool connected) { | 222 void OnNetworkStatusChange(bool connected) { |
| 225 connected_ = connected; | 223 connected_ = connected; |
| 226 } | 224 } |
| 227 | 225 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 243 TEST_F(SyncNetworkChannelTest, NetworkStateChange) { | 241 TEST_F(SyncNetworkChannelTest, NetworkStateChange) { |
| 244 EXPECT_FALSE(connected_); | 242 EXPECT_FALSE(connected_); |
| 245 network_channel_.NotifyNetworkStatusChange(true); | 243 network_channel_.NotifyNetworkStatusChange(true); |
| 246 EXPECT_TRUE(connected_); | 244 EXPECT_TRUE(connected_); |
| 247 network_channel_.NotifyNetworkStatusChange(false); | 245 network_channel_.NotifyNetworkStatusChange(false); |
| 248 EXPECT_FALSE(connected_); | 246 EXPECT_FALSE(connected_); |
| 249 } | 247 } |
| 250 | 248 |
| 251 } // namespace | 249 } // namespace |
| 252 } // namespace syncer | 250 } // namespace syncer |
| OLD | NEW |