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

Unified Diff: sync/notifier/invalidator_registrar_unittest.cc

Issue 11046008: [Invalidations] Require there to be no registered handlers on Invalidator destruction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to HEAD Created 8 years, 2 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 | « sync/notifier/invalidator_registrar.cc ('k') | sync/notifier/invalidator_test_template.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/invalidator_registrar_unittest.cc
diff --git a/sync/notifier/invalidator_registrar_unittest.cc b/sync/notifier/invalidator_registrar_unittest.cc
index 043d7eb71671162915fead288935d7b5d3713653..4d5df6cf7e9f9005a4a122cc1d61ea18d9f7497a 100644
--- a/sync/notifier/invalidator_registrar_unittest.cc
+++ b/sync/notifier/invalidator_registrar_unittest.cc
@@ -124,11 +124,27 @@ INSTANTIATE_TYPED_TEST_CASE_P(
class InvalidatorRegistrarTest : public testing::Test {};
+// Technically the tests below can be part of InvalidatorTest, but we
+// want to keep the number of death tests down.
+
+// When we expect a death via CHECK(), we can't match against the
+// CHECK() message since they are removed in official builds.
+
+// Having registered handlers on destruction should cause a CHECK.
+TEST_F(InvalidatorRegistrarTest, RegisteredHandlerOnDestruction) {
+ scoped_ptr<InvalidatorRegistrar> registrar(new InvalidatorRegistrar());
+ FakeInvalidationHandler handler;
+
+ registrar->RegisterHandler(&handler);
+
+ EXPECT_DEATH({ registrar.reset(); }, "");
+
+ ASSERT_TRUE(registrar.get());
+ registrar->UnregisterHandler(&handler);
+}
+
// Multiple registrations by different handlers on the same object ID should
// cause a CHECK.
-//
-// Technically this can be part of InvalidatorTest, but we want to keep the
-// number of death tests down.
TEST_F(InvalidatorRegistrarTest, MultipleRegistration) {
const invalidation::ObjectId id1(ipc::invalidation::ObjectSource::TEST, "a");
const invalidation::ObjectId id2(ipc::invalidation::ObjectSource::TEST, "a");
@@ -147,9 +163,10 @@ TEST_F(InvalidatorRegistrarTest, MultipleRegistration) {
registrar.UpdateRegisteredIds(&handler1, ids);
registrar.DetachFromThreadForTest();
- // We expect a death via CHECK(). We can't match against the CHECK() message
- // though since they are removed in official builds.
EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, "");
+
+ registrar.UnregisterHandler(&handler2);
+ registrar.UnregisterHandler(&handler1);
}
} // namespace
« no previous file with comments | « sync/notifier/invalidator_registrar.cc ('k') | sync/notifier/invalidator_test_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698