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

Unified Diff: components/sync/model_impl/shared_model_type_processor_unittest.cc

Issue 2935583002: [Sync] Implement support for untracking new entities (Closed)
Patch Set: add comments Created 3 years, 6 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: components/sync/model_impl/shared_model_type_processor_unittest.cc
diff --git a/components/sync/model_impl/shared_model_type_processor_unittest.cc b/components/sync/model_impl/shared_model_type_processor_unittest.cc
index 7a3e115917bccab8d07fbe7b1ef966837bc2a160..2ec3121a170658d1bdeeba3a0cef9d7684af6df0 100644
--- a/components/sync/model_impl/shared_model_type_processor_unittest.cc
+++ b/components/sync/model_impl/shared_model_type_processor_unittest.cc
@@ -1441,7 +1441,9 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryptionInterleaved) {
}
// Tests that UpdateStorageKey propagates storage key to ProcessorEntityTracker
-// and updates corresponding entity's metadata in MetadataChangeList.
+// and updates corresponding entity's metadata in MetadataChangeList, and
+// UntrackEntity will remove corresponding ProcessorEntityTracker and do not add
+// any entity's metadata into MetadataChangeList.
TEST_F(SharedModelTypeProcessorTest, UpdateStorageKey) {
// Setup bridge to not support calls to GetStorageKey. This will cause
// FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will
@@ -1451,7 +1453,14 @@ TEST_F(SharedModelTypeProcessorTest, UpdateStorageKey) {
OnSyncStarting();
// Initial update from server should be handled by MergeSyncData.
- worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1));
+ UpdateResponseDataList updates;
+ updates.push_back(
+ worker()->GenerateUpdateData(kHash1, GenerateSpecifics(kKey1, kValue1)));
+ // Create update which will be ignored by bridge.
+ updates.push_back(
+ worker()->GenerateUpdateData(kHash3, GenerateSpecifics(kKey3, kValue3)));
+ bridge()->SetKeyToIgnore(kKey3);
+ worker()->UpdateFromServer(updates);
EXPECT_EQ(1, bridge()->merge_call_count());
EXPECT_EQ(1U, ProcessorEntityCount());
// Metadata should be written under kKey1. This means that UpdateStorageKey
@@ -1490,4 +1499,28 @@ TEST_F(SharedModelTypeProcessorTest, ReencryptionWithEmptyStorageKeys) {
worker()->VerifyPendingCommits({kHash1});
}
+// Tests that UntrackEntity won't propagate storage key to
+// ProcessorEntityTracker, and no entity's metadata are added into
+// MetadataChangeList.
+TEST_F(SharedModelTypeProcessorTest, UntrackEntity) {
+ // Setup bridge to not support calls to GetStorageKey. This will cause
+ // FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will
+ // DCHECK if GetStorageKey gets called.
+ bridge()->SetSupportsGetStorageKey(false);
+ bridge()->SetKeyToIgnore(kKey1);
+ ModelReadyToSync();
+ OnSyncStarting();
+
+ // Initial update from server should be handled by MergeSyncData.
+ worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1));
+ EXPECT_EQ(1, bridge()->merge_call_count());
+ EXPECT_EQ(0U, ProcessorEntityCount());
+ // Metadata should not be written under kUntrackKey1. This means that
+ // UntrackEntity was called and corresponding ProcessorEntityTracker is
+ // removed and no storage key got propagated to MetadataChangeList.
+ EXPECT_FALSE(db().HasMetadata(kHash1));
+ EXPECT_EQ(0U, db().metadata_count());
+ EXPECT_EQ(0, bridge()->get_storage_key_call_count());
+}
+
} // namespace syncer
« no previous file with comments | « components/sync/model_impl/shared_model_type_processor.cc ('k') | components/sync/test/engine/mock_model_type_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698