#include "components/ntp_tiles/custom_links_manager_impl.h"
#include <stdint.h>
#include <memory>
#include "base/files/scoped_temp_dir.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/ntp_tiles/pref_names.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "extensions/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
Link;
TestingPrefServiceSyncable;
namespace ntp_tiles {
namespace {
struct TestCaseItem { … };
const TestCaseItem kTestCase1[] = …;
const TestCaseItem kTestCase2[] = …;
const TestCaseItem kTestCase3[] = …;
const TestCaseItem kTestCaseMax[] = …;
const char kTestTitle[] = …;
const char16_t kTestTitle16[] = …;
const char kTestUrl[] = …;
#if BUILDFLAG(ENABLE_EXTENSIONS)
const char16_t kTestGmail16[] = …;
const char kTestGmailURL[] = …;
#endif
base::Value::List FillTestList(const char* url,
const char* title,
const bool is_most_visited) { … }
void AddTile(NTPTilesVector* tiles, const char* url, const char16_t* title) { … }
NTPTilesVector FillTestTiles(base::span<const TestCaseItem> test_cases) { … }
std::vector<Link> FillTestLinks(base::span<const TestCaseItem> test_cases) { … }
}
class CustomLinksManagerImplTest : public testing::Test { … };
TEST_F(CustomLinksManagerImplTest, InitializeOnlyOnce) { … }
TEST_F(CustomLinksManagerImplTest, UninitializeDeletesOldLinks) { … }
TEST_F(CustomLinksManagerImplTest, ReInitializeWithNewLinks) { … }
TEST_F(CustomLinksManagerImplTest, AddLink) { … }
TEST_F(CustomLinksManagerImplTest, AddLinkWhenAtMaxLinks) { … }
TEST_F(CustomLinksManagerImplTest, AddDuplicateLink) { … }
TEST_F(CustomLinksManagerImplTest, UpdateLink) { … }
TEST_F(CustomLinksManagerImplTest, UpdateLinkWithInvalidParams) { … }
TEST_F(CustomLinksManagerImplTest, UpdateLinkWhenUrlAlreadyExists) { … }
TEST_F(CustomLinksManagerImplTest, ReorderLink) { … }
TEST_F(CustomLinksManagerImplTest, DeleteLink) { … }
#if BUILDFLAG(ENABLE_EXTENSIONS)
TEST_F(CustomLinksManagerImplTest, MigratedDefaultAppDeletedSingle) { … }
TEST_F(CustomLinksManagerImplTest, DeletedMigratedDefaultAppMultiLink) { … }
#endif
TEST_F(CustomLinksManagerImplTest, DeleteLinkWhenUrlDoesNotExist) { … }
TEST_F(CustomLinksManagerImplTest, UndoAddLink) { … }
TEST_F(CustomLinksManagerImplTest, UndoUpdateLink) { … }
TEST_F(CustomLinksManagerImplTest, UndoDeleteLink) { … }
TEST_F(CustomLinksManagerImplTest, UndoDeleteLinkAfterAdd) { … }
TEST_F(CustomLinksManagerImplTest, ShouldDeleteMostVisitedOnHistoryDeletion) { … }
TEST_F(CustomLinksManagerImplTest,
ShouldDeleteMostVisitedOnAllHistoryDeletion) { … }
TEST_F(CustomLinksManagerImplTest, ShouldDeleteOnHistoryDeletionAfterShutdown) { … }
TEST_F(CustomLinksManagerImplTest, ShouldNotDeleteCustomLinkOnHistoryDeletion) { … }
TEST_F(CustomLinksManagerImplTest, ShouldIgnoreHistoryExpiredDeletions) { … }
TEST_F(CustomLinksManagerImplTest, ShouldIgnoreEmptyHistoryDeletions) { … }
TEST_F(CustomLinksManagerImplTest, ShouldNotUndoAfterHistoryDeletion) { … }
TEST_F(CustomLinksManagerImplTest, UpdateListAfterRemoteChange) { … }
TEST_F(CustomLinksManagerImplTest, InitializeListAfterRemoteChange) { … }
TEST_F(CustomLinksManagerImplTest, UninitializeListAfterRemoteChange) { … }
TEST_F(CustomLinksManagerImplTest, ClearThenUninitializeListAfterRemoteChange) { … }
}