chromium/content/browser/interest_group/interest_group_pa_report_util_unittest.cc

// Copyright 2023 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/interest_group/interest_group_pa_report_util.h"

#include <stdint.h>

#include <limits>
#include <optional>
#include <string>
#include <utility>

#include "base/test/scoped_feature_list.h"
#include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/aggregation_service/aggregatable_report.mojom.h"

namespace content {
namespace {

const PrivateAggregationRequestWithEventType
    kExpectedRequestWithReservedEventType(
        auction_worklet::mojom::PrivateAggregationRequest::New(
            auction_worklet::mojom::AggregatableReportContribution::
                NewHistogramContribution(
                    blink::mojom::AggregatableReportHistogramContribution::New(
                        /*bucket=*/123,
                        /*value=*/45,
                        /*filtering_id=*/std::nullopt)),
            blink::mojom::AggregationServiceMode::kDefault,
            blink::mojom::DebugModeDetails::New()),
        /*event_type=*/std::nullopt);

auction_worklet::mojom::SignalBucketPtr CreateSignalBucket(
    double scale,
    absl::uint128 offset_value,
    bool is_negative,
    auction_worklet::mojom::BaseValue base_value =
        auction_worklet::mojom::BaseValue::kWinningBid) {}

auction_worklet::mojom::SignalValuePtr CreateSignalValue(
    double scale,
    int32_t offset,
    auction_worklet::mojom::BaseValue base_value =
        auction_worklet::mojom::BaseValue::kWinningBid) {}

// Creates a PrivateAggregationRequest with histogram contribution using
// uint128 `bucket` and int `value`.
auction_worklet::mojom::PrivateAggregationRequestPtr CreateHistogramRequest(
    absl::uint128 bucket,
    int32_t value,
    std::optional<uint64_t> filtering_id = std::nullopt) {}

auction_worklet::mojom::EventTypePtr Reserved(
    auction_worklet::mojom::ReservedEventType reserved_event_type) {}

auction_worklet::mojom::EventTypePtr NonReserved(
    const std::string& event_type) {}

// Creates a PrivateAggregationRequest with ForEvent contribution using
// uint128 `bucket` and int `value`.
auction_worklet::mojom::PrivateAggregationRequestPtr CreateForEventRequest(
    absl::uint128 bucket,
    int32_t value,
    auction_worklet::mojom::EventTypePtr event_type,
    std::optional<uint64_t> filtering_id = std::nullopt) {}

// Creates a PrivateAggregationRequest with ForEvent contribution using
// `bucket` object and int `value`.
auction_worklet::mojom::PrivateAggregationRequestPtr
CreateForEventRequestWithBucketObject(
    auction_worklet::mojom::SignalBucketPtr bucket,
    int32_t value,
    auction_worklet::mojom::EventTypePtr event_type,
    std::optional<uint64_t> filtering_id = std::nullopt) {}

// Creates a PrivateAggregationRequest with ForEvent contribution using
// uint128 `bucket` and `value` object.
auction_worklet::mojom::PrivateAggregationRequestPtr
CreateForEventRequestWithValueObject(
    absl::uint128 bucket,
    auction_worklet::mojom::SignalValuePtr value,
    auction_worklet::mojom::EventTypePtr event_type,
    std::optional<uint64_t> filtering_id = std::nullopt) {}

PrivateAggregationRequestWithEventType
CreatePrivateAggregationRequestWithEventType(
    auction_worklet::mojom::PrivateAggregationRequestPtr request,
    const std::optional<std::string>& event_type = std::nullopt) {}

}  // namespace

class InterestGroupPaReportUtilTest : public testing::Test {};

// Expects FillInPrivateAggregationRequest() returns the same request if its
// input `request` is a HistogramContribution, regardless of is_winner being
// true or false.
TEST_F(InterestGroupPaReportUtilTest, HistogramContribution) {}

// FillInPrivateAggregationRequest() sets returned request's
// aggregation_mode and debug_mode_details correctly.
TEST_F(InterestGroupPaReportUtilTest, AggregationModeAndDebugMode) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionReservedEventType) {}

TEST_F(InterestGroupPaReportUtilTest,
       ForEventContributionNonReservedEventType) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionBaseValueWinningBid) {}

TEST_F(InterestGroupPaReportUtilTest,
       ForEventContributionBaseValueHighestScoringOtherBid) {}

TEST_F(InterestGroupPaReportUtilTest,
       ForEventContributionBaseValueRejectReason) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionBaseValueTimings) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionNegativeValue) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionNoScaleOrOffset) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionZeroScale) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionCalculateBucket) {}

TEST_F(InterestGroupPaReportUtilTest, ForEventContributionCalculateValue) {}

TEST_F(InterestGroupPaReportUtilTest,
       FilteringIdPassedUnchangedIfFeatureEnabled) {}

TEST_F(InterestGroupPaReportUtilTest, HasValidFilteringId_FeatureEnabled) {}

TEST_F(InterestGroupPaReportUtilTest, HasValidFilteringId_FeatureDisabled) {}

}  // namespace content