chromium/components/sync_bookmarks/bookmark_model_observer_impl_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/sync_bookmarks/bookmark_model_observer_impl.h"

#include <algorithm>
#include <array>
#include <list>
#include <map>
#include <memory>
#include <utility>
#include <vector>

#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/favicon_base/favicon_types.h"
#include "components/sync/base/features.h"
#include "components/sync/base/time.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/protocol/bookmark_specifics.pb.h"
#include "components/sync/protocol/data_type_state.pb.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync_bookmarks/bookmark_model_view.h"
#include "components/sync_bookmarks/bookmark_specifics_conversions.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 "components/undo/bookmark_undo_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_unittest_util.h"

namespace sync_bookmarks {

namespace {

AtLeast;
ElementsAre;
Eq;
IsEmpty;
IsNull;
Ne;
NiceMock;
NotNull;
SizeIs;
UnorderedElementsAre;

const char kBookmarkBarId[] =;
const char kBookmarkBarTag[] =;
const char kOtherBookmarksId[] =;
const char kOtherBookmarksTag[] =;
const char kMobileBookmarksId[] =;
const char kMobileBookmarksTag[] =;

// Matches |arg| of type SyncedBookmarkTrackerEntity*.
MATCHER_P(HasBookmarkNode, node, "") {}

// Returns a single-color 16x16 image using |color|.
gfx::Image CreateTestImage(SkColor color) {}

void AddPermanentFoldersToTracker(const BookmarkModelView* model,
                                  SyncedBookmarkTracker* tracker) {}

// TestBookmarkClient that supports undoing removals.
class TestBookmarkClientWithUndo : public bookmarks::TestBookmarkClient {};

class BookmarkModelObserverImplTest
    : public testing::TestWithParam<TestBookmarkModelView::ViewType> {};

TEST_P(BookmarkModelObserverImplTest,
       BookmarkAddedShouldPutInTheTrackerAndNudgeForCommit) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkChangedShouldUpdateTheTrackerAndNudgeForCommit) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkMovedShouldUpdateTheTrackerAndNudgeForCommit) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkMovedThatBecameUnsyncableShouldIssueTombstone) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkMovedThatBecameSyncableShouldIssueCreation) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkFolderMovedWithChildrenThatBecameSyncableShouldIssueCreations) {}

TEST_P(BookmarkModelObserverImplTest,
       ReorderChildrenShouldUpdateTheTrackerAndNudgeForCommit) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldReorderChildrenAndUpdateOnlyMovedToRightBookmark) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldReorderChildrenAndUpdateOnlyMovedToLeftBookmark) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldReorderWhenBookmarkMovedToLastPosition) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldReorderWhenBookmarkMovedToFirstPosition) {}

TEST_P(BookmarkModelObserverImplTest, ShouldReorderWhenAllBookmarksReversed) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldNotReorderIfAllBookmarksStillOrdered) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkRemovalShouldUpdateTheTrackerAndNudgeForCommit) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkCreationAndRemovalShouldRequireTwoCommitResponsesBeforeRemoval) {}

TEST_P(BookmarkModelObserverImplTest,
       BookmarkCreationAndRemovalBeforeCommitRequestShouldBeRemovedDirectly) {}

TEST_P(BookmarkModelObserverImplTest, ShouldPositionSiblings) {}

TEST_P(BookmarkModelObserverImplTest, ShouldNotSyncUnsyncableBookmarks) {}

TEST_P(BookmarkModelObserverImplTest, ShouldAddChildrenInArbitraryOrder) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldCallOnBookmarkModelBeingDeletedClosure) {}

TEST_P(BookmarkModelObserverImplTest, ShouldNotIssueCommitUponFaviconLoad) {}

TEST_P(BookmarkModelObserverImplTest, ShouldCommitLocalFaviconChange) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldNudgeForCommitOnFaviconLoadAfterRestart) {}

TEST_P(BookmarkModelObserverImplTest,
       ShouldAddRestoredBookmarkWhenTombstoneCommitMayHaveStarted) {}

// Tests that the bookmark entity will be committed if its favicon is deleted.
TEST_P(BookmarkModelObserverImplTest, ShouldCommitOnDeleteFavicon) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace

}  // namespace sync_bookmarks