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

Unified Diff: components/sync/engine_impl/sync_scheduler_impl_unittest.cc

Issue 2494873003: [Sync] Allow sync start without sign-in if the local sync backend is on. (Closed)
Patch Set: Remove ifdefs around include. Created 4 years 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 | « components/sync/engine_impl/sync_scheduler_impl.cc ('k') | components/sync/engine_impl/syncer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/sync_scheduler_impl_unittest.cc
diff --git a/components/sync/engine_impl/sync_scheduler_impl_unittest.cc b/components/sync/engine_impl/sync_scheduler_impl_unittest.cc
index 94f7e78af0dfe6775e286216a855a72a40785e2d..d4d673470f9c93ad338f8a420b33aa0642f15a2d 100644
--- a/components/sync/engine_impl/sync_scheduler_impl_unittest.cc
+++ b/components/sync/engine_impl/sync_scheduler_impl_unittest.cc
@@ -159,7 +159,7 @@ class SyncSchedulerImplTest : public testing::Test {
context_->set_account_name("Test");
scheduler_ = base::MakeUnique<SyncSchedulerImpl>(
"TestSyncScheduler", BackoffDelayProvider::FromDefaults(), context(),
- syncer_);
+ syncer_, false);
scheduler_->SetDefaultNudgeDelay(default_delay());
}
@@ -283,6 +283,15 @@ class SyncSchedulerImplTest : public testing::Test {
tracker_it->second->wait_interval_->mode = mode;
}
+ void NewSchedulerForLocalBackend() {
+ // The old syncer is destroyed with the scheduler that owns it.
+ syncer_ = new testing::StrictMock<MockSyncer>();
+ scheduler_ = base::MakeUnique<SyncSchedulerImpl>(
+ "TestSyncScheduler", BackoffDelayProvider::FromDefaults(), context(),
+ syncer_, true);
+ scheduler_->SetDefaultNudgeDelay(default_delay());
+ }
+
private:
syncable::Directory* directory() {
return test_user_share_.user_share()->directory.get();
@@ -468,6 +477,56 @@ TEST_F(SyncSchedulerImplTest, ConfigWithStop) {
ASSERT_EQ(0, retry_counter.times_called());
}
+// Verify that in the absence of valid auth token the command will fail.
+TEST_F(SyncSchedulerImplTest, ConfigNoAuthToken) {
+ SyncShareTimes times;
+ const ModelTypeSet model_types(THEMES);
+
+ connection()->ResetAuthToken();
+
+ StartSyncConfiguration();
+
+ CallbackCounter ready_counter;
+ CallbackCounter retry_counter;
+ ConfigurationParams params(
+ GetUpdatesCallerInfo::RECONFIGURATION, model_types,
+ TypesToRoutingInfo(model_types),
+ base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
+ base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
+ scheduler()->ScheduleConfiguration(params);
+ PumpLoop();
+ ASSERT_EQ(0, ready_counter.times_called());
+ ASSERT_EQ(1, retry_counter.times_called());
+}
+
+// Verify that in the absence of valid auth token the command will pass if local
+// sync backend is used.
+TEST_F(SyncSchedulerImplTest, ConfigNoAuthTokenLocalSync) {
+ SyncShareTimes times;
+ const ModelTypeSet model_types(THEMES);
+
+ NewSchedulerForLocalBackend();
+ connection()->ResetAuthToken();
+
+ EXPECT_CALL(*syncer(), ConfigureSyncShare(_, _, _))
+ .WillOnce(DoAll(Invoke(test_util::SimulateConfigureSuccess),
+ RecordSyncShare(&times, true)));
+
+ StartSyncConfiguration();
+
+ CallbackCounter ready_counter;
+ CallbackCounter retry_counter;
+ ConfigurationParams params(
+ GetUpdatesCallerInfo::RECONFIGURATION, model_types,
+ TypesToRoutingInfo(model_types),
+ base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
+ base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
+ scheduler()->ScheduleConfiguration(params);
+ PumpLoop();
+ ASSERT_EQ(1, ready_counter.times_called());
+ ASSERT_EQ(0, retry_counter.times_called());
+}
+
// Issue a nudge when the config has failed. Make sure both the config and
// nudge are executed.
TEST_F(SyncSchedulerImplTest, NudgeWithConfigWithBackingOff) {
« no previous file with comments | « components/sync/engine_impl/sync_scheduler_impl.cc ('k') | components/sync/engine_impl/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698