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

Unified Diff: sync/engine/apply_control_data_updates_unittest.cc

Issue 1393633003: Sync: fix for the code that checks whether the initial download has completed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added more tests Created 5 years, 2 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/apply_control_data_updates_unittest.cc
diff --git a/sync/engine/apply_control_data_updates_unittest.cc b/sync/engine/apply_control_data_updates_unittest.cc
index 7ed6bd4899f0604a3044f142743cc43b7cf3ed7e..61c7844907088318aabac8f718afa38e94aaa5f2 100644
--- a/sync/engine/apply_control_data_updates_unittest.cc
+++ b/sync/engine/apply_control_data_updates_unittest.cc
@@ -914,4 +914,59 @@ TEST_F(ApplyControlDataUpdatesTest, ControlConflict) {
experiments().keystore_encryption().enabled());
}
+// Check that applying a EXPERIMENTS update marks the datatype as downloaded.
+TEST_F(ApplyControlDataUpdatesTest, ExperimentsApplyMarksDownloadCompleted) {
+ EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS));
+
+ // Create root node for EXPERIMENTS datatype
+ {
+ syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
+ syncable::ModelNeutralMutableEntry entry(
+ &trans, syncable::CREATE_NEW_TYPE_ROOT, EXPERIMENTS);
+ ASSERT_TRUE(entry.good());
+ entry.PutServerIsDir(true);
+ entry.PutUniqueServerTag(ModelTypeToRootTag(EXPERIMENTS));
+ }
+
+ EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS));
+
+ std::string experiment_id = "experiment";
+ sync_pb::EntitySpecifics specifics;
+ specifics.mutable_experiments()->mutable_keystore_encryption()->set_enabled(
+ true);
+ entry_factory_->CreateUnappliedNewItem(experiment_id, specifics, false);
+
+ ApplyControlDataUpdates(directory());
+
+ EXPECT_TRUE(directory()->InitialSyncEndedForType(EXPERIMENTS));
+ EXPECT_FALSE(directory()->InitialSyncEndedForType(NIGORI));
Nicolas Zea 2015/10/13 17:51:37 Did you mean to leave this in? (maybe comment why?
stanisc 2015/10/13 21:23:11 This was to verify that there is no side effect on
+}
+
+// Check that applying a NIGORI update marks the datatype as downloaded.
+TEST_F(ApplyControlDataUpdatesTest, NigoriApplyMarksDownloadCompleted) {
+ EXPECT_FALSE(directory()->InitialSyncEndedForType(NIGORI));
+
+ Cryptographer* cryptographer;
+
+ {
+ syncable::ReadTransaction trans(FROM_HERE, directory());
+ cryptographer = directory()->GetCryptographer(&trans);
+ }
+
+ KeyParams params = {"localhost", "dummy", "foobar"};
+ cryptographer->AddKey(params);
+ sync_pb::EntitySpecifics specifics;
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
+ cryptographer->GetKeys(nigori->mutable_encryption_keybag());
+ nigori->set_encrypt_everything(true);
+
+ entry_factory_->CreateUnappliedNewItem(ModelTypeToRootTag(NIGORI), specifics,
+ true);
+
+ ApplyControlDataUpdates(directory());
+
+ EXPECT_TRUE(directory()->InitialSyncEndedForType(NIGORI));
+ EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS));
+}
+
} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698