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

Unified Diff: sync/engine/sync_scheduler_unittest.cc

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
Index: sync/engine/sync_scheduler_unittest.cc
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
index 2b9ea8733ef0864bffba36e783819a88469618c1..0c6db7a8834d94567a04e8cce7cfd145d470bbdb 100644
--- a/sync/engine/sync_scheduler_unittest.cc
+++ b/sync/engine/sync_scheduler_unittest.cc
@@ -189,13 +189,13 @@ class SyncSchedulerTest : public testing::Test {
scheduler_->delay_provider_.reset(delay_);
}
- // Compare a ModelTypeSet to a ModelTypePayloadMap, ignoring
- // payload values.
- bool CompareModelTypeSetToModelTypePayloadMap(
+ // Compare a ModelTypeSet to a ModelTypeStateMap, ignoring
+ // state values.
+ bool CompareModelTypeSetToModelTypeStateMap(
ModelTypeSet lhs,
- const ModelTypePayloadMap& rhs) {
+ const ModelTypeStateMap& rhs) {
size_t count = 0;
- for (ModelTypePayloadMap::const_iterator i = rhs.begin();
+ for (ModelTypeStateMap::const_iterator i = rhs.begin();
i != rhs.end(); ++i, ++count) {
if (!lhs.Has(i->first))
return false;
@@ -271,7 +271,7 @@ TEST_F(SyncSchedulerTest, Nudge) {
RunLoop();
ASSERT_EQ(1U, records.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records.snapshots[0].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
records.snapshots[0].source().updates_source);
@@ -290,7 +290,7 @@ TEST_F(SyncSchedulerTest, Nudge) {
RunLoop();
ASSERT_EQ(1U, records2.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records2.snapshots[0].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
records2.snapshots[0].source().updates_source);
@@ -318,7 +318,7 @@ TEST_F(SyncSchedulerTest, Config) {
ASSERT_EQ(1, counter.times_called());
ASSERT_EQ(1U, records.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records.snapshots[0].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
records.snapshots[0].source().updates_source);
@@ -355,7 +355,7 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
ASSERT_EQ(2U, records.snapshots.size());
ASSERT_EQ(1, counter.times_called());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records.snapshots[1].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
records.snapshots[1].source().updates_source);
@@ -408,12 +408,12 @@ TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) {
ASSERT_EQ(4U, records.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records.snapshots[2].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
records.snapshots[2].source().updates_source);
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(model_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(model_types,
records.snapshots[3].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
records.snapshots[3].source().updates_source);
@@ -439,7 +439,7 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) {
ASSERT_EQ(1U, r.snapshots.size());
EXPECT_GE(r.times[0], optimal_time);
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(
Union(types1, types2), r.snapshots[0].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
r.snapshots[0].source().updates_source);
@@ -455,7 +455,7 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) {
RunLoop();
ASSERT_EQ(1U, r2.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(types3,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(types3,
r2.snapshots[0].source().types));
EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION,
r2.snapshots[0].source().updates_source);
@@ -487,7 +487,7 @@ TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
// Make sure the sync has happened.
ASSERT_EQ(1U, r.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(
Union(types1, types2), r.snapshots[0].source().types));
// Make sure the sync happened at the right time.
@@ -496,23 +496,23 @@ TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
}
// Test nudge scheduling.
-TEST_F(SyncSchedulerTest, NudgeWithPayloads) {
+TEST_F(SyncSchedulerTest, NudgeWithStates) {
StartSyncScheduler(SyncScheduler::NORMAL_MODE);
SyncShareRecords records;
- ModelTypePayloadMap model_types_with_payloads;
- model_types_with_payloads[BOOKMARKS] = "test";
+ ModelTypeStateMap type_state_map;
+ type_state_map[BOOKMARKS].payload = "test";
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&records))))
.RetiresOnSaturation();
- scheduler()->ScheduleNudgeWithPayloadsAsync(
- zero(), NUDGE_SOURCE_LOCAL, model_types_with_payloads, FROM_HERE);
+ scheduler()->ScheduleNudgeWithStatesAsync(
+ zero(), NUDGE_SOURCE_LOCAL, type_state_map, FROM_HERE);
RunLoop();
ASSERT_EQ(1U, records.snapshots.size());
- EXPECT_EQ(model_types_with_payloads, records.snapshots[0].source().types);
+ EXPECT_EQ(type_state_map, records.snapshots[0].source().types);
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
records.snapshots[0].source().updates_source);
@@ -520,46 +520,46 @@ TEST_F(SyncSchedulerTest, NudgeWithPayloads) {
// Make sure a second, later, nudge is unaffected by first (no coalescing).
SyncShareRecords records2;
- model_types_with_payloads.erase(BOOKMARKS);
- model_types_with_payloads[AUTOFILL] = "test2";
+ type_state_map.erase(BOOKMARKS);
+ type_state_map[AUTOFILL].payload = "test2";
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&records2))));
- scheduler()->ScheduleNudgeWithPayloadsAsync(
- zero(), NUDGE_SOURCE_LOCAL, model_types_with_payloads, FROM_HERE);
+ scheduler()->ScheduleNudgeWithStatesAsync(
+ zero(), NUDGE_SOURCE_LOCAL, type_state_map, FROM_HERE);
RunLoop();
ASSERT_EQ(1U, records2.snapshots.size());
- EXPECT_EQ(model_types_with_payloads, records2.snapshots[0].source().types);
+ EXPECT_EQ(type_state_map, records2.snapshots[0].source().types);
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
records2.snapshots[0].source().updates_source);
}
// Test that nudges are coalesced.
-TEST_F(SyncSchedulerTest, NudgeWithPayloadsCoalescing) {
+TEST_F(SyncSchedulerTest, NudgeWithStatesCoalescing) {
StartSyncScheduler(SyncScheduler::NORMAL_MODE);
SyncShareRecords r;
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&r))));
- ModelTypePayloadMap types1, types2, types3;
- types1[BOOKMARKS] = "test1";
- types2[AUTOFILL] = "test2";
- types3[THEMES] = "test3";
+ ModelTypeStateMap types1, types2, types3;
+ types1[BOOKMARKS].payload = "test1";
+ types2[AUTOFILL].payload = "test2";
+ types3[THEMES].payload = "test3";
TimeDelta delay = zero();
TimeTicks optimal_time = TimeTicks::Now() + delay;
- scheduler()->ScheduleNudgeWithPayloadsAsync(
+ scheduler()->ScheduleNudgeWithStatesAsync(
delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE);
- scheduler()->ScheduleNudgeWithPayloadsAsync(
+ scheduler()->ScheduleNudgeWithStatesAsync(
zero(), NUDGE_SOURCE_LOCAL, types2, FROM_HERE);
RunLoop();
ASSERT_EQ(1U, r.snapshots.size());
EXPECT_GE(r.times[0], optimal_time);
- ModelTypePayloadMap coalesced_types;
- CoalescePayloads(&coalesced_types, types1);
- CoalescePayloads(&coalesced_types, types2);
+ ModelTypeStateMap coalesced_types;
+ CoalesceStates(&coalesced_types, types1);
+ CoalesceStates(&coalesced_types, types2);
EXPECT_EQ(coalesced_types, r.snapshots[0].source().types);
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
r.snapshots[0].source().updates_source);
@@ -570,7 +570,7 @@ TEST_F(SyncSchedulerTest, NudgeWithPayloadsCoalescing) {
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&r2))));
- scheduler()->ScheduleNudgeWithPayloadsAsync(
+ scheduler()->ScheduleNudgeWithStatesAsync(
zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE);
RunLoop();
@@ -786,7 +786,7 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
ASSERT_EQ(1, counter.times_called());
ASSERT_EQ(1U, records.snapshots.size());
- EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(config_types,
+ EXPECT_TRUE(CompareModelTypeSetToModelTypeStateMap(config_types,
records.snapshots[0].source().types));
}

Powered by Google App Engine
This is Rietveld 408576698