#include "components/power_bookmarks/storage/power_bookmark_database_impl.h"
#include <memory>
#include <vector>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "components/power_bookmarks/common/power_test_util.h"
#include "components/power_bookmarks/common/search_params.h"
#include "components/sync/protocol/power_bookmark_specifics.pb.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/sqlite_result_code_values.h"
#include "sql/statement.h"
#include "sql/test/test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace power_bookmarks {
namespace {
const sync_pb::PowerBookmarkSpecifics::PowerType kMockType = …;
const sync_pb::PowerBookmarkSpecifics::PowerType kNoteType = …;
std::string WritePower(PowerBookmarkDatabaseImpl* pbdb,
std::unique_ptr<Power> power) { … }
base::Time EpochAndSeconds(int seconds_after_epoch) { … }
bool ContainsPower(const std::vector<std::unique_ptr<Power>>& list,
sync_pb::PowerBookmarkSpecifics::PowerType power_type,
GURL url) { … }
bool ContainsPowerOverview(
const std::vector<std::unique_ptr<PowerOverview>>& list,
sync_pb::PowerBookmarkSpecifics::PowerType power_type,
GURL url,
size_t count) { … }
}
class PowerBookmarkDatabaseImplTest : public testing::Test { … };
TEST_F(PowerBookmarkDatabaseImplTest, InitDatabaseWithErrorCallback) { … }
TEST_F(PowerBookmarkDatabaseImplTest, InitDatabase) { … }
TEST_F(PowerBookmarkDatabaseImplTest, InitDatabaseTwice) { … }
TEST_F(PowerBookmarkDatabaseImplTest, DatabaseNewVersion) { … }
TEST_F(PowerBookmarkDatabaseImplTest, DatabaseHasSchemaNoMeta) { … }
TEST_F(PowerBookmarkDatabaseImplTest, UpdatePowerIfExist) { … }
TEST_F(PowerBookmarkDatabaseImplTest, ShouldNotUpdatePowerIfNotExist) { … }
TEST_F(PowerBookmarkDatabaseImplTest, UpdatePowerShouldMergePower) { … }
TEST_F(PowerBookmarkDatabaseImplTest, UpdateNotesWithMerge) { … }
TEST_F(PowerBookmarkDatabaseImplTest, WritePowerIfNotExist) { … }
TEST_F(PowerBookmarkDatabaseImplTest, ShouldNotCreatePowerIfExist) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForURL) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForURLUnspecifiedType) { … }
#if defined(MEMORY_SANITIZER)
#define MAYBE_GetPowersForURLDeserializingProtoFails …
#else
#define MAYBE_GetPowersForURLDeserializingProtoFails …
#endif
TEST_F(PowerBookmarkDatabaseImplTest,
MAYBE_GetPowersForURLDeserializingProtoFails) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowerOverviewsForType) { … }
#if defined(MEMORY_SANITIZER)
#define MAYBE_GetPowerOverviewsForTypeDeserializingProtoFails …
#else
#define MAYBE_GetPowerOverviewsForTypeDeserializingProtoFails …
#endif
TEST_F(PowerBookmarkDatabaseImplTest,
MAYBE_GetPowerOverviewsForTypeDeserializingProtoFails) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForSearchParams) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForSearchParamsMatchNoteText) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForSearchParamsMatchType) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowerOverviewsForSearchParams) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowerOverviewsCaseSensitive) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowerOverviewsIgnoreCase) { … }
TEST_F(PowerBookmarkDatabaseImplTest,
GetPowerOverviewsForSearchParamsMatchNoteText) { … }
TEST_F(PowerBookmarkDatabaseImplTest,
GetPowerOverviewsForSearchParamsShouldNotMatchNoteUrl) { … }
TEST_F(PowerBookmarkDatabaseImplTest, DeletePower) { … }
TEST_F(PowerBookmarkDatabaseImplTest, DeletePowersForURL) { … }
TEST_F(PowerBookmarkDatabaseImplTest, DeletePowersForURLUnspecifiedType) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetAllPowers) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowersForGUIDs) { … }
TEST_F(PowerBookmarkDatabaseImplTest, GetPowerForGUID) { … }
}