| Index: sync/engine/sync_scheduler_unittest.cc
|
| diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
|
| index 3fb2042fe05b57a50ed09bed6c7eae5fcf8128de..151f76a17e9970da9eee848eabb5e61aa31294a2 100644
|
| --- a/sync/engine/sync_scheduler_unittest.cc
|
| +++ b/sync/engine/sync_scheduler_unittest.cc
|
| @@ -11,7 +11,6 @@
|
| #include "sync/engine/backoff_delay_provider.h"
|
| #include "sync/engine/sync_scheduler_impl.h"
|
| #include "sync/engine/syncer.h"
|
| -#include "sync/internal_api/public/base/model_type_invalidation_map_test_util.h"
|
| #include "sync/sessions/test_util.h"
|
| #include "sync/test/callback_counter.h"
|
| #include "sync/test/engine/fake_model_worker.h"
|
| @@ -26,10 +25,8 @@ using base::TimeTicks;
|
| using testing::_;
|
| using testing::AtLeast;
|
| using testing::DoAll;
|
| -using testing::Eq;
|
| using testing::Invoke;
|
| using testing::Mock;
|
| -using testing::Not;
|
| using testing::Return;
|
| using testing::WithArg;
|
| using testing::WithArgs;
|
| @@ -37,7 +34,6 @@ using testing::WithArgs;
|
| namespace syncer {
|
| using sessions::SyncSession;
|
| using sessions::SyncSessionContext;
|
| -using sessions::SyncSessionSnapshot;
|
| using sync_pb::GetUpdatesCallerInfo;
|
|
|
| class MockSyncer : public Syncer {
|
| @@ -45,15 +41,14 @@ class MockSyncer : public Syncer {
|
| MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet,
|
| const sessions::NudgeTracker&,
|
| sessions::SyncSession*));
|
| - MOCK_METHOD2(ConfigureSyncShare, bool(ModelTypeSet, sessions::SyncSession*));
|
| + MOCK_METHOD3(ConfigureSyncShare,
|
| + bool(ModelTypeSet,
|
| + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource,
|
| + SyncSession*));
|
| MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*));
|
| };
|
|
|
| -// Used when tests want to record syncing activity to examine later.
|
| -struct SyncShareRecords {
|
| - std::vector<TimeTicks> times;
|
| - std::vector<SyncSessionSnapshot> snapshots;
|
| -};
|
| +typedef std::vector<TimeTicks> SyncShareTimes;
|
|
|
| void QuitLoopNow() {
|
| // We use QuitNow() instead of Quit() as the latter may get stalled
|
| @@ -90,22 +85,6 @@ ModelSafeRoutingInfo TypesToRoutingInfo(ModelTypeSet types) {
|
| return routes;
|
| }
|
|
|
| -// Compare a ModelTypeSet to a ModelTypeInvalidationMap, ignoring
|
| -// state values.
|
| -testing::AssertionResult ModelTypeSetMatchesInvalidationMap(
|
| - ModelTypeSet lhs, const ModelTypeInvalidationMap& rhs) {
|
| - ModelTypeSet rhs_set = ModelTypeInvalidationMapToSet(rhs);
|
| -
|
| - if (!rhs_set.Equals(rhs_set)) {
|
| - return testing::AssertionFailure()
|
| - << "ModelTypeSet: " << ModelTypeSetToString(lhs)
|
| - << " does not match ModelTypeInvalidationMap: "
|
| - << ModelTypeSetToString(rhs_set);
|
| - } else {
|
| - return testing::AssertionSuccess();
|
| - }
|
| -}
|
| -
|
| // Convenient to use in tests wishing to analyze SyncShare calls over time.
|
| static const size_t kMinNumSamples = 5;
|
| class SyncSchedulerTest : public testing::Test {
|
| @@ -124,7 +103,7 @@ class SyncSchedulerTest : public testing::Test {
|
|
|
| virtual void SetUp() {
|
| dir_maker_.SetUp();
|
| - syncer_ = new MockSyncer();
|
| + syncer_ = new testing::StrictMock<MockSyncer>();
|
| delay_ = NULL;
|
|
|
| routing_info_[BOOKMARKS] = GROUP_UI;
|
| @@ -179,16 +158,13 @@ class SyncSchedulerTest : public testing::Test {
|
| dir_maker_.TearDown();
|
| }
|
|
|
| - void AnalyzePollRun(const SyncShareRecords& records, size_t min_num_samples,
|
| + void AnalyzePollRun(const SyncShareTimes& times, size_t min_num_samples,
|
| const TimeTicks& optimal_start, const TimeDelta& poll_interval) {
|
| - const std::vector<TimeTicks>& data(records.times);
|
| - EXPECT_GE(data.size(), min_num_samples);
|
| - for (size_t i = 0; i < data.size(); i++) {
|
| + EXPECT_GE(times.size(), min_num_samples);
|
| + for (size_t i = 0; i < times.size(); i++) {
|
| SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
|
| TimeTicks optimal_next_sync = optimal_start + poll_interval * i;
|
| - EXPECT_GE(data[i], optimal_next_sync);
|
| - EXPECT_EQ(GetUpdatesCallerInfo::PERIODIC,
|
| - records.snapshots[i].source().updates_source);
|
| + EXPECT_GE(times[i], optimal_next_sync);
|
| }
|
| }
|
|
|
| @@ -246,22 +222,21 @@ class SyncSchedulerTest : public testing::Test {
|
| ModelSafeRoutingInfo routing_info_;
|
| };
|
|
|
| -void RecordSyncShareImpl(SyncSession* s, SyncShareRecords* record) {
|
| - record->times.push_back(TimeTicks::Now());
|
| - record->snapshots.push_back(s->TakeSnapshot());
|
| +void RecordSyncShareImpl(SyncShareTimes* times) {
|
| + times->push_back(TimeTicks::Now());
|
| }
|
|
|
| -ACTION_P(RecordSyncShare, record) {
|
| - RecordSyncShareImpl(arg0, record);
|
| +ACTION_P(RecordSyncShare, times) {
|
| + RecordSyncShareImpl(times);
|
| if (base::MessageLoop::current()->is_running())
|
| QuitLoopNow();
|
| return true;
|
| }
|
|
|
| -ACTION_P2(RecordSyncShareMultiple, record, quit_after) {
|
| - RecordSyncShareImpl(arg0, record);
|
| - EXPECT_LE(record->times.size(), quit_after);
|
| - if (record->times.size() >= quit_after &&
|
| +ACTION_P2(RecordSyncShareMultiple, times, quit_after) {
|
| + RecordSyncShareImpl(times);
|
| + EXPECT_LE(times->size(), quit_after);
|
| + if (times->size() >= quit_after &&
|
| base::MessageLoop::current()->is_running()) {
|
| QuitLoopNow();
|
| }
|
| @@ -281,12 +256,12 @@ ACTION(QuitLoopNowAction) {
|
|
|
| // Test nudge scheduling.
|
| TEST_F(SyncSchedulerTest, Nudge) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| ModelTypeSet model_types(BOOKMARKS);
|
|
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records))))
|
| + RecordSyncShare(×)))
|
| .RetiresOnSaturation();
|
|
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| @@ -294,42 +269,28 @@ TEST_F(SyncSchedulerTest, Nudge) {
|
| scheduler()->ScheduleLocalNudge(zero(), model_types, FROM_HERE);
|
| RunLoop();
|
|
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - records.snapshots[0].source().updates_source);
|
| -
|
| Mock::VerifyAndClearExpectations(syncer());
|
|
|
| // Make sure a second, later, nudge is unaffected by first (no coalescing).
|
| - SyncShareRecords records2;
|
| + SyncShareTimes times2;
|
| model_types.Remove(BOOKMARKS);
|
| model_types.Put(AUTOFILL);
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records2))));
|
| + RecordSyncShare(×2)));
|
| scheduler()->ScheduleLocalNudge(zero(), model_types, FROM_HERE);
|
| RunLoop();
|
| -
|
| - ASSERT_EQ(1U, records2.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records2.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - records2.snapshots[0].source().updates_source);
|
| }
|
|
|
| // Make sure a regular config command is scheduled fine in the absence of any
|
| // errors.
|
| TEST_F(SyncSchedulerTest, Config) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| const ModelTypeSet model_types(BOOKMARKS);
|
|
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| - WithArg<1>(RecordSyncShare(&records))));
|
| + RecordSyncShare(×)));
|
|
|
| StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
|
|
|
| @@ -341,13 +302,6 @@ TEST_F(SyncSchedulerTest, Config) {
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&counter)));
|
| ASSERT_TRUE(scheduler()->ScheduleConfiguration(params));
|
| ASSERT_EQ(1, counter.times_called());
|
| -
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
|
| - records.snapshots[0].source().updates_source);
|
| }
|
|
|
| // Simulate a failure and make sure the config request is retried.
|
| @@ -355,18 +309,15 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
|
| UseMockDelayProvider();
|
| EXPECT_CALL(*delay(), GetDelay(_))
|
| .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1)));
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| const ModelTypeSet model_types(BOOKMARKS);
|
|
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| - WithArg<1>(RecordSyncShare(&records))))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| - WithArg<1>(RecordSyncShare(&records))));
|
| -
|
| StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
|
|
|
| - ASSERT_EQ(0U, records.snapshots.size());
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| + RecordSyncShare(×)));
|
| +
|
| CallbackCounter counter;
|
| ConfigurationParams params(
|
| GetUpdatesCallerInfo::RECONFIGURATION,
|
| @@ -376,16 +327,14 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
|
| ASSERT_FALSE(scheduler()->ScheduleConfiguration(params));
|
| ASSERT_EQ(0, counter.times_called());
|
|
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| + Mock::VerifyAndClearExpectations(syncer());
|
| +
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| + RecordSyncShare(×)));
|
| RunLoop();
|
|
|
| - ASSERT_EQ(2U, records.snapshots.size());
|
| ASSERT_EQ(1, counter.times_called());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records.snapshots[1].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
|
| - records.snapshots[1].source().updates_source);
|
| }
|
|
|
| // Issue a nudge when the config has failed. Make sure both the config and
|
| @@ -395,23 +344,14 @@ TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) {
|
| UseMockDelayProvider();
|
| EXPECT_CALL(*delay(), GetDelay(_))
|
| .WillRepeatedly(Return(TimeDelta::FromMilliseconds(50)));
|
| - SyncShareRecords records;
|
| -
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| - WithArg<1>(RecordSyncShare(&records))))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| - WithArg<1>(RecordSyncShare(&records))))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| - WithArg<1>(RecordSyncShare(&records))));
|
| -
|
| - EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records))));
|
| + SyncShareTimes times;
|
|
|
| StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
|
|
|
| - ASSERT_EQ(0U, records.snapshots.size());
|
| + // Request a configure and make sure it fails.
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| + RecordSyncShare(×)));
|
| CallbackCounter counter;
|
| ConfigurationParams params(
|
| GetUpdatesCallerInfo::RECONFIGURATION,
|
| @@ -420,50 +360,41 @@ TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) {
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&counter)));
|
| ASSERT_FALSE(scheduler()->ScheduleConfiguration(params));
|
| ASSERT_EQ(0, counter.times_called());
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| + Mock::VerifyAndClearExpectations(syncer());
|
|
|
| + // Ask for a nudge while dealing with repeated configure failure.
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureFailed),
|
| + RecordSyncShare(×)));
|
| scheduler()->ScheduleLocalNudge(zero(), model_types, FROM_HERE);
|
| RunLoop();
|
| // Note that we're not RunLoop()ing for the NUDGE we just scheduled, but
|
| // for the first retry attempt from the config job (after
|
| // waiting ~+/- 50ms).
|
| - ASSERT_EQ(2U, records.snapshots.size());
|
| + Mock::VerifyAndClearExpectations(syncer());
|
| ASSERT_EQ(0, counter.times_called());
|
| - EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
|
| - records.snapshots[1].source().updates_source);
|
|
|
| + // Let the next configure retry succeed.
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| + RecordSyncShare(×)));
|
| RunLoop();
|
| - // This is the 3rd attempt, which we've set up to SimulateSuccess.
|
| - ASSERT_EQ(3U, records.snapshots.size());
|
| - ASSERT_EQ(1, counter.times_called());
|
|
|
| // Now change the mode so nudge can execute.
|
| + EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| + RecordSyncShare(×)));
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| -
|
| - ASSERT_EQ(4U, records.snapshots.size());
|
| -
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records.snapshots[2].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION,
|
| - records.snapshots[2].source().updates_source);
|
| -
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - model_types,
|
| - records.snapshots[3].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - records.snapshots[3].source().updates_source);
|
| -
|
| }
|
|
|
| // Test that nudges are coalesced.
|
| TEST_F(SyncSchedulerTest, NudgeCoalescing) {
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&r))));
|
| + RecordSyncShare(×)));
|
| const ModelTypeSet types1(BOOKMARKS), types2(AUTOFILL), types3(THEMES);
|
| TimeDelta delay = zero();
|
| TimeTicks optimal_time = TimeTicks::Now() + delay;
|
| @@ -471,39 +402,27 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) {
|
| scheduler()->ScheduleLocalNudge(zero(), types2, FROM_HERE);
|
| RunLoop();
|
|
|
| - ASSERT_EQ(1U, r.snapshots.size());
|
| - EXPECT_GE(r.times[0], optimal_time);
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - Union(types1, types2),
|
| - r.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - r.snapshots[0].source().updates_source);
|
| + ASSERT_EQ(1U, times.size());
|
| + EXPECT_GE(times[0], optimal_time);
|
|
|
| Mock::VerifyAndClearExpectations(syncer());
|
|
|
| - SyncShareRecords r2;
|
| + SyncShareTimes times2;
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&r2))));
|
| + RecordSyncShare(×2)));
|
| scheduler()->ScheduleLocalNudge(zero(), types3, FROM_HERE);
|
| RunLoop();
|
| -
|
| - ASSERT_EQ(1U, r2.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - types3,
|
| - r2.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - r2.snapshots[0].source().updates_source);
|
| }
|
|
|
| // Test that nudges are coalesced.
|
| TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&r))));
|
| + RecordSyncShare(×)));
|
| ModelTypeSet types1(BOOKMARKS), types2(AUTOFILL), types3;
|
|
|
| // Create a huge time delay.
|
| @@ -516,64 +435,50 @@ TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
|
| TimeTicks max_time = TimeTicks::Now() + delay;
|
|
|
| RunLoop();
|
| -
|
| - // Make sure the sync has happened.
|
| - ASSERT_EQ(1U, r.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - Union(types1, types2),
|
| - r.snapshots[0].source().types));
|
| + Mock::VerifyAndClearExpectations(syncer());
|
|
|
| // Make sure the sync happened at the right time.
|
| - EXPECT_GE(r.times[0], min_time);
|
| - EXPECT_LE(r.times[0], max_time);
|
| + ASSERT_EQ(1U, times.size());
|
| + EXPECT_GE(times[0], min_time);
|
| + EXPECT_LE(times[0], max_time);
|
| }
|
|
|
| // Test nudge scheduling.
|
| TEST_F(SyncSchedulerTest, NudgeWithStates) {
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| const ModelTypeSet types(BOOKMARKS);
|
| ModelTypeInvalidationMap invalidation_map =
|
| ModelTypeSetToInvalidationMap(types, "test");
|
|
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records))))
|
| + RecordSyncShare(×)))
|
| .RetiresOnSaturation();
|
| scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
|
| RunLoop();
|
|
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| - EXPECT_THAT(invalidation_map, Eq(records.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION,
|
| - records.snapshots[0].source().updates_source);
|
| -
|
| Mock::VerifyAndClearExpectations(syncer());
|
|
|
| // Make sure a second, later, nudge is unaffected by first (no coalescing).
|
| - SyncShareRecords records2;
|
| + SyncShareTimes times2;
|
| invalidation_map.erase(BOOKMARKS);
|
| invalidation_map[AUTOFILL].payload = "test2";
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records2))));
|
| + RecordSyncShare(×2)));
|
| scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
|
| RunLoop();
|
| -
|
| - ASSERT_EQ(1U, records2.snapshots.size());
|
| - EXPECT_THAT(invalidation_map, Eq(records2.snapshots[0].source().types));
|
| - EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION,
|
| - records2.snapshots[0].source().updates_source);
|
| }
|
|
|
| // Test that polling works as expected.
|
| TEST_F(SyncSchedulerTest, Polling) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll_interval(TimeDelta::FromMilliseconds(30));
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples))
|
| .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShareMultiple(&records, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
|
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval);
|
|
|
| @@ -584,16 +489,16 @@ TEST_F(SyncSchedulerTest, Polling) {
|
| RunLoop();
|
|
|
| StopSyncScheduler();
|
| - AnalyzePollRun(records, kMinNumSamples, optimal_start, poll_interval);
|
| + AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval);
|
| }
|
|
|
| // Test that the short poll interval is used.
|
| TEST_F(SyncSchedulerTest, PollNotificationsDisabled) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll_interval(TimeDelta::FromMilliseconds(30));
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples))
|
| .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShareMultiple(&records, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
|
|
| scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval);
|
| scheduler()->SetNotificationsEnabled(false);
|
| @@ -605,12 +510,12 @@ TEST_F(SyncSchedulerTest, PollNotificationsDisabled) {
|
| RunLoop();
|
|
|
| StopSyncScheduler();
|
| - AnalyzePollRun(records, kMinNumSamples, optimal_start, poll_interval);
|
| + AnalyzePollRun(times, kMinNumSamples, optimal_start, poll_interval);
|
| }
|
|
|
| // Test that polling intervals are updated when needed.
|
| TEST_F(SyncSchedulerTest, PollIntervalUpdate) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll1(TimeDelta::FromMilliseconds(120));
|
| TimeDelta poll2(TimeDelta::FromMilliseconds(30));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll1);
|
| @@ -622,7 +527,7 @@ TEST_F(SyncSchedulerTest, PollIntervalUpdate) {
|
| .WillRepeatedly(
|
| DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| WithArg<1>(
|
| - RecordSyncShareMultiple(&records, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples))));
|
|
|
| TimeTicks optimal_start = TimeTicks::Now() + poll1 + poll2;
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| @@ -631,12 +536,12 @@ TEST_F(SyncSchedulerTest, PollIntervalUpdate) {
|
| RunLoop();
|
|
|
| StopSyncScheduler();
|
| - AnalyzePollRun(records, kMinNumSamples, optimal_start, poll2);
|
| + AnalyzePollRun(times, kMinNumSamples, optimal_start, poll2);
|
| }
|
|
|
| // Test that the sessions commit delay is updated when needed.
|
| TEST_F(SyncSchedulerTest, SessionsCommitDelay) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta delay1(TimeDelta::FromMilliseconds(120));
|
| TimeDelta delay2(TimeDelta::FromMilliseconds(30));
|
| scheduler()->OnReceivedSessionsCommitDelay(delay1);
|
| @@ -669,9 +574,9 @@ TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
|
| TimeDelta throttle(TimeDelta::FromMinutes(10));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
|
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillOnce(DoAll(
|
| - WithArg<1>(sessions::test_util::SimulateThrottled(throttle)),
|
| + WithArg<2>(sessions::test_util::SimulateThrottled(throttle)),
|
| Return(true)))
|
| .WillRepeatedly(AddFailureAndQuitLoopNow());
|
|
|
| @@ -694,7 +599,7 @@ TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
|
| }
|
|
|
| TEST_F(SyncSchedulerTest, ThrottlingExpiresFromPoll) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromMilliseconds(15));
|
| TimeDelta throttle1(TimeDelta::FromMilliseconds(150));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| @@ -707,7 +612,7 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromPoll) {
|
| .RetiresOnSaturation();
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShareMultiple(&records, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
|
|
| TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1;
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| @@ -716,11 +621,11 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromPoll) {
|
| RunLoop();
|
|
|
| StopSyncScheduler();
|
| - AnalyzePollRun(records, kMinNumSamples, optimal_start, poll);
|
| + AnalyzePollRun(times, kMinNumSamples, optimal_start, poll);
|
| }
|
|
|
| TEST_F(SyncSchedulerTest, ThrottlingExpiresFromNudge) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromDays(1));
|
| TimeDelta throttle1(TimeDelta::FromMilliseconds(150));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| @@ -748,18 +653,18 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromNudge) {
|
| }
|
|
|
| TEST_F(SyncSchedulerTest, ThrottlingExpiresFromConfigure) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromDays(1));
|
| TimeDelta throttle1(TimeDelta::FromMilliseconds(150));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
|
|
| ::testing::InSequence seq;
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillOnce(DoAll(
|
| - WithArg<1>(sessions::test_util::SimulateThrottled(throttle1)),
|
| + WithArg<2>(sessions::test_util::SimulateThrottled(throttle1)),
|
| Return(true)))
|
| .RetiresOnSaturation();
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| QuitLoopNowAction()));
|
|
|
| @@ -818,7 +723,7 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| EXPECT_CALL(*delay(), GetDelay(_))
|
| .WillRepeatedly(Return(zero()));
|
|
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromDays(1));
|
| TimeDelta throttle1(TimeDelta::FromSeconds(60));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| @@ -834,14 +739,10 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| throttled_types, throttle1)),
|
| Return(true)))
|
| .RetiresOnSaturation();
|
| - EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| - .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records))));
|
|
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| scheduler()->ScheduleLocalNudge(zero(), throttled_types, FROM_HERE);
|
| PumpLoop();
|
| - EXPECT_EQ(0U, records.snapshots.size());
|
| EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types));
|
|
|
| // Ignore invalidations for throttled types.
|
| @@ -849,17 +750,20 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| ModelTypeSetToInvalidationMap(throttled_types, "test");
|
| scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
|
| PumpLoop();
|
| - EXPECT_EQ(0U, records.snapshots.size());
|
|
|
| // Ignore refresh requests for throttled types.
|
| scheduler()->ScheduleLocalRefreshRequest(zero(), throttled_types, FROM_HERE);
|
| PumpLoop();
|
| - EXPECT_EQ(0U, records.snapshots.size());
|
| +
|
| + Mock::VerifyAndClearExpectations(syncer());
|
|
|
| // Local nudges for non-throttled types will trigger a sync.
|
| + EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| + .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| + RecordSyncShare(×)));
|
| scheduler()->ScheduleLocalNudge(zero(), unthrottled_types, FROM_HERE);
|
| RunLoop();
|
| - EXPECT_EQ(1U, records.snapshots.size());
|
| + Mock::VerifyAndClearExpectations(syncer());
|
|
|
| StopSyncScheduler();
|
| }
|
| @@ -867,12 +771,8 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| // Test nudges / polls don't run in config mode and config tasks do.
|
| TEST_F(SyncSchedulerTest, ConfigurationMode) {
|
| TimeDelta poll(TimeDelta::FromMilliseconds(15));
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| - WithArg<1>(RecordSyncShare(&records))))
|
| - .RetiresOnSaturation();
|
|
|
| StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
|
|
|
| @@ -882,6 +782,10 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
|
|
|
| const ModelTypeSet config_types(BOOKMARKS);
|
|
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateConfigureSuccess),
|
| + RecordSyncShare(×)))
|
| + .RetiresOnSaturation();
|
| CallbackCounter counter;
|
| ConfigurationParams params(
|
| GetUpdatesCallerInfo::RECONFIGURATION,
|
| @@ -890,32 +794,20 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&counter)));
|
| ASSERT_TRUE(scheduler()->ScheduleConfiguration(params));
|
| ASSERT_EQ(1, counter.times_called());
|
| -
|
| - ASSERT_EQ(1U, records.snapshots.size());
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - config_types,
|
| - records.snapshots[0].source().types));
|
| + Mock::VerifyAndClearExpectations(syncer());
|
|
|
| // Switch to NORMAL_MODE to ensure NUDGES were properly saved and run.
|
| - // SyncSchedulerWhiteboxTest also provides coverage for this, but much
|
| - // more targeted ('whitebox' style).
|
| scheduler()->OnReceivedLongPollIntervalUpdate(TimeDelta::FromDays(1));
|
| - SyncShareRecords records2;
|
| + SyncShareTimes times2;
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShare(&records2))));
|
| + RecordSyncShare(×2)));
|
|
|
| // TODO(tim): Figure out how to remove this dangerous need to reset
|
| // routing info between mode switches.
|
| context()->set_routing_info(routing_info());
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| - ASSERT_EQ(1U, records2.snapshots.size());
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - records2.snapshots[0].source().updates_source);
|
| - EXPECT_TRUE(ModelTypeSetMatchesInvalidationMap(
|
| - nudge_types,
|
| - records2.snapshots[0].source().types));
|
| PumpLoop();
|
| }
|
|
|
| @@ -982,7 +874,7 @@ TEST_F(BackoffTriggersSyncSchedulerTest, FailDownloadTwice) {
|
| // Have the syncer fail to get the encryption key yet succeed in downloading
|
| // updates. Expect this will leave the scheduler in backoff.
|
| TEST_F(BackoffTriggersSyncSchedulerTest, FailGetEncryptionKey) {
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillOnce(DoAll(
|
| Invoke(sessions::test_util::SimulateGetEncryptionKeyFailed),
|
| Return(true)))
|
| @@ -1006,15 +898,15 @@ TEST_F(BackoffTriggersSyncSchedulerTest, FailGetEncryptionKey) {
|
|
|
| // Test that no polls or extraneous nudges occur when in backoff.
|
| TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromMilliseconds(5));
|
| const ModelTypeSet types(BOOKMARKS);
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| UseMockDelayProvider();
|
|
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| - .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| - WithArg<2>(RecordSyncShareMultiple(&r, 1U))));
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| + RecordSyncShareMultiple(×, 1U)));
|
| EXPECT_CALL(*delay(), GetDelay(_)).
|
| WillRepeatedly(Return(TimeDelta::FromDays(1)));
|
|
|
| @@ -1025,10 +917,8 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
| scheduler()->ScheduleLocalNudge(zero(), types, FROM_HERE);
|
| RunLoop();
|
|
|
| + // From this point forward, no SyncShare functions should be invoked.
|
| Mock::VerifyAndClearExpectations(syncer());
|
| - ASSERT_EQ(1U, r.snapshots.size());
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - r.snapshots[0].source().updates_source);
|
|
|
| // Wait a while (10x poll interval) so a few poll jobs will be attempted.
|
| PumpLoopFor(poll * 10);
|
| @@ -1042,8 +932,6 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
| Mock::VerifyAndClearExpectations(syncer());
|
| Mock::VerifyAndClearExpectations(delay());
|
|
|
| - ASSERT_EQ(1U, r.snapshots.size());
|
| -
|
| EXPECT_CALL(*delay(), GetDelay(_)).Times(0);
|
|
|
| StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
|
| @@ -1060,12 +948,12 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
|
|
| // Test that backoff is shaping traffic properly with consecutive errors.
|
| TEST_F(SyncSchedulerTest, BackoffElevation) {
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| UseMockDelayProvider();
|
|
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)).Times(kMinNumSamples)
|
| .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| - WithArg<2>(RecordSyncShareMultiple(&r, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
|
|
| const TimeDelta first = TimeDelta::FromSeconds(kInitialBackoffRetrySeconds);
|
| const TimeDelta second = TimeDelta::FromMilliseconds(2);
|
| @@ -1090,80 +978,79 @@ TEST_F(SyncSchedulerTest, BackoffElevation) {
|
| scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE);
|
| RunLoop();
|
|
|
| - ASSERT_EQ(kMinNumSamples, r.snapshots.size());
|
| - EXPECT_GE(r.times[1] - r.times[0], second);
|
| - EXPECT_GE(r.times[2] - r.times[1], third);
|
| - EXPECT_GE(r.times[3] - r.times[2], fourth);
|
| - EXPECT_GE(r.times[4] - r.times[3], fifth);
|
| + ASSERT_EQ(kMinNumSamples, times.size());
|
| + EXPECT_GE(times[1] - times[0], second);
|
| + EXPECT_GE(times[2] - times[1], third);
|
| + EXPECT_GE(times[3] - times[2], fourth);
|
| + EXPECT_GE(times[4] - times[3], fifth);
|
| }
|
|
|
| // Test that things go back to normal once a retry makes forward progress.
|
| TEST_F(SyncSchedulerTest, BackoffRelief) {
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| const TimeDelta poll(TimeDelta::FromMilliseconds(10));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
| UseMockDelayProvider();
|
|
|
| const TimeDelta backoff = TimeDelta::FromMilliseconds(5);
|
| -
|
| - EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| - .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| - WithArg<2>(RecordSyncShareMultiple(&r, kMinNumSamples))))
|
| - .WillRepeatedly(DoAll(
|
| - Invoke(sessions::test_util::SimulateNormalSuccess),
|
| - WithArg<2>(RecordSyncShareMultiple(&r, kMinNumSamples))));
|
| - EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| - .WillRepeatedly(DoAll(
|
| - Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShareMultiple(&r, kMinNumSamples))));
|
| EXPECT_CALL(*delay(), GetDelay(_)).WillOnce(Return(backoff));
|
|
|
| // Optimal start for the post-backoff poll party.
|
| TimeTicks optimal_start = TimeTicks::Now();
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| - // Run again to wait for polling.
|
| + // Kick off the test with a failed nudge.
|
| + EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| + RecordSyncShare(×)));
|
| scheduler()->ScheduleLocalNudge(zero(), ModelTypeSet(BOOKMARKS), FROM_HERE);
|
| RunLoop();
|
| -
|
| - StopSyncScheduler();
|
| -
|
| - EXPECT_EQ(kMinNumSamples, r.times.size());
|
| -
|
| - // The first nudge ran as soon as possible. It failed.
|
| + Mock::VerifyAndClearExpectations(syncer());
|
| TimeTicks optimal_job_time = optimal_start;
|
| - EXPECT_GE(r.times[0], optimal_job_time);
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - r.snapshots[0].source().updates_source);
|
| + ASSERT_EQ(1U, times.size());
|
| + EXPECT_GE(times[0], optimal_job_time);
|
|
|
| - // It was followed by a successful retry nudge shortly afterward.
|
| + // The retry succeeds.
|
| + EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
|
| + .WillOnce(DoAll(
|
| + Invoke(sessions::test_util::SimulateNormalSuccess),
|
| + RecordSyncShare(×)));
|
| + RunLoop();
|
| + Mock::VerifyAndClearExpectations(syncer());
|
| optimal_job_time = optimal_job_time + backoff;
|
| - EXPECT_GE(r.times[1], optimal_job_time);
|
| - EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
|
| - r.snapshots[1].source().updates_source);
|
| - // After that, we went back to polling.
|
| - for (size_t i = 2; i < r.snapshots.size(); i++) {
|
| + ASSERT_EQ(2U, times.size());
|
| + EXPECT_GE(times[1], optimal_job_time);
|
| +
|
| + // Now let the Poll timer do its thing.
|
| + EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| + .WillRepeatedly(DoAll(
|
| + Invoke(sessions::test_util::SimulatePollSuccess),
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
| + RunLoop();
|
| + Mock::VerifyAndClearExpectations(syncer());
|
| + ASSERT_EQ(kMinNumSamples, times.size());
|
| + for (size_t i = 2; i < times.size(); i++) {
|
| optimal_job_time = optimal_job_time + poll;
|
| SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
|
| - EXPECT_GE(r.times[i], optimal_job_time);
|
| - EXPECT_EQ(GetUpdatesCallerInfo::PERIODIC,
|
| - r.snapshots[i].source().updates_source);
|
| + EXPECT_GE(times[i], optimal_job_time);
|
| }
|
| +
|
| + StopSyncScheduler();
|
| }
|
|
|
| // Test that poll failures are ignored. They should have no effect on
|
| // subsequent poll attempts, nor should they trigger a backoff/retry.
|
| TEST_F(SyncSchedulerTest, TransientPollFailure) {
|
| - SyncShareRecords r;
|
| + SyncShareTimes times;
|
| const TimeDelta poll_interval(TimeDelta::FromMilliseconds(1));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval);
|
| UseMockDelayProvider(); // Will cause test failure if backoff is initiated.
|
|
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollFailed),
|
| - WithArg<1>(RecordSyncShare(&r))))
|
| + RecordSyncShare(×)))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShare(&r))));
|
| + RecordSyncShare(×)));
|
|
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
|
|
| @@ -1261,7 +1148,7 @@ TEST_F(SyncSchedulerTest, ConnectionChangeCanaryPreemptedByNudge) {
|
| // Tests that we don't crash trying to run two canaries at once if we receive
|
| // extra connection status change notifications. See crbug.com/190085.
|
| TEST_F(SyncSchedulerTest, DoubleCanaryInConfigure) {
|
| - EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_))
|
| + EXPECT_CALL(*syncer(), ConfigureSyncShare(_,_,_))
|
| .WillRepeatedly(DoAll(
|
| Invoke(sessions::test_util::SimulateConfigureConnectionFailure),
|
| Return(true)));
|
| @@ -1285,14 +1172,14 @@ TEST_F(SyncSchedulerTest, DoubleCanaryInConfigure) {
|
| }
|
|
|
| TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) {
|
| - SyncShareRecords records;
|
| + SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromMilliseconds(15));
|
| scheduler()->OnReceivedLongPollIntervalUpdate(poll);
|
|
|
| ::testing::InSequence seq;
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShareMultiple(&records, kMinNumSamples))));
|
| + RecordSyncShareMultiple(×, kMinNumSamples)));
|
|
|
| connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR);
|
| StartSyncScheduler(SyncScheduler::NORMAL_MODE);
|
| @@ -1305,7 +1192,7 @@ TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) {
|
| // poll once more
|
| EXPECT_CALL(*syncer(), PollSyncShare(_,_))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
|
| - WithArg<1>(RecordSyncShare(&records))));
|
| + RecordSyncShare(×)));
|
| scheduler()->OnCredentialsUpdated();
|
| connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK);
|
| StopSyncScheduler();
|
|
|