| Index: sync/notifier/p2p_notifier_unittest.cc
|
| diff --git a/sync/notifier/p2p_notifier_unittest.cc b/sync/notifier/p2p_notifier_unittest.cc
|
| index 28a73c938ad117acfcd253e77031f4a44683ca19..1f3674f04dbdd2eb4f408e2a3aeea44dcdbdc9a3 100644
|
| --- a/sync/notifier/p2p_notifier_unittest.cc
|
| +++ b/sync/notifier/p2p_notifier_unittest.cc
|
| @@ -20,6 +20,8 @@ using ::testing::_;
|
| using ::testing::Mock;
|
| using ::testing::StrictMock;
|
|
|
| +const char kHandlerName[] = "MockObserver";
|
| +
|
| class P2PNotifierTest : public testing::Test {
|
| protected:
|
| P2PNotifierTest()
|
| @@ -27,11 +29,10 @@ class P2PNotifierTest : public testing::Test {
|
| p2p_notifier_(
|
| scoped_ptr<notifier::PushClient>(fake_push_client_),
|
| NOTIFY_OTHERS),
|
| - next_sent_notification_to_reflect_(0) {
|
| - }
|
| + next_sent_notification_to_reflect_(0) {}
|
|
|
| virtual ~P2PNotifierTest() {
|
| - p2p_notifier_.UpdateRegisteredIds(&mock_observer_, ObjectIdSet());
|
| + p2p_notifier_.SetHandler(kHandlerName, NULL);
|
| }
|
|
|
| ModelTypePayloadMap MakePayloadMap(ModelTypeSet types) {
|
| @@ -140,16 +141,17 @@ TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) {
|
| // observer should receive only a notification from the call to
|
| // UpdateEnabledTypes().
|
| TEST_F(P2PNotifierTest, NotificationsBasic) {
|
| - ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
|
| -
|
| - p2p_notifier_.UpdateRegisteredIds(&mock_observer_,
|
| - ModelTypeSetToObjectIdSet(enabled_types));
|
| + const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
|
|
|
| EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
|
| EXPECT_CALL(mock_observer_, OnIncomingNotification(
|
| ModelTypePayloadMapToObjectIdPayloadMap(MakePayloadMap(enabled_types)),
|
| REMOTE_NOTIFICATION));
|
|
|
| + p2p_notifier_.SetHandler(kHandlerName, &mock_observer_);
|
| + p2p_notifier_.UpdateRegisteredIds(kHandlerName,
|
| + ModelTypeSetToObjectIdSet(enabled_types));
|
| +
|
| p2p_notifier_.SetUniqueId("sender");
|
|
|
| const char kEmail[] = "foo@bar.com";
|
| @@ -183,15 +185,9 @@ TEST_F(P2PNotifierTest, NotificationsBasic) {
|
| // target settings. The notifications received by the observer should
|
| // be consistent with the target settings.
|
| TEST_F(P2PNotifierTest, SendNotificationData) {
|
| - ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
|
| - ModelTypeSet changed_types(THEMES, APPS);
|
| - ModelTypeSet expected_types(THEMES);
|
| -
|
| - p2p_notifier_.UpdateRegisteredIds(&mock_observer_,
|
| - ModelTypeSetToObjectIdSet(enabled_types));
|
| -
|
| - const ModelTypePayloadMap& expected_payload_map =
|
| - MakePayloadMap(expected_types);
|
| + const ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
|
| + const ModelTypeSet changed_types(THEMES, APPS);
|
| + const ModelTypeSet expected_types(THEMES);
|
|
|
| EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
|
| EXPECT_CALL(mock_observer_,
|
| @@ -200,6 +196,13 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
|
| MakePayloadMap(enabled_types)),
|
| REMOTE_NOTIFICATION));
|
|
|
| + p2p_notifier_.SetHandler(kHandlerName, &mock_observer_);
|
| + p2p_notifier_.UpdateRegisteredIds(kHandlerName,
|
| + ModelTypeSetToObjectIdSet(enabled_types));
|
| +
|
| + const ModelTypePayloadMap& expected_payload_map =
|
| + MakePayloadMap(expected_types);
|
| +
|
| p2p_notifier_.SetUniqueId("sender");
|
| p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token");
|
|
|
|
|