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

Unified Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2484323002: Add a NetworkQualityEstimator to TestURLRequestContext. (Closed)
Patch Set: Fix tests 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
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 bda59f09c1a716b02115d3206a8e583d4c0bcc53..9ef0715b414da28781ac1662e6b44d1aa68d198b 100644
--- a/net/nqe/network_quality_estimator_unittest.cc
+++ b/net/nqe/network_quality_estimator_unittest.cc
@@ -169,9 +169,13 @@ TEST(NetworkQualityEstimatorTest, TestKbpsRTTUpdates) {
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
tbansal1 2016/11/14 20:39:27 can you reassign these to me. As mentioned elsewhe
mmenke 2016/11/14 20:43:02 Do you want to do it, or would you rather me do it
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -307,9 +311,13 @@ TEST(NetworkQualityEstimatorTest, Caching) {
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
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
@@ -368,9 +376,13 @@ TEST(NetworkQualityEstimatorTest, StoreObservations) {
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
// Push more observations than the maximum buffer size.
const size_t kMaxObservations = 1000;
@@ -413,9 +425,13 @@ TEST(NetworkQualityEstimatorTest, ComputedPercentiles) {
base::TimeTicks(), 100));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
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) {
@@ -1308,9 +1324,13 @@ TEST(NetworkQualityEstimatorTest, TestExternalEstimateProviderMergeEstimates) {
EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps);
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -1355,9 +1375,13 @@ TEST(NetworkQualityEstimatorTest, TestThroughputNoRequestOverlap) {
estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -1388,9 +1412,13 @@ TEST(NetworkQualityEstimatorTest, TestEffectiveConnectionTypeObserver) {
estimator.SetTickClockForTesting(std::move(tick_clock));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
EXPECT_EQ(0U, observer.effective_connection_types().size());
@@ -1451,9 +1479,13 @@ TEST(NetworkQualityEstimatorTest, TestRTTAndThroughputEstimatesObserver) {
estimator.SetTickClockForTesting(std::move(tick_clock));
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
EXPECT_EQ(nqe::internal::InvalidRTT(), observer.http_rtt());
EXPECT_EQ(nqe::internal::InvalidRTT(), observer.transport_rtt());
@@ -1572,9 +1604,13 @@ TEST(NetworkQualityEstimatorTest,
estimator.AddEffectiveConnectionTypeObserver(&observer);
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
EXPECT_EQ(0U, observer.effective_connection_types().size());
@@ -1654,9 +1690,13 @@ TEST(NetworkQualityEstimatorTest, TestRttThroughputObservers) {
estimator.AddThroughputObserver(&throughput_observer);
TestDelegate test_delegate;
- TestURLRequestContext context(true);
+ // Theses tests expect the HttpNetworkSession not to use this NQE, but the
+ // higher layers to do so, so create the context, with its own NQE, and then
+ // just set the one on the URLRequestContext, not the one used by the
+ // HttpNetworkSession.
+ // TODO(mmenke): Fix that?
+ TestURLRequestContext context;
context.set_network_quality_estimator(&estimator);
- context.Init();
EXPECT_EQ(0U, rtt_observer.observations().size());
EXPECT_EQ(0U, throughput_observer.observations().size());

Powered by Google App Engine
This is Rietveld 408576698