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

Unified Diff: sync/internal_api/shared_model_type_processor_unittest.cc

Issue 1918923002: [Sync] USS: Ignore encryption changes during conflict resolution 1/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 8 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
« no previous file with comments | « sync/internal_api/shared_model_type_processor.cc ('k') | sync/protocol/entity_metadata.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/shared_model_type_processor_unittest.cc
diff --git a/sync/internal_api/shared_model_type_processor_unittest.cc b/sync/internal_api/shared_model_type_processor_unittest.cc
index 06b3c273d982fae08ac5798da065786ea875da0b..15060ec762b7fb3ce1acbdef78f40cece4f14e0c 100644
--- a/sync/internal_api/shared_model_type_processor_unittest.cc
+++ b/sync/internal_api/shared_model_type_processor_unittest.cc
@@ -1333,4 +1333,49 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictWhileLoading) {
EXPECT_EQ(1U, worker()->GetNumPendingCommits());
}
+// Tests that a real remote change wins over a local encryption-only change.
+TEST_F(SharedModelTypeProcessorTest, IgnoreLocalEncryption) {
+ InitializeToReadyState();
+ WriteItemAndAck(kTag1, kValue1);
+ worker()->UpdateWithEncryptionKey("k1");
+ OnPendingCommitDataLoaded();
+ EXPECT_EQ(1U, worker()->GetNumPendingCommits());
+ worker()->ExpectNthPendingCommit(0, kTag1, kValue1);
+
+ worker()->UpdateFromServer(kTag1, kValue2);
+ EXPECT_EQ(1U, worker()->GetNumPendingCommits());
+}
+
+// Tests that a real local change wins over a remote encryption-only change.
+TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryption) {
+ InitializeToReadyState();
+ WriteItemAndAck(kTag1, kValue1);
+
+ WriteItem(kTag1, kValue2);
+ UpdateResponseDataList update;
+ update.push_back(worker()->GenerateUpdateData(kTag1, kValue1, 1, "k1"));
+ worker()->UpdateWithEncryptionKey("k1", update);
+
+ EXPECT_EQ(2U, worker()->GetNumPendingCommits());
+ worker()->ExpectNthPendingCommit(1, kTag1, kValue2);
+}
+
+// Same as above but with two commit requests before one ack.
+TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryptionInterleaved) {
+ InitializeToReadyState();
+ WriteItem(kTag1, kValue1);
+ WriteItem(kTag1, kValue2);
+ worker()->AckOnePendingCommit();
+ // kValue1 is now the base value.
+ EXPECT_EQ(1U, worker()->GetNumPendingCommits());
+ worker()->ExpectNthPendingCommit(0, kTag1, kValue2);
+
+ UpdateResponseDataList update;
+ update.push_back(worker()->GenerateUpdateData(kTag1, kValue1, 1, "k1"));
+ worker()->UpdateWithEncryptionKey("k1", update);
+
+ EXPECT_EQ(2U, worker()->GetNumPendingCommits());
+ worker()->ExpectNthPendingCommit(1, kTag1, kValue2);
+}
+
} // namespace syncer_v2
« no previous file with comments | « sync/internal_api/shared_model_type_processor.cc ('k') | sync/protocol/entity_metadata.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698