#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(
123,
45,
std::nullopt)),
blink::mojom::AggregationServiceMode::kDefault,
blink::mojom::DebugModeDetails::New()),
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) { … }
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) { … }
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) { … }
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) { … }
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) { … }
}
class InterestGroupPaReportUtilTest : public testing::Test { … };
TEST_F(InterestGroupPaReportUtilTest, HistogramContribution) { … }
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) { … }
}