#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/variations/service/variations_service.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/json/json_string_value_serializer.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "base/version.h"
#include "components/metrics/clean_exit_beacon.h"
#include "components/metrics/client_info.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_state_manager.h"
#include "components/metrics/test/test_enabled_state_provider.h"
#include "components/prefs/testing_pref_service.h"
#include "components/variations/pref_names.h"
#include "components/variations/proto/study.pb.h"
#include "components/variations/proto/variations_seed.pb.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "components/variations/synthetic_trial_registry.h"
#include "components/variations/variations_seed_simulator.h"
#include "components/version_info/channel.h"
#include "components/web_resource/resource_request_allowed_notifier_test_util.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/url_util.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace variations {
namespace {
const char kBase64SeedData[] = …;
const char kBase64SeedSignature[] = …;
class TestVariationsServiceClient : public VariationsServiceClient { … };
class TestVariationsService : public VariationsService { … };
class TestVariationsServiceObserver : public VariationsService::Observer { … };
const char kTestSeedStudyName[] = …;
const char kTestSeedExperimentName[] = …;
const int kTestSeedExperimentProbability = …;
const char kTestSeedSerialNumber[] = …;
VariationsSeed CreateTestSeed() { … }
std::string SerializeSeed(const VariationsSeed& seed) { … }
std::string ListToString(const base::Value::List& list) { … }
void AddOKResponseWithIM(
const GURL& interception_url,
const std::string& body,
const std::string& im,
network::TestURLLoaderFactory* test_url_loader_factory) { … }
}
class VariationsServiceTest : public ::testing::Test { … };
TEST_F(VariationsServiceTest, GetVariationsServerURL) { … }
TEST_F(VariationsServiceTest, VariationsURLHasParams) { … }
TEST_F(VariationsServiceTest, RequestsInitiallyNotAllowed) { … }
TEST_F(VariationsServiceTest, RequestsInitiallyAllowed) { … }
TEST_F(VariationsServiceTest, SeedStoredWhenOKStatus) { … }
TEST_F(VariationsServiceTest, SeedNotStoredWhenNonOKStatus) { … }
TEST_F(VariationsServiceTest, RequestGzipCompressedSeed) { … }
TEST_F(VariationsServiceTest, RequestDeltaCompressedSeed) { … }
TEST_F(VariationsServiceTest, InstanceManipulations) { … }
TEST_F(VariationsServiceTest, CountryHeader) { … }
TEST_F(VariationsServiceTest, Observer) { … }
TEST_F(VariationsServiceTest, LoadPermanentConsistencyCountry) { … }
TEST_F(VariationsServiceTest, GetStoredPermanentCountry) { … }
TEST_F(VariationsServiceTest, OverrideStoredPermanentCountry) { … }
TEST_F(VariationsServiceTest, SafeMode_StartingRequestIncrementsFetchFailures) { … }
TEST_F(VariationsServiceTest, SafeMode_SuccessfulFetchClearsFailureStreaks) { … }
TEST_F(VariationsServiceTest, SafeMode_NotModifiedFetchClearsFailureStreaks) { … }
TEST_F(VariationsServiceTest, FieldTrialCreatorInitializedCorrectly) { … }
TEST_F(VariationsServiceTest, RetryOverHTTPIfURLisSet) { … }
TEST_F(VariationsServiceTest, DoNotRetryAfterARetry) { … }
TEST_F(VariationsServiceTest, DoNotRetryIfInsecureURLIsHTTPS) { … }
TEST_F(VariationsServiceTest, SeedStoredWhenRedirected) { … }
TEST_F(VariationsServiceTest, NullResponseReceivedWithHTTPOk) { … }
TEST_F(VariationsServiceTest, VariationsServiceStartsRequestOnNetworkChange) { … }
}