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