#include "components/segmentation_platform/internal/database/ukm_database_backend.h"
#include "base/files/scoped_temp_dir.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/segmentation_platform/internal/database/ukm_database_test_utils.h"
#include "components/segmentation_platform/internal/database/ukm_metrics_table.h"
#include "components/segmentation_platform/internal/database/ukm_types.h"
#include "components/segmentation_platform/internal/database/ukm_url_table.h"
#include "components/segmentation_platform/public/types/processed_value.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace segmentation_platform {
namespace {
ProcessedValue;
UrlMatcher;
Contains;
ElementsAre;
ElementsAreArray;
UnorderedElementsAre;
#if BUILDFLAG(IS_POSIX)
constexpr base::FilePath::CharType kBadFilePath[] = …);
#else
constexpr base::FilePath::CharType kBadFilePath[] =
FILE_PATH_LITERAL("C:\\Windows");
#endif
struct DatabaseStats { … };
DatabaseStats GetDatabaseStats(sql::Database& db) { … }
void ExpectEntriesWithUrlId(sql::Database& db,
UrlId url_id,
int expected_count) { … }
ukm::mojom::UkmEntryPtr GetSampleUkmEntry(ukm::SourceId source_id = 10) { … }
UmaMetricEntry GetSampleMetricsRow() { … }
}
class UkmDatabaseBackendTest : public testing::Test { … };
TEST_F(UkmDatabaseBackendTest, EntriesWithoutUrls) { … }
TEST_F(UkmDatabaseBackendTest, UrlIdsForEntries) { … }
TEST_F(UkmDatabaseBackendTest, UpdateSourceUrl) { … }
TEST_F(UkmDatabaseBackendTest, ValidatedUrl) { … }
TEST_F(UkmDatabaseBackendTest, UrlValidation) { … }
TEST_F(UkmDatabaseBackendTest, RemoveUrls) { … }
TEST_F(UkmDatabaseBackendTest, DestructorCommitsTransaction) { … }
TEST_F(UkmDatabaseBackendTest, RemoveUrlsCommitsImmediately) { … }
TEST_F(UkmDatabaseBackendTest, DeleteAllUrls) { … }
TEST_F(UkmDatabaseBackendTest, DeleteOldEntries) { … }
TEST_F(UkmDatabaseBackendTest, ReadOnlyQueries) { … }
class FailedUkmDatabaseTest : public UkmDatabaseBackendTest { … };
TEST_F(FailedUkmDatabaseTest, QueriesAreNoop) { … }
}