From 3b13b364ee7ac1839868dcad6701d2b9b2469c44 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Fri, 21 Feb 2020 19:27:25 +0200 Subject: [PATCH] Test for prevent duplication of brave-sync metainfo in bookmarks on copying --- .../brave_sync/brave_sync_service_unittest.cc | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/components/brave_sync/brave_sync_service_unittest.cc b/components/brave_sync/brave_sync_service_unittest.cc index ebb005a15a6d..4523ad5c1d53 100644 --- a/components/brave_sync/brave_sync_service_unittest.cc +++ b/components/brave_sync/brave_sync_service_unittest.cc @@ -1600,3 +1600,34 @@ TEST_F(BraveSyncServiceTest, CheckOtherBookmarkChildRecord) { sync_service()->CheckOtherBookmarkChildRecord(record_a1.get()); EXPECT_EQ(record_a1->GetBookmark().parentFolderObjectId, object_id_iter1); } + +TEST_F(BraveSyncServiceTest, AddNonClonedBookmarkKeys) { + sync_service()->AddNonClonedBookmarkKeys(model()); + const bookmarks::BookmarkNode* bookmark_a1 = + model()->AddURL(model()->other_node(), 0, base::ASCIIToUTF16("A1"), + GURL("https://a1.com")); + + AsMutable(bookmark_a1)->SetMetaInfo("object_id", "object_id_value"); + AsMutable(bookmark_a1)->SetMetaInfo("order", "order_value"); + AsMutable(bookmark_a1)->SetMetaInfo("sync_timestamp", "sync_timestamp_value"); + AsMutable(bookmark_a1)->SetMetaInfo("version", "version_value"); + + model()->Copy(bookmark_a1, model()->other_node(), 1); + + const bookmarks::BookmarkNode* bookmark_copy = + model()->other_node()->children().at(1).get(); + + std::string meta_object_id; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("object_id", &meta_object_id)); + EXPECT_TRUE(meta_object_id.empty()); + std::string meta_order; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("order", &meta_order)); + EXPECT_TRUE(meta_order.empty()); + std::string meta_sync_timestamp; + EXPECT_FALSE( + bookmark_copy->GetMetaInfo("sync_timestamp", &meta_sync_timestamp)); + EXPECT_TRUE(meta_sync_timestamp.empty()); + std::string meta_version; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("version", &meta_version)); + EXPECT_TRUE(meta_version.empty()); +}