Commit 83da426e authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Delete outdated syncer unit tests for undeletions

Undeletions as a concept no longer exists within the sync engine because
changes as propagated as-is to model processors. The tests deleted here
are hence outdated, exercise the legacy codepath only, and are
conceptually similar to the undeletion-related tests in processor
implementations, most notably ClientTagBasedModelTypeProcessorTest.

A few scenarios lacked unit-test coverage. There are various
integration-like unittests and browser tests, but a bunch of new unit
tests have now been added for them.

Change-Id: I8487887628df1d9c20caf680b7d441d5a654d702
Bug: 923287
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2260661Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781828}
parent de650057
...@@ -447,6 +447,57 @@ TEST_F(ProcessorEntityTest, LocalDeletion) { ...@@ -447,6 +447,57 @@ TEST_F(ProcessorEntityTest, LocalDeletion) {
EXPECT_FALSE(entity->HasCommitData()); EXPECT_FALSE(entity->HasCommitData());
} }
// Test a local deletion followed by an undeletion (creation).
TEST_F(ProcessorEntityTest, LocalUndeletion) {
std::unique_ptr<ProcessorEntity> entity = CreateSynced();
const std::string specifics_hash = entity->metadata().specifics_hash();
entity->Delete();
ASSERT_TRUE(entity->metadata().is_deleted());
ASSERT_TRUE(entity->IsUnsynced());
ASSERT_EQ(1, entity->metadata().sequence_number());
// Undelete the entity with different specifics.
entity->MakeLocalChange(GenerateEntityData(kHash, kName, kValue2));
const std::string specifics_hash_v1 = entity->metadata().specifics_hash();
ASSERT_NE(specifics_hash_v1, specifics_hash);
EXPECT_FALSE(entity->metadata().is_deleted());
EXPECT_EQ(2, entity->metadata().sequence_number());
EXPECT_EQ(0, entity->metadata().acked_sequence_number());
EXPECT_EQ(1, entity->metadata().server_version());
EXPECT_TRUE(entity->IsUnsynced());
EXPECT_TRUE(entity->RequiresCommitRequest());
EXPECT_FALSE(entity->RequiresCommitData());
EXPECT_FALSE(entity->CanClearMetadata());
EXPECT_TRUE(entity->HasCommitData());
// Make a commit.
CommitRequestData request;
entity->InitializeCommitRequestData(&request);
EXPECT_EQ(kId, request.entity->id);
EXPECT_FALSE(entity->RequiresCommitRequest());
// Ack the commit.
entity->ReceiveCommitResponse(GenerateAckData(request, kId, 2), false,
kUnspecifiedModelTypeForUma);
EXPECT_EQ(2, entity->metadata().sequence_number());
EXPECT_EQ(2, entity->metadata().acked_sequence_number());
EXPECT_EQ(2, entity->metadata().server_version());
EXPECT_EQ(specifics_hash_v1, entity->metadata().specifics_hash());
EXPECT_EQ("", entity->metadata().base_specifics_hash());
EXPECT_FALSE(entity->IsUnsynced());
EXPECT_FALSE(entity->RequiresCommitRequest());
EXPECT_FALSE(entity->RequiresCommitData());
EXPECT_FALSE(entity->CanClearMetadata());
EXPECT_FALSE(entity->HasCommitData());
}
// Test that hashes and sequence numbers are handled correctly for the "commit // Test that hashes and sequence numbers are handled correctly for the "commit
// commit, ack ack" case. // commit, ack ack" case.
TEST_F(ProcessorEntityTest, LocalChangesInterleaved) { TEST_F(ProcessorEntityTest, LocalChangesInterleaved) {
......
...@@ -442,6 +442,39 @@ TEST(SyncedBookmarkTrackerTest, ...@@ -442,6 +442,39 @@ TEST(SyncedBookmarkTrackerTest,
Eq(kId1)); Eq(kId1));
} }
TEST(SyncedBookmarkTrackerTest, ShouldUndeleteTombstone) {
std::unique_ptr<SyncedBookmarkTracker> tracker =
SyncedBookmarkTracker::CreateEmpty(sync_pb::ModelTypeState());
const std::string kSyncId = "SYNC_ID";
const int64_t kId = 1;
const int64_t kServerVersion = 1000;
const base::Time kModificationTime(base::Time::Now() -
base::TimeDelta::FromSeconds(1));
const sync_pb::UniquePosition unique_position;
const sync_pb::EntitySpecifics specifics =
GenerateSpecifics(/*title=*/std::string(), /*url=*/std::string());
bookmarks::BookmarkNode node(kId, base::GenerateGUID(), GURL());
const SyncedBookmarkTracker::Entity* entity =
tracker->Add(&node, kSyncId, kServerVersion, kModificationTime,
unique_position, specifics);
ASSERT_THAT(tracker->TrackedUncommittedTombstonesCountForDebugging(), Eq(0U));
// Delete the bookmark, leading to a pending deletion (local tombstone).
tracker->MarkDeleted(tracker->GetEntityForSyncId(kSyncId));
ASSERT_THAT(entity->bookmark_node(), IsNull());
ASSERT_TRUE(entity->metadata()->is_deleted());
ASSERT_THAT(tracker->TrackedUncommittedTombstonesCountForDebugging(), Eq(1U));
// Undelete it.
tracker->UndeleteTombstoneForBookmarkNode(entity, &node);
EXPECT_THAT(entity->bookmark_node(), NotNull());
EXPECT_FALSE(entity->metadata()->is_deleted());
EXPECT_THAT(tracker->TrackedUncommittedTombstonesCountForDebugging(), Eq(0U));
}
TEST(SyncedBookmarkTrackerTest, TEST(SyncedBookmarkTrackerTest,
ShouldOrderParentUpdatesBeforeChildUpdatesAndDeletionsComeLast) { ShouldOrderParentUpdatesBeforeChildUpdatesAndDeletionsComeLast) {
const size_t kMaxEntries = 1000; const size_t kMaxEntries = 1000;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment