Commit 7a5d8e56 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Delete old syncer SyncerBookmarksTest tests

The modern codepaths within the sync engine have barely any special-
handling for bookmarks. The relevant bits already have unit-test
coverage, such as in ModelTypeWorkerTest, and most bookmark-related
logic lives in components/sync_bookmarks, where there is good test
coverage.

Besides that, most scenarios are also covered by sync integration
tests for bookmarks.

Change-Id: Ife306e8924fabaef518400ed0b210fcfdaaaea5a
Bug: 923287
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259859Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781375}
parent aa8e5899
...@@ -2101,254 +2101,6 @@ TEST_F(SyncerTest, CommitOnlyTypes) { ...@@ -2101,254 +2101,6 @@ TEST_F(SyncerTest, CommitOnlyTypes) {
EXPECT_TRUE(commit.entries(1).specifics().has_user_event()); EXPECT_TRUE(commit.entries(1).specifics().has_user_event());
} }
// Tests specifically related to bookmark (and therefore no client tags) sync
// logic. Entities without client tags have custom logic in parts of the code,
// and hence are not covered by e.g. the Undeletion tests below.
class SyncerBookmarksTest : public SyncerTest {
public:
SyncerBookmarksTest() : metahandle_(syncable::kInvalidMetaHandle) {}
void Create() {
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry bookmark(&trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
ASSERT_TRUE(bookmark.good());
bookmark.PutSpecifics(DefaultBookmarkSpecifics());
EXPECT_FALSE(bookmark.GetIsUnappliedUpdate());
EXPECT_FALSE(bookmark.GetId().ServerKnows());
metahandle_ = bookmark.GetMetahandle();
local_id_ = bookmark.GetId();
bookmark.PutIsUnsynced(true);
}
void Update() {
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry bookmark(&trans, GET_BY_ID, local_id_);
ASSERT_TRUE(bookmark.good());
bookmark.PutSpecifics(DefaultBookmarkSpecifics());
EXPECT_FALSE(bookmark.GetIsUnappliedUpdate());
bookmark.PutIsUnsynced(true);
if (bookmark.GetSyncing())
bookmark.PutDirtySync(true);
}
void Delete() {
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, GET_BY_HANDLE, metahandle_);
ASSERT_TRUE(entry.good());
EXPECT_EQ(metahandle_, entry.GetMetahandle());
// The order of setting IS_UNSYNCED vs IS_DEL matters. See
// WriteNode::Tombstone().
entry.PutIsUnsynced(true);
if (entry.GetSyncing())
entry.PutDirtySync(true);
entry.PutIsDel(true);
}
void UpdateAndDelete() {
Update();
Delete();
}
void Undelete() {
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, GET_BY_HANDLE, metahandle_);
ASSERT_TRUE(entry.good());
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_TRUE(entry.GetIsDel());
entry.PutIsDel(false);
entry.PutIsUnsynced(true);
if (entry.GetSyncing())
entry.PutDirtySync(true);
}
int64_t GetMetahandleOfTag() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_TRUE(entry.good());
if (!entry.good()) {
return syncable::kInvalidMetaHandle;
}
return entry.GetMetahandle();
}
Id GetServerId() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_TRUE(entry.good());
if (!entry.good()) {
return Id();
}
return entry.GetId();
}
void ExpectUnsyncedCreation() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_FALSE(entry.GetIsDel());
EXPECT_FALSE(entry.GetServerIsDel()); // Never been committed.
EXPECT_LT(entry.GetBaseVersion(), 0);
EXPECT_TRUE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
}
void ExpectUnsyncedUndeletion() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_FALSE(entry.GetIsDel());
EXPECT_TRUE(entry.GetServerIsDel());
EXPECT_GE(entry.GetBaseVersion(), 0);
EXPECT_TRUE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
EXPECT_TRUE(entry.GetId().ServerKnows());
}
void ExpectUnsyncedEdit() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_FALSE(entry.GetIsDel());
EXPECT_FALSE(entry.GetServerIsDel());
EXPECT_GE(entry.GetBaseVersion(), 0);
EXPECT_TRUE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
EXPECT_TRUE(entry.GetId().ServerKnows());
}
void ExpectUnsyncedDeletion() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_TRUE(entry.GetIsDel());
EXPECT_FALSE(entry.GetServerIsDel());
EXPECT_TRUE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
EXPECT_GE(entry.GetBaseVersion(), 0);
EXPECT_GE(entry.GetServerVersion(), 0);
}
void ExpectSyncedAndCreated() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_FALSE(entry.GetIsDel());
EXPECT_FALSE(entry.GetServerIsDel());
EXPECT_GE(entry.GetBaseVersion(), 0);
EXPECT_EQ(entry.GetBaseVersion(), entry.GetServerVersion());
EXPECT_FALSE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
}
void ExpectSyncedAndDeleted() {
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_TRUE(entry.GetIsDel());
EXPECT_TRUE(entry.GetServerIsDel());
EXPECT_FALSE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
EXPECT_GE(entry.GetBaseVersion(), 0);
EXPECT_GE(entry.GetServerVersion(), 0);
}
protected:
syncable::Id local_id_;
int64_t metahandle_;
};
TEST_F(SyncerBookmarksTest, CreateSyncThenDeleteSync) {
Create();
ExpectUnsyncedCreation();
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndCreated();
Delete();
ExpectUnsyncedDeletion();
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndDeleted();
}
TEST_F(SyncerBookmarksTest, CreateThenDeleteBeforeSync) {
Create();
ExpectUnsyncedCreation();
Delete();
// Deleting before the initial commit should result in not needing to send
// the delete to the server. It will still be in an unsynced state, but with
// IS_UNSYNCED set to false.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
EXPECT_EQ(metahandle_, entry.GetMetahandle());
EXPECT_TRUE(entry.GetIsDel());
EXPECT_FALSE(entry.GetServerIsDel());
EXPECT_FALSE(entry.GetIsUnsynced());
EXPECT_FALSE(entry.GetIsUnappliedUpdate());
EXPECT_EQ(-1, entry.GetBaseVersion());
EXPECT_EQ(0, entry.GetServerVersion());
}
}
TEST_F(SyncerBookmarksTest, LocalDeleteRemoteChangeConflict) {
Create();
ExpectUnsyncedCreation();
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndCreated();
Delete();
ExpectUnsyncedDeletion();
// Trigger a getupdates that modifies the bookmark. The update should be
// clobbered by the local delete.
mock_server_->AddUpdateBookmark(GetServerId(), Id::GetRoot(), "dummy", 10, 10,
local_cache_guid(), local_id_.GetServerId());
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndDeleted();
}
TEST_F(SyncerBookmarksTest, CreateThenDeleteDuringCommit) {
Create();
ExpectUnsyncedCreation();
// In the middle of the initial creation commit, perform a deletion.
mock_server_->SetMidCommitCallback(
base::BindOnce(&SyncerBookmarksTest::Delete, base::Unretained(this)));
// Commits creation.
EXPECT_TRUE(SyncShareNudge());
// Commits deletion.
mock_server_->SetMidCommitCallback(base::DoNothing());
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndDeleted();
}
TEST_F(SyncerBookmarksTest, CreateThenUpdateAndDeleteDuringCommit) {
Create();
ExpectUnsyncedCreation();
// In the middle of the initial creation commit, perform an updated followed
// by a deletion. This should trigger performing two consecutive commit
// cycles, resulting in the bookmark being both deleted and synced.
mock_server_->SetMidCommitCallback(base::BindOnce(
&SyncerBookmarksTest::UpdateAndDelete, base::Unretained(this)));
// Commits creation.
EXPECT_TRUE(SyncShareNudge());
// Commits update and deletion.
mock_server_->SetMidCommitCallback(base::DoNothing());
EXPECT_TRUE(SyncShareNudge());
ExpectSyncedAndDeleted();
}
// Test what happens if a client deletes, then recreates, an object very // Test what happens if a client deletes, then recreates, an object very
// quickly. It is possible that the deletion gets sent as a commit, and // quickly. It is possible that the deletion gets sent as a commit, and
// the undelete happens during the commit request. The principle here // the undelete happens during the commit request. The principle here
......
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