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

Unified Diff: components/invalidation/invalidation_service_test_template.h

Issue 1146533005: [Sync] InvalidationService shouldn't CHECK when registering ObjectId for more than one handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from Bartosz. Created 5 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/invalidation/invalidation_service_android.cc ('k') | components/invalidation/invalidator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/invalidation/invalidation_service_test_template.h
diff --git a/components/invalidation/invalidation_service_test_template.h b/components/invalidation/invalidation_service_test_template.h
index dc4a8419c03b34adcec3ed5247ee355a427f60f8..3f2e764691513dd8413228f47f663dc1a85dbae2 100644
--- a/components/invalidation/invalidation_service_test_template.h
+++ b/components/invalidation/invalidation_service_test_template.h
@@ -134,7 +134,7 @@ TYPED_TEST_P(InvalidationServiceTest, Basic) {
syncer::ObjectIdSet ids;
ids.insert(this->id1);
ids.insert(this->id2);
- invalidator->UpdateRegisteredInvalidationIds(&handler, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler, ids));
this->delegate_.TriggerOnInvalidatorStateChange(
syncer::INVALIDATIONS_ENABLED);
@@ -150,7 +150,7 @@ TYPED_TEST_P(InvalidationServiceTest, Basic) {
ids.erase(this->id1);
ids.insert(this->id3);
- invalidator->UpdateRegisteredInvalidationIds(&handler, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler, ids));
expected_invalidations = syncer::ObjectIdInvalidationMap();
expected_invalidations.Insert(syncer::Invalidation::Init(this->id2, 2, "2"));
@@ -201,13 +201,13 @@ TYPED_TEST_P(InvalidationServiceTest, MultipleHandlers) {
syncer::ObjectIdSet ids;
ids.insert(this->id1);
ids.insert(this->id2);
- invalidator->UpdateRegisteredInvalidationIds(&handler1, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler1, ids));
}
{
syncer::ObjectIdSet ids;
ids.insert(this->id3);
- invalidator->UpdateRegisteredInvalidationIds(&handler2, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler2, ids));
}
// Don't register any IDs for handler3.
@@ -215,7 +215,7 @@ TYPED_TEST_P(InvalidationServiceTest, MultipleHandlers) {
{
syncer::ObjectIdSet ids;
ids.insert(this->id4);
- invalidator->UpdateRegisteredInvalidationIds(&handler4, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler4, ids));
}
invalidator->UnregisterInvalidationHandler(&handler4);
@@ -272,6 +272,29 @@ TYPED_TEST_P(InvalidationServiceTest, MultipleHandlers) {
invalidator->UnregisterInvalidationHandler(&handler1);
}
+// Multiple registrations by different handlers on the same object ID should
+// return false.
+TYPED_TEST_P(InvalidationServiceTest, MultipleRegistrations) {
+ invalidation::InvalidationService* const invalidator =
+ this->CreateAndInitializeInvalidationService();
+
+ syncer::FakeInvalidationHandler handler1;
+ syncer::FakeInvalidationHandler handler2;
+
+ invalidator->RegisterInvalidationHandler(&handler1);
+ invalidator->RegisterInvalidationHandler(&handler2);
+
+ // Registering both handlers for the same ObjectId. First call should succeed,
+ // second should fail.
+ syncer::ObjectIdSet ids;
+ ids.insert(this->id1);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler1, ids));
+ EXPECT_FALSE(invalidator->UpdateRegisteredInvalidationIds(&handler2, ids));
+
+ invalidator->UnregisterInvalidationHandler(&handler2);
+ invalidator->UnregisterInvalidationHandler(&handler1);
+}
+
// Make sure that passing an empty set to UpdateRegisteredInvalidationIds clears
// the corresponding entries for the handler.
TYPED_TEST_P(InvalidationServiceTest, EmptySetUnregisters) {
@@ -290,19 +313,19 @@ TYPED_TEST_P(InvalidationServiceTest, EmptySetUnregisters) {
syncer::ObjectIdSet ids;
ids.insert(this->id1);
ids.insert(this->id2);
- invalidator->UpdateRegisteredInvalidationIds(&handler1, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler1, ids));
}
{
syncer::ObjectIdSet ids;
ids.insert(this->id3);
- invalidator->UpdateRegisteredInvalidationIds(&handler2, ids);
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(&handler2, ids));
}
// Unregister the IDs for the first observer. It should not receive any
// further invalidations.
- invalidator->UpdateRegisteredInvalidationIds(&handler1,
- syncer::ObjectIdSet());
+ EXPECT_TRUE(invalidator->UpdateRegisteredInvalidationIds(
+ &handler1, syncer::ObjectIdSet()));
this->delegate_.TriggerOnInvalidatorStateChange(
syncer::INVALIDATIONS_ENABLED);
@@ -381,7 +404,10 @@ TYPED_TEST_P(InvalidationServiceTest, GetInvalidatorStateAlwaysCurrent) {
}
REGISTER_TYPED_TEST_CASE_P(InvalidationServiceTest,
- Basic, MultipleHandlers, EmptySetUnregisters,
+ Basic,
+ MultipleHandlers,
+ MultipleRegistrations,
+ EmptySetUnregisters,
GetInvalidatorStateAlwaysCurrent);
#endif // COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_TEST_TEMPLATE_H_
« no previous file with comments | « components/invalidation/invalidation_service_android.cc ('k') | components/invalidation/invalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698