| OLD | NEW |
| 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/notifier/fake_invalidation_handler.h" | 11 #include "sync/notifier/fake_invalidation_handler.h" |
| 12 #include "sync/notifier/invalidator_test_template.h" | 12 #include "sync/notifier/invalidator_test_template.h" |
| 13 #include "sync/notifier/object_id_invalidation_map_test_util.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 namespace syncer { | 15 namespace syncer { |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 class P2PInvalidatorTestDelegate { | 19 class P2PInvalidatorTestDelegate { |
| 21 public: | 20 public: |
| 22 P2PInvalidatorTestDelegate() : fake_push_client_(NULL) {} | 21 P2PInvalidatorTestDelegate() : fake_push_client_(NULL) {} |
| 23 | 22 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 58 |
| 60 void TriggerOnInvalidatorStateChange(InvalidatorState state) { | 59 void TriggerOnInvalidatorStateChange(InvalidatorState state) { |
| 61 if (state == INVALIDATIONS_ENABLED) { | 60 if (state == INVALIDATIONS_ENABLED) { |
| 62 fake_push_client_->EnableNotifications(); | 61 fake_push_client_->EnableNotifications(); |
| 63 } else { | 62 } else { |
| 64 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(state)); | 63 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(state)); |
| 65 } | 64 } |
| 66 } | 65 } |
| 67 | 66 |
| 68 void TriggerOnIncomingInvalidation( | 67 void TriggerOnIncomingInvalidation( |
| 69 const ObjectIdInvalidationMap& invalidation_map) { | 68 const ObjectIdInvalidationMap& invalidations) { |
| 70 const P2PNotificationData notification_data( | 69 const P2PNotificationData notification_data( |
| 71 std::string(), NOTIFY_ALL, invalidation_map); | 70 std::string(), NOTIFY_ALL, invalidations); |
| 72 notifier::Notification notification; | 71 notifier::Notification notification; |
| 73 notification.channel = kSyncP2PNotificationChannel; | 72 notification.channel = kSyncP2PNotificationChannel; |
| 74 notification.data = notification_data.ToString(); | 73 notification.data = notification_data.ToString(); |
| 75 fake_push_client_->SimulateIncomingNotification(notification); | 74 fake_push_client_->SimulateIncomingNotification(notification); |
| 76 } | 75 } |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 // Owned by |invalidator_|. | 78 // Owned by |invalidator_|. |
| 80 notifier::FakePushClient* fake_push_client_; | 79 notifier::FakePushClient* fake_push_client_; |
| 81 scoped_ptr<P2PInvalidator> invalidator_; | 80 scoped_ptr<P2PInvalidator> invalidator_; |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 class P2PInvalidatorTest : public testing::Test { | 83 class P2PInvalidatorTest : public testing::Test { |
| 85 protected: | 84 protected: |
| 86 P2PInvalidatorTest() | 85 P2PInvalidatorTest() |
| 87 : next_sent_notification_to_reflect_(0) { | 86 : next_sent_notification_to_reflect_(0) { |
| 88 delegate_.CreateInvalidator("sender", | 87 delegate_.CreateInvalidator("sender", |
| 89 "fake_state", | 88 "fake_state", |
| 90 base::WeakPtr<InvalidationStateTracker>()); | 89 base::WeakPtr<InvalidationStateTracker>()); |
| 91 delegate_.GetInvalidator()->RegisterHandler(&fake_handler_); | 90 delegate_.GetInvalidator()->RegisterHandler(&fake_handler_); |
| 92 } | 91 } |
| 93 | 92 |
| 94 virtual ~P2PInvalidatorTest() { | 93 virtual ~P2PInvalidatorTest() { |
| 95 delegate_.GetInvalidator()->UnregisterHandler(&fake_handler_); | 94 delegate_.GetInvalidator()->UnregisterHandler(&fake_handler_); |
| 96 } | 95 } |
| 97 | 96 |
| 98 ObjectIdInvalidationMap MakeInvalidationMap(ModelTypeSet types) { | 97 ObjectIdInvalidationMap MakeInvalidationMap(ModelTypeSet types) { |
| 99 ObjectIdInvalidationMap invalidations; | 98 ObjectIdInvalidationMap invalidations; |
| 100 ObjectIdSet ids = ModelTypeSetToObjectIdSet(types); | 99 ObjectIdSet ids = ModelTypeSetToObjectIdSet(types); |
| 101 return ObjectIdSetToInvalidationMap(ids, | 100 return ObjectIdInvalidationMap::InvalidateAll(ids); |
| 102 Invalidation::kUnknownVersion, | |
| 103 std::string()); | |
| 104 } | 101 } |
| 105 | 102 |
| 106 // Simulate receiving all the notifications we sent out since last | 103 // Simulate receiving all the notifications we sent out since last |
| 107 // time this was called. | 104 // time this was called. |
| 108 void ReflectSentNotifications() { | 105 void ReflectSentNotifications() { |
| 109 const std::vector<notifier::Notification>& sent_notifications = | 106 const std::vector<notifier::Notification>& sent_notifications = |
| 110 delegate_.GetPushClient()->sent_notifications(); | 107 delegate_.GetPushClient()->sent_notifications(); |
| 111 for(size_t i = next_sent_notification_to_reflect_; | 108 for(size_t i = next_sent_notification_to_reflect_; |
| 112 i < sent_notifications.size(); ++i) { | 109 i < sent_notifications.size(); ++i) { |
| 113 delegate_.GetInvalidator()->OnIncomingNotification(sent_notifications[i]); | 110 delegate_.GetInvalidator()->OnIncomingNotification(sent_notifications[i]); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 156 } |
| 160 } | 157 } |
| 161 | 158 |
| 162 // Make sure the P2PNotificationData <-> string conversions work for a | 159 // Make sure the P2PNotificationData <-> string conversions work for a |
| 163 // default-constructed P2PNotificationData. | 160 // default-constructed P2PNotificationData. |
| 164 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { | 161 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { |
| 165 const P2PNotificationData notification_data; | 162 const P2PNotificationData notification_data; |
| 166 EXPECT_TRUE(notification_data.IsTargeted(std::string())); | 163 EXPECT_TRUE(notification_data.IsTargeted(std::string())); |
| 167 EXPECT_FALSE(notification_data.IsTargeted("other1")); | 164 EXPECT_FALSE(notification_data.IsTargeted("other1")); |
| 168 EXPECT_FALSE(notification_data.IsTargeted("other2")); | 165 EXPECT_FALSE(notification_data.IsTargeted("other2")); |
| 169 EXPECT_TRUE(notification_data.GetIdInvalidationMap().empty()); | 166 EXPECT_TRUE(notification_data.GetIdInvalidationMap().Empty()); |
| 170 const std::string& notification_data_str = notification_data.ToString(); | 167 const std::string& notification_data_str = notification_data.ToString(); |
| 171 EXPECT_EQ( | 168 EXPECT_EQ( |
| 172 "{\"idInvalidationMap\":[],\"notificationType\":\"notifySelf\"," | 169 "{\"invalidations\":[],\"notificationType\":\"notifySelf\"," |
| 173 "\"senderId\":\"\"}", notification_data_str); | 170 "\"senderId\":\"\"}", notification_data_str); |
| 174 | 171 |
| 175 P2PNotificationData notification_data_parsed; | 172 P2PNotificationData notification_data_parsed; |
| 176 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); | 173 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); |
| 177 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); | 174 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); |
| 178 } | 175 } |
| 179 | 176 |
| 180 // Make sure the P2PNotificationData <-> string conversions work for a | 177 // Make sure the P2PNotificationData <-> string conversions work for a |
| 181 // non-default-constructed P2PNotificationData. | 178 // non-default-constructed P2PNotificationData. |
| 182 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { | 179 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { |
| 183 const ObjectIdInvalidationMap& invalidation_map = | 180 |
| 184 ObjectIdSetToInvalidationMap( | 181 ObjectIdInvalidationMap invalidations = |
| 185 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), | 182 ObjectIdInvalidationMap::InvalidateAll( |
| 186 Invalidation::kUnknownVersion, | 183 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES))); |
| 187 std::string()); | 184 const P2PNotificationData notification_data("sender", |
| 188 const P2PNotificationData notification_data( | 185 NOTIFY_ALL, |
| 189 "sender", NOTIFY_ALL, invalidation_map); | 186 invalidations); |
| 190 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 187 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
| 191 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 188 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
| 192 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 189 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
| 193 EXPECT_THAT(invalidation_map, | 190 EXPECT_EQ(invalidations, notification_data.GetIdInvalidationMap()); |
| 194 Eq(notification_data.GetIdInvalidationMap())); | |
| 195 const std::string& notification_data_str = notification_data.ToString(); | 191 const std::string& notification_data_str = notification_data.ToString(); |
| 196 EXPECT_EQ( | 192 EXPECT_EQ( |
| 197 "{\"idInvalidationMap\":[" | 193 "{\"invalidations\":[" |
| 198 "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}," | 194 "{\"isUnknownVersion\":true," |
| 199 "\"state\":{\"ackHandle\":{\"state\":\"\",\"timestamp\":\"0\"}," | 195 "\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}}," |
| 200 "\"payload\":\"\",\"version\":\"-1\"}}," | 196 "{\"isUnknownVersion\":true," |
| 201 "{\"objectId\":{\"name\":\"THEME\",\"source\":1004}," | 197 "\"objectId\":{\"name\":\"THEME\",\"source\":1004}}" |
| 202 "\"state\":{\"ackHandle\":{\"state\":\"\",\"timestamp\":\"0\"}," | |
| 203 "\"payload\":\"\",\"version\":\"-1\"}}" | |
| 204 "],\"notificationType\":\"notifyAll\"," | 198 "],\"notificationType\":\"notifyAll\"," |
| 205 "\"senderId\":\"sender\"}", notification_data_str); | 199 "\"senderId\":\"sender\"}", notification_data_str); |
| 206 | 200 |
| 207 P2PNotificationData notification_data_parsed; | 201 P2PNotificationData notification_data_parsed; |
| 208 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); | 202 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); |
| 209 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); | 203 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); |
| 210 } | 204 } |
| 211 | 205 |
| 212 // Set up the P2PInvalidator, simulate a successful connection, and send | 206 // Set up the P2PInvalidator, simulate a successful connection, and send |
| 213 // a notification with the default target (NOTIFY_OTHERS). The | 207 // a notification with the default target (NOTIFY_OTHERS). The |
| (...skipping 27 matching lines...) Expand all Loading... |
| 241 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); | 235 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); |
| 242 | 236 |
| 243 ReflectSentNotifications(); | 237 ReflectSentNotifications(); |
| 244 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); | 238 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 245 EXPECT_THAT( | 239 EXPECT_THAT( |
| 246 MakeInvalidationMap(enabled_types), | 240 MakeInvalidationMap(enabled_types), |
| 247 Eq(fake_handler_.GetLastInvalidationMap())); | 241 Eq(fake_handler_.GetLastInvalidationMap())); |
| 248 | 242 |
| 249 // Sent with target NOTIFY_OTHERS so should not be propagated to | 243 // Sent with target NOTIFY_OTHERS so should not be propagated to |
| 250 // |fake_handler_|. | 244 // |fake_handler_|. |
| 251 { | 245 invalidator->SendInvalidation( |
| 252 const ObjectIdInvalidationMap& invalidation_map = | 246 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS))); |
| 253 ObjectIdSetToInvalidationMap( | |
| 254 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), | |
| 255 Invalidation::kUnknownVersion, | |
| 256 std::string()); | |
| 257 invalidator->SendInvalidation(invalidation_map); | |
| 258 } | |
| 259 | 247 |
| 260 ReflectSentNotifications(); | 248 ReflectSentNotifications(); |
| 261 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); | 249 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 262 } | 250 } |
| 263 | 251 |
| 264 // Set up the P2PInvalidator and send out notifications with various | 252 // Set up the P2PInvalidator and send out notifications with various |
| 265 // target settings. The notifications received by the observer should | 253 // target settings. The notifications received by the observer should |
| 266 // be consistent with the target settings. | 254 // be consistent with the target settings. |
| 267 TEST_F(P2PInvalidatorTest, SendNotificationData) { | 255 TEST_F(P2PInvalidatorTest, SendNotificationData) { |
| 268 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); | 256 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); |
| 269 const ModelTypeSet changed_types(THEMES, APPS); | 257 const ModelTypeSet changed_types(THEMES, APPS); |
| 270 const ModelTypeSet expected_types(THEMES); | 258 const ModelTypeSet expected_types(THEMES); |
| 271 | 259 |
| 272 const ObjectIdInvalidationMap& invalidation_map = | 260 const ObjectIdInvalidationMap& invalidation_map = |
| 273 ObjectIdSetToInvalidationMap(ModelTypeSetToObjectIdSet(changed_types), | 261 MakeInvalidationMap(changed_types); |
| 274 Invalidation::kUnknownVersion, | |
| 275 std::string()); | |
| 276 | 262 |
| 277 P2PInvalidator* const invalidator = delegate_.GetInvalidator(); | 263 P2PInvalidator* const invalidator = delegate_.GetInvalidator(); |
| 278 notifier::FakePushClient* const push_client = delegate_.GetPushClient(); | 264 notifier::FakePushClient* const push_client = delegate_.GetPushClient(); |
| 279 | 265 |
| 280 invalidator->UpdateRegisteredIds(&fake_handler_, | 266 invalidator->UpdateRegisteredIds(&fake_handler_, |
| 281 ModelTypeSetToObjectIdSet(enabled_types)); | 267 ModelTypeSetToObjectIdSet(enabled_types)); |
| 282 | 268 |
| 283 invalidator->UpdateCredentials("foo@bar.com", "fake_token"); | 269 invalidator->UpdateCredentials("foo@bar.com", "fake_token"); |
| 284 | 270 |
| 285 ReflectSentNotifications(); | 271 ReflectSentNotifications(); |
| 286 push_client->EnableNotifications(); | 272 push_client->EnableNotifications(); |
| 287 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); | 273 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); |
| 288 | 274 |
| 289 ReflectSentNotifications(); | 275 ReflectSentNotifications(); |
| 290 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); | 276 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 291 EXPECT_THAT(MakeInvalidationMap(enabled_types), | 277 EXPECT_EQ(ModelTypeSetToObjectIdSet(enabled_types), |
| 292 Eq(fake_handler_.GetLastInvalidationMap())); | 278 fake_handler_.GetLastInvalidationMap().GetObjectIds()); |
| 293 | 279 |
| 294 // Should be dropped. | 280 // Should be dropped. |
| 295 invalidator->SendNotificationDataForTest(P2PNotificationData()); | 281 invalidator->SendNotificationDataForTest(P2PNotificationData()); |
| 296 ReflectSentNotifications(); | 282 ReflectSentNotifications(); |
| 297 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); | 283 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 298 | 284 |
| 299 const ObjectIdInvalidationMap& expected_ids = | 285 const ObjectIdSet& expected_ids = ModelTypeSetToObjectIdSet(expected_types); |
| 300 MakeInvalidationMap(expected_types); | |
| 301 | 286 |
| 302 // Should be propagated. | 287 // Should be propagated. |
| 303 invalidator->SendNotificationDataForTest( | 288 invalidator->SendNotificationDataForTest( |
| 304 P2PNotificationData("sender", NOTIFY_SELF, invalidation_map)); | 289 P2PNotificationData("sender", NOTIFY_SELF, invalidation_map)); |
| 305 ReflectSentNotifications(); | 290 ReflectSentNotifications(); |
| 306 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); | 291 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 307 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap())); | 292 EXPECT_EQ(expected_ids, |
| 293 fake_handler_.GetLastInvalidationMap().GetObjectIds()); |
| 308 | 294 |
| 309 // Should be dropped. | 295 // Should be dropped. |
| 310 invalidator->SendNotificationDataForTest( | 296 invalidator->SendNotificationDataForTest( |
| 311 P2PNotificationData("sender2", NOTIFY_SELF, invalidation_map)); | 297 P2PNotificationData("sender2", NOTIFY_SELF, invalidation_map)); |
| 312 ReflectSentNotifications(); | 298 ReflectSentNotifications(); |
| 313 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); | 299 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 314 | 300 |
| 315 // Should be dropped. | 301 // Should be dropped. |
| 316 invalidator->SendNotificationDataForTest( | 302 invalidator->SendNotificationDataForTest( |
| 317 P2PNotificationData("sender", NOTIFY_SELF, ObjectIdInvalidationMap())); | 303 P2PNotificationData("sender", NOTIFY_SELF, ObjectIdInvalidationMap())); |
| 318 ReflectSentNotifications(); | 304 ReflectSentNotifications(); |
| 319 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); | 305 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 320 | 306 |
| 321 // Should be dropped. | 307 // Should be dropped. |
| 322 invalidator->SendNotificationDataForTest( | 308 invalidator->SendNotificationDataForTest( |
| 323 P2PNotificationData("sender", NOTIFY_OTHERS, invalidation_map)); | 309 P2PNotificationData("sender", NOTIFY_OTHERS, invalidation_map)); |
| 324 ReflectSentNotifications(); | 310 ReflectSentNotifications(); |
| 325 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); | 311 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 326 | 312 |
| 327 // Should be propagated. | 313 // Should be propagated. |
| 328 invalidator->SendNotificationDataForTest( | 314 invalidator->SendNotificationDataForTest( |
| 329 P2PNotificationData("sender2", NOTIFY_OTHERS, invalidation_map)); | 315 P2PNotificationData("sender2", NOTIFY_OTHERS, invalidation_map)); |
| 330 ReflectSentNotifications(); | 316 ReflectSentNotifications(); |
| 331 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); | 317 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); |
| 332 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap())); | 318 EXPECT_EQ(expected_ids, |
| 319 fake_handler_.GetLastInvalidationMap().GetObjectIds()); |
| 333 | 320 |
| 334 // Should be dropped. | 321 // Should be dropped. |
| 335 invalidator->SendNotificationDataForTest( | 322 invalidator->SendNotificationDataForTest( |
| 336 P2PNotificationData("sender2", NOTIFY_OTHERS, ObjectIdInvalidationMap())); | 323 P2PNotificationData("sender2", NOTIFY_OTHERS, ObjectIdInvalidationMap())); |
| 337 ReflectSentNotifications(); | 324 ReflectSentNotifications(); |
| 338 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); | 325 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); |
| 339 | 326 |
| 340 // Should be propagated. | 327 // Should be propagated. |
| 341 invalidator->SendNotificationDataForTest( | 328 invalidator->SendNotificationDataForTest( |
| 342 P2PNotificationData("sender", NOTIFY_ALL, invalidation_map)); | 329 P2PNotificationData("sender", NOTIFY_ALL, invalidation_map)); |
| 343 ReflectSentNotifications(); | 330 ReflectSentNotifications(); |
| 344 EXPECT_EQ(4, fake_handler_.GetInvalidationCount()); | 331 EXPECT_EQ(4, fake_handler_.GetInvalidationCount()); |
| 345 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap())); | 332 EXPECT_EQ(expected_ids, |
| 333 fake_handler_.GetLastInvalidationMap().GetObjectIds()); |
| 346 | 334 |
| 347 // Should be propagated. | 335 // Should be propagated. |
| 348 invalidator->SendNotificationDataForTest( | 336 invalidator->SendNotificationDataForTest( |
| 349 P2PNotificationData("sender2", NOTIFY_ALL, invalidation_map)); | 337 P2PNotificationData("sender2", NOTIFY_ALL, invalidation_map)); |
| 350 ReflectSentNotifications(); | 338 ReflectSentNotifications(); |
| 351 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); | 339 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); |
| 352 EXPECT_THAT(expected_ids, Eq(fake_handler_.GetLastInvalidationMap())); | 340 EXPECT_EQ(expected_ids, |
| 341 fake_handler_.GetLastInvalidationMap().GetObjectIds()); |
| 353 | 342 |
| 354 // Should be dropped. | 343 // Should be dropped. |
| 355 invalidator->SendNotificationDataForTest( | 344 invalidator->SendNotificationDataForTest( |
| 356 P2PNotificationData("sender2", NOTIFY_ALL, ObjectIdInvalidationMap())); | 345 P2PNotificationData("sender2", NOTIFY_ALL, ObjectIdInvalidationMap())); |
| 357 ReflectSentNotifications(); | 346 ReflectSentNotifications(); |
| 358 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); | 347 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); |
| 359 } | 348 } |
| 360 | 349 |
| 361 INSTANTIATE_TYPED_TEST_CASE_P( | 350 INSTANTIATE_TYPED_TEST_CASE_P( |
| 362 P2PInvalidatorTest, InvalidatorTest, | 351 P2PInvalidatorTest, InvalidatorTest, |
| 363 P2PInvalidatorTestDelegate); | 352 P2PInvalidatorTestDelegate); |
| 364 | 353 |
| 365 } // namespace | 354 } // namespace |
| 366 | 355 |
| 367 } // namespace syncer | 356 } // namespace syncer |
| OLD | NEW |