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

Side by Side Diff: sync/engine/sync_scheduler_unittest.cc

Issue 1251203002: [Sync] Add ClearServerData support to Sync Scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve comments Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) 1430 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
1431 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), 1431 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
1432 RecordSyncShare(&times, true))); 1432 RecordSyncShare(&times, true)));
1433 1433
1434 // Run to wait for retrying. 1434 // Run to wait for retrying.
1435 RunLoop(); 1435 RunLoop();
1436 1436
1437 StopSyncScheduler(); 1437 StopSyncScheduler();
1438 } 1438 }
1439 1439
1440 TEST_F(SyncSchedulerTest, ScheduleClearServerData_Succeeds) {
1441 StartSyncConfiguration();
1442 scheduler()->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time());
1443 CallbackCounter success_counter;
1444 ClearParams params(base::Bind(&CallbackCounter::Callback,
1445 base::Unretained(&success_counter)));
1446 scheduler()->ScheduleClearServerData(params);
1447 PumpLoop();
1448 ASSERT_EQ(1, success_counter.times_called());
1449 }
1450
1451 TEST_F(SyncSchedulerTest, ScheduleClearServerData_FailsRetriesSucceeds) {
1452 UseMockDelayProvider();
1453 TimeDelta delta(TimeDelta::FromMilliseconds(20));
1454 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(delta));
1455
1456 StartSyncConfiguration();
1457 scheduler()->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time());
1458 CallbackCounter success_counter;
1459 ClearParams params(base::Bind(&CallbackCounter::Callback,
1460 base::Unretained(&success_counter)));
1461
1462 // Next request will fail.
1463 connection()->SetServerNotReachable();
1464 scheduler()->ScheduleClearServerData(params);
1465 PumpLoop();
1466 ASSERT_EQ(0, success_counter.times_called());
1467 ASSERT_TRUE(scheduler()->IsBackingOff());
1468
1469 // Now succeed.
1470 connection()->SetServerReachable();
1471 PumpLoopFor(2 * delta);
1472 ASSERT_EQ(1, success_counter.times_called());
1473 ASSERT_FALSE(scheduler()->IsBackingOff());
1474 }
1475
1440 } // namespace syncer 1476 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698