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

Unified Diff: sync/notifier/p2p_notifier_unittest.cc

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FOR_THE_HORDE 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 side-by-side diff with in-line comments
Download patch
Index: sync/notifier/p2p_notifier_unittest.cc
diff --git a/sync/notifier/p2p_notifier_unittest.cc b/sync/notifier/p2p_notifier_unittest.cc
index e6e406a2d74acfd34738252785d1719c78b16578..2f7b2c922880ca0ce4d7478aec59a9e87a07c7bc 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"
@@ -27,15 +28,14 @@ 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_);
}
virtual ~P2PNotifierTest() {
- p2p_notifier_.RemoveObserver(&mock_observer_);
+ p2p_notifier_.UpdateRegisteredIds(&mock_observer_, ObjectIdSet());
}
ModelTypePayloadMap MakePayloadMap(ModelTypeSet types) {
- return ModelTypePayloadMapFromEnumSet(types, "");
+ return ModelTypePayloadMapFromEnumSet(types, std::string());
}
// Simulate receiving all the notifications we sent out since last
@@ -142,10 +142,13 @@ TEST_F(P2PNotifierTest, P2PNotificationDataNonDefault) {
TEST_F(P2PNotifierTest, NotificationsBasic) {
ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
+ p2p_notifier_.UpdateRegisteredIds(&mock_observer_,
+ ModelTypeSetToObjectIdSet(enabled_types));
+
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 +166,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 +185,24 @@ TEST_F(P2PNotifierTest, NotificationsBasic) {
TEST_F(P2PNotifierTest, SendNotificationData) {
ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
- ModelTypeSet changed_types(THEMES, APPS);
+ p2p_notifier_.UpdateRegisteredIds(&mock_observer_,
+ ModelTypeSetToObjectIdSet(enabled_types));
+
+ ModelTypeSet changed_types(BOOKMARKS, APPS);
+ ModelTypeSet expected_changed_types(BOOKMARKS);
- const ModelTypePayloadMap& changed_payload_map =
- MakePayloadMap(changed_types);
+ const 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 +217,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 +247,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 +264,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 +274,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));

Powered by Google App Engine
This is Rietveld 408576698