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

Unified Diff: net/quic/quic_network_transaction_unittest.cc

Issue 1672513002: Expose packet loss counts from QUIC to NetworkQualityEstimator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments Created 4 years, 10 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
Index: net/quic/quic_network_transaction_unittest.cc
diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
index c6b4527922c48554e773fbde942353b12ace78c2..d00fd4baec8e7c7b2e242890e84ca242fdcf280e 100644
--- a/net/quic/quic_network_transaction_unittest.cc
+++ b/net/quic/quic_network_transaction_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
#include <vector>
#include "base/compiler_specific.h"
@@ -182,6 +184,30 @@ class TestRTTObserver : public NetworkQualityEstimator::RTTObserver {
bool rtt_notification_received_;
};
+class TestPacketLossObserver
+ : public NetworkQualityEstimator::PacketLossObserver {
+ public:
+ TestPacketLossObserver() : notification_received_(false) {}
+
+ bool notification_received() const { return notification_received_; }
+
+ // NetworkQualityEstimator::PacketLossObserver implementation:
+ void OnPacketLossObservation(
+ uint64_t num_packets_lost,
+ uint64_t num_packets_received_in_order,
+ uint64_t num_packets_received_not_in_order,
+ const base::TimeTicks& timestamp,
bengr 2016/02/19 00:45:09 Declare.
tbansal1 2016/02/26 01:15:00 Did not notice that file was not included. This cl
+ net::NetworkQualityEstimator::ObservationSource source) override {
+ if (source != NetworkQualityEstimator::QUIC) {
+ NOTIMPLEMENTED();
+ }
+ notification_received_ = true;
+ }
+
+ private:
+ bool notification_received_;
+};
+
class QuicNetworkTransactionTest
: public PlatformTest,
public ::testing::WithParamInterface<QuicVersion> {
@@ -440,6 +466,8 @@ class QuicNetworkTransactionTest
}
test_network_quality_estimator_->AddRTTObserver(&rtt_observer_);
+ test_network_quality_estimator_->AddPacketLossObserver(
+ &packet_loss_observer_);
if (use_next_protos) {
params_.parse_alternative_services = true;
@@ -579,6 +607,7 @@ class QuicNetworkTransactionTest
scoped_ptr<CTVerifier> cert_transparency_verifier_;
scoped_ptr<TestNetworkQualityEstimator> test_network_quality_estimator_;
TestRTTObserver rtt_observer_;
+ TestPacketLossObserver packet_loss_observer_;
scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_;
scoped_ptr<ProxyService> proxy_service_;
scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_;
@@ -637,8 +666,10 @@ TEST_P(QuicNetworkTransactionTest, ForceQuic) {
CreateSession();
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
SendRequestAndExpectQuicResponse("hello!");
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
// Check that the NetLog was filled reasonably.
TestNetLogEntry::List entries;
@@ -699,6 +730,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
mock_quic_data.AddSocketDataToFactory(&socket_factory_);
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
// There is no need to set up an alternate protocol job, because
// no attempt will be made to speak to the proxy over TCP.
@@ -707,6 +739,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70);
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
}
// Regression test for https://crbug.com/492458. Test that for an HTTP
@@ -2291,6 +2324,7 @@ TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
maker_.set_hostname("www.example.org");
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
MockQuicData mock_quic_data;
mock_quic_data.AddWrite(
ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
@@ -2309,6 +2343,7 @@ TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE);
SendRequestAndExpectQuicResponse("hello!");
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
}
TEST_P(QuicNetworkTransactionTest, QuicUpload) {

Powered by Google App Engine
This is Rietveld 408576698