Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Side by Side Diff: sync/notifier/p2p_notifier_unittest.cc

Issue 10833004: [Sync] Make P2PNotifier emit a notification only if some enabled types changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed MC_DeleteBookmarks Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/notifier/p2p_notifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 p2p_notifier_.SendNotification(changed_types); 175 p2p_notifier_.SendNotification(changed_types);
176 } 176 }
177 177
178 ReflectSentNotifications(); 178 ReflectSentNotifications();
179 } 179 }
180 180
181 // Set up the P2PNotifier and send out notifications with various 181 // Set up the P2PNotifier and send out notifications with various
182 // target settings. The notifications received by the observer should 182 // target settings. The notifications received by the observer should
183 // be consistent with the target settings. 183 // be consistent with the target settings.
184 TEST_F(P2PNotifierTest, SendNotificationData) { 184 TEST_F(P2PNotifierTest, SendNotificationData) {
185 ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES); 185 ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
186 ModelTypeSet changed_types(THEMES, APPS);
187 ModelTypeSet expected_types(THEMES);
186 188
187 ModelTypeSet changed_types(THEMES, APPS); 189 const ModelTypePayloadMap& expected_payload_map =
188 190 MakePayloadMap(expected_types);
189 const ModelTypePayloadMap& changed_payload_map =
190 MakePayloadMap(changed_types);
191 191
192 EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); 192 EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
193 EXPECT_CALL(mock_observer_, 193 EXPECT_CALL(mock_observer_,
194 OnIncomingNotification(MakePayloadMap(enabled_types), 194 OnIncomingNotification(MakePayloadMap(enabled_types),
195 REMOTE_NOTIFICATION)); 195 REMOTE_NOTIFICATION));
196 196
197 p2p_notifier_.SetUniqueId("sender"); 197 p2p_notifier_.SetUniqueId("sender");
198 p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token"); 198 p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token");
199 p2p_notifier_.UpdateEnabledTypes(enabled_types); 199 p2p_notifier_.UpdateEnabledTypes(enabled_types);
200 200
201 ReflectSentNotifications(); 201 ReflectSentNotifications();
202 fake_push_client_->EnableNotifications(); 202 fake_push_client_->EnableNotifications();
203 203
204 ReflectSentNotifications(); 204 ReflectSentNotifications();
205 205
206 // Should be dropped. 206 // Should be dropped.
207 Mock::VerifyAndClearExpectations(&mock_observer_); 207 Mock::VerifyAndClearExpectations(&mock_observer_);
208 p2p_notifier_.SendNotificationDataForTest(P2PNotificationData()); 208 p2p_notifier_.SendNotificationDataForTest(P2PNotificationData());
209 209
210 ReflectSentNotifications(); 210 ReflectSentNotifications();
211 211
212 // Should be propagated. 212 // Should be propagated.
213 Mock::VerifyAndClearExpectations(&mock_observer_); 213 Mock::VerifyAndClearExpectations(&mock_observer_);
214 EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, 214 EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
215 REMOTE_NOTIFICATION)); 215 REMOTE_NOTIFICATION));
216 p2p_notifier_.SendNotificationDataForTest( 216 p2p_notifier_.SendNotificationDataForTest(
217 P2PNotificationData("sender", NOTIFY_SELF, changed_types)); 217 P2PNotificationData("sender", NOTIFY_SELF, changed_types));
218 218
219 ReflectSentNotifications(); 219 ReflectSentNotifications();
220 220
221 // Should be dropped. 221 // Should be dropped.
222 Mock::VerifyAndClearExpectations(&mock_observer_); 222 Mock::VerifyAndClearExpectations(&mock_observer_);
223 p2p_notifier_.SendNotificationDataForTest( 223 p2p_notifier_.SendNotificationDataForTest(
224 P2PNotificationData("sender2", NOTIFY_SELF, changed_types)); 224 P2PNotificationData("sender2", NOTIFY_SELF, changed_types));
225 225
226 ReflectSentNotifications(); 226 ReflectSentNotifications();
227 227
228 // Should be dropped. 228 // Should be dropped.
229 Mock::VerifyAndClearExpectations(&mock_observer_); 229 Mock::VerifyAndClearExpectations(&mock_observer_);
230 p2p_notifier_.SendNotificationDataForTest( 230 p2p_notifier_.SendNotificationDataForTest(
231 P2PNotificationData("sender", NOTIFY_SELF, ModelTypeSet())); 231 P2PNotificationData("sender", NOTIFY_SELF, ModelTypeSet()));
232 232
233 ReflectSentNotifications(); 233 ReflectSentNotifications();
234 234
235 // Should be dropped. 235 // Should be dropped.
236 p2p_notifier_.SendNotificationDataForTest( 236 p2p_notifier_.SendNotificationDataForTest(
237 P2PNotificationData("sender", NOTIFY_OTHERS, changed_types)); 237 P2PNotificationData("sender", NOTIFY_OTHERS, changed_types));
238 238
239 ReflectSentNotifications(); 239 ReflectSentNotifications();
240 240
241 // Should be propagated. 241 // Should be propagated.
242 Mock::VerifyAndClearExpectations(&mock_observer_); 242 Mock::VerifyAndClearExpectations(&mock_observer_);
243 EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, 243 EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
244 REMOTE_NOTIFICATION)); 244 REMOTE_NOTIFICATION));
245 p2p_notifier_.SendNotificationDataForTest( 245 p2p_notifier_.SendNotificationDataForTest(
246 P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types)); 246 P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types));
247 247
248 ReflectSentNotifications(); 248 ReflectSentNotifications();
249 249
250 // Should be dropped. 250 // Should be dropped.
251 Mock::VerifyAndClearExpectations(&mock_observer_); 251 Mock::VerifyAndClearExpectations(&mock_observer_);
252 p2p_notifier_.SendNotificationDataForTest( 252 p2p_notifier_.SendNotificationDataForTest(
253 P2PNotificationData("sender2", NOTIFY_OTHERS, ModelTypeSet())); 253 P2PNotificationData("sender2", NOTIFY_OTHERS, ModelTypeSet()));
254 254
255 ReflectSentNotifications(); 255 ReflectSentNotifications();
256 256
257 // Should be propagated. 257 // Should be propagated.
258 Mock::VerifyAndClearExpectations(&mock_observer_); 258 Mock::VerifyAndClearExpectations(&mock_observer_);
259 EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, 259 EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
260 REMOTE_NOTIFICATION)); 260 REMOTE_NOTIFICATION));
261 p2p_notifier_.SendNotificationDataForTest( 261 p2p_notifier_.SendNotificationDataForTest(
262 P2PNotificationData("sender", NOTIFY_ALL, changed_types)); 262 P2PNotificationData("sender", NOTIFY_ALL, changed_types));
263 263
264 ReflectSentNotifications(); 264 ReflectSentNotifications();
265 265
266 // Should be propagated. 266 // Should be propagated.
267 Mock::VerifyAndClearExpectations(&mock_observer_); 267 Mock::VerifyAndClearExpectations(&mock_observer_);
268 EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, 268 EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
269 REMOTE_NOTIFICATION)); 269 REMOTE_NOTIFICATION));
270 p2p_notifier_.SendNotificationDataForTest( 270 p2p_notifier_.SendNotificationDataForTest(
271 P2PNotificationData("sender2", NOTIFY_ALL, changed_types)); 271 P2PNotificationData("sender2", NOTIFY_ALL, changed_types));
272 272
273 ReflectSentNotifications(); 273 ReflectSentNotifications();
274 274
275 // Should be dropped. 275 // Should be dropped.
276 Mock::VerifyAndClearExpectations(&mock_observer_); 276 Mock::VerifyAndClearExpectations(&mock_observer_);
277 p2p_notifier_.SendNotificationDataForTest( 277 p2p_notifier_.SendNotificationDataForTest(
278 P2PNotificationData("sender2", NOTIFY_ALL, ModelTypeSet())); 278 P2PNotificationData("sender2", NOTIFY_ALL, ModelTypeSet()));
279 279
280 ReflectSentNotifications(); 280 ReflectSentNotifications();
281 } 281 }
282 282
283 } // namespace 283 } // namespace
284 284
285 } // namespace syncer 285 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/p2p_notifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698