#include "base/metrics/field_trial.h"
#include <stddef.h>
#include <string_view>
#include <utility>
#include "base/base_switches.h"
#include "base/build_time.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial_list_including_low_anonymity.h"
#include "base/metrics/field_trial_param_associator.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/gtest_util.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/multiprocess_test.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_shared_memory_util.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
#if BUILDFLAG(USE_BLINK)
#include "base/process/launch.h"
#endif
#if BUILDFLAG(IS_POSIX)
#include "base/files/platform_file.h"
#include "base/posix/global_descriptors.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "base/mac/mach_port_rendezvous.h"
#endif
namespace base {
namespace {
const char kDefaultGroupName[] = …;
scoped_refptr<FieldTrial> CreateFieldTrial(
const std::string& trial_name,
int total_probability,
const std::string& default_group_name,
bool is_low_anonymity = false) { … }
class TestFieldTrialObserver : public FieldTrialList::Observer { … };
class FieldTrialObserverAccessingGroup : public FieldTrialList::Observer { … };
std::string MockEscapeQueryParamValue(const std::string& input) { … }
}
class TestFieldTrialObserverIncludingLowAnonymity
: public FieldTrialList::Observer { … };
class FieldTrialTest : public ::testing::Test { … };
MATCHER(CompareActiveGroupToFieldTrial, "") { … }
TEST_F(FieldTrialTest, Registration) { … }
TEST_F(FieldTrialTest, AbsoluteProbabilities) { … }
TEST_F(FieldTrialTest, SmallProbabilities_49) { … }
TEST_F(FieldTrialTest, SmallProbabilities_51) { … }
TEST_F(FieldTrialTest, MiddleProbabilities_49) { … }
TEST_F(FieldTrialTest, MiddleProbabilities_51) { … }
TEST_F(FieldTrialTest, OneWinner) { … }
TEST_F(FieldTrialTest, ActiveGroups) { … }
TEST_F(FieldTrialTest, ActiveGroupsNotFinalized) { … }
TEST_F(FieldTrialTest, GetGroupNameWithoutActivation) { … }
TEST_F(FieldTrialTest, SaveAll) { … }
TEST_F(FieldTrialTest, Restore) { … }
TEST_F(FieldTrialTest, RestoreNotEndingWithSlash) { … }
TEST_F(FieldTrialTest, BogusRestore) { … }
TEST_F(FieldTrialTest, DuplicateRestore) { … }
TEST_F(FieldTrialTest, CreateTrialsFromStringNotActive) { … }
TEST_F(FieldTrialTest, CreateTrialsFromStringForceActivation) { … }
TEST_F(FieldTrialTest, CreateTrialsFromStringNotActiveObserver) { … }
TEST_F(FieldTrialTest, CreateFieldTrial) { … }
TEST_F(FieldTrialTest, CreateFieldTrialIsNotActive) { … }
TEST_F(FieldTrialTest, DuplicateFieldTrial) { … }
TEST_F(FieldTrialTest, ForcedFieldTrials) { … }
TEST_F(FieldTrialTest, ForcedFieldTrialsDefaultGroup) { … }
TEST_F(FieldTrialTest, SetForced) { … }
TEST_F(FieldTrialTest, SetForcedDefaultOnly) { … }
TEST_F(FieldTrialTest, SetForcedDefaultWithExtraGroup) { … }
TEST_F(FieldTrialTest, SetForcedTurnFeatureOn) { … }
TEST_F(FieldTrialTest, SetForcedTurnFeatureOff) { … }
TEST_F(FieldTrialTest, SetForcedChangeDefault_Default) { … }
TEST_F(FieldTrialTest, SetForcedChangeDefault_NonDefault) { … }
TEST_F(FieldTrialTest, Observe) { … }
TEST_F(FieldTrialTest, ObserveReentrancy) { … }
TEST_F(FieldTrialTest, NotDisabled) { … }
TEST_F(FieldTrialTest, FloatBoundariesGiveEqualGroupSizes) { … }
TEST_F(FieldTrialTest, DoesNotSurpassTotalProbability) { … }
TEST_F(FieldTrialTest, CreateSimulatedFieldTrial) { … }
TEST(FieldTrialTestWithoutList, StatesStringFormat) { … }
class FieldTrialListTest : public ::testing::Test { … };
TEST_F(FieldTrialListTest, InstantiateAllocator) { … }
TEST_F(FieldTrialListTest, AddTrialsToAllocator) { … }
TEST_F(FieldTrialListTest, DoNotAddSimulatedFieldTrialsToAllocator) { … }
TEST_F(FieldTrialListTest, AssociateFieldTrialParams) { … }
TEST_F(FieldTrialListTest, ClearParamsFromSharedMemory) { … }
TEST_F(FieldTrialListTest, DumpAndFetchFromSharedMemory) { … }
#if BUILDFLAG(USE_BLINK)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE)
constexpr GlobalDescriptors::Key kFDKey = …;
#endif
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
MULTIPROCESS_TEST_MAIN(CreateTrialsInChildProcess) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(FieldTrialListTest, PassFieldTrialSharedMemoryOnCommandLine) { … }
#endif
TEST_F(FieldTrialListTest, CheckReadOnlySharedMemoryRegion) { … }
#endif
TEST_F(FieldTrialListTest, TestGetRandomizedFieldTrialCount) { … }
TEST_F(FieldTrialTest, TestAllParamsToString) { … }
TEST_F(FieldTrialTest, GetActiveFieldTrialGroups_LowAnonymity) { … }
TEST_F(FieldTrialTest, ObserveIncludingLowAnonymity) { … }
TEST_F(FieldTrialTest, ParseFieldTrialsString) { … }
TEST_F(FieldTrialTest, ParseFieldTrialsStringTwoStudies) { … }
TEST_F(FieldTrialTest, ParseFieldTrialsStringEmpty) { … }
TEST_F(FieldTrialTest, ParseFieldTrialsStringInvalid) { … }
TEST_F(FieldTrialTest, BuildFieldTrialStateString) { … }
}