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

Side by Side Diff: sync/notifier/p2p_invalidator_unittest.cc

Issue 11052007: Rename ModelType/ObjectIdStateMap to InvalidationMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/notifier/p2p_invalidator.cc ('k') | sync/notifier/sync_invalidation_listener.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/notifier/p2p_invalidator.h" 5 #include "sync/notifier/p2p_invalidator.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "jingle/notifier/listener/fake_push_client.h" 9 #include "jingle/notifier/listener/fake_push_client.h"
10 #include "sync/internal_api/public/base/model_type.h" 10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/internal_api/public/base/model_type_state_map.h" 11 #include "sync/internal_api/public/base/model_type_invalidation_map.h"
12 #include "sync/notifier/fake_invalidation_handler.h" 12 #include "sync/notifier/fake_invalidation_handler.h"
13 #include "sync/notifier/invalidator_test_template.h" 13 #include "sync/notifier/invalidator_test_template.h"
14 #include "sync/notifier/object_id_state_map_test_util.h" 14 #include "sync/notifier/object_id_invalidation_map_test_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace syncer { 17 namespace syncer {
18 18
19 namespace { 19 namespace {
20 20
21 class P2PInvalidatorTestDelegate { 21 class P2PInvalidatorTestDelegate {
22 public: 22 public:
23 P2PInvalidatorTestDelegate() : fake_push_client_(NULL) {} 23 P2PInvalidatorTestDelegate() : fake_push_client_(NULL) {}
24 24
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 void TriggerOnInvalidatorStateChange(InvalidatorState state) { 59 void TriggerOnInvalidatorStateChange(InvalidatorState state) {
60 if (state == INVALIDATIONS_ENABLED) { 60 if (state == INVALIDATIONS_ENABLED) {
61 fake_push_client_->EnableNotifications(); 61 fake_push_client_->EnableNotifications();
62 } else { 62 } else {
63 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(state)); 63 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(state));
64 } 64 }
65 } 65 }
66 66
67 void TriggerOnIncomingInvalidation(const ObjectIdStateMap& id_state_map, 67 void TriggerOnIncomingInvalidation(
68 IncomingInvalidationSource source) { 68 const ObjectIdInvalidationMap& invalidation_map,
69 IncomingInvalidationSource source) {
69 const P2PNotificationData notification_data( 70 const P2PNotificationData notification_data(
70 "", NOTIFY_ALL, id_state_map, source); 71 "", NOTIFY_ALL, invalidation_map, source);
71 notifier::Notification notification; 72 notifier::Notification notification;
72 notification.channel = kSyncP2PNotificationChannel; 73 notification.channel = kSyncP2PNotificationChannel;
73 notification.data = notification_data.ToString(); 74 notification.data = notification_data.ToString();
74 fake_push_client_->SimulateIncomingNotification(notification); 75 fake_push_client_->SimulateIncomingNotification(notification);
75 } 76 }
76 77
77 static bool InvalidatorHandlesDeprecatedState() { 78 static bool InvalidatorHandlesDeprecatedState() {
78 return false; 79 return false;
79 } 80 }
80 81
81 private: 82 private:
82 // Owned by |invalidator_|. 83 // Owned by |invalidator_|.
83 notifier::FakePushClient* fake_push_client_; 84 notifier::FakePushClient* fake_push_client_;
84 scoped_ptr<P2PInvalidator> invalidator_; 85 scoped_ptr<P2PInvalidator> invalidator_;
85 }; 86 };
86 87
87 class P2PInvalidatorTest : public testing::Test { 88 class P2PInvalidatorTest : public testing::Test {
88 protected: 89 protected:
89 P2PInvalidatorTest() 90 P2PInvalidatorTest()
90 : next_sent_notification_to_reflect_(0) { 91 : next_sent_notification_to_reflect_(0) {
91 delegate_.CreateInvalidator("fake_state", 92 delegate_.CreateInvalidator("fake_state",
92 base::WeakPtr<InvalidationStateTracker>()); 93 base::WeakPtr<InvalidationStateTracker>());
93 delegate_.GetInvalidator()->RegisterHandler(&fake_handler_); 94 delegate_.GetInvalidator()->RegisterHandler(&fake_handler_);
94 } 95 }
95 96
96 virtual ~P2PInvalidatorTest() { 97 virtual ~P2PInvalidatorTest() {
97 delegate_.GetInvalidator()->UnregisterHandler(&fake_handler_); 98 delegate_.GetInvalidator()->UnregisterHandler(&fake_handler_);
98 } 99 }
99 100
100 ModelTypeStateMap MakeStateMap(ModelTypeSet types) { 101 ModelTypeInvalidationMap MakeInvalidationMap(ModelTypeSet types) {
101 return ModelTypeSetToStateMap(types, std::string()); 102 return ModelTypeSetToInvalidationMap(types, std::string());
102 } 103 }
103 104
104 // Simulate receiving all the notifications we sent out since last 105 // Simulate receiving all the notifications we sent out since last
105 // time this was called. 106 // time this was called.
106 void ReflectSentNotifications() { 107 void ReflectSentNotifications() {
107 const std::vector<notifier::Notification>& sent_notifications = 108 const std::vector<notifier::Notification>& sent_notifications =
108 delegate_.GetPushClient()->sent_notifications(); 109 delegate_.GetPushClient()->sent_notifications();
109 for(size_t i = next_sent_notification_to_reflect_; 110 for(size_t i = next_sent_notification_to_reflect_;
110 i < sent_notifications.size(); ++i) { 111 i < sent_notifications.size(); ++i) {
111 delegate_.GetInvalidator()->OnIncomingNotification(sent_notifications[i]); 112 delegate_.GetInvalidator()->OnIncomingNotification(sent_notifications[i]);
(...skipping 17 matching lines...) Expand all
129 EXPECT_FALSE(target_str.empty()); 130 EXPECT_FALSE(target_str.empty());
130 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str)); 131 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str));
131 } 132 }
132 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown")); 133 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown"));
133 } 134 }
134 135
135 // Make sure notification targeting works correctly. 136 // Make sure notification targeting works correctly.
136 TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) { 137 TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) {
137 { 138 {
138 const P2PNotificationData notification_data( 139 const P2PNotificationData notification_data(
139 "sender", NOTIFY_SELF, ObjectIdStateMap(), REMOTE_INVALIDATION); 140 "sender", NOTIFY_SELF, ObjectIdInvalidationMap(), REMOTE_INVALIDATION);
140 EXPECT_TRUE(notification_data.IsTargeted("sender")); 141 EXPECT_TRUE(notification_data.IsTargeted("sender"));
141 EXPECT_FALSE(notification_data.IsTargeted("other1")); 142 EXPECT_FALSE(notification_data.IsTargeted("other1"));
142 EXPECT_FALSE(notification_data.IsTargeted("other2")); 143 EXPECT_FALSE(notification_data.IsTargeted("other2"));
143 } 144 }
144 { 145 {
145 const P2PNotificationData notification_data( 146 const P2PNotificationData notification_data(
146 "sender", NOTIFY_OTHERS, ObjectIdStateMap(), REMOTE_INVALIDATION); 147 "sender", NOTIFY_OTHERS, ObjectIdInvalidationMap(),
148 REMOTE_INVALIDATION);
147 EXPECT_FALSE(notification_data.IsTargeted("sender")); 149 EXPECT_FALSE(notification_data.IsTargeted("sender"));
148 EXPECT_TRUE(notification_data.IsTargeted("other1")); 150 EXPECT_TRUE(notification_data.IsTargeted("other1"));
149 EXPECT_TRUE(notification_data.IsTargeted("other2")); 151 EXPECT_TRUE(notification_data.IsTargeted("other2"));
150 } 152 }
151 { 153 {
152 const P2PNotificationData notification_data( 154 const P2PNotificationData notification_data(
153 "sender", NOTIFY_ALL, ObjectIdStateMap(), REMOTE_INVALIDATION); 155 "sender", NOTIFY_ALL, ObjectIdInvalidationMap(), REMOTE_INVALIDATION);
154 EXPECT_TRUE(notification_data.IsTargeted("sender")); 156 EXPECT_TRUE(notification_data.IsTargeted("sender"));
155 EXPECT_TRUE(notification_data.IsTargeted("other1")); 157 EXPECT_TRUE(notification_data.IsTargeted("other1"));
156 EXPECT_TRUE(notification_data.IsTargeted("other2")); 158 EXPECT_TRUE(notification_data.IsTargeted("other2"));
157 } 159 }
158 } 160 }
159 161
160 // Make sure the P2PNotificationData <-> string conversions work for a 162 // Make sure the P2PNotificationData <-> string conversions work for a
161 // default-constructed P2PNotificationData. 163 // default-constructed P2PNotificationData.
162 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { 164 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
163 const P2PNotificationData notification_data; 165 const P2PNotificationData notification_data;
164 EXPECT_TRUE(notification_data.IsTargeted("")); 166 EXPECT_TRUE(notification_data.IsTargeted(""));
165 EXPECT_FALSE(notification_data.IsTargeted("other1")); 167 EXPECT_FALSE(notification_data.IsTargeted("other1"));
166 EXPECT_FALSE(notification_data.IsTargeted("other2")); 168 EXPECT_FALSE(notification_data.IsTargeted("other2"));
167 EXPECT_TRUE(notification_data.GetIdStateMap().empty()); 169 EXPECT_TRUE(notification_data.GetIdInvalidationMap().empty());
168 const std::string& notification_data_str = notification_data.ToString(); 170 const std::string& notification_data_str = notification_data.ToString();
169 EXPECT_EQ( 171 EXPECT_EQ(
170 "{\"idStateMap\":[],\"notificationType\":\"notifySelf\",\"senderId\":" 172 "{\"idInvalidationMap\":[],\"notificationType\":\"notifySelf\","
171 "\"\",\"source\":0}", notification_data_str); 173 "\"senderId\":\"\",\"source\":0}", notification_data_str);
172 174
173 P2PNotificationData notification_data_parsed; 175 P2PNotificationData notification_data_parsed;
174 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); 176 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str));
175 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); 177 EXPECT_TRUE(notification_data.Equals(notification_data_parsed));
176 } 178 }
177 179
178 // Make sure the P2PNotificationData <-> string conversions work for a 180 // Make sure the P2PNotificationData <-> string conversions work for a
179 // non-default-constructed P2PNotificationData. 181 // non-default-constructed P2PNotificationData.
180 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { 182 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) {
181 const ObjectIdStateMap& id_state_map = 183 const ObjectIdInvalidationMap& invalidation_map =
182 ObjectIdSetToStateMap( 184 ObjectIdSetToInvalidationMap(
183 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), ""); 185 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), "");
184 const P2PNotificationData notification_data( 186 const P2PNotificationData notification_data(
185 "sender", NOTIFY_ALL, id_state_map, LOCAL_INVALIDATION); 187 "sender", NOTIFY_ALL, invalidation_map, LOCAL_INVALIDATION);
186 EXPECT_TRUE(notification_data.IsTargeted("sender")); 188 EXPECT_TRUE(notification_data.IsTargeted("sender"));
187 EXPECT_TRUE(notification_data.IsTargeted("other1")); 189 EXPECT_TRUE(notification_data.IsTargeted("other1"));
188 EXPECT_TRUE(notification_data.IsTargeted("other2")); 190 EXPECT_TRUE(notification_data.IsTargeted("other2"));
189 EXPECT_THAT(id_state_map, Eq(notification_data.GetIdStateMap())); 191 EXPECT_THAT(invalidation_map,
192 Eq(notification_data.GetIdInvalidationMap()));
190 const std::string& notification_data_str = notification_data.ToString(); 193 const std::string& notification_data_str = notification_data.ToString();
191 EXPECT_EQ( 194 EXPECT_EQ(
192 "{\"idStateMap\":[" 195 "{\"idInvalidationMap\":["
193 "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}," 196 "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004},"
194 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}}," 197 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}},"
195 "{\"objectId\":{\"name\":\"THEME\",\"source\":1004}," 198 "{\"objectId\":{\"name\":\"THEME\",\"source\":1004},"
196 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}}" 199 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}}"
197 "],\"notificationType\":\"notifyAll\"," 200 "],\"notificationType\":\"notifyAll\","
198 "\"senderId\":\"sender\",\"source\":1}", notification_data_str); 201 "\"senderId\":\"sender\",\"source\":1}", notification_data_str);
199 202
200 P2PNotificationData notification_data_parsed; 203 P2PNotificationData notification_data_parsed;
201 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); 204 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str));
202 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); 205 EXPECT_TRUE(notification_data.Equals(notification_data_parsed));
(...skipping 28 matching lines...) Expand all
231 EXPECT_EQ(kEmail, push_client->email()); 234 EXPECT_EQ(kEmail, push_client->email());
232 EXPECT_EQ(kToken, push_client->token()); 235 EXPECT_EQ(kToken, push_client->token());
233 236
234 ReflectSentNotifications(); 237 ReflectSentNotifications();
235 push_client->EnableNotifications(); 238 push_client->EnableNotifications();
236 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); 239 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState());
237 240
238 ReflectSentNotifications(); 241 ReflectSentNotifications();
239 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); 242 EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
240 EXPECT_THAT( 243 EXPECT_THAT(
241 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), 244 ModelTypeInvalidationMapToObjectIdInvalidationMap(
242 Eq(fake_handler_.GetLastInvalidationIdStateMap())); 245 MakeInvalidationMap(enabled_types)),
246 Eq(fake_handler_.GetLastInvalidationMap()));
243 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource()); 247 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource());
244 248
245 // Sent with target NOTIFY_OTHERS so should not be propagated to 249 // Sent with target NOTIFY_OTHERS so should not be propagated to
246 // |fake_handler_|. 250 // |fake_handler_|.
247 { 251 {
248 const ObjectIdStateMap& id_state_map = 252 const ObjectIdInvalidationMap& invalidation_map =
249 ObjectIdSetToStateMap( 253 ObjectIdSetToInvalidationMap(
250 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), ""); 254 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), "");
251 invalidator->SendInvalidation(id_state_map); 255 invalidator->SendInvalidation(invalidation_map);
252 } 256 }
253 257
254 ReflectSentNotifications(); 258 ReflectSentNotifications();
255 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); 259 EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
256 } 260 }
257 261
258 // Set up the P2PInvalidator and send out notifications with various 262 // Set up the P2PInvalidator and send out notifications with various
259 // target settings. The notifications received by the observer should 263 // target settings. The notifications received by the observer should
260 // be consistent with the target settings. 264 // be consistent with the target settings.
261 TEST_F(P2PInvalidatorTest, SendNotificationData) { 265 TEST_F(P2PInvalidatorTest, SendNotificationData) {
262 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); 266 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
263 const ModelTypeSet changed_types(THEMES, APPS); 267 const ModelTypeSet changed_types(THEMES, APPS);
264 const ModelTypeSet expected_types(THEMES); 268 const ModelTypeSet expected_types(THEMES);
265 269
266 const ObjectIdStateMap& id_state_map = 270 const ObjectIdInvalidationMap& invalidation_map =
267 ObjectIdSetToStateMap( 271 ObjectIdSetToInvalidationMap(
268 ModelTypeSetToObjectIdSet(changed_types), ""); 272 ModelTypeSetToObjectIdSet(changed_types), "");
269 273
270 P2PInvalidator* const invalidator = delegate_.GetInvalidator(); 274 P2PInvalidator* const invalidator = delegate_.GetInvalidator();
271 notifier::FakePushClient* const push_client = delegate_.GetPushClient(); 275 notifier::FakePushClient* const push_client = delegate_.GetPushClient();
272 276
273 invalidator->UpdateRegisteredIds(&fake_handler_, 277 invalidator->UpdateRegisteredIds(&fake_handler_,
274 ModelTypeSetToObjectIdSet(enabled_types)); 278 ModelTypeSetToObjectIdSet(enabled_types));
275 279
276 invalidator->SetUniqueId("sender"); 280 invalidator->SetUniqueId("sender");
277 invalidator->UpdateCredentials("foo@bar.com", "fake_token"); 281 invalidator->UpdateCredentials("foo@bar.com", "fake_token");
278 282
279 ReflectSentNotifications(); 283 ReflectSentNotifications();
280 push_client->EnableNotifications(); 284 push_client->EnableNotifications();
281 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); 285 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState());
282 286
283 ReflectSentNotifications(); 287 ReflectSentNotifications();
284 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); 288 EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
285 EXPECT_THAT( 289 EXPECT_THAT(
286 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), 290 ModelTypeInvalidationMapToObjectIdInvalidationMap(
287 Eq(fake_handler_.GetLastInvalidationIdStateMap())); 291 MakeInvalidationMap(enabled_types)),
292 Eq(fake_handler_.GetLastInvalidationMap()));
288 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource()); 293 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource());
289 294
290 // Should be dropped. 295 // Should be dropped.
291 invalidator->SendNotificationDataForTest(P2PNotificationData()); 296 invalidator->SendNotificationDataForTest(P2PNotificationData());
292 ReflectSentNotifications(); 297 ReflectSentNotifications();
293 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); 298 EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
294 299
295 const ObjectIdStateMap& expected_ids = 300 const ObjectIdInvalidationMap& expected_ids =
296 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types)); 301 ModelTypeInvalidationMapToObjectIdInvalidationMap(
302 MakeInvalidationMap(expected_types));
297 303
298 // Should be propagated. 304 // Should be propagated.
299 invalidator->SendNotificationDataForTest( 305 invalidator->SendNotificationDataForTest(
300 P2PNotificationData("sender", NOTIFY_SELF, 306 P2PNotificationData("sender", NOTIFY_SELF,
301 id_state_map, REMOTE_INVALIDATION)); 307 invalidation_map, REMOTE_INVALIDATION));
302 ReflectSentNotifications(); 308 ReflectSentNotifications();
303 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); 309 EXPECT_EQ(2, fake_handler_.GetInvalidationCount());
304 EXPECT_THAT( 310 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
305 expected_ids,
306 Eq(fake_handler_.GetLastInvalidationIdStateMap()));
307 311
308 // Should be dropped. 312 // Should be dropped.
309 invalidator->SendNotificationDataForTest( 313 invalidator->SendNotificationDataForTest(
310 P2PNotificationData("sender2", NOTIFY_SELF, 314 P2PNotificationData("sender2", NOTIFY_SELF,
311 id_state_map, REMOTE_INVALIDATION)); 315 invalidation_map, REMOTE_INVALIDATION));
312 ReflectSentNotifications(); 316 ReflectSentNotifications();
313 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); 317 EXPECT_EQ(2, fake_handler_.GetInvalidationCount());
314 318
315 // Should be dropped. 319 // Should be dropped.
316 invalidator->SendNotificationDataForTest( 320 invalidator->SendNotificationDataForTest(
317 P2PNotificationData("sender", NOTIFY_SELF, 321 P2PNotificationData("sender", NOTIFY_SELF,
318 ObjectIdStateMap(), REMOTE_INVALIDATION)); 322 ObjectIdInvalidationMap(), REMOTE_INVALIDATION));
319 ReflectSentNotifications(); 323 ReflectSentNotifications();
320 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); 324 EXPECT_EQ(2, fake_handler_.GetInvalidationCount());
321 325
322 // Should be dropped. 326 // Should be dropped.
323 invalidator->SendNotificationDataForTest( 327 invalidator->SendNotificationDataForTest(
324 P2PNotificationData("sender", NOTIFY_OTHERS, 328 P2PNotificationData("sender", NOTIFY_OTHERS,
325 id_state_map, REMOTE_INVALIDATION)); 329 invalidation_map, REMOTE_INVALIDATION));
326 ReflectSentNotifications(); 330 ReflectSentNotifications();
327 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); 331 EXPECT_EQ(2, fake_handler_.GetInvalidationCount());
328 332
329 // Should be propagated. 333 // Should be propagated.
330 invalidator->SendNotificationDataForTest( 334 invalidator->SendNotificationDataForTest(
331 P2PNotificationData("sender2", NOTIFY_OTHERS, 335 P2PNotificationData("sender2", NOTIFY_OTHERS,
332 id_state_map, REMOTE_INVALIDATION)); 336 invalidation_map, REMOTE_INVALIDATION));
333 ReflectSentNotifications(); 337 ReflectSentNotifications();
334 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); 338 EXPECT_EQ(3, fake_handler_.GetInvalidationCount());
335 EXPECT_THAT( 339 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
336 expected_ids,
337 Eq(fake_handler_.GetLastInvalidationIdStateMap()));
338 340
339 // Should be dropped. 341 // Should be dropped.
340 invalidator->SendNotificationDataForTest( 342 invalidator->SendNotificationDataForTest(
341 P2PNotificationData("sender2", NOTIFY_OTHERS, 343 P2PNotificationData("sender2", NOTIFY_OTHERS,
342 ObjectIdStateMap(), REMOTE_INVALIDATION)); 344 ObjectIdInvalidationMap(), REMOTE_INVALIDATION));
343 ReflectSentNotifications(); 345 ReflectSentNotifications();
344 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); 346 EXPECT_EQ(3, fake_handler_.GetInvalidationCount());
345 347
346 // Should be propagated. 348 // Should be propagated.
347 invalidator->SendNotificationDataForTest( 349 invalidator->SendNotificationDataForTest(
348 P2PNotificationData("sender", NOTIFY_ALL, 350 P2PNotificationData("sender", NOTIFY_ALL,
349 id_state_map, REMOTE_INVALIDATION)); 351 invalidation_map, REMOTE_INVALIDATION));
350 ReflectSentNotifications(); 352 ReflectSentNotifications();
351 EXPECT_EQ(4, fake_handler_.GetInvalidationCount()); 353 EXPECT_EQ(4, fake_handler_.GetInvalidationCount());
352 EXPECT_THAT( 354 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
353 expected_ids,
354 Eq(fake_handler_.GetLastInvalidationIdStateMap()));
355 355
356 // Should be propagated. 356 // Should be propagated.
357 invalidator->SendNotificationDataForTest( 357 invalidator->SendNotificationDataForTest(
358 P2PNotificationData("sender2", NOTIFY_ALL, 358 P2PNotificationData("sender2", NOTIFY_ALL,
359 id_state_map, REMOTE_INVALIDATION)); 359 invalidation_map, REMOTE_INVALIDATION));
360 ReflectSentNotifications(); 360 ReflectSentNotifications();
361 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); 361 EXPECT_EQ(5, fake_handler_.GetInvalidationCount());
362 EXPECT_THAT( 362 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap()));
363 expected_ids,
364 Eq(fake_handler_.GetLastInvalidationIdStateMap()));
365 363
366 // Should be dropped. 364 // Should be dropped.
367 invalidator->SendNotificationDataForTest( 365 invalidator->SendNotificationDataForTest(
368 P2PNotificationData("sender2", NOTIFY_ALL, 366 P2PNotificationData("sender2", NOTIFY_ALL,
369 ObjectIdStateMap(), REMOTE_INVALIDATION)); 367 ObjectIdInvalidationMap(), REMOTE_INVALIDATION));
370 ReflectSentNotifications(); 368 ReflectSentNotifications();
371 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); 369 EXPECT_EQ(5, fake_handler_.GetInvalidationCount());
372 } 370 }
373 371
374 INSTANTIATE_TYPED_TEST_CASE_P( 372 INSTANTIATE_TYPED_TEST_CASE_P(
375 P2PInvalidatorTest, InvalidatorTest, 373 P2PInvalidatorTest, InvalidatorTest,
376 P2PInvalidatorTestDelegate); 374 P2PInvalidatorTestDelegate);
377 375
378 } // namespace 376 } // namespace
379 377
380 } // namespace syncer 378 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/p2p_invalidator.cc ('k') | sync/notifier/sync_invalidation_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698