| 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/registration_manager.h" | 5 #include "sync/notifier/registration_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 // Basic test of UpdateRegisteredIds to make sure we properly register | 233 // Basic test of UpdateRegisteredIds to make sure we properly register |
| 234 // new IDs and unregister any IDs no longer in the set. | 234 // new IDs and unregister any IDs no longer in the set. |
| 235 TEST_F(RegistrationManagerTest, UpdateRegisteredIds) { | 235 TEST_F(RegistrationManagerTest, UpdateRegisteredIds) { |
| 236 ObjectIdSet ids = GetSequenceOfIds(kObjectIdsCount - 1); | 236 ObjectIdSet ids = GetSequenceOfIds(kObjectIdsCount - 1); |
| 237 | 237 |
| 238 EXPECT_TRUE(fake_registration_manager_.GetRegisteredIdsForTest().empty()); | 238 EXPECT_TRUE(fake_registration_manager_.GetRegisteredIdsForTest().empty()); |
| 239 EXPECT_TRUE(fake_invalidation_client_.GetRegisteredIdsForTest().empty()); | 239 EXPECT_TRUE(fake_invalidation_client_.GetRegisteredIdsForTest().empty()); |
| 240 | 240 |
| 241 fake_registration_manager_.UpdateRegisteredIds(ids); | 241 ObjectIdSet expected_unregistered_ids; |
| 242 |
| 243 ObjectIdSet unregistered_ids = |
| 244 fake_registration_manager_.UpdateRegisteredIds(ids); |
| 245 EXPECT_EQ(expected_unregistered_ids, unregistered_ids); |
| 242 EXPECT_EQ(ids, fake_registration_manager_.GetRegisteredIdsForTest()); | 246 EXPECT_EQ(ids, fake_registration_manager_.GetRegisteredIdsForTest()); |
| 243 EXPECT_EQ(ids, fake_invalidation_client_.GetRegisteredIdsForTest()); | 247 EXPECT_EQ(ids, fake_invalidation_client_.GetRegisteredIdsForTest()); |
| 244 | 248 |
| 245 ids.insert(GetIdForIndex(kObjectIdsCount - 1)); | 249 ids.insert(GetIdForIndex(kObjectIdsCount - 1)); |
| 246 ids.erase(GetIdForIndex(kObjectIdsCount - 2)); | 250 ids.erase(GetIdForIndex(kObjectIdsCount - 2)); |
| 247 fake_registration_manager_.UpdateRegisteredIds(ids); | 251 unregistered_ids = fake_registration_manager_.UpdateRegisteredIds(ids); |
| 252 expected_unregistered_ids.insert(GetIdForIndex(kObjectIdsCount - 2)); |
| 253 EXPECT_EQ(expected_unregistered_ids, unregistered_ids); |
| 248 EXPECT_EQ(ids, fake_registration_manager_.GetRegisteredIdsForTest()); | 254 EXPECT_EQ(ids, fake_registration_manager_.GetRegisteredIdsForTest()); |
| 249 EXPECT_EQ(ids, fake_invalidation_client_.GetRegisteredIdsForTest()); | 255 EXPECT_EQ(ids, fake_invalidation_client_.GetRegisteredIdsForTest()); |
| 250 } | 256 } |
| 251 | 257 |
| 252 int GetRoundedBackoff(double retry_interval, double jitter) { | 258 int GetRoundedBackoff(double retry_interval, double jitter) { |
| 253 const double kInitialRetryInterval = 3.0; | 259 const double kInitialRetryInterval = 3.0; |
| 254 const double kMinRetryInterval = 2.0; | 260 const double kMinRetryInterval = 2.0; |
| 255 const double kMaxRetryInterval = 20.0; | 261 const double kMaxRetryInterval = 20.0; |
| 256 const double kBackoffExponent = 2.0; | 262 const double kBackoffExponent = 2.0; |
| 257 const double kMaxJitter = 0.5; | 263 const double kMaxJitter = 0.5; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 fake_registration_manager_.GetPendingRegistrationsForTest()); | 422 fake_registration_manager_.GetPendingRegistrationsForTest()); |
| 417 | 423 |
| 418 fake_registration_manager_.MarkAllRegistrationsLost(); | 424 fake_registration_manager_.MarkAllRegistrationsLost(); |
| 419 ExpectPendingRegistrations( | 425 ExpectPendingRegistrations( |
| 420 enabled_ids, 0.0, | 426 enabled_ids, 0.0, |
| 421 fake_registration_manager_.GetPendingRegistrationsForTest()); | 427 fake_registration_manager_.GetPendingRegistrationsForTest()); |
| 422 } | 428 } |
| 423 | 429 |
| 424 } // namespace | 430 } // namespace |
| 425 } // namespace syncer | 431 } // namespace syncer |
| OLD | NEW |