#include <stddef.h>
#include <memory>
#include <utility>
#include "base/memory/ref_counted_memory.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/policy/profile_policy_connector_builder.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/bookmarks_helper.h"
#include "chrome/browser/sync/test/integration/encryption_helper.h"
#include "chrome/browser/sync/test/integration/sync_service_impl_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/sync/engine/cycle/sync_cycle_snapshot.h"
#include "components/sync/engine/loopback_server/persistent_permanent_entity.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_service_impl.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/resource/resource_scale_factor.h"
namespace {
BookmarkNode;
AddFolder;
AddURL;
AllModelsMatch;
BookmarkModelMatchesFakeServerChecker;
BookmarksMatchChecker;
CheckFaviconExpired;
CheckHasNoFavicon;
ContainsDuplicateBookmarks;
CountAllBookmarks;
CountBookmarksWithTitlesMatching;
CountBookmarksWithUrlsMatching;
CountFoldersWithTitlesMatching;
CreateFavicon;
DeleteFaviconMappings;
ExpireFavicon;
GetBookmarkBarNode;
GetBookmarkModel;
GetManagedNode;
GetOtherNode;
GetSyncedBookmarksNode;
GetUniqueNodeByURL;
HasNodeWithURL;
IndexedFolderName;
IndexedSubfolderName;
IndexedSubsubfolderName;
IndexedURL;
IndexedURLTitle;
IsFolderWithTitle;
IsFolderWithTitleAndChildren;
IsFolderWithTitleAndChildrenAre;
IsUrlBookmarkWithTitleAndUrl;
Move;
Remove;
ReverseChildOrder;
SetFavicon;
SetTitle;
SetURL;
SortChildren;
Contains;
ElementsAre;
ElementsAreArray;
IsEmpty;
NotNull;
SizeIs;
UnorderedElementsAreArray;
BookmarkNodeMatcher;
const char kGenericURL[] = …;
const char kGenericURLTitle[] = …;
const char kGenericFolderName[] = …;
const char kGenericSubfolderName[] = …;
const char kValidPassphrase[] = …;
class TwoClientBookmarksSyncTest : public SyncTest { … };
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, Sanity) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SimultaneousURLChanges) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddFirstFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_Add3FoldersInShuffledOrder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_AddFirstBMWithoutFavicon) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddFirstBMWithFavicon) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_SetFaviconHiDPI) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_UpdatingTitleDoesNotUpdateFaviconLastUpdatedTime) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_SetFaviconTwoBookmarksSameIconURL) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_DeleteFavicon) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddFirstBMUnderFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_AddSeveralBMsUnderBMBarAndOtherBM) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddSeveralBMsAndFolders) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DuplicateBMWithDifferentURLSameName) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DuplicateBookmarksWithSameURL) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_RenameBMName) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_RenameBMURL) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_TwiceRenamingBookmarkName) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_TwiceRenamingBookmarkURL) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_RenameBMFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_RenameEmptyBMFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_RenameBMFolderWithLongHierarchy) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_RenameBMFolderThatHasParentAndChildren) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_RenameBMNameAndURL) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DeleteBMEmptyAccountAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelBMNonEmptyAccountAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelFirstBMUnderBMFoldNonEmptyFoldAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelLastBMUnderBMFoldNonEmptyFoldAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelMiddleBMUnderBMFoldNonEmptyFoldAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelBMsUnderBMFoldEmptyFolderAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelEmptyBMFoldEmptyAccountAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelEmptyBMFoldNonEmptyAccountAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelBMFoldWithBMsNonEmptyAccountAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_ReverseTheOrderOfTwoBMs) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_ReverseTheOrderOf10BMs) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_MovingBMsFromBMBarToBMFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_MovingBMsFromBMFoldToBMBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_MovingBMsFromParentBMFoldToChildBMFold) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_MovingBMsFromChildBMFoldToParentBMFold) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_HoistBMs10LevelUp) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_SinkBMs10LevelDown) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_SinkEmptyBMFold5LevelsDown) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_SinkNonEmptyBMFold5LevelsDown) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_HoistFolder5LevelsUp) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_ReverseTheOrderOfTwoBMFolders) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SC_ReverseTheOrderOfTenBMFolders) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_BiDirectionalPushAddingBM) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_BiDirectionalPush_AddingSameBMs) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_Merge_CaseInsensitivity_InNames) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_SimpleMergeOfDifferentBMModels) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeSimpleBMHierarchyUnderBMBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeSimpleBMHierarchyEqualSetsUnderBMBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeBMFoldersWithDifferentBMs) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeDifferentBMModelsModeratelyComplex) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeSimpleBMHierarchySubsetUnderBMFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_MergeSimpleBMHierarchySubsetUnderBookmarkBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_Merge_SimpleBMHierarchy_Under_BMFolder) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BMFolder) { … }
IN_PROC_BROWSER_TEST_F(
TwoClientBookmarksSyncTest,
MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BookmarkBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_Merge_SimpleBMHierarchy_DuplicateBMs_Under_BMBar) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, DisableBookmarks) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, DisableSync) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, MC_DuplicateFolders) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, MC_DeleteBookmark) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_BookmarkNameChangeConflict) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_BookmarkURLChangeConflict) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
MC_FolderNameChangeConflict) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
FirstClientEnablesEncryptionWithPassSecondChanges) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, RacyPositionChanges) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, CreateSyncedBookmarks) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
BookmarkAllNodesRemovedEvent) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, ManagedBookmarks) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, E2E_ONLY(SanitySetup)) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
E2E_ONLY(OneClientAddsBookmark)) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
OneClientAddsFolderAndBookmark) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
E2E_ONLY(TwoClientsAddBookmarks)) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
E2E_ENABLED(AddBookmarkWhileDisabled)) { … }
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, ReorderChildren) { … }
}