Index: sync/notifier/p2p_notifier_unittest.cc |
diff --git a/sync/notifier/p2p_notifier_unittest.cc b/sync/notifier/p2p_notifier_unittest.cc |
index a219824c5e6e5013791e14e680c3d8bdf0133390..2a295e203eb355a72dd0673db3a0e6865f60413c 100644 |
--- a/sync/notifier/p2p_notifier_unittest.cc |
+++ b/sync/notifier/p2p_notifier_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "jingle/notifier/listener/fake_push_client.h" |
#include "sync/internal_api/public/base/model_type.h" |
+#include "sync/internal_api/public/base/model_type_payload_map.h" |
#include "sync/notifier/mock_sync_notifier_observer.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -17,6 +18,7 @@ namespace { |
using ::testing::_; |
using ::testing::Mock; |
+using ::testing::Return; |
using ::testing::StrictMock; |
class P2PNotifierTest : public testing::Test { |
@@ -27,11 +29,11 @@ class P2PNotifierTest : public testing::Test { |
scoped_ptr<notifier::PushClient>(fake_push_client_), |
NOTIFY_OTHERS), |
next_sent_notification_to_reflect_(0) { |
- p2p_notifier_.AddObserver(&mock_observer_); |
+ p2p_notifier_.AddHandler(&mock_observer_); |
} |
virtual ~P2PNotifierTest() { |
- p2p_notifier_.RemoveObserver(&mock_observer_); |
+ p2p_notifier_.RemoveHandler(&mock_observer_); |
} |
syncer::ModelTypePayloadMap MakePayloadMap(syncer::ModelTypeSet types) { |
@@ -142,10 +144,14 @@ TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) { |
TEST_F(P2PNotifierTest, NotificationsBasic) { |
syncer::ModelTypeSet enabled_types(syncer::BOOKMARKS, syncer::PREFERENCES); |
+ EXPECT_CALL(mock_observer_, GetHandledIds()) |
+ .WillOnce(Return(ModelTypeSetToObjectIdSet(enabled_types))); |
+ p2p_notifier_.ReloadHandlers(); |
+ |
EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
- EXPECT_CALL(mock_observer_, |
- OnIncomingNotification(MakePayloadMap(enabled_types), |
- REMOTE_NOTIFICATION)); |
+ EXPECT_CALL(mock_observer_, OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(MakePayloadMap(enabled_types)), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SetUniqueId("sender"); |
@@ -163,8 +169,6 @@ TEST_F(P2PNotifierTest, NotificationsBasic) { |
EXPECT_EQ(kEmail, fake_push_client_->email()); |
EXPECT_EQ(kToken, fake_push_client_->token()); |
- p2p_notifier_.UpdateEnabledTypes(enabled_types); |
- |
ReflectSentNotifications(); |
fake_push_client_->EnableNotifications(); |
@@ -184,19 +188,25 @@ TEST_F(P2PNotifierTest, NotificationsBasic) { |
TEST_F(P2PNotifierTest, SendNotificationData) { |
syncer::ModelTypeSet enabled_types(syncer::BOOKMARKS, syncer::PREFERENCES); |
- syncer::ModelTypeSet changed_types(syncer::THEMES, syncer::APPS); |
+ EXPECT_CALL(mock_observer_, GetHandledIds()) |
+ .WillOnce(Return(ModelTypeSetToObjectIdSet(enabled_types))); |
+ p2p_notifier_.ReloadHandlers(); |
+ |
+ syncer::ModelTypeSet changed_types(syncer::BOOKMARKS, syncer::APPS); |
+ syncer::ModelTypeSet expected_changed_types(syncer::BOOKMARKS); |
- const syncer::ModelTypePayloadMap& changed_payload_map = |
- MakePayloadMap(changed_types); |
+ const syncer::ModelTypePayloadMap& expected_changed_payload_map = |
+ MakePayloadMap(expected_changed_types); |
EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
EXPECT_CALL(mock_observer_, |
- OnIncomingNotification(MakePayloadMap(enabled_types), |
- REMOTE_NOTIFICATION)); |
+ OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap( |
+ MakePayloadMap(enabled_types)), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SetUniqueId("sender"); |
p2p_notifier_.UpdateCredentials("foo@bar.com", "fake_token"); |
- p2p_notifier_.UpdateEnabledTypes(enabled_types); |
ReflectSentNotifications(); |
fake_push_client_->EnableNotifications(); |
@@ -211,8 +221,9 @@ TEST_F(P2PNotifierTest, SendNotificationData) { |
// Should be propagated. |
Mock::VerifyAndClearExpectations(&mock_observer_); |
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, |
- REMOTE_NOTIFICATION)); |
+ EXPECT_CALL(mock_observer_, OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(expected_changed_payload_map), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SendNotificationDataForTest( |
P2PNotificationData("sender", NOTIFY_SELF, changed_types)); |
@@ -240,8 +251,9 @@ TEST_F(P2PNotifierTest, SendNotificationData) { |
// Should be propagated. |
Mock::VerifyAndClearExpectations(&mock_observer_); |
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, |
- REMOTE_NOTIFICATION)); |
+ EXPECT_CALL(mock_observer_, OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(expected_changed_payload_map), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SendNotificationDataForTest( |
P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types)); |
@@ -256,8 +268,9 @@ TEST_F(P2PNotifierTest, SendNotificationData) { |
// Should be propagated. |
Mock::VerifyAndClearExpectations(&mock_observer_); |
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, |
- REMOTE_NOTIFICATION)); |
+ EXPECT_CALL(mock_observer_, OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(expected_changed_payload_map), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SendNotificationDataForTest( |
P2PNotificationData("sender", NOTIFY_ALL, changed_types)); |
@@ -265,8 +278,9 @@ TEST_F(P2PNotifierTest, SendNotificationData) { |
// Should be propagated. |
Mock::VerifyAndClearExpectations(&mock_observer_); |
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map, |
- REMOTE_NOTIFICATION)); |
+ EXPECT_CALL(mock_observer_, OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(expected_changed_payload_map), |
+ REMOTE_NOTIFICATION)); |
p2p_notifier_.SendNotificationDataForTest( |
P2PNotificationData("sender2", NOTIFY_ALL, changed_types)); |