| 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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 void DestroyInvalidator() { | 50 void DestroyInvalidator() { |
| 51 invalidator_.reset(); | 51 invalidator_.reset(); |
| 52 fake_push_client_ = NULL; | 52 fake_push_client_ = NULL; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void WaitForInvalidator() { | 55 void WaitForInvalidator() { |
| 56 // Do Nothing. | 56 // Do Nothing. |
| 57 } | 57 } |
| 58 | 58 |
| 59 void TriggerOnNotificationsEnabled() { | 59 void TriggerOnInvalidatorStateChange(InvalidatorState state) { |
| 60 fake_push_client_->EnableNotifications(); | 60 if (state == INVALIDATIONS_ENABLED) { |
| 61 fake_push_client_->EnableNotifications(); |
| 62 } else { |
| 63 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(state)); |
| 64 } |
| 61 } | 65 } |
| 62 | 66 |
| 63 void TriggerOnIncomingNotification(const ObjectIdStateMap& id_state_map, | 67 void TriggerOnIncomingInvalidation(const ObjectIdStateMap& id_state_map, |
| 64 IncomingNotificationSource source) { | 68 IncomingInvalidationSource source) { |
| 65 const P2PNotificationData notification_data( | 69 const P2PNotificationData notification_data( |
| 66 "", NOTIFY_ALL, id_state_map, source); | 70 "", NOTIFY_ALL, id_state_map, source); |
| 67 notifier::Notification notification; | 71 notifier::Notification notification; |
| 68 notification.channel = kSyncP2PNotificationChannel; | 72 notification.channel = kSyncP2PNotificationChannel; |
| 69 notification.data = notification_data.ToString(); | 73 notification.data = notification_data.ToString(); |
| 70 fake_push_client_->SimulateIncomingNotification(notification); | 74 fake_push_client_->SimulateIncomingNotification(notification); |
| 71 } | 75 } |
| 72 | 76 |
| 73 void TriggerOnNotificationsDisabled(NotificationsDisabledReason reason) { | |
| 74 fake_push_client_->DisableNotifications(ToNotifierReasonForTest(reason)); | |
| 75 } | |
| 76 | |
| 77 static bool InvalidatorHandlesDeprecatedState() { | 77 static bool InvalidatorHandlesDeprecatedState() { |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // Owned by |invalidator_|. | 82 // Owned by |invalidator_|. |
| 83 notifier::FakePushClient* fake_push_client_; | 83 notifier::FakePushClient* fake_push_client_; |
| 84 scoped_ptr<P2PInvalidator> invalidator_; | 84 scoped_ptr<P2PInvalidator> invalidator_; |
| 85 }; | 85 }; |
| 86 | 86 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_FALSE(target_str.empty()); | 129 EXPECT_FALSE(target_str.empty()); |
| 130 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str)); | 130 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str)); |
| 131 } | 131 } |
| 132 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown")); | 132 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown")); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Make sure notification targeting works correctly. | 135 // Make sure notification targeting works correctly. |
| 136 TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) { | 136 TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) { |
| 137 { | 137 { |
| 138 const P2PNotificationData notification_data( | 138 const P2PNotificationData notification_data( |
| 139 "sender", NOTIFY_SELF, ObjectIdStateMap(), REMOTE_NOTIFICATION); | 139 "sender", NOTIFY_SELF, ObjectIdStateMap(), REMOTE_INVALIDATION); |
| 140 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 140 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
| 141 EXPECT_FALSE(notification_data.IsTargeted("other1")); | 141 EXPECT_FALSE(notification_data.IsTargeted("other1")); |
| 142 EXPECT_FALSE(notification_data.IsTargeted("other2")); | 142 EXPECT_FALSE(notification_data.IsTargeted("other2")); |
| 143 } | 143 } |
| 144 { | 144 { |
| 145 const P2PNotificationData notification_data( | 145 const P2PNotificationData notification_data( |
| 146 "sender", NOTIFY_OTHERS, ObjectIdStateMap(), REMOTE_NOTIFICATION); | 146 "sender", NOTIFY_OTHERS, ObjectIdStateMap(), REMOTE_INVALIDATION); |
| 147 EXPECT_FALSE(notification_data.IsTargeted("sender")); | 147 EXPECT_FALSE(notification_data.IsTargeted("sender")); |
| 148 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 148 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
| 149 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 149 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
| 150 } | 150 } |
| 151 { | 151 { |
| 152 const P2PNotificationData notification_data( | 152 const P2PNotificationData notification_data( |
| 153 "sender", NOTIFY_ALL, ObjectIdStateMap(), REMOTE_NOTIFICATION); | 153 "sender", NOTIFY_ALL, ObjectIdStateMap(), REMOTE_INVALIDATION); |
| 154 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 154 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
| 155 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 155 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
| 156 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 156 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Make sure the P2PNotificationData <-> string conversions work for a | 160 // Make sure the P2PNotificationData <-> string conversions work for a |
| 161 // default-constructed P2PNotificationData. | 161 // default-constructed P2PNotificationData. |
| 162 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { | 162 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { |
| 163 const P2PNotificationData notification_data; | 163 const P2PNotificationData notification_data; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 175 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); | 175 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Make sure the P2PNotificationData <-> string conversions work for a | 178 // Make sure the P2PNotificationData <-> string conversions work for a |
| 179 // non-default-constructed P2PNotificationData. | 179 // non-default-constructed P2PNotificationData. |
| 180 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { | 180 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { |
| 181 const ObjectIdStateMap& id_state_map = | 181 const ObjectIdStateMap& id_state_map = |
| 182 ObjectIdSetToStateMap( | 182 ObjectIdSetToStateMap( |
| 183 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), ""); | 183 ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), ""); |
| 184 const P2PNotificationData notification_data( | 184 const P2PNotificationData notification_data( |
| 185 "sender", NOTIFY_ALL, id_state_map, LOCAL_NOTIFICATION); | 185 "sender", NOTIFY_ALL, id_state_map, LOCAL_INVALIDATION); |
| 186 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 186 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
| 187 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 187 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
| 188 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 188 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
| 189 EXPECT_THAT(id_state_map, Eq(notification_data.GetIdStateMap())); | 189 EXPECT_THAT(id_state_map, Eq(notification_data.GetIdStateMap())); |
| 190 const std::string& notification_data_str = notification_data.ToString(); | 190 const std::string& notification_data_str = notification_data.ToString(); |
| 191 EXPECT_EQ( | 191 EXPECT_EQ( |
| 192 "{\"idStateMap\":[" | 192 "{\"idStateMap\":[" |
| 193 "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}," | 193 "{\"objectId\":{\"name\":\"BOOKMARK\",\"source\":1004}," |
| 194 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}}," | 194 "\"state\":{\"ackHandle\":{},\"payload\":\"\"}}," |
| 195 "{\"objectId\":{\"name\":\"THEME\",\"source\":1004}," | 195 "{\"objectId\":{\"name\":\"THEME\",\"source\":1004}," |
| (...skipping 30 matching lines...) Expand all Loading... |
| 226 expected_subscription.from = kEmail; | 226 expected_subscription.from = kEmail; |
| 227 EXPECT_TRUE(notifier::SubscriptionListsEqual( | 227 EXPECT_TRUE(notifier::SubscriptionListsEqual( |
| 228 push_client->subscriptions(), | 228 push_client->subscriptions(), |
| 229 notifier::SubscriptionList(1, expected_subscription))); | 229 notifier::SubscriptionList(1, expected_subscription))); |
| 230 } | 230 } |
| 231 EXPECT_EQ(kEmail, push_client->email()); | 231 EXPECT_EQ(kEmail, push_client->email()); |
| 232 EXPECT_EQ(kToken, push_client->token()); | 232 EXPECT_EQ(kToken, push_client->token()); |
| 233 | 233 |
| 234 ReflectSentNotifications(); | 234 ReflectSentNotifications(); |
| 235 push_client->EnableNotifications(); | 235 push_client->EnableNotifications(); |
| 236 EXPECT_EQ(NO_NOTIFICATION_ERROR, | 236 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); |
| 237 fake_handler_.GetNotificationsDisabledReason()); | |
| 238 | 237 |
| 239 ReflectSentNotifications(); | 238 ReflectSentNotifications(); |
| 240 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); | 239 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 241 EXPECT_THAT( | 240 EXPECT_THAT( |
| 242 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), | 241 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), |
| 243 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 242 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 244 EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource()); | 243 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource()); |
| 245 | 244 |
| 246 // Sent with target NOTIFY_OTHERS so should not be propagated to | 245 // Sent with target NOTIFY_OTHERS so should not be propagated to |
| 247 // |fake_handler_|. | 246 // |fake_handler_|. |
| 248 { | 247 { |
| 249 const ObjectIdStateMap& id_state_map = | 248 const ObjectIdStateMap& id_state_map = |
| 250 ObjectIdSetToStateMap( | 249 ObjectIdSetToStateMap( |
| 251 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), ""); | 250 ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), ""); |
| 252 invalidator->SendNotification(id_state_map); | 251 invalidator->SendInvalidation(id_state_map); |
| 253 } | 252 } |
| 254 | 253 |
| 255 ReflectSentNotifications(); | 254 ReflectSentNotifications(); |
| 256 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); | 255 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 257 } | 256 } |
| 258 | 257 |
| 259 // Set up the P2PInvalidator and send out notifications with various | 258 // Set up the P2PInvalidator and send out notifications with various |
| 260 // target settings. The notifications received by the observer should | 259 // target settings. The notifications received by the observer should |
| 261 // be consistent with the target settings. | 260 // be consistent with the target settings. |
| 262 TEST_F(P2PInvalidatorTest, SendNotificationData) { | 261 TEST_F(P2PInvalidatorTest, SendNotificationData) { |
| 263 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); | 262 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); |
| 264 const ModelTypeSet changed_types(THEMES, APPS); | 263 const ModelTypeSet changed_types(THEMES, APPS); |
| 265 const ModelTypeSet expected_types(THEMES); | 264 const ModelTypeSet expected_types(THEMES); |
| 266 | 265 |
| 267 const ObjectIdStateMap& id_state_map = | 266 const ObjectIdStateMap& id_state_map = |
| 268 ObjectIdSetToStateMap( | 267 ObjectIdSetToStateMap( |
| 269 ModelTypeSetToObjectIdSet(changed_types), ""); | 268 ModelTypeSetToObjectIdSet(changed_types), ""); |
| 270 | 269 |
| 271 P2PInvalidator* const invalidator = delegate_.GetInvalidator(); | 270 P2PInvalidator* const invalidator = delegate_.GetInvalidator(); |
| 272 notifier::FakePushClient* const push_client = delegate_.GetPushClient(); | 271 notifier::FakePushClient* const push_client = delegate_.GetPushClient(); |
| 273 | 272 |
| 274 invalidator->UpdateRegisteredIds(&fake_handler_, | 273 invalidator->UpdateRegisteredIds(&fake_handler_, |
| 275 ModelTypeSetToObjectIdSet(enabled_types)); | 274 ModelTypeSetToObjectIdSet(enabled_types)); |
| 276 | 275 |
| 277 invalidator->SetUniqueId("sender"); | 276 invalidator->SetUniqueId("sender"); |
| 278 invalidator->UpdateCredentials("foo@bar.com", "fake_token"); | 277 invalidator->UpdateCredentials("foo@bar.com", "fake_token"); |
| 279 | 278 |
| 280 ReflectSentNotifications(); | 279 ReflectSentNotifications(); |
| 281 push_client->EnableNotifications(); | 280 push_client->EnableNotifications(); |
| 282 EXPECT_EQ(NO_NOTIFICATION_ERROR, | 281 EXPECT_EQ(INVALIDATIONS_ENABLED, fake_handler_.GetInvalidatorState()); |
| 283 fake_handler_.GetNotificationsDisabledReason()); | |
| 284 | 282 |
| 285 ReflectSentNotifications(); | 283 ReflectSentNotifications(); |
| 286 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); | 284 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 287 EXPECT_THAT( | 285 EXPECT_THAT( |
| 288 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), | 286 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), |
| 289 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 287 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 290 EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource()); | 288 EXPECT_EQ(REMOTE_INVALIDATION, fake_handler_.GetLastInvalidationSource()); |
| 291 | 289 |
| 292 // Should be dropped. | 290 // Should be dropped. |
| 293 invalidator->SendNotificationDataForTest(P2PNotificationData()); | 291 invalidator->SendNotificationDataForTest(P2PNotificationData()); |
| 294 ReflectSentNotifications(); | 292 ReflectSentNotifications(); |
| 295 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); | 293 EXPECT_EQ(1, fake_handler_.GetInvalidationCount()); |
| 296 | 294 |
| 297 const ObjectIdStateMap& expected_ids = | 295 const ObjectIdStateMap& expected_ids = |
| 298 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types)); | 296 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types)); |
| 299 | 297 |
| 300 // Should be propagated. | 298 // Should be propagated. |
| 301 invalidator->SendNotificationDataForTest( | 299 invalidator->SendNotificationDataForTest( |
| 302 P2PNotificationData("sender", NOTIFY_SELF, | 300 P2PNotificationData("sender", NOTIFY_SELF, |
| 303 id_state_map, REMOTE_NOTIFICATION)); | 301 id_state_map, REMOTE_INVALIDATION)); |
| 304 ReflectSentNotifications(); | 302 ReflectSentNotifications(); |
| 305 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); | 303 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 306 EXPECT_THAT( | 304 EXPECT_THAT( |
| 307 expected_ids, | 305 expected_ids, |
| 308 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 306 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 309 | 307 |
| 310 // Should be dropped. | 308 // Should be dropped. |
| 311 invalidator->SendNotificationDataForTest( | 309 invalidator->SendNotificationDataForTest( |
| 312 P2PNotificationData("sender2", NOTIFY_SELF, | 310 P2PNotificationData("sender2", NOTIFY_SELF, |
| 313 id_state_map, REMOTE_NOTIFICATION)); | 311 id_state_map, REMOTE_INVALIDATION)); |
| 314 ReflectSentNotifications(); | 312 ReflectSentNotifications(); |
| 315 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); | 313 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 316 | 314 |
| 317 // Should be dropped. | 315 // Should be dropped. |
| 318 invalidator->SendNotificationDataForTest( | 316 invalidator->SendNotificationDataForTest( |
| 319 P2PNotificationData("sender", NOTIFY_SELF, | 317 P2PNotificationData("sender", NOTIFY_SELF, |
| 320 ObjectIdStateMap(), REMOTE_NOTIFICATION)); | 318 ObjectIdStateMap(), REMOTE_INVALIDATION)); |
| 321 ReflectSentNotifications(); | 319 ReflectSentNotifications(); |
| 322 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); | 320 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 323 | 321 |
| 324 // Should be dropped. | 322 // Should be dropped. |
| 325 invalidator->SendNotificationDataForTest( | 323 invalidator->SendNotificationDataForTest( |
| 326 P2PNotificationData("sender", NOTIFY_OTHERS, | 324 P2PNotificationData("sender", NOTIFY_OTHERS, |
| 327 id_state_map, REMOTE_NOTIFICATION)); | 325 id_state_map, REMOTE_INVALIDATION)); |
| 328 ReflectSentNotifications(); | 326 ReflectSentNotifications(); |
| 329 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); | 327 EXPECT_EQ(2, fake_handler_.GetInvalidationCount()); |
| 330 | 328 |
| 331 // Should be propagated. | 329 // Should be propagated. |
| 332 invalidator->SendNotificationDataForTest( | 330 invalidator->SendNotificationDataForTest( |
| 333 P2PNotificationData("sender2", NOTIFY_OTHERS, | 331 P2PNotificationData("sender2", NOTIFY_OTHERS, |
| 334 id_state_map, REMOTE_NOTIFICATION)); | 332 id_state_map, REMOTE_INVALIDATION)); |
| 335 ReflectSentNotifications(); | 333 ReflectSentNotifications(); |
| 336 EXPECT_EQ(3, fake_handler_.GetNotificationCount()); | 334 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); |
| 337 EXPECT_THAT( | 335 EXPECT_THAT( |
| 338 expected_ids, | 336 expected_ids, |
| 339 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 337 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 340 | 338 |
| 341 // Should be dropped. | 339 // Should be dropped. |
| 342 invalidator->SendNotificationDataForTest( | 340 invalidator->SendNotificationDataForTest( |
| 343 P2PNotificationData("sender2", NOTIFY_OTHERS, | 341 P2PNotificationData("sender2", NOTIFY_OTHERS, |
| 344 ObjectIdStateMap(), REMOTE_NOTIFICATION)); | 342 ObjectIdStateMap(), REMOTE_INVALIDATION)); |
| 345 ReflectSentNotifications(); | 343 ReflectSentNotifications(); |
| 346 EXPECT_EQ(3, fake_handler_.GetNotificationCount()); | 344 EXPECT_EQ(3, fake_handler_.GetInvalidationCount()); |
| 347 | 345 |
| 348 // Should be propagated. | 346 // Should be propagated. |
| 349 invalidator->SendNotificationDataForTest( | 347 invalidator->SendNotificationDataForTest( |
| 350 P2PNotificationData("sender", NOTIFY_ALL, | 348 P2PNotificationData("sender", NOTIFY_ALL, |
| 351 id_state_map, REMOTE_NOTIFICATION)); | 349 id_state_map, REMOTE_INVALIDATION)); |
| 352 ReflectSentNotifications(); | 350 ReflectSentNotifications(); |
| 353 EXPECT_EQ(4, fake_handler_.GetNotificationCount()); | 351 EXPECT_EQ(4, fake_handler_.GetInvalidationCount()); |
| 354 EXPECT_THAT( | 352 EXPECT_THAT( |
| 355 expected_ids, | 353 expected_ids, |
| 356 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 354 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 357 | 355 |
| 358 // Should be propagated. | 356 // Should be propagated. |
| 359 invalidator->SendNotificationDataForTest( | 357 invalidator->SendNotificationDataForTest( |
| 360 P2PNotificationData("sender2", NOTIFY_ALL, | 358 P2PNotificationData("sender2", NOTIFY_ALL, |
| 361 id_state_map, REMOTE_NOTIFICATION)); | 359 id_state_map, REMOTE_INVALIDATION)); |
| 362 ReflectSentNotifications(); | 360 ReflectSentNotifications(); |
| 363 EXPECT_EQ(5, fake_handler_.GetNotificationCount()); | 361 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); |
| 364 EXPECT_THAT( | 362 EXPECT_THAT( |
| 365 expected_ids, | 363 expected_ids, |
| 366 Eq(fake_handler_.GetLastNotificationIdStateMap())); | 364 Eq(fake_handler_.GetLastInvalidationIdStateMap())); |
| 367 | 365 |
| 368 // Should be dropped. | 366 // Should be dropped. |
| 369 invalidator->SendNotificationDataForTest( | 367 invalidator->SendNotificationDataForTest( |
| 370 P2PNotificationData("sender2", NOTIFY_ALL, | 368 P2PNotificationData("sender2", NOTIFY_ALL, |
| 371 ObjectIdStateMap(), REMOTE_NOTIFICATION)); | 369 ObjectIdStateMap(), REMOTE_INVALIDATION)); |
| 372 ReflectSentNotifications(); | 370 ReflectSentNotifications(); |
| 373 EXPECT_EQ(5, fake_handler_.GetNotificationCount()); | 371 EXPECT_EQ(5, fake_handler_.GetInvalidationCount()); |
| 374 } | 372 } |
| 375 | 373 |
| 376 INSTANTIATE_TYPED_TEST_CASE_P( | 374 INSTANTIATE_TYPED_TEST_CASE_P( |
| 377 P2PInvalidatorTest, InvalidatorTest, | 375 P2PInvalidatorTest, InvalidatorTest, |
| 378 P2PInvalidatorTestDelegate); | 376 P2PInvalidatorTestDelegate); |
| 379 | 377 |
| 380 } // namespace | 378 } // namespace |
| 381 | 379 |
| 382 } // namespace syncer | 380 } // namespace syncer |
| OLD | NEW |