Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/sync/notifier/registration_manager_unittest.cc

Issue 8772074: [Sync] Convert syncable/ directory to ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/notifier/registration_manager.h" 5 #include "chrome/browser/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Fake invalidation client that just stores the currently-registered 55 // Fake invalidation client that just stores the currently-registered
56 // model types. 56 // model types.
57 class FakeInvalidationClient : public invalidation::InvalidationClient { 57 class FakeInvalidationClient : public invalidation::InvalidationClient {
58 public: 58 public:
59 FakeInvalidationClient() {} 59 FakeInvalidationClient() {}
60 60
61 virtual ~FakeInvalidationClient() {} 61 virtual ~FakeInvalidationClient() {}
62 62
63 void LoseRegistration(syncable::ModelType model_type) { 63 void LoseRegistration(syncable::ModelType model_type) {
64 EXPECT_GT(registered_types_.count(model_type), 0u); 64 EXPECT_TRUE(registered_types_.Has(model_type));
65 registered_types_.erase(model_type); 65 registered_types_.Remove(model_type);
66 } 66 }
67 67
68 void LoseAllRegistrations() { 68 void LoseAllRegistrations() {
69 registered_types_.clear(); 69 registered_types_.Clear();
70 } 70 }
71 71
72 // invalidation::InvalidationClient implementation. 72 // invalidation::InvalidationClient implementation.
73 73
74 virtual void Start() {} 74 virtual void Start() {}
75 virtual void Stop() {} 75 virtual void Stop() {}
76 virtual void Acknowledge(const invalidation::AckHandle& handle) {} 76 virtual void Acknowledge(const invalidation::AckHandle& handle) {}
77 77
78 virtual void Register(const invalidation::ObjectId& oid) { 78 virtual void Register(const invalidation::ObjectId& oid) {
79 syncable::ModelType model_type = ObjectIdToModelType(oid); 79 syncable::ModelType model_type = ObjectIdToModelType(oid);
80 EXPECT_EQ(0u, registered_types_.count(model_type)); 80 EXPECT_FALSE(registered_types_.Has(model_type));
81 registered_types_.insert(model_type); 81 registered_types_.Put(model_type);
82 } 82 }
83 83
84 virtual void Register(const std::vector<invalidation::ObjectId>& oids) { 84 virtual void Register(const std::vector<invalidation::ObjectId>& oids) {
85 // Unused for now. 85 // Unused for now.
86 } 86 }
87 87
88 virtual void Unregister(const invalidation::ObjectId& oid) { 88 virtual void Unregister(const invalidation::ObjectId& oid) {
89 syncable::ModelType model_type = ObjectIdToModelType(oid); 89 syncable::ModelType model_type = ObjectIdToModelType(oid);
90 EXPECT_GT(registered_types_.count(model_type), 0u); 90 EXPECT_TRUE(registered_types_.Has(model_type));
91 registered_types_.erase(model_type); 91 registered_types_.Remove(model_type);
92 } 92 }
93 93
94 virtual void Unregister(const std::vector<invalidation::ObjectId>& oids) { 94 virtual void Unregister(const std::vector<invalidation::ObjectId>& oids) {
95 // Unused for now. 95 // Unused for now.
96 } 96 }
97 97
98 const syncable::ModelTypeSet GetRegisteredTypes() const { 98 const syncable::ModelEnumSet GetRegisteredTypes() const {
99 return registered_types_; 99 return registered_types_;
100 } 100 }
101 101
102 private: 102 private:
103 syncable::ModelTypeSet registered_types_; 103 syncable::ModelEnumSet registered_types_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationClient); 105 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationClient);
106 }; 106 };
107 107
108 const syncable::ModelType kModelTypes[] = { 108 const syncable::ModelType kModelTypes[] = {
109 syncable::BOOKMARKS, 109 syncable::BOOKMARKS,
110 syncable::PREFERENCES, 110 syncable::PREFERENCES,
111 syncable::THEMES, 111 syncable::THEMES,
112 syncable::AUTOFILL, 112 syncable::AUTOFILL,
113 syncable::EXTENSIONS, 113 syncable::EXTENSIONS,
114 }; 114 };
115 const size_t kModelTypeCount = arraysize(kModelTypes); 115 const size_t kModelTypeCount = arraysize(kModelTypes);
116 116
117 syncable::ModelEnumSet FromPtr(
118 const syncable::ModelType* types, size_t count) {
119 syncable::ModelEnumSet type_set;
120 for (size_t i = 0; i < count; ++i) {
121 type_set.Put(types[i]);
122 }
123 return type_set;
124 }
125
117 void ExpectPendingRegistrations( 126 void ExpectPendingRegistrations(
118 const syncable::ModelTypeSet& expected_pending_types, 127 syncable::ModelEnumSet expected_pending_types,
119 double expected_delay_seconds, 128 double expected_delay_seconds,
120 const RegistrationManager::PendingRegistrationMap& pending_registrations) { 129 const RegistrationManager::PendingRegistrationMap& pending_registrations) {
121 syncable::ModelTypeSet pending_types; 130 syncable::ModelEnumSet pending_types;
122 for (RegistrationManager::PendingRegistrationMap::const_iterator it = 131 for (RegistrationManager::PendingRegistrationMap::const_iterator it =
123 pending_registrations.begin(); it != pending_registrations.end(); 132 pending_registrations.begin(); it != pending_registrations.end();
124 ++it) { 133 ++it) {
125 SCOPED_TRACE(syncable::ModelTypeToString(it->first)); 134 SCOPED_TRACE(syncable::ModelTypeToString(it->first));
126 pending_types.insert(it->first); 135 pending_types.Put(it->first);
127 base::TimeDelta offset = 136 base::TimeDelta offset =
128 it->second.last_registration_request - 137 it->second.last_registration_request -
129 it->second.registration_attempt; 138 it->second.registration_attempt;
130 base::TimeDelta expected_delay = 139 base::TimeDelta expected_delay =
131 base::TimeDelta::FromSeconds( 140 base::TimeDelta::FromSeconds(
132 static_cast<int64>(expected_delay_seconds)) + offset; 141 static_cast<int64>(expected_delay_seconds)) + offset;
133 // TODO(akalin): Add base::PrintTo() for base::Time and 142 // TODO(akalin): Add base::PrintTo() for base::Time and
134 // base::TimeDeltas. 143 // base::TimeDeltas.
135 EXPECT_EQ(it->second.delay, expected_delay) 144 EXPECT_EQ(it->second.delay, expected_delay)
136 << it->second.delay.InMicroseconds() 145 << it->second.delay.InMicroseconds()
137 << ", " << expected_delay.InMicroseconds(); 146 << ", " << expected_delay.InMicroseconds();
138 if (it->second.delay <= base::TimeDelta()) { 147 if (it->second.delay <= base::TimeDelta()) {
139 EXPECT_EQ(it->second.actual_delay, base::TimeDelta()); 148 EXPECT_EQ(it->second.actual_delay, base::TimeDelta());
140 } else { 149 } else {
141 EXPECT_EQ(it->second.delay, it->second.actual_delay); 150 EXPECT_EQ(it->second.delay, it->second.actual_delay);
142 } 151 }
143 } 152 }
144 EXPECT_EQ(expected_pending_types, pending_types); 153 EXPECT_TRUE(pending_types.Equals(expected_pending_types));
145 } 154 }
146 155
147 class RegistrationManagerTest : public testing::Test { 156 class RegistrationManagerTest : public testing::Test {
148 protected: 157 protected:
149 RegistrationManagerTest() 158 RegistrationManagerTest()
150 : fake_registration_manager_(&fake_invalidation_client_) {} 159 : fake_registration_manager_(&fake_invalidation_client_) {}
151 160
152 virtual ~RegistrationManagerTest() {} 161 virtual ~RegistrationManagerTest() {}
153 162
154 void LoseRegistrations(const syncable::ModelTypeSet& types) { 163 void LoseRegistrations(syncable::ModelEnumSet types) {
155 for (syncable::ModelTypeSet::const_iterator it = types.begin(); 164 for (syncable::ModelEnumSet::Iterator it = types.First();
156 it != types.end(); ++it) { 165 it.Good(); it.Inc()) {
157 fake_invalidation_client_.LoseRegistration(*it); 166 fake_invalidation_client_.LoseRegistration(it.Get());
158 fake_registration_manager_.MarkRegistrationLost(*it); 167 fake_registration_manager_.MarkRegistrationLost(it.Get());
159 } 168 }
160 } 169 }
161 170
162 void DisableTypes(const syncable::ModelTypeSet& types) { 171 void DisableTypes(syncable::ModelEnumSet types) {
163 for (syncable::ModelTypeSet::const_iterator it = types.begin(); 172 for (syncable::ModelEnumSet::Iterator it = types.First();
164 it != types.end(); ++it) { 173 it.Good(); it.Inc()) {
165 fake_invalidation_client_.LoseRegistration(*it); 174 fake_invalidation_client_.LoseRegistration(it.Get());
166 fake_registration_manager_.DisableType(*it); 175 fake_registration_manager_.DisableType(it.Get());
167 } 176 }
168 } 177 }
169 178
170 // Used by MarkRegistrationLostBackoff* tests. 179 // Used by MarkRegistrationLostBackoff* tests.
171 void RunBackoffTest(double jitter) { 180 void RunBackoffTest(double jitter) {
172 fake_registration_manager_.SetJitter(jitter); 181 fake_registration_manager_.SetJitter(jitter);
173 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount); 182 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
174 fake_registration_manager_.SetRegisteredTypes(types); 183 fake_registration_manager_.SetRegisteredTypes(types);
175 184
176 // Lose some types. 185 // Lose some types.
177 syncable::ModelTypeSet lost_types(kModelTypes, kModelTypes + 2); 186 syncable::ModelEnumSet lost_types = FromPtr(kModelTypes, 2);
178 LoseRegistrations(lost_types); 187 LoseRegistrations(lost_types);
179 ExpectPendingRegistrations( 188 ExpectPendingRegistrations(
180 lost_types, 0.0, 189 lost_types, 0.0,
181 fake_registration_manager_.GetPendingRegistrations()); 190 fake_registration_manager_.GetPendingRegistrations());
182 191
183 // Trigger another failure to start delaying. 192 // Trigger another failure to start delaying.
184 fake_registration_manager_.FirePendingRegistrationsForTest(); 193 fake_registration_manager_.FirePendingRegistrationsForTest();
185 LoseRegistrations(lost_types); 194 LoseRegistrations(lost_types);
186 195
187 double scaled_jitter = 196 double scaled_jitter =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 FakeRegistrationManager fake_registration_manager_; 232 FakeRegistrationManager fake_registration_manager_;
224 233
225 private: 234 private:
226 // Needed by timers in RegistrationManager. 235 // Needed by timers in RegistrationManager.
227 MessageLoop message_loop_; 236 MessageLoop message_loop_;
228 237
229 DISALLOW_COPY_AND_ASSIGN(RegistrationManagerTest); 238 DISALLOW_COPY_AND_ASSIGN(RegistrationManagerTest);
230 }; 239 };
231 240
232 TEST_F(RegistrationManagerTest, SetRegisteredTypes) { 241 TEST_F(RegistrationManagerTest, SetRegisteredTypes) {
233 syncable::ModelTypeSet no_types; 242 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
234 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount);
235 243
236 EXPECT_EQ(no_types, fake_registration_manager_.GetRegisteredTypes()); 244 EXPECT_TRUE(fake_registration_manager_.GetRegisteredTypes().Empty());
237 EXPECT_EQ(no_types, fake_invalidation_client_.GetRegisteredTypes()); 245 EXPECT_TRUE(fake_invalidation_client_.GetRegisteredTypes().Empty());
238 246
239 fake_registration_manager_.SetRegisteredTypes(types); 247 fake_registration_manager_.SetRegisteredTypes(types);
240 EXPECT_EQ(types, fake_registration_manager_.GetRegisteredTypes()); 248 EXPECT_TRUE(fake_registration_manager_.GetRegisteredTypes().Equals(types));
241 EXPECT_EQ(types, fake_invalidation_client_.GetRegisteredTypes()); 249 EXPECT_TRUE(fake_invalidation_client_.GetRegisteredTypes().Equals(types));
242 250
243 types.insert(syncable::APPS); 251 types.Put(syncable::APPS);
244 types.erase(syncable::BOOKMARKS); 252 types.Remove(syncable::BOOKMARKS);
245 fake_registration_manager_.SetRegisteredTypes(types); 253 fake_registration_manager_.SetRegisteredTypes(types);
246 EXPECT_EQ(types, fake_registration_manager_.GetRegisteredTypes()); 254 EXPECT_TRUE(fake_registration_manager_.GetRegisteredTypes().Equals(types));
247 EXPECT_EQ(types, fake_invalidation_client_.GetRegisteredTypes()); 255 EXPECT_TRUE(fake_invalidation_client_.GetRegisteredTypes().Equals(types));
248 } 256 }
249 257
250 int GetRoundedBackoff(double retry_interval, double jitter) { 258 int GetRoundedBackoff(double retry_interval, double jitter) {
251 const double kInitialRetryInterval = 3.0; 259 const double kInitialRetryInterval = 3.0;
252 const double kMinRetryInterval = 2.0; 260 const double kMinRetryInterval = 2.0;
253 const double kMaxRetryInterval = 20.0; 261 const double kMaxRetryInterval = 20.0;
254 const double kBackoffExponent = 2.0; 262 const double kBackoffExponent = 2.0;
255 const double kMaxJitter = 0.5; 263 const double kMaxJitter = 0.5;
256 264
257 return static_cast<int>( 265 return static_cast<int>(
(...skipping 21 matching lines...) Expand all
279 EXPECT_EQ(10, GetRoundedBackoff(5.0, 0.0)); 287 EXPECT_EQ(10, GetRoundedBackoff(5.0, 0.0));
280 EXPECT_EQ(12, GetRoundedBackoff(5.0, +1.0)); 288 EXPECT_EQ(12, GetRoundedBackoff(5.0, +1.0));
281 289
282 // Test ceiling. 290 // Test ceiling.
283 EXPECT_EQ(19, GetRoundedBackoff(13.0, -1.0)); 291 EXPECT_EQ(19, GetRoundedBackoff(13.0, -1.0));
284 EXPECT_EQ(20, GetRoundedBackoff(13.0, 0.0)); 292 EXPECT_EQ(20, GetRoundedBackoff(13.0, 0.0));
285 EXPECT_EQ(20, GetRoundedBackoff(13.0, +1.0)); 293 EXPECT_EQ(20, GetRoundedBackoff(13.0, +1.0));
286 } 294 }
287 295
288 TEST_F(RegistrationManagerTest, MarkRegistrationLost) { 296 TEST_F(RegistrationManagerTest, MarkRegistrationLost) {
289 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount); 297 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
290 298
291 fake_registration_manager_.SetRegisteredTypes(types); 299 fake_registration_manager_.SetRegisteredTypes(types);
292 EXPECT_TRUE(fake_registration_manager_.GetPendingRegistrations().empty()); 300 EXPECT_TRUE(fake_registration_manager_.GetPendingRegistrations().empty());
293 301
294 // Lose some types. 302 // Lose some types.
295 syncable::ModelTypeSet lost_types( 303 syncable::ModelEnumSet lost_types = FromPtr(
296 kModelTypes, kModelTypes + 3); 304 kModelTypes, 3);
297 syncable::ModelTypeSet non_lost_types( 305 syncable::ModelEnumSet non_lost_types = FromPtr(
298 kModelTypes + 3, kModelTypes + kModelTypeCount); 306 kModelTypes + 3, kModelTypeCount - 3);
299 LoseRegistrations(lost_types); 307 LoseRegistrations(lost_types);
300 ExpectPendingRegistrations( 308 ExpectPendingRegistrations(
301 lost_types, 0.0, 309 lost_types, 0.0,
302 fake_registration_manager_.GetPendingRegistrations()); 310 fake_registration_manager_.GetPendingRegistrations());
303 EXPECT_EQ(non_lost_types, fake_registration_manager_.GetRegisteredTypes()); 311 EXPECT_TRUE(
304 EXPECT_EQ(non_lost_types, fake_invalidation_client_.GetRegisteredTypes()); 312 fake_registration_manager_.GetRegisteredTypes().Equals(non_lost_types));
313 EXPECT_TRUE(
314 fake_invalidation_client_.GetRegisteredTypes().Equals(non_lost_types));
305 315
306 // Pretend we waited long enough to re-register. 316 // Pretend we waited long enough to re-register.
307 fake_registration_manager_.FirePendingRegistrationsForTest(); 317 fake_registration_manager_.FirePendingRegistrationsForTest();
308 EXPECT_EQ(types, fake_registration_manager_.GetRegisteredTypes()); 318 EXPECT_TRUE(
309 EXPECT_EQ(types, fake_invalidation_client_.GetRegisteredTypes()); 319 fake_registration_manager_.GetRegisteredTypes().Equals(types));
320 EXPECT_TRUE(
321 fake_invalidation_client_.GetRegisteredTypes().Equals(types));
310 } 322 }
311 323
312 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffLow) { 324 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffLow) {
313 RunBackoffTest(-1.0); 325 RunBackoffTest(-1.0);
314 } 326 }
315 327
316 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffMid) { 328 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffMid) {
317 RunBackoffTest(0.0); 329 RunBackoffTest(0.0);
318 } 330 }
319 331
320 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffHigh) { 332 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffHigh) {
321 RunBackoffTest(+1.0); 333 RunBackoffTest(+1.0);
322 } 334 }
323 335
324 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffReset) { 336 TEST_F(RegistrationManagerTest, MarkRegistrationLostBackoffReset) {
325 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount); 337 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
326 338
327 fake_registration_manager_.SetRegisteredTypes(types); 339 fake_registration_manager_.SetRegisteredTypes(types);
328 340
329 // Lose some types. 341 // Lose some types.
330 syncable::ModelTypeSet lost_types(kModelTypes, kModelTypes + 2); 342 syncable::ModelEnumSet lost_types = FromPtr(kModelTypes, 2);
331 LoseRegistrations(lost_types); 343 LoseRegistrations(lost_types);
332 ExpectPendingRegistrations( 344 ExpectPendingRegistrations(
333 lost_types, 0.0, 345 lost_types, 0.0,
334 fake_registration_manager_.GetPendingRegistrations()); 346 fake_registration_manager_.GetPendingRegistrations());
335 347
336 // Trigger another failure to start delaying. 348 // Trigger another failure to start delaying.
337 fake_registration_manager_.FirePendingRegistrationsForTest(); 349 fake_registration_manager_.FirePendingRegistrationsForTest();
338 LoseRegistrations(lost_types); 350 LoseRegistrations(lost_types);
339 double expected_delay = 351 double expected_delay =
340 RegistrationManager::kInitialRegistrationDelaySeconds; 352 RegistrationManager::kInitialRegistrationDelaySeconds;
341 ExpectPendingRegistrations( 353 ExpectPendingRegistrations(
342 lost_types, expected_delay, 354 lost_types, expected_delay,
343 fake_registration_manager_.GetPendingRegistrations()); 355 fake_registration_manager_.GetPendingRegistrations());
344 356
345 // Set types again. 357 // Set types again.
346 fake_registration_manager_.SetRegisteredTypes(types); 358 fake_registration_manager_.SetRegisteredTypes(types);
347 ExpectPendingRegistrations( 359 ExpectPendingRegistrations(
348 syncable::ModelTypeSet(), 0.0, 360 syncable::ModelEnumSet(), 0.0,
349 fake_registration_manager_.GetPendingRegistrations()); 361 fake_registration_manager_.GetPendingRegistrations());
350 } 362 }
351 363
352 TEST_F(RegistrationManagerTest, MarkAllRegistrationsLost) { 364 TEST_F(RegistrationManagerTest, MarkAllRegistrationsLost) {
353 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount); 365 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
354 366
355 fake_registration_manager_.SetRegisteredTypes(types); 367 fake_registration_manager_.SetRegisteredTypes(types);
356 368
357 fake_invalidation_client_.LoseAllRegistrations(); 369 fake_invalidation_client_.LoseAllRegistrations();
358 fake_registration_manager_.MarkAllRegistrationsLost(); 370 fake_registration_manager_.MarkAllRegistrationsLost();
359 371
360 syncable::ModelTypeSet expected_types; 372 syncable::ModelEnumSet expected_types;
361 EXPECT_EQ(expected_types, fake_registration_manager_.GetRegisteredTypes()); 373 EXPECT_TRUE(
362 EXPECT_EQ(expected_types, fake_invalidation_client_.GetRegisteredTypes()); 374 fake_registration_manager_.GetRegisteredTypes().Equals(expected_types));
375 EXPECT_TRUE(
376 fake_invalidation_client_.GetRegisteredTypes().Equals(expected_types));
363 377
364 ExpectPendingRegistrations( 378 ExpectPendingRegistrations(
365 types, 0.0, 379 types, 0.0,
366 fake_registration_manager_.GetPendingRegistrations()); 380 fake_registration_manager_.GetPendingRegistrations());
367 381
368 // Trigger another failure to start delaying. 382 // Trigger another failure to start delaying.
369 fake_registration_manager_.FirePendingRegistrationsForTest(); 383 fake_registration_manager_.FirePendingRegistrationsForTest();
370 fake_invalidation_client_.LoseAllRegistrations(); 384 fake_invalidation_client_.LoseAllRegistrations();
371 fake_registration_manager_.MarkAllRegistrationsLost(); 385 fake_registration_manager_.MarkAllRegistrationsLost();
372 double expected_delay = 386 double expected_delay =
373 RegistrationManager::kInitialRegistrationDelaySeconds; 387 RegistrationManager::kInitialRegistrationDelaySeconds;
374 ExpectPendingRegistrations( 388 ExpectPendingRegistrations(
375 types, expected_delay, 389 types, expected_delay,
376 fake_registration_manager_.GetPendingRegistrations()); 390 fake_registration_manager_.GetPendingRegistrations());
377 391
378 // Pretend we waited long enough to re-register. 392 // Pretend we waited long enough to re-register.
379 fake_registration_manager_.FirePendingRegistrationsForTest(); 393 fake_registration_manager_.FirePendingRegistrationsForTest();
380 EXPECT_EQ(types, fake_registration_manager_.GetRegisteredTypes()); 394 EXPECT_TRUE(
381 EXPECT_EQ(types, fake_invalidation_client_.GetRegisteredTypes()); 395 fake_registration_manager_.GetRegisteredTypes().Equals(types));
396 EXPECT_TRUE(
397 fake_invalidation_client_.GetRegisteredTypes().Equals(types));
382 } 398 }
383 399
384 TEST_F(RegistrationManagerTest, DisableType) { 400 TEST_F(RegistrationManagerTest, DisableType) {
385 syncable::ModelTypeSet types(kModelTypes, kModelTypes + kModelTypeCount); 401 syncable::ModelEnumSet types = FromPtr(kModelTypes, kModelTypeCount);
386 402
387 fake_registration_manager_.SetRegisteredTypes(types); 403 fake_registration_manager_.SetRegisteredTypes(types);
388 EXPECT_TRUE(fake_registration_manager_.GetPendingRegistrations().empty()); 404 EXPECT_TRUE(fake_registration_manager_.GetPendingRegistrations().empty());
389 405
390 // Disable some types. 406 // Disable some types.
391 syncable::ModelTypeSet disabled_types( 407 syncable::ModelEnumSet disabled_types = FromPtr(
392 kModelTypes, kModelTypes + 3); 408 kModelTypes, 3);
393 syncable::ModelTypeSet enabled_types( 409 syncable::ModelEnumSet enabled_types = FromPtr(
394 kModelTypes + 3, kModelTypes + kModelTypeCount); 410 kModelTypes + 3, kModelTypeCount - 3);
395 DisableTypes(disabled_types); 411 DisableTypes(disabled_types);
396 ExpectPendingRegistrations( 412 ExpectPendingRegistrations(
397 syncable::ModelTypeSet(), 0.0, 413 syncable::ModelEnumSet(), 0.0,
398 fake_registration_manager_.GetPendingRegistrations()); 414 fake_registration_manager_.GetPendingRegistrations());
399 EXPECT_EQ(enabled_types, fake_registration_manager_.GetRegisteredTypes()); 415 EXPECT_TRUE(
400 EXPECT_EQ(enabled_types, fake_invalidation_client_.GetRegisteredTypes()); 416 fake_registration_manager_.GetRegisteredTypes().Equals(enabled_types));
417 EXPECT_TRUE(
418 fake_invalidation_client_.GetRegisteredTypes().Equals(enabled_types));
401 419
402 fake_registration_manager_.SetRegisteredTypes(types); 420 fake_registration_manager_.SetRegisteredTypes(types);
403 EXPECT_EQ(enabled_types, fake_registration_manager_.GetRegisteredTypes()); 421 EXPECT_TRUE(
422 fake_registration_manager_.GetRegisteredTypes().Equals(enabled_types));
404 423
405 fake_registration_manager_.MarkRegistrationLost(*disabled_types.begin()); 424 fake_registration_manager_.MarkRegistrationLost(
425 disabled_types.First().Get());
406 ExpectPendingRegistrations( 426 ExpectPendingRegistrations(
407 syncable::ModelTypeSet(), 0.0, 427 syncable::ModelEnumSet(), 0.0,
408 fake_registration_manager_.GetPendingRegistrations()); 428 fake_registration_manager_.GetPendingRegistrations());
409 429
410 fake_registration_manager_.MarkAllRegistrationsLost(); 430 fake_registration_manager_.MarkAllRegistrationsLost();
411 ExpectPendingRegistrations( 431 ExpectPendingRegistrations(
412 enabled_types, 0.0, 432 enabled_types, 0.0,
413 fake_registration_manager_.GetPendingRegistrations()); 433 fake_registration_manager_.GetPendingRegistrations());
414 } 434 }
415 435
416 } // namespace 436 } // namespace
417 } // namespace notifier 437 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/registration_manager.cc ('k') | chrome/browser/sync/notifier/sync_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698