Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2506303002: Revert of Add a NetworkQualityEstimator to TestURLRequestContext. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_transaction_test_util.cc ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/network_quality_estimator_unittest.cc
diff --git a/net/nqe/network_quality_estimator_unittest.cc b/net/nqe/network_quality_estimator_unittest.cc
index 09cb6ad1ee1d12368964ad8731dab26bc09166c1..bda59f09c1a716b02115d3206a8e583d4c0bcc53 100644
--- a/net/nqe/network_quality_estimator_unittest.cc
+++ b/net/nqe/network_quality_estimator_unittest.cc
@@ -169,13 +169,9 @@
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -311,13 +307,9 @@
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
// Start two requests so that the network quality is added to cache store at
// the beginning of the second request from the network traffic observed from
@@ -376,13 +368,9 @@
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
// Push more observations than the maximum buffer size.
const size_t kMaxObservations = 1000;
@@ -425,13 +413,9 @@
base::TimeTicks(), 100));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
// Number of observations are more than the maximum buffer size.
for (size_t i = 0; i < 1000U; ++i) {
@@ -1324,13 +1308,9 @@
EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps);
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -1375,13 +1355,9 @@
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -1412,13 +1388,9 @@
estimator.SetTickClockForTesting(std::move(tick_clock));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
EXPECT_EQ(0U, observer.effective_connection_types().size());
@@ -1479,13 +1451,9 @@
estimator.SetTickClockForTesting(std::move(tick_clock));
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
EXPECT_EQ(nqe::internal::InvalidRTT(), observer.http_rtt());
EXPECT_EQ(nqe::internal::InvalidRTT(), observer.transport_rtt());
@@ -1604,13 +1572,9 @@
estimator.AddEffectiveConnectionTypeObserver(&observer);
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
EXPECT_EQ(0U, observer.effective_connection_types().size());
@@ -1690,13 +1654,9 @@
estimator.AddThroughputObserver(&throughput_observer);
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
EXPECT_EQ(0U, rtt_observer.observations().size());
EXPECT_EQ(0U, throughput_observer.observations().size());
@@ -1785,6 +1745,13 @@
TestDelegate test_delegate;
TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+
+ std::unique_ptr<HttpNetworkSession::Params> params(
+ new HttpNetworkSession::Params);
+ // |estimator| should be notified of TCP RTT observations.
+ params->socket_performance_watcher_factory =
+ estimator.GetSocketPerformanceWatcherFactory();
+ context.set_http_network_session_params(std::move(params));
context.Init();
EXPECT_EQ(0U, rtt_observer.observations().size());
@@ -1938,13 +1905,9 @@
base::HistogramTester histogram_tester;
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its
- // own NQE, and then just set the one on the URLRequestContext, not the
- // one used by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
// Start a main-frame request which should cause network quality estimator
// to record accuracy UMA.
@@ -2172,13 +2135,9 @@
estimator.set_rand_double(test.rand_double);
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
// Start a main-frame request that should cause network quality estimator to
// record the network quality at the last main frame request.
@@ -2339,13 +2298,9 @@
estimator.AddEffectiveConnectionTypeObserver(&observer);
TestDelegate test_delegate;
- // These tests expect the URLRequestContext to use the NQE, but not the
- // HttpNetworkSession. To do this, have to create the context, with its own
- // NQE, and then just set the one on the URLRequestContext, not the one used
- // by the HttpNetworkSession.
- // TODO(tbansal): Fix that.
- TestURLRequestContext context;
+ TestURLRequestContext context(true);
context.set_network_quality_estimator(&estimator);
+ context.Init();
EXPECT_EQ(0U, observer.effective_connection_types().size());
« no previous file with comments | « net/http/http_transaction_test_util.cc ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698