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

Unified Diff: net/base/network_quality_estimator_unittest.cc

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder initialization in constructor Created 4 years, 8 months 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 | « jingle/glue/fake_ssl_client_socket_unittest.cc ('k') | net/dns/address_sorter_posix_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_quality_estimator_unittest.cc
diff --git a/net/base/network_quality_estimator_unittest.cc b/net/base/network_quality_estimator_unittest.cc
index 13d35b1b1a0b632fc2884c82c0cfdacfbae2381d..8641c84dcf4d7cb0c6d1211ff52545e04c5b8dea 100644
--- a/net/base/network_quality_estimator_unittest.cc
+++ b/net/base/network_quality_estimator_unittest.cc
@@ -4,6 +4,7 @@
#include "net/base/network_quality_estimator.h"
+#include <stddef.h>
#include <stdint.h>
#include <limits>
@@ -1122,4 +1123,59 @@ TEST(NetworkQualityEstimatorTest, TestObservers) {
rtt_observer.observations().at(3).rtt_ms);
}
+// TestTCPSocketRTT requires kernel support for tcp_info struct, and so it is
+// enabled only on certain platforms.
+#if defined(TCP_INFO) || defined(OS_LINUX)
+#define MAYBE_TestTCPSocketRTT TestTCPSocketRTT
+#else
+#define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT
+#endif
+// Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs,
+// which in turn notifies registered RTT observers.
+TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) {
+ TestRTTObserver rtt_observer;
+ std::map<std::string, std::string> variation_params;
+ TestNetworkQualityEstimator estimator(variation_params);
+ estimator.AddRTTObserver(&rtt_observer);
+
+ TestDelegate test_delegate;
+ TestURLRequestContext context(true);
+ context.set_network_quality_estimator(&estimator);
+
+ scoped_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());
+
+ // Send two requests. Verify that the completion of each request generates at
+ // least one TCP RTT observation.
+ for (size_t i = 0; i < 2; ++i) {
+ size_t before_count_tcp_rtt_observations = 0;
+ for (const auto& observation : rtt_observer.observations()) {
+ if (observation.source == NetworkQualityEstimator::TCP)
+ ++before_count_tcp_rtt_observations;
+ }
+
+ scoped_ptr<URLRequest> request(context.CreateRequest(
+ estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
+ request->Start();
+ base::RunLoop().Run();
+
+ size_t after_count_tcp_rtt_observations = 0;
+ for (const auto& observation : rtt_observer.observations()) {
+ if (observation.source == NetworkQualityEstimator::TCP)
+ ++after_count_tcp_rtt_observations;
+ }
+ // At least one notification should be received per socket performance
+ // watcher.
+ EXPECT_LE(1U, after_count_tcp_rtt_observations -
+ before_count_tcp_rtt_observations)
+ << i;
+ }
+}
+
} // namespace net
« no previous file with comments | « jingle/glue/fake_ssl_client_socket_unittest.cc ('k') | net/dns/address_sorter_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698