chromium/content/browser/private_aggregation/private_aggregation_budgeter_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 "content/browser/private_aggregation/private_aggregation_budgeter.h"

#include <stdint.h>

#include <memory>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/barrier_closure.h"
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/task/thread_pool.h"
#include "base/task/updateable_sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "content/browser/private_aggregation/private_aggregation_budget_key.h"
#include "content/browser/private_aggregation/private_aggregation_budget_storage.h"
#include "content/browser/private_aggregation/proto/private_aggregation_budgets.pb.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/private_aggregation_data_model.h"
#include "net/base/schemeful_site.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/protobuf/src/google/protobuf/repeated_ptr_field.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace content {

namespace {
BudgetEntryValidityStatus;

RequestResult;

constexpr auto kExampleTime =;

class PrivateAggregationBudgeterUnderTest : public PrivateAggregationBudgeter {};

// TODO(alexmt): Consider moving logic shared with
// PrivateAggregationBudgetStorageTest to a joint test harness.
class PrivateAggregationBudgeterTest : public testing::Test {};

TEST_F(PrivateAggregationBudgeterTest,
       BudgeterCreated_DatabaseInitializedLazily) {}

TEST_F(PrivateAggregationBudgeterTest,
       DatabaseInitializationFails_StatusIsClosed) {}

TEST_F(PrivateAggregationBudgeterTest, InMemory_StillInitializes) {}

TEST_F(PrivateAggregationBudgeterTest, DatabaseReopened_DataPersisted) {}

TEST_F(PrivateAggregationBudgeterTest,
       InMemoryDatabaseReopened_DataNotPersisted) {}

TEST_F(PrivateAggregationBudgeterTest, ConsumeBudgetSameKey) {}

TEST_F(PrivateAggregationBudgeterTest,
       ConsumeBudgetDifferentWindowsSmallerScope) {}

TEST_F(PrivateAggregationBudgeterTest,
       ConsumeBudgetDifferentWindowsLargerScope) {}

TEST_F(PrivateAggregationBudgeterTest, ConsumeBudgetDifferentApis) {}

TEST_F(PrivateAggregationBudgeterTest, ConsumeBudgetDifferentSites) {}

TEST_F(PrivateAggregationBudgeterTest, ConsumeBudgetDifferentOriginsSameSite) {}

TEST_F(PrivateAggregationBudgeterTest, ConsumeBudgetValueTooLarge) {}

TEST_F(PrivateAggregationBudgeterTest, BudgetValidityMetricsRecorded) {}

TEST_F(PrivateAggregationBudgeterTest,
       EnoughBudgetIfNotEnoughOverallMetricRecorded) {}

TEST_F(PrivateAggregationBudgeterTest,
       ConsumeBudgetBeforeInitialized_QueriesAreQueued) {}

TEST_F(PrivateAggregationBudgeterTest,
       ClearDataBeforeInitialized_QueriesAreQueued) {}

TEST_F(PrivateAggregationBudgeterTest,
       ConsumeBudgetBeforeFailedInitialization_QueuedQueriesAreRejected) {}

TEST_F(PrivateAggregationBudgeterTest,
       MaxPendingCallsExceeded_AdditionalConsumeBudgetCallsRejected) {}

TEST_F(PrivateAggregationBudgeterTest,
       MaxPendingCallsExceeded_AdditionalDataClearingCallsAllowed) {}

TEST_F(PrivateAggregationBudgeterTest,
       BudgeterDestroyedImmediatelyAfterCreation_DoesNotCrash) {}

TEST_F(PrivateAggregationBudgeterTest,
       BudgeterDestroyedImmediatelyAfterInitializationStarted_DoesNotCrash) {}

TEST_F(PrivateAggregationBudgeterTest,
       BudgeterDestroyedImmediatelyAfterInitialization_DoesNotCrash) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataBasicTest) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataCrossesWindowBoundary) {}

TEST_F(PrivateAggregationBudgeterTest,
       ClearDataDoesntAffectWindowsOutsideRange) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataAllApisAffected) {}

TEST_F(PrivateAggregationBudgeterTest, ClearAllDataBasicTest) {}

TEST_F(PrivateAggregationBudgeterTest, ClearAllDataNullTimes) {}

TEST_F(PrivateAggregationBudgeterTest, ClearAllDataNullStartNonNullEndTime) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataFilterSelectsOrigins) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataAllTimeFilterSelectsOrigins) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataUnusedSameSiteOrigin) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataSameSiteOriginUsed) {}

TEST_F(PrivateAggregationBudgeterTest,
       ClearDataOriginLastUsedBeforeDeletionWindow) {}

TEST_F(PrivateAggregationBudgeterTest,
       BudgeterDestroyedImmedatelyAfterClearData_CallbackStillRun) {}

TEST_F(PrivateAggregationBudgeterTest, ClearDataByDataKey) {}

TEST_F(PrivateAggregationBudgeterTest, StaleDataClearedOnInitialization) {}

TEST_F(PrivateAggregationBudgeterTest, StaleDataClearedAfterConsumeBudget) {}

}  // namespace

}  // namespace content