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

Side by Side Diff: components/invalidation/invalidator_registrar_unittest.cc

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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "components/invalidation/fake_invalidation_handler.h" 8 #include "components/invalidation/fake_invalidation_handler.h"
9 #include "components/invalidation/invalidator_registrar.h" 9 #include "components/invalidation/invalidator_registrar.h"
10 #include "components/invalidation/invalidator_test_template.h" 10 #include "components/invalidation/invalidator_test_template.h"
(...skipping 15 matching lines...) Expand all
26 26
27 InvalidatorRegistrar* GetRegistrar() { 27 InvalidatorRegistrar* GetRegistrar() {
28 return &registrar_; 28 return &registrar_;
29 } 29 }
30 30
31 // Invalidator implementation. 31 // Invalidator implementation.
32 void RegisterHandler(InvalidationHandler* handler) override { 32 void RegisterHandler(InvalidationHandler* handler) override {
33 registrar_.RegisterHandler(handler); 33 registrar_.RegisterHandler(handler);
34 } 34 }
35 35
36 void UpdateRegisteredIds(InvalidationHandler* handler, 36 bool UpdateRegisteredIds(InvalidationHandler* handler,
37 const ObjectIdSet& ids) override { 37 const ObjectIdSet& ids) override {
38 registrar_.UpdateRegisteredIds(handler, ids); 38 return registrar_.UpdateRegisteredIds(handler, ids);
39 } 39 }
40 40
41 void UnregisterHandler(InvalidationHandler* handler) override { 41 void UnregisterHandler(InvalidationHandler* handler) override {
42 registrar_.UnregisterHandler(handler); 42 registrar_.UnregisterHandler(handler);
43 } 43 }
44 44
45 InvalidatorState GetInvalidatorState() const override { 45 InvalidatorState GetInvalidatorState() const override {
46 return registrar_.GetInvalidatorState(); 46 return registrar_.GetInvalidatorState();
47 } 47 }
48 48
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 private: 104 private:
105 scoped_ptr<RegistrarInvalidator> invalidator_; 105 scoped_ptr<RegistrarInvalidator> invalidator_;
106 }; 106 };
107 107
108 INSTANTIATE_TYPED_TEST_CASE_P( 108 INSTANTIATE_TYPED_TEST_CASE_P(
109 RegistrarInvalidatorTest, InvalidatorTest, 109 RegistrarInvalidatorTest, InvalidatorTest,
110 RegistrarInvalidatorTestDelegate); 110 RegistrarInvalidatorTestDelegate);
111 111
112 class InvalidatorRegistrarTest : public testing::Test {};
113
114 // Technically the test below can be part of InvalidatorTest, but we
115 // want to keep the number of death tests down.
116
117 // When we expect a death via CHECK(), we can't match against the
118 // CHECK() message since they are removed in official builds.
119
120 #if GTEST_HAS_DEATH_TEST
121
122 // Multiple registrations by different handlers on the same object ID should
123 // cause a CHECK.
124 TEST_F(InvalidatorRegistrarTest, MultipleRegistration) {
125 const invalidation::ObjectId id1(ipc::invalidation::ObjectSource::TEST, "a");
126 const invalidation::ObjectId id2(ipc::invalidation::ObjectSource::TEST, "a");
127
128 InvalidatorRegistrar registrar;
129
130 FakeInvalidationHandler handler1;
131 registrar.RegisterHandler(&handler1);
132
133 FakeInvalidationHandler handler2;
134 registrar.RegisterHandler(&handler2);
135
136 ObjectIdSet ids;
137 ids.insert(id1);
138 ids.insert(id2);
139 registrar.UpdateRegisteredIds(&handler1, ids);
140
141 registrar.DetachFromThreadForTest();
142 EXPECT_DEATH({ registrar.UpdateRegisteredIds(&handler2, ids); }, "");
143
144 registrar.UnregisterHandler(&handler2);
145 registrar.UnregisterHandler(&handler1);
146 }
147 #endif // GTEST_HAS_DEATH_TEST
148
149 } // namespace 112 } // namespace
150 113
151 } // namespace syncer 114 } // namespace syncer
OLDNEW
« no previous file with comments | « components/invalidation/invalidator_registrar.cc ('k') | components/invalidation/invalidator_test_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698