| Index: chrome/browser/io_thread_unittest.cc
|
| diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc
|
| index 8ac33d274239e62b8f983496912297d5433d43fb..05d25292d5a637256dd55053e59b83b0f1da6730 100644
|
| --- a/chrome/browser/io_thread_unittest.cc
|
| +++ b/chrome/browser/io_thread_unittest.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include <stddef.h>
|
|
|
| +#include <map>
|
| +#include <string>
|
| +
|
| #include "base/at_exit.h"
|
| #include "base/command_line.h"
|
| #include "base/macros.h"
|
| @@ -29,6 +32,8 @@
|
| #include "net/http/http_auth_preferences.h"
|
| #include "net/http/http_auth_scheme.h"
|
| #include "net/http/http_network_session.h"
|
| +#include "net/nqe/effective_connection_type.h"
|
| +#include "net/nqe/network_quality_estimator.h"
|
| #include "net/quic/chromium/quic_stream_factory.h"
|
| #include "net/quic/core/quic_tag.h"
|
| #include "net/quic/core/quic_versions.h"
|
| @@ -82,6 +87,12 @@ class IOThreadTestWithIOThreadObject : public testing::Test {
|
| EXPECT_EQ(expected, http_auth_preferences->NegotiateEnablePort());
|
| }
|
|
|
| + void CheckEffectiveConnectionType(net::EffectiveConnectionType expected) {
|
| + ASSERT_EQ(expected,
|
| + io_thread_->globals()
|
| + ->network_quality_estimator->GetEffectiveConnectionType());
|
| + }
|
| +
|
| #if defined(OS_ANDROID)
|
| void CheckAuthAndroidNegoitateAccountType(std::string expected) {
|
| auto* http_auth_preferences =
|
| @@ -248,6 +259,55 @@ TEST_F(IOThreadTestWithIOThreadObject, UpdateAuthAndroidNegotiateAccountType) {
|
| }
|
| #endif
|
|
|
| +TEST_F(IOThreadTestWithIOThreadObject, ForceECTFromCommandLine) {
|
| + base::CommandLine::Init(0, nullptr);
|
| + ASSERT_TRUE(base::CommandLine::InitializedForCurrentProcess());
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + "--force-effective-connection-type", "Slow-2G");
|
| +
|
| + RunOnIOThreadBlocking(base::Bind(
|
| + &IOThreadTestWithIOThreadObject::CheckEffectiveConnectionType,
|
| + base::Unretained(this), net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G));
|
| +}
|
| +
|
| +TEST_F(IOThreadTestWithIOThreadObject, ForceECTUsingFieldTrial) {
|
| + base::CommandLine::Init(0, nullptr);
|
| + ASSERT_TRUE(base::CommandLine::InitializedForCurrentProcess());
|
| +
|
| + variations::testing::ClearAllVariationParams();
|
| + std::map<std::string, std::string> variation_params;
|
| + variation_params["force_effective_connection_type"] = "2G";
|
| + ASSERT_TRUE(variations::AssociateVariationParams(
|
| + "NetworkQualityEstimator", "Enabled", variation_params));
|
| +
|
| + base::FieldTrialList field_trial_list(nullptr);
|
| + base::FieldTrialList::CreateFieldTrial("NetworkQualityEstimator", "Enabled");
|
| +
|
| + RunOnIOThreadBlocking(
|
| + base::Bind(&IOThreadTestWithIOThreadObject::CheckEffectiveConnectionType,
|
| + base::Unretained(this), net::EFFECTIVE_CONNECTION_TYPE_2G));
|
| +}
|
| +
|
| +TEST_F(IOThreadTestWithIOThreadObject, ECTFromCommandLineOverridesFieldTrial) {
|
| + base::CommandLine::Init(0, nullptr);
|
| + ASSERT_TRUE(base::CommandLine::InitializedForCurrentProcess());
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + "--force-effective-connection-type", "Slow-2G");
|
| +
|
| + variations::testing::ClearAllVariationParams();
|
| + std::map<std::string, std::string> variation_params;
|
| + variation_params["force_effective_connection_type"] = "2G";
|
| + ASSERT_TRUE(variations::AssociateVariationParams(
|
| + "NetworkQualityEstimator", "Enabled", variation_params));
|
| +
|
| + base::FieldTrialList field_trial_list(nullptr);
|
| + base::FieldTrialList::CreateFieldTrial("NetworkQualityEstimator", "Enabled");
|
| +
|
| + RunOnIOThreadBlocking(base::Bind(
|
| + &IOThreadTestWithIOThreadObject::CheckEffectiveConnectionType,
|
| + base::Unretained(this), net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G));
|
| +}
|
| +
|
| class ConfigureParamsFromFieldTrialsAndCommandLineTest
|
| : public ::testing::Test {
|
| public:
|
|
|