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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 message_loop_.RunUntilIdle(); | 174 message_loop_.RunUntilIdle(); |
175 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()), | 175 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()), |
176 results); | 176 results); |
177 } | 177 } |
178 | 178 |
179 class TestSyncNetworkChannel : public SyncNetworkChannel { | 179 class TestSyncNetworkChannel : public SyncNetworkChannel { |
180 public: | 180 public: |
181 TestSyncNetworkChannel() {} | 181 TestSyncNetworkChannel() {} |
182 virtual ~TestSyncNetworkChannel() {} | 182 virtual ~TestSyncNetworkChannel() {} |
183 | 183 |
184 using SyncNetworkChannel::NotifyStateChange; | 184 using SyncNetworkChannel::NotifyNetworkStatusChange; |
| 185 using SyncNetworkChannel::NotifyChannelStateChange; |
185 using SyncNetworkChannel::DeliverIncomingMessage; | 186 using SyncNetworkChannel::DeliverIncomingMessage; |
186 | 187 |
187 virtual void SendMessage(const std::string& message) OVERRIDE { | 188 virtual void SendMessage(const std::string& message) OVERRIDE { |
188 } | 189 } |
189 | 190 |
190 virtual void UpdateCredentials(const std::string& email, | 191 virtual void UpdateCredentials(const std::string& email, |
191 const std::string& token) OVERRIDE { | 192 const std::string& token) OVERRIDE { |
192 } | 193 } |
193 | 194 |
194 virtual int GetInvalidationClientType() OVERRIDE { | 195 virtual int GetInvalidationClientType() OVERRIDE { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 227 |
227 void OnNetworkStatusChange(bool connected) { | 228 void OnNetworkStatusChange(bool connected) { |
228 connected_ = connected; | 229 connected_ = connected; |
229 } | 230 } |
230 | 231 |
231 TestSyncNetworkChannel network_channel_; | 232 TestSyncNetworkChannel network_channel_; |
232 InvalidatorState last_invalidator_state_; | 233 InvalidatorState last_invalidator_state_; |
233 bool connected_; | 234 bool connected_; |
234 }; | 235 }; |
235 | 236 |
236 // Simulate network channel state change. It should propagate to observer. | 237 // Simulate channel state change. It should propagate to observer. |
237 TEST_F(SyncNetworkChannelTest, OnNetworkChannelStateChanged) { | 238 TEST_F(SyncNetworkChannelTest, ChannelStateChange) { |
238 EXPECT_EQ(DEFAULT_INVALIDATION_ERROR, last_invalidator_state_); | 239 EXPECT_EQ(DEFAULT_INVALIDATION_ERROR, last_invalidator_state_); |
| 240 network_channel_.NotifyChannelStateChange(INVALIDATIONS_ENABLED); |
| 241 EXPECT_EQ(INVALIDATIONS_ENABLED, last_invalidator_state_); |
| 242 network_channel_.NotifyChannelStateChange(INVALIDATION_CREDENTIALS_REJECTED); |
| 243 EXPECT_EQ(INVALIDATION_CREDENTIALS_REJECTED, last_invalidator_state_); |
| 244 } |
| 245 |
| 246 // Simulate network state change. It should propagate to cacheinvalidations. |
| 247 TEST_F(SyncNetworkChannelTest, NetworkStateChange) { |
239 EXPECT_FALSE(connected_); | 248 EXPECT_FALSE(connected_); |
240 network_channel_.NotifyStateChange(INVALIDATIONS_ENABLED); | 249 network_channel_.NotifyNetworkStatusChange(true); |
241 EXPECT_EQ(INVALIDATIONS_ENABLED, last_invalidator_state_); | |
242 EXPECT_TRUE(connected_); | 250 EXPECT_TRUE(connected_); |
243 network_channel_.NotifyStateChange(INVALIDATION_CREDENTIALS_REJECTED); | 251 network_channel_.NotifyNetworkStatusChange(false); |
244 EXPECT_EQ(INVALIDATION_CREDENTIALS_REJECTED, last_invalidator_state_); | |
245 EXPECT_FALSE(connected_); | 252 EXPECT_FALSE(connected_); |
246 } | 253 } |
247 | 254 |
248 } // namespace | 255 } // namespace |
249 } // namespace syncer | 256 } // namespace syncer |
OLD | NEW |