#include "components/sync_bookmarks/bookmark_model_merger.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/uuid.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/browser/bookmark_uuids.h"
#include "components/favicon/core/test/mock_favicon_service.h"
#include "components/sync/base/features.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync_bookmarks/bookmark_model_view.h"
#include "components/sync_bookmarks/bookmark_specifics_conversions.h"
#include "components/sync_bookmarks/switches.h"
#include "components/sync_bookmarks/synced_bookmark_tracker.h"
#include "components/sync_bookmarks/synced_bookmark_tracker_entity.h"
#include "components/sync_bookmarks/test_bookmark_model_view.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
Eq;
IsEmpty;
IsNull;
NotNull;
UnorderedElementsAre;
namespace sync_bookmarks {
namespace {
MATCHER_P(HasTitle, title, "") { … }
enum class ExpectedBookmarksUuidDuplicates { … };
const char kBookmarkBarId[] = …;
const char kBookmarkBarTag[] = …;
enum class ExpectedRemoteBookmarkUpdateError { … };
MATCHER_P(ElementRawPointersAre, expected_raw_ptr, "") { … }
MATCHER_P2(ElementRawPointersAre, expected_raw_ptr0, expected_raw_ptr1, "") { … }
base::Uuid BookmarkBarUuid() { … }
std::string GetFakeServerIdFromUuid(const base::Uuid& uuid) { … }
class UpdateResponseDataBuilder { … };
syncer::UpdateResponseData CreateUpdateResponseData(
const base::Uuid& uuid,
const base::Uuid& parent_uuid,
const std::string& title,
const std::string& url,
bool is_folder,
const syncer::UniquePosition& unique_position,
const std::string& icon_url = std::string(),
const std::string& icon_data = std::string()) { … }
syncer::UpdateResponseData CreateBookmarkBarNodeUpdateData() { … }
syncer::UniquePosition PositionOf(const bookmarks::BookmarkNode* node,
const SyncedBookmarkTracker& tracker) { … }
bool PositionsInTrackerMatchModel(const bookmarks::BookmarkNode* node,
const SyncedBookmarkTracker& tracker) { … }
std::unique_ptr<SyncedBookmarkTracker> Merge(
syncer::UpdateResponseDataList updates,
BookmarkModelView* bookmark_model) { … }
static syncer::UniquePosition MakeRandomPosition() { … }
}
TEST(BookmarkModelMergerTest, ShouldMergeLocalAndRemoteModels) { … }
TEST(BookmarkModelMergerTest, ShouldMergeRemoteReorderToLocalModel) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreManagedNodes) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreUnsyncableNodes) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreUnsyncableNodeWithCollidingUuid) { … }
TEST(BookmarkModelMergerTest, ShouldMergeFaviconsForRemoteNodesOnly) { … }
TEST(BookmarkModelMergerTest,
ShouldMergeLocalAndRemoteNodesWhenRemoteHasLegacyCanonicalTitle) { … }
TEST(BookmarkModelMergerTest,
ShouldMergeLocalAndRemoteNodesWhenRemoteHasLegacyTruncatedTitle) { … }
TEST(BookmarkModelMergerTest,
ShouldMergeNodesWhenRemoteHasLegacyTruncatedTitleInFullTitle) { … }
TEST(BookmarkModelMergerTest,
ShouldMergeLocalAndRemoteNodesWhenLocalHasLegacyTruncatedTitle) { … }
TEST(BookmarkModelMergerTest, ShouldMergeAndUseRemoteUuid) { … }
TEST(BookmarkModelMergerTest,
ShouldMergeAndKeepOldUuidWhenRemoteUuidIsInvalid) { … }
TEST(BookmarkModelMergerTest, ShouldMergeBookmarkByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldMergeBookmarkByUuidAndReparent) { … }
TEST(BookmarkModelMergerTest, ShouldMergeFolderByUuidAndNotSemantics) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreChildrenForNonFolderNodes) { … }
TEST(
BookmarkModelMergerTest,
ShouldIgnoreFolderSemanticsMatchAndLaterMatchByUuidWithSemanticsNodeFirst) { … }
TEST(BookmarkModelMergerTest,
ShouldIgnoreFolderSemanticsMatchAndLaterMatchByUuidWithUuidNodeFirst) { … }
TEST(BookmarkModelMergerTest, ShouldReplaceBookmarkUuidWithConflictingURLs) { … }
TEST(BookmarkModelMergerTest, ShouldReplaceBookmarkUuidWithConflictingTypes) { … }
TEST(BookmarkModelMergerTest,
ShouldReplaceBookmarkUuidWithConflictingTypesAndLocalChildren) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreRemoteUuidIfOrphanNode) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreRemoteUuidIfInvalidSpecifics) { … }
TEST(BookmarkModelMergerTest, ShouldIgnoreRemoteUpdateWithInvalidUuid) { … }
TEST(BookmarkModelMergerTest,
ShouldProcessLocalCreationWithUntrackedPredecessorNode) { … }
TEST(BookmarkModelMergerTest, ShouldLogMetricsForInvalidSpecifics) { … }
TEST(BookmarkModelMergerTest, ShouldLogMetricsForChildrenOfNonFolder) { … }
TEST(BookmarkModelMergerTest, ShouldLogMetricsForChildrenOfOrphanUpdates) { … }
TEST(BookmarkModelMergerTest, ShouldLogMetricsForUnsupportedServerTag) { … }
TEST(BookmarkModelMergerTest, ShouldLogMetricsForkDescendantOfRootNode) { … }
TEST(BookmarkModelMergerTest, ShouldRemoveMatchingDuplicatesByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldRemoveDifferentDuplicatesByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldRemoveMatchingFolderDuplicatesByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldRemoveDifferentFolderDuplicatesByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldEnsureLimitDepthOfTree) { … }
TEST(BookmarkModelMergerTest, ShouldReuploadBookmarkOnEmptyUniquePosition) { … }
TEST(BookmarkModelMergerTest, ShouldRemoveDifferentTypeDuplicatesByUuid) { … }
TEST(BookmarkModelMergerTest, ShouldReportTimeMetrics) { … }
}