chromium/components/segmentation_platform/internal/database/ukm_database_backend_unittest.cc

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

#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;

// Set path to protected file which fails to open the database.
#if BUILDFLAG(IS_POSIX)
constexpr base::FilePath::CharType kBadFilePath[] =);
#else
constexpr base::FilePath::CharType kBadFilePath[] =
    FILE_PATH_LITERAL("C:\\Windows");
#endif

// Stats about the database tables.
struct DatabaseStats {};

// Computes stats about the database tables.
DatabaseStats GetDatabaseStats(sql::Database& db) {}

// Checks if the metrics table has exactly `expected_count` metrics with the
// `url_id`.
void ExpectEntriesWithUrlId(sql::Database& db,
                            UrlId url_id,
                            int expected_count) {}

// Creates a sample UKM entry, with a single event.
ukm::mojom::UkmEntryPtr GetSampleUkmEntry(ukm::SourceId source_id = 10) {}

UmaMetricEntry GetSampleMetricsRow() {}

}  // namespace

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) {}

}  // namespace segmentation_platform