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