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

Unified Diff: components/sync/engine_impl/sync_manager_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_manager_impl.cc ('k') | components/sync/engine_impl/sync_scheduler_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/sync_manager_impl_unittest.cc
diff --git a/components/sync/engine_impl/sync_manager_impl_unittest.cc b/components/sync/engine_impl/sync_manager_impl_unittest.cc
index 5f9db5d87496b9cf1ca89f82dd314c7f339d41fa..afaab93d635294de0a75e045dc895f9113103a5f 100644
--- a/components/sync/engine_impl/sync_manager_impl_unittest.cc
+++ b/components/sync/engine_impl/sync_manager_impl_unittest.cc
@@ -996,8 +996,7 @@ class SyncManagerTest : public testing::Test,
virtual ~SyncManagerTest() {}
- // Test implementation.
- void SetUp() {
+ virtual void DoSetUp(bool enable_local_sync_backend) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
extensions_activity_ = new ExtensionsActivity();
@@ -1035,8 +1034,11 @@ class SyncManagerTest : public testing::Test,
args.workers = workers;
args.extensions_activity = extensions_activity_.get(),
args.change_delegate = this;
- args.credentials = credentials;
+ if (!enable_local_sync_backend)
+ args.credentials = credentials;
args.invalidator_client_id = "fake_invalidator_client_id";
+ args.enable_local_sync_backend = enable_local_sync_backend;
+ args.local_sync_backend_folder = temp_dir_.GetPath();
args.engine_components_factory.reset(GetFactory());
args.encryptor = &encryptor_;
args.unrecoverable_error_handler =
@@ -1060,6 +1062,9 @@ class SyncManagerTest : public testing::Test,
PumpLoop();
}
+ // Test implementation.
+ void SetUp() { DoSetUp(false); }
+
void TearDown() {
sync_manager_.RemoveObserver(&manager_observer_);
sync_manager_.ShutdownOnSyncThread(STOP_SYNC);
@@ -2692,6 +2697,38 @@ TEST_F(SyncManagerTest, IncrementTransactionVersion) {
}
}
+class SyncManagerWithLocalBackendTest : public SyncManagerTest {
+ protected:
+ void SetUp() override { DoSetUp(true); }
+};
+
+// This test checks that we can successfully initialize without credentials in
+// the local backend case.
+TEST_F(SyncManagerWithLocalBackendTest, StartSyncInLocalMode) {
+ EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
+ EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
+ EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
+ EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false));
+
+ sync_manager_.GetEncryptionHandler()->Init();
+ PumpLoop();
+
+ const ModelTypeSet encrypted_types = GetEncryptedTypes();
+ EXPECT_TRUE(encrypted_types.Has(PASSWORDS));
+ EXPECT_FALSE(IsEncryptEverythingEnabledForTest());
+
+ {
+ ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
+ ReadNode node(&trans);
+ EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(GetIdForDataType(NIGORI)));
+ sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
+ EXPECT_TRUE(nigori.has_encryption_keybag());
+ Cryptographer* cryptographer = trans.GetCryptographer();
+ EXPECT_TRUE(cryptographer->is_ready());
+ EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encryption_keybag()));
+ }
+}
+
class MockSyncScheduler : public FakeSyncScheduler {
public:
MockSyncScheduler() : FakeSyncScheduler() {}
@@ -2717,7 +2754,8 @@ class ComponentsFactory : public TestEngineComponentsFactory {
std::unique_ptr<SyncScheduler> BuildScheduler(
const std::string& name,
SyncCycleContext* context,
- CancelationSignal* stop_handle) override {
+ CancelationSignal* stop_handle,
+ bool local_sync_backend_enabled) override {
*cycle_context_ = context;
return std::move(scheduler_to_use_);
}
« no previous file with comments | « components/sync/engine_impl/sync_manager_impl.cc ('k') | components/sync/engine_impl/sync_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698