| 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 b5a8d6d16a3e10182619ddc09ba06b534b9faa09..5cc527c6e7a634bdab186597e54d893aaeb1e3f9 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 <stddef.h>
|
| +
|
| #include <vector>
|
|
|
| #include "base/compiler_specific.h"
|
| @@ -10,6 +12,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 +185,30 @@ class TestRTTObserver : public NetworkQualityEstimator::RTTObserver {
|
| bool rtt_notification_received_;
|
| };
|
|
|
| +class TestPacketCountObserver
|
| + : public NetworkQualityEstimator::PacketCountObserver {
|
| + public:
|
| + TestPacketCountObserver() : notification_received_(false) {}
|
| +
|
| + bool notification_received() const { return notification_received_; }
|
| +
|
| + // NetworkQualityEstimator::PacketCountObserver implementation:
|
| + void OnIncrementalPacketCountObservation(
|
| + size_t packets_missing,
|
| + 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> {
|
| @@ -437,6 +464,8 @@ class QuicNetworkTransactionTest
|
| }
|
|
|
| test_network_quality_estimator_->AddRTTObserver(&rtt_observer_);
|
| + test_network_quality_estimator_->AddPacketCountObserver(
|
| + &packet_count_observer_);
|
|
|
| session_.reset(new HttpNetworkSession(params_));
|
| session_->quic_stream_factory()->set_require_confirmation(false);
|
| @@ -571,6 +600,7 @@ class QuicNetworkTransactionTest
|
| scoped_ptr<CTVerifier> cert_transparency_verifier_;
|
| scoped_ptr<TestNetworkQualityEstimator> test_network_quality_estimator_;
|
| TestRTTObserver rtt_observer_;
|
| + TestPacketCountObserver packet_count_observer_;
|
| scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_;
|
| scoped_ptr<ProxyService> proxy_service_;
|
| scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_;
|
| @@ -631,8 +661,10 @@ TEST_P(QuicNetworkTransactionTest, ForceQuic) {
|
| CreateSession();
|
|
|
| EXPECT_FALSE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_FALSE(packet_count_observer_.notification_received());
|
| SendRequestAndExpectQuicResponse("hello!");
|
| EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(packet_count_observer_.notification_received());
|
|
|
| // Check that the NetLog was filled reasonably.
|
| TestNetLogEntry::List entries;
|
| @@ -693,6 +725,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
|
| mock_quic_data.AddSocketDataToFactory(&socket_factory_);
|
|
|
| EXPECT_FALSE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_FALSE(packet_count_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.
|
|
|
| @@ -703,6 +736,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
|
|
|
| SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70);
|
| EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(packet_count_observer_.notification_received());
|
| }
|
|
|
| // Regression test for https://crbug.com/492458. Test that for an HTTP
|
| @@ -2301,6 +2335,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_count_observer_.notification_received());
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddWrite(
|
| ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
|
| @@ -2319,6 +2354,7 @@ TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE);
|
| SendRequestAndExpectQuicResponse("hello!");
|
| EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(packet_count_observer_.notification_received());
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, QuicUpload) {
|
|
|