| Index: chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc
|
| diff --git a/chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc b/chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc
|
| index 5704812cf42d0c6b4ff80c5fff8e5419cf5bdf2e..3b132029bab0015b907e072fc1f2aef07e9cf3d9 100644
|
| --- a/chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc
|
| +++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc
|
| @@ -14,26 +14,49 @@
|
| #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "components/variations/variations_associated_data.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/test/browser_test.h"
|
| #include "net/base/network_change_notifier.h"
|
| #include "net/nqe/cached_network_quality.h"
|
| #include "net/nqe/effective_connection_type.h"
|
| #include "net/nqe/network_id.h"
|
| +#include "net/nqe/network_quality_estimator.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| class Profile;
|
|
|
| namespace {
|
|
|
| +class TestEffectiveConnectionTypeObserver
|
| + : public net::NetworkQualityEstimator::EffectiveConnectionTypeObserver {
|
| + public:
|
| + TestEffectiveConnectionTypeObserver() {}
|
| + ~TestEffectiveConnectionTypeObserver() override {}
|
| +
|
| + // net::NetworkQualityEstimator::EffectiveConnectionTypeObserver
|
| + // implementation:
|
| + void OnEffectiveConnectionTypeChanged(
|
| + net::EffectiveConnectionType type) override {
|
| + effective_connection_type_ = type;
|
| + }
|
| +
|
| + // The most recently set EffectiveConnectionType.
|
| + net::EffectiveConnectionType effective_connection_type() const {
|
| + return effective_connection_type_;
|
| + }
|
| +
|
| + private:
|
| + net::EffectiveConnectionType effective_connection_type_;
|
| +};
|
| +
|
| class UINetworkQualityEstimatorServiceBrowserTest
|
| : public InProcessBrowserTest {
|
| public:
|
| UINetworkQualityEstimatorServiceBrowserTest() {}
|
|
|
| // Enables persistent caching if |persistent_caching_enabled| is true.
|
| // Verifies that the network quality prefs are written correctly, and that
|
| // they are written only if the persistent caching was enabled.
|
| void VerifyWritingReadingPrefs(bool persistent_caching_enabled) {
|
| if (persistent_caching_enabled) {
|
| @@ -131,30 +154,45 @@ class UINetworkQualityEstimatorServiceBrowserTest
|
| } // namespace
|
|
|
| IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest,
|
| VerifyNQEState) {
|
| // Verifies that NQE notifying EffectiveConnectionTypeObservers causes the
|
| // UINetworkQualityEstimatorService to receive an updated
|
| // EffectiveConnectionType.
|
| Profile* profile = ProfileManager::GetActiveUserProfile();
|
| UINetworkQualityEstimatorService* nqe_service =
|
| UINetworkQualityEstimatorServiceFactory::GetForProfile(profile);
|
| + TestEffectiveConnectionTypeObserver nqe_observer;
|
| + nqe_service->AddEffectiveConnectionTypeObserver(&nqe_observer);
|
|
|
| nqe_test_util::OverrideEffectiveConnectionTypeAndWait(
|
| net::EFFECTIVE_CONNECTION_TYPE_OFFLINE);
|
| EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_OFFLINE,
|
| nqe_service->GetEffectiveConnectionType());
|
| + EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_OFFLINE,
|
| + nqe_observer.effective_connection_type());
|
|
|
| nqe_test_util::OverrideEffectiveConnectionTypeAndWait(
|
| net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
|
| EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
|
| nqe_service->GetEffectiveConnectionType());
|
| + EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
|
| + nqe_observer.effective_connection_type());
|
| +
|
| + nqe_service->RemoveEffectiveConnectionTypeObserver(&nqe_observer);
|
| +
|
| + nqe_test_util::OverrideEffectiveConnectionTypeAndWait(
|
| + net::EFFECTIVE_CONNECTION_TYPE_OFFLINE);
|
| + EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_OFFLINE,
|
| + nqe_service->GetEffectiveConnectionType());
|
| + EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
|
| + nqe_observer.effective_connection_type());
|
| }
|
|
|
| // Verify that prefs are not writen when writing of the prefs is not enabled
|
| // via field trial.
|
| IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest,
|
| WritingToPrefsDisabled) {
|
| VerifyWritingReadingPrefs(false);
|
| }
|
|
|
| // Verify that prefs are writen when writing of the prefs is enabled via field
|
|
|