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