OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/notifier/sync_system_resources.h" | 5 #include "sync/notifier/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::SetNetworkState; |
185 using SyncNetworkChannel::DeliverIncomingMessage; | 185 using SyncNetworkChannel::DeliverIncomingMessage; |
186 | 186 |
187 virtual void SendEncodedMessage(const std::string& encoded_message) OVERRIDE { | 187 virtual void SendEncodedMessage(const std::string& encoded_message) OVERRIDE { |
188 last_encoded_message_ = encoded_message; | 188 last_encoded_message_ = encoded_message; |
189 } | 189 } |
190 | 190 |
191 virtual void UpdateCredentials(const std::string& email, | 191 virtual void UpdateCredentials(const std::string& email, |
192 const std::string& token) OVERRIDE { | 192 const std::string& token) OVERRIDE { |
193 } | 193 } |
194 | 194 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 data, &message, &service_context, &scheduling_hash)); | 295 data, &message, &service_context, &scheduling_hash)); |
296 EXPECT_EQ(kMessage, message); | 296 EXPECT_EQ(kMessage, message); |
297 EXPECT_EQ(kServiceContext, service_context); | 297 EXPECT_EQ(kServiceContext, service_context); |
298 EXPECT_EQ(kSchedulingHash, scheduling_hash); | 298 EXPECT_EQ(kSchedulingHash, scheduling_hash); |
299 } | 299 } |
300 | 300 |
301 // Simulate network channel state change. It should propagate to observer. | 301 // Simulate network channel state change. It should propagate to observer. |
302 TEST_F(SyncNetworkChannelTest, OnNetworkChannelStateChanged) { | 302 TEST_F(SyncNetworkChannelTest, OnNetworkChannelStateChanged) { |
303 EXPECT_EQ(DEFAULT_INVALIDATION_ERROR, last_invalidator_state_); | 303 EXPECT_EQ(DEFAULT_INVALIDATION_ERROR, last_invalidator_state_); |
304 EXPECT_FALSE(connected_); | 304 EXPECT_FALSE(connected_); |
305 network_channel_.NotifyStateChange(INVALIDATIONS_ENABLED); | 305 network_channel_.SetNetworkState(INVALIDATIONS_ENABLED); |
306 EXPECT_EQ(INVALIDATIONS_ENABLED, last_invalidator_state_); | 306 EXPECT_EQ(INVALIDATIONS_ENABLED, last_invalidator_state_); |
307 EXPECT_TRUE(connected_); | 307 EXPECT_TRUE(connected_); |
308 network_channel_.NotifyStateChange(INVALIDATION_CREDENTIALS_REJECTED); | 308 network_channel_.SetNetworkState(INVALIDATION_CREDENTIALS_REJECTED); |
309 EXPECT_EQ(INVALIDATION_CREDENTIALS_REJECTED, last_invalidator_state_); | 309 EXPECT_EQ(INVALIDATION_CREDENTIALS_REJECTED, last_invalidator_state_); |
310 EXPECT_FALSE(connected_); | 310 EXPECT_FALSE(connected_); |
311 } | 311 } |
312 | 312 |
313 // Call SendMessage on the channel. SendEncodedMessage should be called for it. | 313 // Call SendMessage on the channel. SendEncodedMessage should be called for it. |
314 TEST_F(SyncNetworkChannelTest, SendMessage) { | 314 TEST_F(SyncNetworkChannelTest, SendMessage) { |
315 network_channel_.SendMessage(kMessage); | 315 network_channel_.SendMessage(kMessage); |
316 std::string expected_encoded_message = | 316 std::string expected_encoded_message = |
317 SyncNetworkChannel::EncodeMessageForTest( | 317 SyncNetworkChannel::EncodeMessageForTest( |
318 kMessage, | 318 kMessage, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 network_channel_.last_encoded_message_, | 398 network_channel_.last_encoded_message_, |
399 &message, &service_context, &scheduling_hash)); | 399 &message, &service_context, &scheduling_hash)); |
400 EXPECT_EQ(kMessage, message); | 400 EXPECT_EQ(kMessage, message); |
401 EXPECT_EQ(kServiceContext, service_context); | 401 EXPECT_EQ(kServiceContext, service_context); |
402 EXPECT_EQ(kSchedulingHash, scheduling_hash); | 402 EXPECT_EQ(kSchedulingHash, scheduling_hash); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 } // namespace | 406 } // namespace |
407 } // namespace syncer | 407 } // namespace syncer |
OLD | NEW |