chromium/components/variations/service/limited_entropy_randomization_unittest.cc

// Copyright 2024 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/variations/service/limited_entropy_randomization.h"

#include <cstdint>
#include <utility>
#include <vector>

#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/variations/entropy_provider.h"
#include "components/variations/limited_entropy_mode_gate.h"
#include "components/variations/proto/layer.pb.h"
#include "components/variations/proto/study.pb.h"
#include "components/variations/proto/variations_seed.pb.h"
#include "components/variations/variations_layers.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace variations {

namespace {

inline constexpr int kTestLayerId =;
inline constexpr int kTestLayerMemberId =;
inline constexpr char kTestClientId[] =;

// Hard code the enum bucket values, and use these in tests so that any
// re-numbering can be detected.
// LimitedEntropySeedRejectionReason::kHighEntropyUsage
inline constexpr int kHighEntropyUsageBucket =;
// LimitedEntropySeedRejectionReason::kMoreThenOneLimitedLayer
inline constexpr int kMoreThenOneLimitedLayerBucket =;
// LimitedEntropySeedRejectionReason::kLimitedLayerHasInvalidSlotBounds
inline constexpr int kLimitedLayerHasInvalidSlotBoundsBucket =;
// LimitedEntropySeedRejectionReason::kLimitedLayerDoesNotContainSlots
inline constexpr int kLimitedLayerDoesNotContainSlotsBucket =;
// InvalidLayerReason::kNoSlots
inline constexpr int kNoSlotsBucket =;
// InvalidLayerReason::kInvalidSlotBounds
inline constexpr int kInvalidSlotBoundsBucket =;

// The following value ensures slot 0 is selected  (among 100 slots) when the
// limited entropy provider is used.
inline constexpr char kTestLimitedEntropyRandomizationSource[] =;

Study::Experiment CreateExperiment(int weight) {}

Study::Experiment CreateGoogleWebExperiment(int weight,
                                            int google_web_experiment_id) {}

Study::Experiment CreateTriggerExperiment(
    int weight,
    int google_web_trigger_experiment_id) {}

std::vector<Study::Experiment> CreateExperimentsWithTwoBitsOfEntropy() {}

LayerMemberReference CreateLayerMemberReference(
    uint32_t layer_id,
    const std::vector<uint32_t>& layer_member_ids) {}

// Creates a test study.
Study CreateTestStudy(const std::vector<Study::Experiment>& experiments) {}

Study CreateTestStudy(const std::vector<Study::Experiment>& experiments,
                      const LayerMemberReference& layer_member_reference) {}

// Creates a test layer member with slot ranges given as <start, end> pairs.
Layer::LayerMember CreateLayerMember(
    int layer_member_id,
    const std::vector<std::pair<int, int>>& slot_ranges) {}

Layer CreateLayer(int layer_id,
                  int num_slots,
                  Layer::EntropyMode entropy_mode,
                  const std::vector<Layer::LayerMember>& layer_members) {}

VariationsSeed CreateTestSeed(const std::vector<Layer>& layers,
                              const std::vector<Study>& studies) {}

}  // namespace

class LimitedEntropyRandomizationTest : public ::testing::Test {};

TEST_F(LimitedEntropyRandomizationTest, TestEntropyUsedByStudy) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByStudy_MultipleExperimentsWithID) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByStudy_NoGoogleWebExperimentID) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByStudy_SkipZeroProbabilityWeightedStudies) {}

TEST_F(LimitedEntropyRandomizationTest, TestEntropyUsedByStudy_NoExperiments) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByStudy_WithGoogleWebTriggerExpID) {}

TEST_F(LimitedEntropyRandomizationTest, TestEntropyUsedByLimitedLayer) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_MultipleStudiesInLayerMember) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_StudiesOfDifferentEntropyInLayerMember) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_MultipleLayerMembers) {}

TEST_F(LimitedEntropyRandomizationTest, ReferencingMultipleLayers) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_SomeStudiesDoNotReferenceLayer) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_SomeStudiesReferenceOtherLayers) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_NoStudiesReferencingLimitedLayer) {}

TEST_F(
    LimitedEntropyRandomizationTest,
    TestEntropyUsedByLimitedLayer_NoReferencingStudiesWithGoogleExperimentID) {}

TEST_F(LimitedEntropyRandomizationTest,
       TestEntropyUsedByLimitedLayer_NoLayerMembers) {}

TEST_F(LimitedEntropyRandomizationTest, SeedRejection_EntropyOveruse) {}

TEST_F(LimitedEntropyRandomizationTest, SeedRejection_MultipleLimitedLayer) {}

TEST_F(LimitedEntropyRandomizationTest, SeedRejection_InvalidSlotBounds) {}

TEST_F(LimitedEntropyRandomizationTest, SeedRejection_NoSlots) {}

TEST_F(LimitedEntropyRandomizationTest, DoNotRejectTheSeed_NonLimitedLayer) {}

}  // namespace variations