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

Unified Diff: sync/notifier/sync_notifier_registrar_unittest.cc

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 4 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
« no previous file with comments | « sync/notifier/sync_notifier_registrar.cc ('k') | sync/sessions/session_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/sync_notifier_registrar_unittest.cc
diff --git a/sync/notifier/sync_notifier_registrar_unittest.cc b/sync/notifier/sync_notifier_registrar_unittest.cc
index e8c1b408d048306f4fb3987c79457396d7d3ea79..f78ebc9749259bd26ed48249018eb661021ef0f4 100644
--- a/sync/notifier/sync_notifier_registrar_unittest.cc
+++ b/sync/notifier/sync_notifier_registrar_unittest.cc
@@ -4,6 +4,7 @@
#include "google/cacheinvalidation/types.pb.h"
#include "sync/notifier/mock_sync_notifier_observer.h"
+#include "sync/notifier/object_id_state_map_test_util.h"
#include "sync/notifier/sync_notifier_registrar.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -40,13 +41,13 @@ TEST_F(SyncNotifierRegistrarTest, Basic) {
registrar.RegisterHandler(&handler);
- ObjectIdPayloadMap payloads;
- payloads[kObjectId1] = "1";
- payloads[kObjectId2] = "2";
- payloads[kObjectId3] = "3";
+ ObjectIdStateMap states;
+ states[kObjectId1].payload = "1";
+ states[kObjectId2].payload = "2";
+ states[kObjectId3].payload = "3";
// Should be ignored since no IDs are registered to |handler|.
- registrar.DispatchInvalidationsToHandlers(payloads, REMOTE_NOTIFICATION);
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
Mock::VerifyAndClearExpectations(&handler);
@@ -56,14 +57,14 @@ TEST_F(SyncNotifierRegistrarTest, Basic) {
registrar.UpdateRegisteredIds(&handler, ids);
{
- ObjectIdPayloadMap expected_payloads;
- expected_payloads[kObjectId1] = "1";
- expected_payloads[kObjectId2] = "2";
- EXPECT_CALL(handler, OnIncomingNotification(expected_payloads,
- REMOTE_NOTIFICATION));
+ ObjectIdStateMap expected_states;
+ expected_states[kObjectId1].payload = "1";
+ expected_states[kObjectId2].payload = "2";
+ EXPECT_CALL(handler, OnIncomingNotification(
+ expected_states, REMOTE_NOTIFICATION));
}
- registrar.DispatchInvalidationsToHandlers(payloads, REMOTE_NOTIFICATION);
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
Mock::VerifyAndClearExpectations(&handler);
@@ -72,22 +73,22 @@ TEST_F(SyncNotifierRegistrarTest, Basic) {
registrar.UpdateRegisteredIds(&handler, ids);
{
- ObjectIdPayloadMap expected_payloads;
- expected_payloads[kObjectId2] = "2";
- expected_payloads[kObjectId3] = "3";
- EXPECT_CALL(handler, OnIncomingNotification(expected_payloads,
- REMOTE_NOTIFICATION));
+ ObjectIdStateMap expected_states;
+ expected_states[kObjectId2].payload = "2";
+ expected_states[kObjectId3].payload = "3";
+ EXPECT_CALL(handler, OnIncomingNotification(
+ expected_states, REMOTE_NOTIFICATION));
}
// Removed object IDs should not be notified, newly-added ones should.
- registrar.DispatchInvalidationsToHandlers(payloads, REMOTE_NOTIFICATION);
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
Mock::VerifyAndClearExpectations(&handler);
registrar.UnregisterHandler(&handler);
// Should be ignored since |handler| isn't registered anymore.
- registrar.DispatchInvalidationsToHandlers(payloads, REMOTE_NOTIFICATION);
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
}
// Register handlers and some IDs for those handlers, register a handler with
@@ -99,11 +100,11 @@ TEST_F(SyncNotifierRegistrarTest, MultipleHandlers) {
StrictMock<MockSyncNotifierObserver> handler1;
EXPECT_CALL(handler1, OnNotificationsEnabled());
{
- ObjectIdPayloadMap expected_payloads;
- expected_payloads[kObjectId1] = "1";
- expected_payloads[kObjectId2] = "2";
- EXPECT_CALL(handler1, OnIncomingNotification(expected_payloads,
- REMOTE_NOTIFICATION));
+ ObjectIdStateMap expected_states;
+ expected_states[kObjectId1].payload = "1";
+ expected_states[kObjectId2].payload = "2";
+ EXPECT_CALL(handler1, OnIncomingNotification(
+ expected_states, REMOTE_NOTIFICATION));
}
EXPECT_CALL(handler1,
OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
@@ -111,10 +112,10 @@ TEST_F(SyncNotifierRegistrarTest, MultipleHandlers) {
StrictMock<MockSyncNotifierObserver> handler2;
EXPECT_CALL(handler2, OnNotificationsEnabled());
{
- ObjectIdPayloadMap expected_payloads;
- expected_payloads[kObjectId3] = "3";
- EXPECT_CALL(handler2, OnIncomingNotification(expected_payloads,
- REMOTE_NOTIFICATION));
+ ObjectIdStateMap expected_states;
+ expected_states[kObjectId3].payload = "3";
+ EXPECT_CALL(handler2, OnIncomingNotification(
+ expected_states, REMOTE_NOTIFICATION));
}
EXPECT_CALL(handler2,
OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
@@ -158,12 +159,12 @@ TEST_F(SyncNotifierRegistrarTest, MultipleHandlers) {
registrar.EmitOnNotificationsEnabled();
{
- ObjectIdPayloadMap payloads;
- payloads[kObjectId1] = "1";
- payloads[kObjectId2] = "2";
- payloads[kObjectId3] = "3";
- payloads[kObjectId4] = "4";
- registrar.DispatchInvalidationsToHandlers(payloads, REMOTE_NOTIFICATION);
+ ObjectIdStateMap states;
+ states[kObjectId1].payload = "1";
+ states[kObjectId2].payload = "2";
+ states[kObjectId3].payload = "3";
+ states[kObjectId4].payload = "4";
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
}
registrar.EmitOnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR);
}
@@ -202,10 +203,10 @@ TEST_F(SyncNotifierRegistrarTest, EmptySetUnregisters) {
StrictMock<MockSyncNotifierObserver> handler2;
EXPECT_CALL(handler2, OnNotificationsEnabled());
{
- ObjectIdPayloadMap expected_payloads;
- expected_payloads[kObjectId3] = "3";
- EXPECT_CALL(handler2, OnIncomingNotification(expected_payloads,
- REMOTE_NOTIFICATION));
+ ObjectIdStateMap expected_states;
+ expected_states[kObjectId3].payload = "3";
+ EXPECT_CALL(handler2, OnIncomingNotification(
+ expected_states, REMOTE_NOTIFICATION));
}
EXPECT_CALL(handler2,
OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
@@ -234,12 +235,11 @@ TEST_F(SyncNotifierRegistrarTest, EmptySetUnregisters) {
registrar.EmitOnNotificationsEnabled();
{
- ObjectIdPayloadMap payloads;
- payloads[kObjectId1] = "1";
- payloads[kObjectId2] = "2";
- payloads[kObjectId3] = "3";
- registrar.DispatchInvalidationsToHandlers(payloads,
- REMOTE_NOTIFICATION);
+ ObjectIdStateMap states;
+ states[kObjectId1].payload = "1";
+ states[kObjectId2].payload = "2";
+ states[kObjectId3].payload = "3";
+ registrar.DispatchInvalidationsToHandlers(states, REMOTE_NOTIFICATION);
}
registrar.EmitOnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR);
}
« no previous file with comments | « sync/notifier/sync_notifier_registrar.cc ('k') | sync/sessions/session_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698