#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[] = …;
inline constexpr int kHighEntropyUsageBucket = …;
inline constexpr int kMoreThenOneLimitedLayerBucket = …;
inline constexpr int kLimitedLayerHasInvalidSlotBoundsBucket = …;
inline constexpr int kLimitedLayerDoesNotContainSlotsBucket = …;
inline constexpr int kNoSlotsBucket = …;
inline constexpr int kInvalidSlotBoundsBucket = …;
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) { … }
Study CreateTestStudy(const std::vector<Study::Experiment>& experiments) { … }
Study CreateTestStudy(const std::vector<Study::Experiment>& experiments,
const LayerMemberReference& layer_member_reference) { … }
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) { … }
}
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) { … }
}