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_notifier.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_state_map.h" |
12 #include "sync/notifier/fake_sync_notifier_observer.h" | 12 #include "sync/notifier/fake_invalidation_handler.h" |
13 #include "sync/notifier/object_id_state_map_test_util.h" | 13 #include "sync/notifier/object_id_state_map_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace syncer { | 16 namespace syncer { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class P2PNotifierTest : public testing::Test { | 20 class P2PInvalidatorTest : public testing::Test { |
21 protected: | 21 protected: |
22 P2PNotifierTest() | 22 P2PInvalidatorTest() |
23 : fake_push_client_(new notifier::FakePushClient()), | 23 : fake_push_client_(new notifier::FakePushClient()), |
24 p2p_notifier_( | 24 p2p_notifier_( |
25 scoped_ptr<notifier::PushClient>(fake_push_client_), | 25 scoped_ptr<notifier::PushClient>(fake_push_client_), |
26 NOTIFY_OTHERS), | 26 NOTIFY_OTHERS), |
27 next_sent_notification_to_reflect_(0) { | 27 next_sent_notification_to_reflect_(0) { |
28 p2p_notifier_.RegisterHandler(&fake_observer_); | 28 p2p_notifier_.RegisterHandler(&fake_handler_); |
29 } | 29 } |
30 | 30 |
31 virtual ~P2PNotifierTest() { | 31 virtual ~P2PInvalidatorTest() { |
32 p2p_notifier_.UnregisterHandler(&fake_observer_); | 32 p2p_notifier_.UnregisterHandler(&fake_handler_); |
33 } | 33 } |
34 | 34 |
35 ModelTypeStateMap MakeStateMap(ModelTypeSet types) { | 35 ModelTypeStateMap MakeStateMap(ModelTypeSet types) { |
36 return ModelTypeSetToStateMap(types, std::string()); | 36 return ModelTypeSetToStateMap(types, std::string()); |
37 } | 37 } |
38 | 38 |
39 // Simulate receiving all the notifications we sent out since last | 39 // Simulate receiving all the notifications we sent out since last |
40 // time this was called. | 40 // time this was called. |
41 void ReflectSentNotifications() { | 41 void ReflectSentNotifications() { |
42 const std::vector<notifier::Notification>& sent_notifications = | 42 const std::vector<notifier::Notification>& sent_notifications = |
43 fake_push_client_->sent_notifications(); | 43 fake_push_client_->sent_notifications(); |
44 for(size_t i = next_sent_notification_to_reflect_; | 44 for(size_t i = next_sent_notification_to_reflect_; |
45 i < sent_notifications.size(); ++i) { | 45 i < sent_notifications.size(); ++i) { |
46 p2p_notifier_.OnIncomingNotification(sent_notifications[i]); | 46 p2p_notifier_.OnIncomingNotification(sent_notifications[i]); |
47 } | 47 } |
48 next_sent_notification_to_reflect_ = sent_notifications.size(); | 48 next_sent_notification_to_reflect_ = sent_notifications.size(); |
49 } | 49 } |
50 | 50 |
51 // Owned by |p2p_notifier_|. | 51 // Owned by |p2p_notifier_|. |
52 notifier::FakePushClient* fake_push_client_; | 52 notifier::FakePushClient* fake_push_client_; |
53 P2PNotifier p2p_notifier_; | 53 P2PInvalidator p2p_notifier_; |
54 FakeSyncNotifierObserver fake_observer_; | 54 FakeInvalidationHandler fake_handler_; |
55 | 55 |
56 private: | 56 private: |
57 size_t next_sent_notification_to_reflect_; | 57 size_t next_sent_notification_to_reflect_; |
58 }; | 58 }; |
59 | 59 |
60 // Make sure the P2PNotificationTarget <-> string conversions work. | 60 // Make sure the P2PNotificationTarget <-> string conversions work. |
61 TEST_F(P2PNotifierTest, P2PNotificationTarget) { | 61 TEST_F(P2PInvalidatorTest, P2PNotificationTarget) { |
62 for (int i = FIRST_NOTIFICATION_TARGET; | 62 for (int i = FIRST_NOTIFICATION_TARGET; |
63 i <= LAST_NOTIFICATION_TARGET; ++i) { | 63 i <= LAST_NOTIFICATION_TARGET; ++i) { |
64 P2PNotificationTarget target = static_cast<P2PNotificationTarget>(i); | 64 P2PNotificationTarget target = static_cast<P2PNotificationTarget>(i); |
65 const std::string& target_str = P2PNotificationTargetToString(target); | 65 const std::string& target_str = P2PNotificationTargetToString(target); |
66 EXPECT_FALSE(target_str.empty()); | 66 EXPECT_FALSE(target_str.empty()); |
67 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str)); | 67 EXPECT_EQ(target, P2PNotificationTargetFromString(target_str)); |
68 } | 68 } |
69 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown")); | 69 EXPECT_EQ(NOTIFY_SELF, P2PNotificationTargetFromString("unknown")); |
70 } | 70 } |
71 | 71 |
72 // Make sure notification targeting works correctly. | 72 // Make sure notification targeting works correctly. |
73 TEST_F(P2PNotifierTest, P2PNotificationDataIsTargeted) { | 73 TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) { |
74 { | 74 { |
75 const P2PNotificationData notification_data( | 75 const P2PNotificationData notification_data( |
76 "sender", NOTIFY_SELF, ModelTypeSet()); | 76 "sender", NOTIFY_SELF, ModelTypeSet()); |
77 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 77 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
78 EXPECT_FALSE(notification_data.IsTargeted("other1")); | 78 EXPECT_FALSE(notification_data.IsTargeted("other1")); |
79 EXPECT_FALSE(notification_data.IsTargeted("other2")); | 79 EXPECT_FALSE(notification_data.IsTargeted("other2")); |
80 } | 80 } |
81 { | 81 { |
82 const P2PNotificationData notification_data( | 82 const P2PNotificationData notification_data( |
83 "sender", NOTIFY_OTHERS, ModelTypeSet()); | 83 "sender", NOTIFY_OTHERS, ModelTypeSet()); |
84 EXPECT_FALSE(notification_data.IsTargeted("sender")); | 84 EXPECT_FALSE(notification_data.IsTargeted("sender")); |
85 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 85 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
86 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 86 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
87 } | 87 } |
88 { | 88 { |
89 const P2PNotificationData notification_data( | 89 const P2PNotificationData notification_data( |
90 "sender", NOTIFY_ALL, ModelTypeSet()); | 90 "sender", NOTIFY_ALL, ModelTypeSet()); |
91 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 91 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
92 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 92 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
93 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 93 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 // Make sure the P2PNotificationData <-> string conversions work for a | 97 // Make sure the P2PNotificationData <-> string conversions work for a |
98 // default-constructed P2PNotificationData. | 98 // default-constructed P2PNotificationData. |
99 TEST_F(P2PNotifierTest, P2PNotificationDataDefault) { | 99 TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) { |
100 const P2PNotificationData notification_data; | 100 const P2PNotificationData notification_data; |
101 EXPECT_TRUE(notification_data.IsTargeted("")); | 101 EXPECT_TRUE(notification_data.IsTargeted("")); |
102 EXPECT_FALSE(notification_data.IsTargeted("other1")); | 102 EXPECT_FALSE(notification_data.IsTargeted("other1")); |
103 EXPECT_FALSE(notification_data.IsTargeted("other2")); | 103 EXPECT_FALSE(notification_data.IsTargeted("other2")); |
104 EXPECT_TRUE(notification_data.GetChangedTypes().Empty()); | 104 EXPECT_TRUE(notification_data.GetChangedTypes().Empty()); |
105 const std::string& notification_data_str = notification_data.ToString(); | 105 const std::string& notification_data_str = notification_data.ToString(); |
106 EXPECT_EQ( | 106 EXPECT_EQ( |
107 "{\"changedTypes\":[],\"notificationType\":\"notifySelf\"," | 107 "{\"changedTypes\":[],\"notificationType\":\"notifySelf\"," |
108 "\"senderId\":\"\"}", notification_data_str); | 108 "\"senderId\":\"\"}", notification_data_str); |
109 | 109 |
110 P2PNotificationData notification_data_parsed; | 110 P2PNotificationData notification_data_parsed; |
111 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); | 111 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); |
112 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); | 112 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); |
113 } | 113 } |
114 | 114 |
115 // Make sure the P2PNotificationData <-> string conversions work for a | 115 // Make sure the P2PNotificationData <-> string conversions work for a |
116 // non-default-constructed P2PNotificationData. | 116 // non-default-constructed P2PNotificationData. |
117 TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) { | 117 TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) { |
118 const ModelTypeSet changed_types(BOOKMARKS, THEMES); | 118 const ModelTypeSet changed_types(BOOKMARKS, THEMES); |
119 const P2PNotificationData notification_data( | 119 const P2PNotificationData notification_data( |
120 "sender", NOTIFY_ALL, changed_types); | 120 "sender", NOTIFY_ALL, changed_types); |
121 EXPECT_TRUE(notification_data.IsTargeted("sender")); | 121 EXPECT_TRUE(notification_data.IsTargeted("sender")); |
122 EXPECT_TRUE(notification_data.IsTargeted("other1")); | 122 EXPECT_TRUE(notification_data.IsTargeted("other1")); |
123 EXPECT_TRUE(notification_data.IsTargeted("other2")); | 123 EXPECT_TRUE(notification_data.IsTargeted("other2")); |
124 EXPECT_TRUE(notification_data.GetChangedTypes().Equals(changed_types)); | 124 EXPECT_TRUE(notification_data.GetChangedTypes().Equals(changed_types)); |
125 const std::string& notification_data_str = notification_data.ToString(); | 125 const std::string& notification_data_str = notification_data.ToString(); |
126 EXPECT_EQ( | 126 EXPECT_EQ( |
127 "{\"changedTypes\":[\"Bookmarks\",\"Themes\"]," | 127 "{\"changedTypes\":[\"Bookmarks\",\"Themes\"]," |
128 "\"notificationType\":\"notifyAll\"," | 128 "\"notificationType\":\"notifyAll\"," |
129 "\"senderId\":\"sender\"}", notification_data_str); | 129 "\"senderId\":\"sender\"}", notification_data_str); |
130 | 130 |
131 P2PNotificationData notification_data_parsed; | 131 P2PNotificationData notification_data_parsed; |
132 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); | 132 EXPECT_TRUE(notification_data_parsed.ResetFromString(notification_data_str)); |
133 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); | 133 EXPECT_TRUE(notification_data.Equals(notification_data_parsed)); |
134 } | 134 } |
135 | 135 |
136 // Set up the P2PNotifier, simulate a successful connection, and send | 136 // Set up the P2PInvalidator, simulate a successful connection, and send |
137 // a notification with the default target (NOTIFY_OTHERS). The | 137 // a notification with the default target (NOTIFY_OTHERS). The |
138 // observer should receive only a notification from the call to | 138 // observer should receive only a notification from the call to |
139 // UpdateEnabledTypes(). | 139 // UpdateEnabledTypes(). |
140 TEST_F(P2PNotifierTest, NotificationsBasic) { | 140 TEST_F(P2PInvalidatorTest, NotificationsBasic) { |
141 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES); | 141 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES); |
142 | 142 |
143 p2p_notifier_.UpdateRegisteredIds(&fake_observer_, | 143 p2p_notifier_.UpdateRegisteredIds(&fake_handler_, |
144 ModelTypeSetToObjectIdSet(enabled_types)); | 144 ModelTypeSetToObjectIdSet(enabled_types)); |
145 | 145 |
146 p2p_notifier_.SetUniqueId("sender"); | 146 p2p_notifier_.SetUniqueId("sender"); |
147 | 147 |
148 const char kEmail[] = "foo@bar.com"; | 148 const char kEmail[] = "foo@bar.com"; |
149 const char kToken[] = "token"; | 149 const char kToken[] = "token"; |
150 p2p_notifier_.UpdateCredentials(kEmail, kToken); | 150 p2p_notifier_.UpdateCredentials(kEmail, kToken); |
151 { | 151 { |
152 notifier::Subscription expected_subscription; | 152 notifier::Subscription expected_subscription; |
153 expected_subscription.channel = kSyncP2PNotificationChannel; | 153 expected_subscription.channel = kSyncP2PNotificationChannel; |
154 expected_subscription.from = kEmail; | 154 expected_subscription.from = kEmail; |
155 EXPECT_TRUE(notifier::SubscriptionListsEqual( | 155 EXPECT_TRUE(notifier::SubscriptionListsEqual( |
156 fake_push_client_->subscriptions(), | 156 fake_push_client_->subscriptions(), |
157 notifier::SubscriptionList(1, expected_subscription))); | 157 notifier::SubscriptionList(1, expected_subscription))); |
158 } | 158 } |
159 EXPECT_EQ(kEmail, fake_push_client_->email()); | 159 EXPECT_EQ(kEmail, fake_push_client_->email()); |
160 EXPECT_EQ(kToken, fake_push_client_->token()); | 160 EXPECT_EQ(kToken, fake_push_client_->token()); |
161 | 161 |
162 ReflectSentNotifications(); | 162 ReflectSentNotifications(); |
163 fake_push_client_->EnableNotifications(); | 163 fake_push_client_->EnableNotifications(); |
164 EXPECT_EQ(NO_NOTIFICATION_ERROR, | 164 EXPECT_EQ(NO_NOTIFICATION_ERROR, |
165 fake_observer_.GetNotificationsDisabledReason()); | 165 fake_handler_.GetNotificationsDisabledReason()); |
166 | 166 |
167 ReflectSentNotifications(); | 167 ReflectSentNotifications(); |
168 EXPECT_EQ(1, fake_observer_.GetNotificationCount()); | 168 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); |
169 EXPECT_THAT( | 169 EXPECT_THAT( |
170 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), | 170 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), |
171 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 171 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
172 EXPECT_EQ(REMOTE_NOTIFICATION, fake_observer_.GetLastNotificationSource()); | 172 EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource()); |
173 | 173 |
174 // Sent with target NOTIFY_OTHERS so should not be propagated to | 174 // Sent with target NOTIFY_OTHERS so should not be propagated to |
175 // |fake_observer_|. | 175 // |fake_handler_|. |
176 { | 176 { |
177 ModelTypeSet changed_types(THEMES, APPS); | 177 ModelTypeSet changed_types(THEMES, APPS); |
178 p2p_notifier_.SendNotification(changed_types); | 178 p2p_notifier_.SendNotification(changed_types); |
179 } | 179 } |
180 | 180 |
181 ReflectSentNotifications(); | 181 ReflectSentNotifications(); |
182 EXPECT_EQ(1, fake_observer_.GetNotificationCount()); | 182 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); |
183 } | 183 } |
184 | 184 |
185 // Set up the P2PNotifier and send out notifications with various | 185 // Set up the P2PInvalidator and send out notifications with various |
186 // target settings. The notifications received by the observer should | 186 // target settings. The notifications received by the observer should |
187 // be consistent with the target settings. | 187 // be consistent with the target settings. |
188 TEST_F(P2PNotifierTest, SendNotificationData) { | 188 TEST_F(P2PInvalidatorTest, SendNotificationData) { |
189 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); | 189 const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES); |
190 const ModelTypeSet changed_types(THEMES, APPS); | 190 const ModelTypeSet changed_types(THEMES, APPS); |
191 const ModelTypeSet expected_types(THEMES); | 191 const ModelTypeSet expected_types(THEMES); |
192 | 192 |
193 p2p_notifier_.UpdateRegisteredIds(&fake_observer_, | 193 p2p_notifier_.UpdateRegisteredIds(&fake_handler_, |
194 ModelTypeSetToObjectIdSet(enabled_types)); | 194 ModelTypeSetToObjectIdSet(enabled_types)); |
195 | 195 |
196 p2p_notifier_.SetUniqueId("sender"); | 196 p2p_notifier_.SetUniqueId("sender"); |
197 p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token"); | 197 p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token"); |
198 | 198 |
199 ReflectSentNotifications(); | 199 ReflectSentNotifications(); |
200 fake_push_client_->EnableNotifications(); | 200 fake_push_client_->EnableNotifications(); |
201 EXPECT_EQ(NO_NOTIFICATION_ERROR, | 201 EXPECT_EQ(NO_NOTIFICATION_ERROR, |
202 fake_observer_.GetNotificationsDisabledReason()); | 202 fake_handler_.GetNotificationsDisabledReason()); |
203 | 203 |
204 ReflectSentNotifications(); | 204 ReflectSentNotifications(); |
205 EXPECT_EQ(1, fake_observer_.GetNotificationCount()); | 205 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); |
206 EXPECT_THAT( | 206 EXPECT_THAT( |
207 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), | 207 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(enabled_types)), |
208 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 208 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
209 EXPECT_EQ(REMOTE_NOTIFICATION, fake_observer_.GetLastNotificationSource()); | 209 EXPECT_EQ(REMOTE_NOTIFICATION, fake_handler_.GetLastNotificationSource()); |
210 | 210 |
211 // Should be dropped. | 211 // Should be dropped. |
212 p2p_notifier_.SendNotificationDataForTest(P2PNotificationData()); | 212 p2p_notifier_.SendNotificationDataForTest(P2PNotificationData()); |
213 ReflectSentNotifications(); | 213 ReflectSentNotifications(); |
214 EXPECT_EQ(1, fake_observer_.GetNotificationCount()); | 214 EXPECT_EQ(1, fake_handler_.GetNotificationCount()); |
215 | 215 |
216 const ObjectIdStateMap& expected_ids = | 216 const ObjectIdStateMap& expected_ids = |
217 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types)); | 217 ModelTypeStateMapToObjectIdStateMap(MakeStateMap(expected_types)); |
218 | 218 |
219 // Should be propagated. | 219 // Should be propagated. |
220 p2p_notifier_.SendNotificationDataForTest( | 220 p2p_notifier_.SendNotificationDataForTest( |
221 P2PNotificationData("sender", NOTIFY_SELF, changed_types)); | 221 P2PNotificationData("sender", NOTIFY_SELF, changed_types)); |
222 ReflectSentNotifications(); | 222 ReflectSentNotifications(); |
223 EXPECT_EQ(2, fake_observer_.GetNotificationCount()); | 223 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); |
224 EXPECT_THAT( | 224 EXPECT_THAT( |
225 expected_ids, | 225 expected_ids, |
226 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 226 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
227 | 227 |
228 // Should be dropped. | 228 // Should be dropped. |
229 p2p_notifier_.SendNotificationDataForTest( | 229 p2p_notifier_.SendNotificationDataForTest( |
230 P2PNotificationData("sender2", NOTIFY_SELF, changed_types)); | 230 P2PNotificationData("sender2", NOTIFY_SELF, changed_types)); |
231 ReflectSentNotifications(); | 231 ReflectSentNotifications(); |
232 EXPECT_EQ(2, fake_observer_.GetNotificationCount()); | 232 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); |
233 | 233 |
234 // Should be dropped. | 234 // Should be dropped. |
235 p2p_notifier_.SendNotificationDataForTest( | 235 p2p_notifier_.SendNotificationDataForTest( |
236 P2PNotificationData("sender", NOTIFY_SELF, ModelTypeSet())); | 236 P2PNotificationData("sender", NOTIFY_SELF, ModelTypeSet())); |
237 ReflectSentNotifications(); | 237 ReflectSentNotifications(); |
238 EXPECT_EQ(2, fake_observer_.GetNotificationCount()); | 238 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); |
239 | 239 |
240 // Should be dropped. | 240 // Should be dropped. |
241 p2p_notifier_.SendNotificationDataForTest( | 241 p2p_notifier_.SendNotificationDataForTest( |
242 P2PNotificationData("sender", NOTIFY_OTHERS, changed_types)); | 242 P2PNotificationData("sender", NOTIFY_OTHERS, changed_types)); |
243 ReflectSentNotifications(); | 243 ReflectSentNotifications(); |
244 EXPECT_EQ(2, fake_observer_.GetNotificationCount()); | 244 EXPECT_EQ(2, fake_handler_.GetNotificationCount()); |
245 | 245 |
246 // Should be propagated. | 246 // Should be propagated. |
247 p2p_notifier_.SendNotificationDataForTest( | 247 p2p_notifier_.SendNotificationDataForTest( |
248 P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types)); | 248 P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types)); |
249 ReflectSentNotifications(); | 249 ReflectSentNotifications(); |
250 EXPECT_EQ(3, fake_observer_.GetNotificationCount()); | 250 EXPECT_EQ(3, fake_handler_.GetNotificationCount()); |
251 EXPECT_THAT( | 251 EXPECT_THAT( |
252 expected_ids, | 252 expected_ids, |
253 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 253 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
254 | 254 |
255 // Should be dropped. | 255 // Should be dropped. |
256 p2p_notifier_.SendNotificationDataForTest( | 256 p2p_notifier_.SendNotificationDataForTest( |
257 P2PNotificationData("sender2", NOTIFY_OTHERS, ModelTypeSet())); | 257 P2PNotificationData("sender2", NOTIFY_OTHERS, ModelTypeSet())); |
258 ReflectSentNotifications(); | 258 ReflectSentNotifications(); |
259 EXPECT_EQ(3, fake_observer_.GetNotificationCount()); | 259 EXPECT_EQ(3, fake_handler_.GetNotificationCount()); |
260 | 260 |
261 // Should be propagated. | 261 // Should be propagated. |
262 p2p_notifier_.SendNotificationDataForTest( | 262 p2p_notifier_.SendNotificationDataForTest( |
263 P2PNotificationData("sender", NOTIFY_ALL, changed_types)); | 263 P2PNotificationData("sender", NOTIFY_ALL, changed_types)); |
264 ReflectSentNotifications(); | 264 ReflectSentNotifications(); |
265 EXPECT_EQ(4, fake_observer_.GetNotificationCount()); | 265 EXPECT_EQ(4, fake_handler_.GetNotificationCount()); |
266 EXPECT_THAT( | 266 EXPECT_THAT( |
267 expected_ids, | 267 expected_ids, |
268 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 268 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
269 | 269 |
270 // Should be propagated. | 270 // Should be propagated. |
271 p2p_notifier_.SendNotificationDataForTest( | 271 p2p_notifier_.SendNotificationDataForTest( |
272 P2PNotificationData("sender2", NOTIFY_ALL, changed_types)); | 272 P2PNotificationData("sender2", NOTIFY_ALL, changed_types)); |
273 ReflectSentNotifications(); | 273 ReflectSentNotifications(); |
274 EXPECT_EQ(5, fake_observer_.GetNotificationCount()); | 274 EXPECT_EQ(5, fake_handler_.GetNotificationCount()); |
275 EXPECT_THAT( | 275 EXPECT_THAT( |
276 expected_ids, | 276 expected_ids, |
277 Eq(fake_observer_.GetLastNotificationIdStateMap())); | 277 Eq(fake_handler_.GetLastNotificationIdStateMap())); |
278 | 278 |
279 // Should be dropped. | 279 // Should be dropped. |
280 p2p_notifier_.SendNotificationDataForTest( | 280 p2p_notifier_.SendNotificationDataForTest( |
281 P2PNotificationData("sender2", NOTIFY_ALL, ModelTypeSet())); | 281 P2PNotificationData("sender2", NOTIFY_ALL, ModelTypeSet())); |
282 ReflectSentNotifications(); | 282 ReflectSentNotifications(); |
283 EXPECT_EQ(5, fake_observer_.GetNotificationCount()); | 283 EXPECT_EQ(5, fake_handler_.GetNotificationCount()); |
284 } | 284 } |
285 | 285 |
286 } // namespace | 286 } // namespace |
287 | 287 |
288 } // namespace syncer | 288 } // namespace syncer |
OLD | NEW |