| Index: net/quic/quic_stream_factory_test.cc
|
| diff --git a/net/quic/quic_stream_factory_test.cc b/net/quic/quic_stream_factory_test.cc
|
| index fdc023b28ac5d8420c165d16d3cc5baf0530cb7b..11192e650373825840a76c49b4c07a4992b60257 100644
|
| --- a/net/quic/quic_stream_factory_test.cc
|
| +++ b/net/quic/quic_stream_factory_test.cc
|
| @@ -135,6 +135,10 @@ class QuicStreamFactoryPeer {
|
| factory->disable_disk_cache_ = disable_disk_cache;
|
| }
|
|
|
| + static bool IsQuicDisabled(QuicStreamFactory* factory, uint16 port) {
|
| + return factory->IsQuicDisabled(port);
|
| + }
|
| +
|
| static size_t GetNumberOfActiveJobs(QuicStreamFactory* factory,
|
| const QuicServerId& server_id) {
|
| return (factory->active_jobs_[server_id]).size();
|
| @@ -206,6 +210,8 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<TestParams> {
|
| /*enable_connection_racing=*/false,
|
| /*enable_non_blocking_io=*/true,
|
| /*disable_disk_cache=*/false,
|
| + /*max_number_of_lossy_connections=*/0,
|
| + /*packet_loss_threshold=*/1.0f,
|
| /*receive_buffer_size=*/0,
|
| QuicTagVector()),
|
| host_port_pair_(kDefaultServerHostName, kDefaultServerPort),
|
| @@ -1681,5 +1687,54 @@ TEST_P(QuicStreamFactoryTest, EnableNotLoadFromDiskCache) {
|
| EXPECT_TRUE(socket_data.at_write_eof());
|
| }
|
|
|
| +TEST_P(QuicStreamFactoryTest, BadPacketLoss) {
|
| + EXPECT_FALSE(
|
| + QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port()));
|
| +
|
| + MockRead reads[] = {
|
| + MockRead(ASYNC, OK, 0) // EOF
|
| + };
|
| + DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0);
|
| + socket_factory_.AddSocketDataProvider(&socket_data);
|
| + socket_data.StopAfter(1);
|
| +
|
| + QuicStreamRequest request(&factory_);
|
| + EXPECT_EQ(ERR_IO_PENDING,
|
| + request.Request(host_port_pair_, is_https_, privacy_mode_, "GET",
|
| + net_log_, callback_.callback()));
|
| + EXPECT_EQ(OK, callback_.WaitForResult());
|
| + scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
|
| + EXPECT_TRUE(stream.get());
|
| +
|
| + QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession(
|
| + &factory_, host_port_pair_, is_https_);
|
| +
|
| + // Set packet_loss_rate to a lower value than packet_loss_threshold.
|
| + // OnBadPacketLoss shouldn't disable QUIC.
|
| + QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_);
|
| + EXPECT_FALSE(factory_.OnBadPacketLoss(session, server_id,
|
| + /*packet_loss_rate=*/0.9f));
|
| + EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(
|
| + &factory_, host_port_pair_, is_https_));
|
| + EXPECT_FALSE(
|
| + QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port()));
|
| +
|
| + // Set packet_loss_rate to higher value than packet_loss_threshold.
|
| + // OnBadPacketLoss should disable QUIC.
|
| + EXPECT_TRUE(factory_.OnBadPacketLoss(session, server_id,
|
| + /*packet_loss_rate=*/1.0f));
|
| + EXPECT_TRUE(
|
| + QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port()));
|
| +
|
| + // The session should be marked as going away.
|
| + EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession(
|
| + &factory_, host_port_pair_, is_https_));
|
| + EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get());
|
| +
|
| + stream.reset();
|
| + EXPECT_TRUE(socket_data.at_read_eof());
|
| + EXPECT_TRUE(socket_data.at_write_eof());
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace net
|
|
|