#include "components/network_session_configurator/browser/network_session_configurator.h"
#include <map>
#include <memory>
#include <string>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/network_session_configurator/common/network_features.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/variations/variations_associated_data.h"
#include "net/base/host_mapping_rules.h"
#include "net/base/host_port_pair.h"
#include "net/http/http_network_session.h"
#include "net/http/http_stream_factory.h"
#include "net/third_party/quiche/src/quiche/quic/core/crypto/crypto_protocol.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quiche/spdy/core/spdy_protocol.h"
#include "net/url_request/url_request_context_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace network_session_configurator {
class NetworkSessionConfiguratorTest : public testing::Test { … };
TEST_F(NetworkSessionConfiguratorTest, Defaults) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2FieldTrialGroupNameDoesNotMatter) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2FieldTrialDisable) { … }
TEST_F(NetworkSessionConfiguratorTest, DisableQuicFromFieldTrialGroup) { … }
TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromParams) { … }
TEST_F(NetworkSessionConfiguratorTest, ValidQuicParams) { … }
TEST_F(NetworkSessionConfiguratorTest, InvalidQuicParams) { … }
TEST_F(NetworkSessionConfiguratorTest, EnableQuicForDataReductionProxy) { … }
TEST_F(NetworkSessionConfiguratorTest, DisableRetryWithoutAltSvcOnQuicErrors) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicCloseSessionsOnIpChangeFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicGoAwaySessionsOnIpChangeFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicRetransmittableOnWireTimeoutMillisecondsFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
InitialDelayForBrokenAlternativeServiceSeconds) { … }
TEST_F(NetworkSessionConfiguratorTest, ExponentialBackOffOnInitialDelay) { … }
TEST_F(NetworkSessionConfiguratorTest,
DisableExponentialBackOffOnInitialDelay) { … }
TEST_F(NetworkSessionConfiguratorTest, DelayMainJobWithAvailableSpdySession) { … }
TEST_F(NetworkSessionConfiguratorTest,
NotDelayMainJobWithAvailableSpdySession) { … }
TEST_F(NetworkSessionConfiguratorTest, EnableOriginFrame) { … }
TEST_F(NetworkSessionConfiguratorTest, DonotEnableOriginFrame) { … }
TEST_F(NetworkSessionConfiguratorTest, SkipDnsWithOriginFrame) { … }
TEST_F(NetworkSessionConfiguratorTest, DonotSkipDnsWithOriginFrame) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicIdleConnectionTimeoutSecondsFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
NegativeQuicReducedPingTimeoutSecondsFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
LargeQuicReducedPingTimeoutSecondsFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicReducedPingTimeoutSecondsFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicMaxTimeBeforeCryptoHandshakeSeconds) { … }
TEST_F(NetworkSessionConfiguratorTest,
NegativeQuicMaxTimeBeforeCryptoHandshakeSeconds) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicMaxIdleTimeBeforeCryptoHandshakeSeconds) { … }
TEST_F(NetworkSessionConfiguratorTest,
NegativeQuicMaxIdleTimeBeforeCryptoHandshakeSeconds) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicEstimateInitialRtt) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicMigrateSessionsOnNetworkChangeV2FromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicMigrateSessionsEarlyV2FromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicRetryOnAlternateNetworkBeforeHandshakeFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicIdleSessionMigrationPeriodFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicMaxTimeOnNonDefaultNetworkFromFieldTrialParams) { … }
TEST_F(
NetworkSessionConfiguratorTest,
QuicMaxNumMigrationsToNonDefaultNetworkOnWriteErrorFromFieldTrialParams) { … }
TEST_F(
NetworkSessionConfiguratorTest,
QuicMaxNumMigrationsToNonDefaultNetworkOnPathDegradingFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
DisableQuicAllowPortMigrationFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
ConfigureMultiPortProbingIntervalFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicDisableTlsZeroRttFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicDisableGQuicZeroRttFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest, PacketLengthFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicVersionFromFieldTrialParamsAlpn) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicConnectionOptionsFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicClientConnectionOptionsFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicHostAllowlist) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicHostAllowlistEmpty) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicFlags) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2SettingsFromFieldTrialParams) { … }
TEST_F(NetworkSessionConfiguratorTest, ForceQuic) { … }
TEST_F(NetworkSessionConfiguratorTest, DisableHttp2) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicConnectionOptions) { … }
TEST_F(NetworkSessionConfiguratorTest, QuicMaxPacketLength) { … }
TEST_F(NetworkSessionConfiguratorTest, OriginToForceQuicOn) { … }
TEST_F(NetworkSessionConfiguratorTest, OriginToForceQuicOn2) { … }
TEST_F(NetworkSessionConfiguratorTest, OriginToForceQuicOn3) { … }
TEST_F(NetworkSessionConfiguratorTest, EnableUserAlternateProtocolPorts) { … }
TEST_F(NetworkSessionConfiguratorTest, TestingFixedPorts) { … }
TEST_F(NetworkSessionConfiguratorTest, IgnoreCertificateErrors) { … }
TEST_F(NetworkSessionConfiguratorTest, HostRules) { … }
TEST_F(NetworkSessionConfiguratorTest, DefaultCacheBackend) { … }
TEST_F(NetworkSessionConfiguratorTest, SimpleCacheTrialExperimentYes) { … }
TEST_F(NetworkSessionConfiguratorTest, SimpleCacheTrialDisable) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettingsFromCommandLine) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettingsFromFieldTrial) { … }
TEST_F(NetworkSessionConfiguratorTest,
DisableHttp2GreaseSettingsFromCommandLineOverridesFieldTrial) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseFrameTypeFromCommandLine) { … }
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseFrameTypeFromFieldTrial) { … }
TEST_F(NetworkSessionConfiguratorTest,
Http2EndStreamWithDataFrameFromFieldTrial) { … }
TEST_F(NetworkSessionConfiguratorTest,
QuicInitialRttForHandshakeFromFieldTrailParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
ReportReceivedEcnFromFieldTrailParams) { … }
TEST_F(NetworkSessionConfiguratorTest,
ReportReceivedEcnFromFeature) { … }
class NetworkSessionConfiguratorWithQuicVersionTest
: public NetworkSessionConfiguratorTest,
public ::testing::WithParamInterface<quic::ParsedQuicVersion> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest, QuicVersion) { … }
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest, QuicVersionAlpn) { … }
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest,
SameQuicVersionsFromFieldTrialParams) { … }
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest,
SameQuicVersionsFromFieldTrialParamsAlpn) { … }
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest, ObsoleteQuicVersion) { … }
TEST_P(NetworkSessionConfiguratorWithQuicVersionTest,
ObsoleteQuicVersionWithGoodVersion) { … }
class NetworkSessionConfiguratorWithNewAlpsCodepointTest
: public NetworkSessionConfiguratorTest,
public ::testing::WithParamInterface<std::tuple<bool, bool>> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(NetworkSessionConfiguratorWithNewAlpsCodepointTest, NoFieldTrialParams) { … }
TEST_P(NetworkSessionConfiguratorWithNewAlpsCodepointTest,
FromFieldTrialParams) { … }
}