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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc

Issue 56113003: Implement new invalidations ack tracking system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More review fixes Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void StorePolicy(PolicyObject object) { 100 void StorePolicy(PolicyObject object) {
101 StorePolicy(object, 0); 101 StorePolicy(object, 0);
102 } 102 }
103 103
104 // Disables the invalidation service. It is enabled by default. 104 // Disables the invalidation service. It is enabled by default.
105 void DisableInvalidationService(); 105 void DisableInvalidationService();
106 106
107 // Enables the invalidation service. It is enabled by default. 107 // Enables the invalidation service. It is enabled by default.
108 void EnableInvalidationService(); 108 void EnableInvalidationService();
109 109
110 // Causes the invalidation service to fire an invalidation. Returns an ack 110 // Causes the invalidation service to fire an invalidation.
111 // handle which be used to verify that the invalidation was acknowledged. 111 syncer::Invalidation FireInvalidation(
112 syncer::AckHandle FireInvalidation(
113 PolicyObject object, 112 PolicyObject object,
114 int64 version, 113 int64 version,
115 const std::string& payload); 114 const std::string& payload);
116 115
117 // Causes the invalidation service to fire an invalidation with unknown 116 // Causes the invalidation service to fire an invalidation with unknown
118 // version. Returns an ack handle which be used to verify that the 117 // version.
119 // invalidation was acknowledged. 118 syncer::Invalidation FireUnknownVersionInvalidation(PolicyObject object);
120 syncer::AckHandle FireUnknownVersionInvalidation(PolicyObject object);
121 119
122 // Checks the expected value of the currently set invalidation info. 120 // Checks the expected value of the currently set invalidation info.
123 bool CheckInvalidationInfo(int64 version, const std::string& payload); 121 bool CheckInvalidationInfo(int64 version, const std::string& payload);
124 122
125 // Checks that the policy was not refreshed due to an invalidation. 123 // Checks that the policy was not refreshed due to an invalidation.
126 bool CheckPolicyNotRefreshed(); 124 bool CheckPolicyNotRefreshed();
127 125
128 // Checks that the policy was refreshed due to an invalidation within an 126 // Checks that the policy was refreshed due to an invalidation within an
129 // appropriate timeframe depending on whether the invalidation had unknown 127 // appropriate timeframe depending on whether the invalidation had unknown
130 // version. 128 // version.
131 bool CheckPolicyRefreshed(); 129 bool CheckPolicyRefreshed();
132 bool CheckPolicyRefreshedWithUnknownVersion(); 130 bool CheckPolicyRefreshedWithUnknownVersion();
133 131
132 bool IsUnsent(const syncer::Invalidation& invalidation);
133
134 // Checks that the state changed callback of the invalidation handler was not
135 // called.
136 bool CheckStateChangedNotCalled();
Steve Condie 2013/11/25 19:57:29 CheckStateChangedNotCalled not used.
rlarocque 2013/11/25 21:51:25 Done.
137
134 // Returns the invalidations enabled state set by the invalidator on the 138 // Returns the invalidations enabled state set by the invalidator on the
135 // refresh scheduler. 139 // refresh scheduler.
136 bool InvalidationsEnabled(); 140 bool InvalidationsEnabled();
137 141
138 // Determines if the invalidation with the given ack handle has been 142 // Determines if the invalidation with the given ack handle has been
139 // acknowledged. 143 // acknowledged.
140 bool IsInvalidationAcknowledged(const syncer::AckHandle& ack_handle); 144 bool IsInvalidationAcknowledged(const syncer::Invalidation& invalidation);
141 145
142 // Determines if the invalidator has registered for an object with the 146 // Determines if the invalidator has registered for an object with the
143 // invalidation service. 147 // invalidation service.
144 bool IsInvalidatorRegistered(); 148 bool IsInvalidatorRegistered();
145 149
146 // Get the current count for the given metric. 150 // Get the current count for the given metric.
147 base::HistogramBase::Count GetCount(MetricPolicyRefresh metric); 151 base::HistogramBase::Count GetCount(MetricPolicyRefresh metric);
148 base::HistogramBase::Count GetInvalidationCount(bool with_payload); 152 base::HistogramBase::Count GetInvalidationCount(bool with_payload);
149 153
150 private: 154 private:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 policy_value_b_("zxcv"), 214 policy_value_b_("zxcv"),
211 policy_value_cur_(policy_value_a_) {} 215 policy_value_cur_(policy_value_a_) {}
212 216
213 void CloudPolicyInvalidatorTest::SetUp() { 217 void CloudPolicyInvalidatorTest::SetUp() {
214 base::StatisticsRecorder::Initialize(); 218 base::StatisticsRecorder::Initialize();
215 refresh_samples_ = GetHistogramSamples(kMetricPolicyRefresh); 219 refresh_samples_ = GetHistogramSamples(kMetricPolicyRefresh);
216 invalidations_samples_ = GetHistogramSamples(kMetricPolicyInvalidations); 220 invalidations_samples_ = GetHistogramSamples(kMetricPolicyInvalidations);
217 } 221 }
218 222
219 void CloudPolicyInvalidatorTest::TearDown() { 223 void CloudPolicyInvalidatorTest::TearDown() {
220 EXPECT_FALSE(invalidation_service_.ReceivedInvalidAcknowledgement());
221 if (invalidator_) 224 if (invalidator_)
222 invalidator_->Shutdown(); 225 invalidator_->Shutdown();
223 core_.Disconnect(); 226 core_.Disconnect();
224 } 227 }
225 228
226 void CloudPolicyInvalidatorTest::StartInvalidator( 229 void CloudPolicyInvalidatorTest::StartInvalidator(
227 bool initialize, 230 bool initialize,
228 bool start_refresh_scheduler) { 231 bool start_refresh_scheduler) {
229 invalidator_.reset(new CloudPolicyInvalidator(&core_, task_runner_)); 232 invalidator_.reset(new CloudPolicyInvalidator(&core_, task_runner_));
230 if (start_refresh_scheduler) { 233 if (start_refresh_scheduler) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 297
295 void CloudPolicyInvalidatorTest::DisableInvalidationService() { 298 void CloudPolicyInvalidatorTest::DisableInvalidationService() {
296 invalidation_service_.SetInvalidatorState( 299 invalidation_service_.SetInvalidatorState(
297 syncer::TRANSIENT_INVALIDATION_ERROR); 300 syncer::TRANSIENT_INVALIDATION_ERROR);
298 } 301 }
299 302
300 void CloudPolicyInvalidatorTest::EnableInvalidationService() { 303 void CloudPolicyInvalidatorTest::EnableInvalidationService() {
301 invalidation_service_.SetInvalidatorState(syncer::INVALIDATIONS_ENABLED); 304 invalidation_service_.SetInvalidatorState(syncer::INVALIDATIONS_ENABLED);
302 } 305 }
303 306
304 syncer::AckHandle CloudPolicyInvalidatorTest::FireInvalidation( 307 syncer::Invalidation CloudPolicyInvalidatorTest::FireInvalidation(
305 PolicyObject object, 308 PolicyObject object,
306 int64 version, 309 int64 version,
307 const std::string& payload) { 310 const std::string& payload) {
308 syncer::Invalidation invalidation = syncer::Invalidation::Init( 311 syncer::Invalidation invalidation = syncer::Invalidation::Init(
309 GetPolicyObjectId(object), 312 GetPolicyObjectId(object),
310 version, 313 version,
311 payload); 314 payload);
312 invalidation_service_.EmitInvalidationForTest(invalidation); 315 invalidation_service_.EmitInvalidationForTest(invalidation);
313 return invalidation.ack_handle(); 316 return invalidation;
314 } 317 }
315 318
316 syncer::AckHandle CloudPolicyInvalidatorTest::FireUnknownVersionInvalidation( 319 syncer::Invalidation CloudPolicyInvalidatorTest::FireUnknownVersionInvalidation(
317 PolicyObject object) { 320 PolicyObject object) {
318 syncer::Invalidation invalidation = 321 syncer::Invalidation invalidation = syncer::Invalidation::InitUnknownVersion(
319 syncer::Invalidation::InitUnknownVersion(GetPolicyObjectId(object)); 322 GetPolicyObjectId(object));
320 invalidation_service_.EmitInvalidationForTest(invalidation); 323 invalidation_service_.EmitInvalidationForTest(invalidation);
321 return invalidation.ack_handle(); 324 return invalidation;
322 } 325 }
323 326
324 bool CloudPolicyInvalidatorTest::CheckInvalidationInfo( 327 bool CloudPolicyInvalidatorTest::CheckInvalidationInfo(
325 int64 version, 328 int64 version,
326 const std::string& payload) { 329 const std::string& payload) {
327 MockCloudPolicyClient* client = 330 MockCloudPolicyClient* client =
328 static_cast<MockCloudPolicyClient*>(core_.client()); 331 static_cast<MockCloudPolicyClient*>(core_.client());
329 return version == client->invalidation_version_ && 332 return version == client->invalidation_version_ &&
330 payload == client->invalidation_payload_; 333 payload == client->invalidation_payload_;
331 } 334 }
332 335
333 bool CloudPolicyInvalidatorTest::CheckPolicyNotRefreshed() { 336 bool CloudPolicyInvalidatorTest::CheckPolicyNotRefreshed() {
334 return CheckPolicyRefreshCount(0); 337 return CheckPolicyRefreshCount(0);
335 } 338 }
336 339
337 bool CloudPolicyInvalidatorTest::CheckPolicyRefreshed() { 340 bool CloudPolicyInvalidatorTest::CheckPolicyRefreshed() {
338 return CheckPolicyRefreshed(base::TimeDelta()); 341 return CheckPolicyRefreshed(base::TimeDelta());
339 } 342 }
340 343
344 bool CloudPolicyInvalidatorTest::IsUnsent(
345 const syncer::Invalidation& invalidation) {
346 return invalidation_service_.GetMockAckHandler()->IsUnsent(invalidation);
347 }
348
341 bool CloudPolicyInvalidatorTest::CheckPolicyRefreshedWithUnknownVersion() { 349 bool CloudPolicyInvalidatorTest::CheckPolicyRefreshedWithUnknownVersion() {
342 return CheckPolicyRefreshed(base::TimeDelta::FromMinutes( 350 return CheckPolicyRefreshed(base::TimeDelta::FromMinutes(
343 CloudPolicyInvalidator::kMissingPayloadDelay)); 351 CloudPolicyInvalidator::kMissingPayloadDelay));
344 } 352 }
345 353
346 bool CloudPolicyInvalidatorTest::InvalidationsEnabled() { 354 bool CloudPolicyInvalidatorTest::InvalidationsEnabled() {
347 return core_.refresh_scheduler()->invalidations_available(); 355 return core_.refresh_scheduler()->invalidations_available();
348 } 356 }
349 357
350 bool CloudPolicyInvalidatorTest::IsInvalidationAcknowledged( 358 bool CloudPolicyInvalidatorTest::IsInvalidationAcknowledged(
351 const syncer::AckHandle& ack_handle) { 359 const syncer::Invalidation& invalidation) {
352 return invalidation_service_.IsInvalidationAcknowledged(ack_handle); 360 // The acknowledgement task is run through a WeakHandle that posts back to our
361 // own thread. We need to run any posted tasks before we can check
362 // acknowledgement status.
363 loop_.RunUntilIdle();
364
365 EXPECT_FALSE(IsUnsent(invalidation));
366 return !invalidation_service_.GetMockAckHandler()->IsUnacked(invalidation);
353 } 367 }
354 368
355 bool CloudPolicyInvalidatorTest::IsInvalidatorRegistered() { 369 bool CloudPolicyInvalidatorTest::IsInvalidatorRegistered() {
356 return !invalidation_service_.invalidator_registrar() 370 return !invalidation_service_.invalidator_registrar()
357 .GetRegisteredIds(invalidator_.get()).empty(); 371 .GetRegisteredIds(invalidator_.get()).empty();
358 } 372 }
359 373
360 base::HistogramBase::Count CloudPolicyInvalidatorTest::GetCount( 374 base::HistogramBase::Count CloudPolicyInvalidatorTest::GetCount(
361 MetricPolicyRefresh metric) { 375 MetricPolicyRefresh metric) {
362 return GetHistogramSamples(kMetricPolicyRefresh)->GetCount(metric) - 376 return GetHistogramSamples(kMetricPolicyRefresh)->GetCount(metric) -
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (!histogram) 429 if (!histogram)
416 return scoped_ptr<base::HistogramSamples>(new base::SampleMap()); 430 return scoped_ptr<base::HistogramSamples>(new base::SampleMap());
417 return histogram->SnapshotSamples(); 431 return histogram->SnapshotSamples();
418 } 432 }
419 433
420 TEST_F(CloudPolicyInvalidatorTest, Uninitialized) { 434 TEST_F(CloudPolicyInvalidatorTest, Uninitialized) {
421 // No invalidations should be processed if the invalidator is not initialized. 435 // No invalidations should be processed if the invalidator is not initialized.
422 StartInvalidator(false /* initialize */, true /* start_refresh_scheduler */); 436 StartInvalidator(false /* initialize */, true /* start_refresh_scheduler */);
423 StorePolicy(POLICY_OBJECT_A); 437 StorePolicy(POLICY_OBJECT_A);
424 EXPECT_FALSE(IsInvalidatorRegistered()); 438 EXPECT_FALSE(IsInvalidatorRegistered());
425 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 439 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
426 EXPECT_TRUE(CheckPolicyNotRefreshed()); 440 EXPECT_TRUE(CheckPolicyNotRefreshed());
427 } 441 }
428 442
429 TEST_F(CloudPolicyInvalidatorTest, RefreshSchedulerNotStarted) { 443 TEST_F(CloudPolicyInvalidatorTest, RefreshSchedulerNotStarted) {
430 // No invalidations should be processed if the refresh scheduler is not 444 // No invalidations should be processed if the refresh scheduler is not
431 // started. 445 // started.
432 StartInvalidator(true /* initialize */, false /* start_refresh_scheduler */); 446 StartInvalidator(true /* initialize */, false /* start_refresh_scheduler */);
433 StorePolicy(POLICY_OBJECT_A); 447 StorePolicy(POLICY_OBJECT_A);
434 EXPECT_FALSE(IsInvalidatorRegistered()); 448 EXPECT_FALSE(IsInvalidatorRegistered());
435 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 449 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
436 EXPECT_TRUE(CheckPolicyNotRefreshed()); 450 EXPECT_TRUE(CheckPolicyNotRefreshed());
437 } 451 }
438 452
439 TEST_F(CloudPolicyInvalidatorTest, DisconnectCoreThenInitialize) { 453 TEST_F(CloudPolicyInvalidatorTest, DisconnectCoreThenInitialize) {
440 // No invalidations should be processed if the core is disconnected before 454 // No invalidations should be processed if the core is disconnected before
441 // initialization. 455 // initialization.
442 StartInvalidator(false /* initialize */, true /* start_refresh_scheduler */); 456 StartInvalidator(false /* initialize */, true /* start_refresh_scheduler */);
443 DisconnectCore(); 457 DisconnectCore();
444 InitializeInvalidator(); 458 InitializeInvalidator();
445 StorePolicy(POLICY_OBJECT_A); 459 StorePolicy(POLICY_OBJECT_A);
446 EXPECT_FALSE(IsInvalidatorRegistered()); 460 EXPECT_FALSE(IsInvalidatorRegistered());
447 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 461 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
448 EXPECT_TRUE(CheckPolicyNotRefreshed()); 462 EXPECT_TRUE(CheckPolicyNotRefreshed());
449 } 463 }
450 464
451 TEST_F(CloudPolicyInvalidatorTest, InitializeThenStartRefreshScheduler) { 465 TEST_F(CloudPolicyInvalidatorTest, InitializeThenStartRefreshScheduler) {
452 // Make sure registration occurs and invalidations are processed when 466 // Make sure registration occurs and invalidations are processed when
453 // Initialize is called before starting the refresh scheduler. 467 // Initialize is called before starting the refresh scheduler.
454 // Note that the reverse case (start refresh scheduler then initialize) is 468 // Note that the reverse case (start refresh scheduler then initialize) is
455 // the default behavior for the test fixture, so will be tested in most other 469 // the default behavior for the test fixture, so will be tested in most other
456 // tests. 470 // tests.
457 StartInvalidator(true /* initialize */, false /* start_refresh_scheduler */); 471 StartInvalidator(true /* initialize */, false /* start_refresh_scheduler */);
458 ConnectCore(); 472 ConnectCore();
459 StartRefreshScheduler(); 473 StartRefreshScheduler();
460 StorePolicy(POLICY_OBJECT_A); 474 StorePolicy(POLICY_OBJECT_A);
461 EXPECT_TRUE(IsInvalidatorRegistered()); 475 EXPECT_TRUE(IsInvalidatorRegistered());
462 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 476 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
463 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 477 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
464 } 478 }
465 479
466 TEST_F(CloudPolicyInvalidatorTest, RegisterOnStoreLoaded) { 480 TEST_F(CloudPolicyInvalidatorTest, RegisterOnStoreLoaded) {
467 // No registration when store is not loaded. 481 // No registration when store is not loaded.
468 StartInvalidator(); 482 StartInvalidator();
469 EXPECT_FALSE(IsInvalidatorRegistered()); 483 EXPECT_FALSE(IsInvalidatorRegistered());
470 EXPECT_FALSE(InvalidationsEnabled()); 484 EXPECT_FALSE(InvalidationsEnabled());
471 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 485 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
472 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 486 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
473 EXPECT_TRUE(CheckPolicyNotRefreshed()); 487 EXPECT_TRUE(CheckPolicyNotRefreshed());
474 488
475 // No registration when store is loaded with no invalidation object id. 489 // No registration when store is loaded with no invalidation object id.
476 StorePolicy(POLICY_OBJECT_NONE); 490 StorePolicy(POLICY_OBJECT_NONE);
477 EXPECT_FALSE(IsInvalidatorRegistered()); 491 EXPECT_FALSE(IsInvalidatorRegistered());
478 EXPECT_FALSE(InvalidationsEnabled()); 492 EXPECT_FALSE(InvalidationsEnabled());
479 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 493 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
480 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 494 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
481 EXPECT_TRUE(CheckPolicyNotRefreshed()); 495 EXPECT_TRUE(CheckPolicyNotRefreshed());
482 496
483 // Check registration when store is loaded for object A. 497 // Check registration when store is loaded for object A.
484 StorePolicy(POLICY_OBJECT_A); 498 StorePolicy(POLICY_OBJECT_A);
485 EXPECT_TRUE(IsInvalidatorRegistered()); 499 EXPECT_TRUE(IsInvalidatorRegistered());
486 EXPECT_TRUE(InvalidationsEnabled()); 500 EXPECT_TRUE(InvalidationsEnabled());
487 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 501 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
488 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 502 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
489 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 503 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
490 EXPECT_TRUE(CheckPolicyNotRefreshed()); 504 EXPECT_TRUE(CheckPolicyNotRefreshed());
491 } 505 }
492 506
493 TEST_F(CloudPolicyInvalidatorTest, ChangeRegistration) { 507 TEST_F(CloudPolicyInvalidatorTest, ChangeRegistration) {
494 // Register for object A. 508 // Register for object A.
495 StartInvalidator(); 509 StartInvalidator();
496 StorePolicy(POLICY_OBJECT_A); 510 StorePolicy(POLICY_OBJECT_A);
497 EXPECT_TRUE(IsInvalidatorRegistered()); 511 EXPECT_TRUE(IsInvalidatorRegistered());
498 EXPECT_TRUE(InvalidationsEnabled()); 512 EXPECT_TRUE(InvalidationsEnabled());
499 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 513 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
500 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 514 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
501 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 515 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
502 EXPECT_TRUE(CheckPolicyNotRefreshed()); 516 EXPECT_TRUE(CheckPolicyNotRefreshed());
503 syncer::AckHandle ack = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 517 syncer::Invalidation inv = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
504 518
505 // Check re-registration for object B. Make sure the pending invalidation for 519 // Check re-registration for object B. Make sure the pending invalidation for
506 // object A is acknowledged without making the callback. 520 // object A is acknowledged without making the callback.
507 StorePolicy(POLICY_OBJECT_B); 521 StorePolicy(POLICY_OBJECT_B);
508 EXPECT_TRUE(IsInvalidatorRegistered()); 522 EXPECT_TRUE(IsInvalidatorRegistered());
509 EXPECT_TRUE(InvalidationsEnabled()); 523 EXPECT_TRUE(InvalidationsEnabled());
510 EXPECT_TRUE(IsInvalidationAcknowledged(ack)); 524 EXPECT_TRUE(IsInvalidationAcknowledged(inv));
511 EXPECT_TRUE(CheckPolicyNotRefreshed()); 525 EXPECT_TRUE(CheckPolicyNotRefreshed());
512 526
513 // Make sure future invalidations for object A are ignored and for object B 527 // Make sure future invalidations for object A are ignored and for object B
514 // are processed. 528 // are processed.
515 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 529 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
516 EXPECT_TRUE(CheckPolicyNotRefreshed()); 530 EXPECT_TRUE(CheckPolicyNotRefreshed());
517 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 531 FireUnknownVersionInvalidation(POLICY_OBJECT_B);
518 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 532 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
519 } 533 }
520 534
521 TEST_F(CloudPolicyInvalidatorTest, UnregisterOnStoreLoaded) { 535 TEST_F(CloudPolicyInvalidatorTest, UnregisterOnStoreLoaded) {
522 // Register for object A. 536 // Register for object A.
523 StartInvalidator(); 537 StartInvalidator();
524 StorePolicy(POLICY_OBJECT_A); 538 StorePolicy(POLICY_OBJECT_A);
525 EXPECT_TRUE(IsInvalidatorRegistered()); 539 EXPECT_TRUE(IsInvalidatorRegistered());
526 EXPECT_TRUE(InvalidationsEnabled()); 540 EXPECT_TRUE(InvalidationsEnabled());
527 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 541 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
528 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 542 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
529 543
530 // Check unregistration when store is loaded with no invalidation object id. 544 // Check unregistration when store is loaded with no invalidation object id.
531 syncer::AckHandle ack = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 545 syncer::Invalidation inv = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
532 EXPECT_FALSE(IsInvalidationAcknowledged(ack)); 546 EXPECT_FALSE(IsInvalidationAcknowledged(inv));
533 StorePolicy(POLICY_OBJECT_NONE); 547 StorePolicy(POLICY_OBJECT_NONE);
534 EXPECT_FALSE(IsInvalidatorRegistered()); 548 EXPECT_FALSE(IsInvalidatorRegistered());
535 EXPECT_TRUE(IsInvalidationAcknowledged(ack)); 549 EXPECT_TRUE(IsInvalidationAcknowledged(inv));
536 EXPECT_FALSE(InvalidationsEnabled()); 550 EXPECT_FALSE(InvalidationsEnabled());
537 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 551 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_A)));
538 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 552 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
539 EXPECT_TRUE(CheckPolicyNotRefreshed()); 553 EXPECT_TRUE(CheckPolicyNotRefreshed());
540 554
541 // Check re-registration for object B. 555 // Check re-registration for object B.
542 StorePolicy(POLICY_OBJECT_B); 556 StorePolicy(POLICY_OBJECT_B);
543 EXPECT_TRUE(IsInvalidatorRegistered()); 557 EXPECT_TRUE(IsInvalidatorRegistered());
544 EXPECT_TRUE(InvalidationsEnabled()); 558 EXPECT_TRUE(InvalidationsEnabled());
545 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 559 FireUnknownVersionInvalidation(POLICY_OBJECT_B);
546 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 560 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
547 } 561 }
548 562
549 TEST_F(CloudPolicyInvalidatorTest, HandleInvalidation) { 563 TEST_F(CloudPolicyInvalidatorTest, HandleInvalidation) {
550 // Register and fire invalidation 564 // Register and fire invalidation
551 StorePolicy(POLICY_OBJECT_A); 565 StorePolicy(POLICY_OBJECT_A);
552 StartInvalidator(); 566 StartInvalidator();
553 EXPECT_TRUE(InvalidationsEnabled()); 567 EXPECT_TRUE(InvalidationsEnabled());
554 syncer::AckHandle ack = FireInvalidation(POLICY_OBJECT_A, 12, "test_payload"); 568 syncer::Invalidation inv =
569 FireInvalidation(POLICY_OBJECT_A, 12, "test_payload");
555 570
556 // Make sure client info is set as soon as the invalidation is received. 571 // Make sure client info is set as soon as the invalidation is received.
557 EXPECT_TRUE(CheckInvalidationInfo(12, "test_payload")); 572 EXPECT_TRUE(CheckInvalidationInfo(12, "test_payload"));
558 EXPECT_TRUE(CheckPolicyRefreshed()); 573 EXPECT_TRUE(CheckPolicyRefreshed());
559 574
560 // Make sure invalidation is not acknowledged until the store is loaded. 575 // Make sure invalidation is not acknowledged until the store is loaded.
561 EXPECT_FALSE(IsInvalidationAcknowledged(ack)); 576 EXPECT_FALSE(IsInvalidationAcknowledged(inv));
562 EXPECT_TRUE(CheckInvalidationInfo(12, "test_payload")); 577 EXPECT_TRUE(CheckInvalidationInfo(12, "test_payload"));
563 StorePolicy(POLICY_OBJECT_A, 12); 578 StorePolicy(POLICY_OBJECT_A, 12);
564 EXPECT_TRUE(IsInvalidationAcknowledged(ack)); 579 EXPECT_TRUE(IsInvalidationAcknowledged(inv));
565 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 580 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
566 } 581 }
567 582
568 TEST_F(CloudPolicyInvalidatorTest, HandleInvalidationWithUnknownVersion) { 583 TEST_F(CloudPolicyInvalidatorTest, HandleInvalidationWithUnknownVersion) {
569 // Register and fire invalidation with unknown version. 584 // Register and fire invalidation with unknown version.
570 StorePolicy(POLICY_OBJECT_A); 585 StorePolicy(POLICY_OBJECT_A);
571 StartInvalidator(); 586 StartInvalidator();
572 syncer::AckHandle ack = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 587 syncer::Invalidation inv = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
573 588
574 // Make sure client info is not set until after the invalidation callback is 589 // Make sure client info is not set until after the invalidation callback is
575 // made. 590 // made.
576 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 591 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
577 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 592 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
578 EXPECT_TRUE(CheckInvalidationInfo(-1, std::string())); 593 EXPECT_TRUE(CheckInvalidationInfo(-1, std::string()));
579 594
580 // Make sure invalidation is not acknowledged until the store is loaded. 595 // Make sure invalidation is not acknowledged until the store is loaded.
581 EXPECT_FALSE(IsInvalidationAcknowledged(ack)); 596 EXPECT_FALSE(IsInvalidationAcknowledged(inv));
582 StorePolicy(POLICY_OBJECT_A, -1); 597 StorePolicy(POLICY_OBJECT_A, -1);
583 EXPECT_TRUE(IsInvalidationAcknowledged(ack)); 598 EXPECT_TRUE(IsInvalidationAcknowledged(inv));
584 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 599 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
585 } 600 }
586 601
587 TEST_F(CloudPolicyInvalidatorTest, HandleMultipleInvalidations) { 602 TEST_F(CloudPolicyInvalidatorTest, HandleMultipleInvalidations) {
588 // Generate multiple invalidations. 603 // Generate multiple invalidations.
589 StorePolicy(POLICY_OBJECT_A); 604 StorePolicy(POLICY_OBJECT_A);
590 StartInvalidator(); 605 StartInvalidator();
591 syncer::AckHandle ack1 = FireInvalidation(POLICY_OBJECT_A, 1, "test1"); 606 syncer::Invalidation inv1 = FireInvalidation(POLICY_OBJECT_A, 1, "test1");
592 EXPECT_TRUE(CheckInvalidationInfo(1, "test1")); 607 EXPECT_TRUE(CheckInvalidationInfo(1, "test1"));
593 syncer::AckHandle ack2 = FireInvalidation(POLICY_OBJECT_A, 2, "test2"); 608 syncer::Invalidation inv2 = FireInvalidation(POLICY_OBJECT_A, 2, "test2");
594 EXPECT_TRUE(CheckInvalidationInfo(2, "test2")); 609 EXPECT_TRUE(CheckInvalidationInfo(2, "test2"));
595 syncer::AckHandle ack3= FireInvalidation(POLICY_OBJECT_A, 3, "test3"); 610 syncer::Invalidation inv3 = FireInvalidation(POLICY_OBJECT_A, 3, "test3");
596 EXPECT_TRUE(CheckInvalidationInfo(3, "test3")); 611 EXPECT_TRUE(CheckInvalidationInfo(3, "test3"));
597 612
598 // Make sure the replaced invalidations are acknowledged. 613 // Make sure the replaced invalidations are acknowledged.
599 EXPECT_TRUE(IsInvalidationAcknowledged(ack1)); 614 EXPECT_TRUE(IsInvalidationAcknowledged(inv1));
600 EXPECT_TRUE(IsInvalidationAcknowledged(ack2)); 615 EXPECT_TRUE(IsInvalidationAcknowledged(inv2));
601 616
602 // Make sure the policy is refreshed once. 617 // Make sure the policy is refreshed once.
603 EXPECT_TRUE(CheckPolicyRefreshed()); 618 EXPECT_TRUE(CheckPolicyRefreshed());
604 619
605 // Make sure that the last invalidation is only acknowledged after the store 620 // Make sure that the last invalidation is only acknowledged after the store
606 // is loaded with the latest version. 621 // is loaded with the latest version.
607 StorePolicy(POLICY_OBJECT_A, 1); 622 StorePolicy(POLICY_OBJECT_A, 1);
608 EXPECT_FALSE(IsInvalidationAcknowledged(ack3)); 623 EXPECT_FALSE(IsInvalidationAcknowledged(inv3));
609 StorePolicy(POLICY_OBJECT_A, 2); 624 StorePolicy(POLICY_OBJECT_A, 2);
610 EXPECT_FALSE(IsInvalidationAcknowledged(ack3)); 625 EXPECT_FALSE(IsInvalidationAcknowledged(inv3));
611 StorePolicy(POLICY_OBJECT_A, 3); 626 StorePolicy(POLICY_OBJECT_A, 3);
612 EXPECT_TRUE(IsInvalidationAcknowledged(ack3)); 627 EXPECT_TRUE(IsInvalidationAcknowledged(inv3));
613 } 628 }
614 629
615 TEST_F(CloudPolicyInvalidatorTest, 630 TEST_F(CloudPolicyInvalidatorTest,
616 HandleMultipleInvalidationsWithUnknownVersion) { 631 HandleMultipleInvalidationsWithUnknownVersion) {
617 // Validate that multiple invalidations with unknown version each generate 632 // Validate that multiple invalidations with unknown version each generate
618 // unique invalidation version numbers. 633 // unique invalidation version numbers.
619 StorePolicy(POLICY_OBJECT_A); 634 StorePolicy(POLICY_OBJECT_A);
620 StartInvalidator(); 635 StartInvalidator();
621 syncer::AckHandle ack1 = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 636 syncer::Invalidation inv1 = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
622 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 637 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
623 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 638 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
624 EXPECT_TRUE(CheckInvalidationInfo(-1, std::string())); 639 EXPECT_TRUE(CheckInvalidationInfo(-1, std::string()));
625 syncer::AckHandle ack2 = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 640 syncer::Invalidation inv2 = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
626 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 641 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
627 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 642 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
628 EXPECT_TRUE(CheckInvalidationInfo(-2, std::string())); 643 EXPECT_TRUE(CheckInvalidationInfo(-2, std::string()));
629 syncer::AckHandle ack3 = FireUnknownVersionInvalidation(POLICY_OBJECT_A); 644 syncer::Invalidation inv3 = FireUnknownVersionInvalidation(POLICY_OBJECT_A);
630 EXPECT_TRUE(CheckInvalidationInfo(0, std::string())); 645 EXPECT_TRUE(CheckInvalidationInfo(0, std::string()));
631 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion()); 646 EXPECT_TRUE(CheckPolicyRefreshedWithUnknownVersion());
632 EXPECT_TRUE(CheckInvalidationInfo(-3, std::string())); 647 EXPECT_TRUE(CheckInvalidationInfo(-3, std::string()));
633 648
634 // Make sure the replaced invalidations are acknowledged. 649 // Make sure the replaced invalidations are acknowledged.
635 EXPECT_TRUE(IsInvalidationAcknowledged(ack1)); 650 EXPECT_TRUE(IsInvalidationAcknowledged(inv1));
636 EXPECT_TRUE(IsInvalidationAcknowledged(ack2)); 651 EXPECT_TRUE(IsInvalidationAcknowledged(inv2));
637 652
638 // Make sure that the last invalidation is only acknowledged after the store 653 // Make sure that the last invalidation is only acknowledged after the store
639 // is loaded with the last unknown version. 654 // is loaded with the last unknown version.
640 StorePolicy(POLICY_OBJECT_A, -1); 655 StorePolicy(POLICY_OBJECT_A, -1);
641 EXPECT_FALSE(IsInvalidationAcknowledged(ack3)); 656 EXPECT_FALSE(IsInvalidationAcknowledged(inv3));
642 StorePolicy(POLICY_OBJECT_A, -2); 657 StorePolicy(POLICY_OBJECT_A, -2);
643 EXPECT_FALSE(IsInvalidationAcknowledged(ack3)); 658 EXPECT_FALSE(IsInvalidationAcknowledged(inv3));
644 StorePolicy(POLICY_OBJECT_A, -3); 659 StorePolicy(POLICY_OBJECT_A, -3);
645 EXPECT_TRUE(IsInvalidationAcknowledged(ack3)); 660 EXPECT_TRUE(IsInvalidationAcknowledged(inv3));
646 } 661 }
647 662
648 TEST_F(CloudPolicyInvalidatorTest, AcknowledgeBeforeRefresh) { 663 TEST_F(CloudPolicyInvalidatorTest, AcknowledgeBeforeRefresh) {
649 // Generate an invalidation. 664 // Generate an invalidation.
650 StorePolicy(POLICY_OBJECT_A); 665 StorePolicy(POLICY_OBJECT_A);
651 StartInvalidator(); 666 StartInvalidator();
652 syncer::AckHandle ack = FireInvalidation(POLICY_OBJECT_A, 3, "test"); 667 syncer::Invalidation inv = FireInvalidation(POLICY_OBJECT_A, 3, "test");
653 668
654 // Ensure that the policy is not refreshed and the invalidation is 669 // Ensure that the policy is not refreshed and the invalidation is
655 // acknowledged if the store is loaded with the latest version before the 670 // acknowledged if the store is loaded with the latest version before the
656 // refresh can occur. 671 // refresh can occur.
657 StorePolicy(POLICY_OBJECT_A, 3); 672 StorePolicy(POLICY_OBJECT_A, 3);
658 EXPECT_TRUE(IsInvalidationAcknowledged(ack)); 673 EXPECT_TRUE(IsInvalidationAcknowledged(inv));
659 EXPECT_TRUE(CheckPolicyNotRefreshed()); 674 EXPECT_TRUE(CheckPolicyNotRefreshed());
660 } 675 }
661 676
662 TEST_F(CloudPolicyInvalidatorTest, NoCallbackAfterShutdown) { 677 TEST_F(CloudPolicyInvalidatorTest, NoCallbackAfterShutdown) {
663 // Generate an invalidation. 678 // Generate an invalidation.
664 StorePolicy(POLICY_OBJECT_A); 679 StorePolicy(POLICY_OBJECT_A);
665 StartInvalidator(); 680 StartInvalidator();
666 syncer::AckHandle ack = FireInvalidation(POLICY_OBJECT_A, 3, "test"); 681 syncer::Invalidation inv = FireInvalidation(POLICY_OBJECT_A, 3, "test");
667 682
668 // Ensure that the policy refresh is not made after the invalidator is shut 683 // Ensure that the policy refresh is not made after the invalidator is shut
669 // down. 684 // down.
670 ShutdownInvalidator(); 685 ShutdownInvalidator();
671 EXPECT_TRUE(CheckPolicyNotRefreshed()); 686 EXPECT_TRUE(CheckPolicyNotRefreshed());
672 DestroyInvalidator(); 687 DestroyInvalidator();
673 } 688 }
674 689
675 TEST_F(CloudPolicyInvalidatorTest, StateChanged) { 690 TEST_F(CloudPolicyInvalidatorTest, StateChanged) {
676 // Test invalidation service state changes while not registered. 691 // Test invalidation service state changes while not registered.
(...skipping 29 matching lines...) Expand all
706 EXPECT_FALSE(InvalidationsEnabled()); 721 EXPECT_FALSE(InvalidationsEnabled());
707 StorePolicy(POLICY_OBJECT_NONE); 722 StorePolicy(POLICY_OBJECT_NONE);
708 StorePolicy(POLICY_OBJECT_A); 723 StorePolicy(POLICY_OBJECT_A);
709 EXPECT_FALSE(InvalidationsEnabled()); 724 EXPECT_FALSE(InvalidationsEnabled());
710 } 725 }
711 726
712 TEST_F(CloudPolicyInvalidatorTest, Disconnect) { 727 TEST_F(CloudPolicyInvalidatorTest, Disconnect) {
713 // Generate an invalidation. 728 // Generate an invalidation.
714 StorePolicy(POLICY_OBJECT_A); 729 StorePolicy(POLICY_OBJECT_A);
715 StartInvalidator(); 730 StartInvalidator();
716 syncer::AckHandle ack = FireInvalidation(POLICY_OBJECT_A, 1, "test"); 731 syncer::Invalidation inv = FireInvalidation(POLICY_OBJECT_A, 1, "test");
717 EXPECT_TRUE(InvalidationsEnabled()); 732 EXPECT_TRUE(InvalidationsEnabled());
718 733
719 // Ensure that the policy is not refreshed after disconnecting the core, but 734 // Ensure that the policy is not refreshed after disconnecting the core, but
720 // a call to indicate that invalidations are disabled is made. 735 // a call to indicate that invalidations are disabled is made.
721 DisconnectCore(); 736 DisconnectCore();
722 EXPECT_TRUE(CheckPolicyNotRefreshed()); 737 EXPECT_TRUE(CheckPolicyNotRefreshed());
723 738
724 // Ensure that invalidation service events do not cause refreshes while the 739 // Ensure that invalidation service events do not cause refreshes while the
725 // invalidator is stopped. 740 // invalidator is stopped.
726 FireInvalidation(POLICY_OBJECT_A, 2, "test"); 741 EXPECT_TRUE(IsUnsent(FireInvalidation(POLICY_OBJECT_A, 2, "test")));
727 EXPECT_TRUE(CheckPolicyNotRefreshed()); 742 EXPECT_TRUE(CheckPolicyNotRefreshed());
728 DisableInvalidationService(); 743 DisableInvalidationService();
729 EnableInvalidationService(); 744 EnableInvalidationService();
730 745
731 // Connect and disconnect without starting the refresh scheduler. 746 // Connect and disconnect without starting the refresh scheduler.
732 ConnectCore(); 747 ConnectCore();
733 FireInvalidation(POLICY_OBJECT_A, 3, "test"); 748 EXPECT_TRUE(IsUnsent(FireInvalidation(POLICY_OBJECT_A, 3, "test")));
734 EXPECT_TRUE(CheckPolicyNotRefreshed()); 749 EXPECT_TRUE(CheckPolicyNotRefreshed());
735 DisconnectCore(); 750 DisconnectCore();
736 FireInvalidation(POLICY_OBJECT_A, 4, "test"); 751 EXPECT_TRUE(IsUnsent(FireInvalidation(POLICY_OBJECT_A, 4, "test")));
737 EXPECT_TRUE(CheckPolicyNotRefreshed()); 752 EXPECT_TRUE(CheckPolicyNotRefreshed());
738 753
739 // Ensure that the invalidator returns to normal after reconnecting. 754 // Ensure that the invalidator returns to normal after reconnecting.
740 ConnectCore(); 755 ConnectCore();
741 StartRefreshScheduler(); 756 StartRefreshScheduler();
742 EXPECT_TRUE(CheckPolicyNotRefreshed()); 757 EXPECT_TRUE(CheckPolicyNotRefreshed());
743 EXPECT_TRUE(InvalidationsEnabled()); 758 EXPECT_TRUE(InvalidationsEnabled());
744 FireInvalidation(POLICY_OBJECT_A, 5, "test"); 759 FireInvalidation(POLICY_OBJECT_A, 5, "test");
745 EXPECT_TRUE(CheckInvalidationInfo(5, "test")); 760 EXPECT_TRUE(CheckInvalidationInfo(5, "test"));
746 EXPECT_TRUE(CheckPolicyRefreshed()); 761 EXPECT_TRUE(CheckPolicyRefreshed());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 EXPECT_EQ(0, GetCount(METRIC_POLICY_REFRESH_CHANGED_NO_INVALIDATIONS)); 840 EXPECT_EQ(0, GetCount(METRIC_POLICY_REFRESH_CHANGED_NO_INVALIDATIONS));
826 EXPECT_EQ(4, GetCount(METRIC_POLICY_REFRESH_UNCHANGED)); 841 EXPECT_EQ(4, GetCount(METRIC_POLICY_REFRESH_UNCHANGED));
827 EXPECT_EQ(2, GetCount(METRIC_POLICY_REFRESH_INVALIDATED_CHANGED)); 842 EXPECT_EQ(2, GetCount(METRIC_POLICY_REFRESH_INVALIDATED_CHANGED));
828 EXPECT_EQ(1, GetCount(METRIC_POLICY_REFRESH_INVALIDATED_UNCHANGED)); 843 EXPECT_EQ(1, GetCount(METRIC_POLICY_REFRESH_INVALIDATED_UNCHANGED));
829 } 844 }
830 845
831 TEST_F(CloudPolicyInvalidatorTest, InvalidationMetrics) { 846 TEST_F(CloudPolicyInvalidatorTest, InvalidationMetrics) {
832 // Generate a mix of versioned and unknown-version invalidations. 847 // Generate a mix of versioned and unknown-version invalidations.
833 StorePolicy(POLICY_OBJECT_A); 848 StorePolicy(POLICY_OBJECT_A);
834 StartInvalidator(); 849 StartInvalidator();
835 FireUnknownVersionInvalidation(POLICY_OBJECT_B); 850 EXPECT_TRUE(IsUnsent(FireUnknownVersionInvalidation(POLICY_OBJECT_B)));
836 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 851 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
837 FireInvalidation(POLICY_OBJECT_B, 1, "test"); 852 EXPECT_TRUE(IsUnsent(FireInvalidation(POLICY_OBJECT_B, 1, "test")));
838 FireInvalidation(POLICY_OBJECT_A, 1, "test"); 853 FireInvalidation(POLICY_OBJECT_A, 1, "test");
839 FireInvalidation(POLICY_OBJECT_A, 2, "test"); 854 FireInvalidation(POLICY_OBJECT_A, 2, "test");
840 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 855 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
841 FireUnknownVersionInvalidation(POLICY_OBJECT_A); 856 FireUnknownVersionInvalidation(POLICY_OBJECT_A);
842 FireInvalidation(POLICY_OBJECT_A, 3, "test"); 857 FireInvalidation(POLICY_OBJECT_A, 3, "test");
843 FireInvalidation(POLICY_OBJECT_A, 4, "test"); 858 FireInvalidation(POLICY_OBJECT_A, 4, "test");
844 859
845 // Verify that received invalidations metrics are correct. 860 // Verify that received invalidations metrics are correct.
846 EXPECT_EQ(3, GetInvalidationCount(false /* with_payload */)); 861 EXPECT_EQ(3, GetInvalidationCount(false /* with_payload */));
847 EXPECT_EQ(4, GetInvalidationCount(true /* with_payload */)); 862 EXPECT_EQ(4, GetInvalidationCount(true /* with_payload */));
848 } 863 }
849 864
850 } // namespace policy 865 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698