| 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..78578e510226050af2222c24fff892cc6546f68d 100644
|
| --- a/net/quic/quic_network_transaction_unittest.cc
|
| +++ b/net/quic/quic_network_transaction_unittest.cc
|
| @@ -2,6 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <stddef.h>
|
| +#include <stdint.h>
|
| +
|
| #include <vector>
|
|
|
| #include "base/compiler_specific.h"
|
| @@ -10,6 +13,7 @@
|
| #include "base/run_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/time/time.h"
|
| #include "net/base/chunked_upload_data_stream.h"
|
| #include "net/base/network_quality_estimator.h"
|
| #include "net/base/socket_performance_watcher.h"
|
| @@ -182,6 +186,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(
|
| + size_t packets_lost,
|
| + size_t packets_received_in_order,
|
| + size_t packets_received_out_of_order,
|
| + const base::TimeTicks& timestamp,
|
| + 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 +468,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 +609,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 +668,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 +732,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 +741,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 +2326,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 +2345,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) {
|
|
|