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

Side by Side Diff: net/quic/quic_stream_factory_test.cc

Issue 1932833002: QuicStreamFactoryTest cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); 1096 std::unique_ptr<QuicHttpStream> stream = request.CreateStream();
1097 EXPECT_TRUE(stream.get()); 1097 EXPECT_TRUE(stream.get());
1098 1098
1099 // Mark the session as going away. Ensure that while it is still alive 1099 // Mark the session as going away. Ensure that while it is still alive
1100 // that it is no longer active. 1100 // that it is no longer active.
1101 QuicChromiumClientSession* session = GetActiveSession(host_port_pair_); 1101 QuicChromiumClientSession* session = GetActiveSession(host_port_pair_);
1102 factory_->OnSessionGoingAway(session); 1102 factory_->OnSessionGoingAway(session);
1103 EXPECT_EQ(true, 1103 EXPECT_EQ(true,
1104 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); 1104 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session));
1105 EXPECT_FALSE(HasActiveSession(host_port_pair_)); 1105 EXPECT_FALSE(HasActiveSession(host_port_pair_));
1106 EXPECT_FALSE(HasActiveSession(host_port_pair_));
1107 1106
1108 // Create a new request for the same destination and verify that a 1107 // Create a new request for the same destination and verify that a
1109 // new session is created. 1108 // new session is created.
1110 QuicStreamRequest request2(factory_.get()); 1109 QuicStreamRequest request2(factory_.get());
1111 EXPECT_EQ(ERR_IO_PENDING, 1110 EXPECT_EQ(ERR_IO_PENDING,
1112 request2.Request(host_port_pair_, privacy_mode_, 1111 request2.Request(host_port_pair_, privacy_mode_,
1113 /*cert_verify_flags=*/0, url_, "GET", net_log_, 1112 /*cert_verify_flags=*/0, url_, "GET", net_log_,
1114 callback_.callback())); 1113 callback_.callback()));
1115 EXPECT_EQ(OK, callback_.WaitForResult()); 1114 EXPECT_EQ(OK, callback_.WaitForResult());
1116 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream(); 1115 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream();
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 host_port_pair_.port())); 2797 host_port_pair_.port()));
2799 EXPECT_TRUE(HasActiveSession(host_port_pair_)); 2798 EXPECT_TRUE(HasActiveSession(host_port_pair_));
2800 2799
2801 // Test N-in-a-row high packet loss connections. 2800 // Test N-in-a-row high packet loss connections.
2802 2801
2803 DVLOG(1) << "Create 2nd session and test packet loss"; 2802 DVLOG(1) << "Create 2nd session and test packet loss";
2804 2803
2805 TestCompletionCallback callback2; 2804 TestCompletionCallback callback2;
2806 QuicStreamRequest request2(factory_.get()); 2805 QuicStreamRequest request2(factory_.get());
2807 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, 2806 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_,
2808 /*cert_verify_flags=*/0, url_, "GET", net_log_, 2807 /*cert_verify_flags=*/0, url2_, "GET",
2809 callback2.callback())); 2808 net_log_, callback2.callback()));
2810 QuicChromiumClientSession* session2 = GetActiveSession(server2); 2809 QuicChromiumClientSession* session2 = GetActiveSession(server2);
2811 2810
2812 // If there is no packet loss during handshake confirmation, number of lossy 2811 // If there is no packet loss during handshake confirmation, number of lossy
2813 // connections for the port should be 0. 2812 // connections for the port should be 0.
2814 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( 2813 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections(
2815 factory_.get(), server2.port())); 2814 factory_.get(), server2.port()));
2816 EXPECT_FALSE( 2815 EXPECT_FALSE(
2817 factory_->OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); 2816 factory_->OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f));
2818 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( 2817 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections(
2819 factory_.get(), server2.port())); 2818 factory_.get(), server2.port()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in 2850 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in
2852 // a row and that should close the session and disable QUIC. 2851 // a row and that should close the session and disable QUIC.
2853 EXPECT_TRUE( 2852 EXPECT_TRUE(
2854 factory_->OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); 2853 factory_->OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f));
2855 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( 2854 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections(
2856 factory_.get(), server3.port())); 2855 factory_.get(), server3.port()));
2857 EXPECT_FALSE(session3->connection()->connected()); 2856 EXPECT_FALSE(session3->connection()->connected());
2858 EXPECT_TRUE( 2857 EXPECT_TRUE(
2859 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server3.port())); 2858 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server3.port()));
2860 EXPECT_FALSE(HasActiveSession(server3)); 2859 EXPECT_FALSE(HasActiveSession(server3));
2861 EXPECT_FALSE(HasActiveSession(server3));
2862 2860
2863 // Set packet_loss_rate to higher value than packet_loss_threshold 3rd time in 2861 // Set packet_loss_rate to higher value than packet_loss_threshold 3rd time in
2864 // a row and IsQuicDisabled() should close the session. 2862 // a row and IsQuicDisabled() should close the session.
2865 EXPECT_TRUE( 2863 EXPECT_TRUE(
2866 factory_->OnHandshakeConfirmed(session4, /*packet_loss_rate=*/1.0f)); 2864 factory_->OnHandshakeConfirmed(session4, /*packet_loss_rate=*/1.0f));
2867 EXPECT_EQ(3, QuicStreamFactoryPeer::GetNumberOfLossyConnections( 2865 EXPECT_EQ(3, QuicStreamFactoryPeer::GetNumberOfLossyConnections(
2868 factory_.get(), server4.port())); 2866 factory_.get(), server4.port()));
2869 EXPECT_FALSE(session4->connection()->connected()); 2867 EXPECT_FALSE(session4->connection()->connected());
2870 EXPECT_TRUE( 2868 EXPECT_TRUE(
2871 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server4.port())); 2869 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server4.port()));
2872 EXPECT_FALSE(HasActiveSession(server4)); 2870 EXPECT_FALSE(HasActiveSession(server4));
2873 EXPECT_FALSE(HasActiveSession(server4));
2874 2871
2875 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); 2872 std::unique_ptr<QuicHttpStream> stream = request.CreateStream();
2876 EXPECT_TRUE(stream.get()); 2873 EXPECT_TRUE(stream.get());
2877 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream(); 2874 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream();
2878 EXPECT_TRUE(stream2.get()); 2875 EXPECT_TRUE(stream2.get());
2879 std::unique_ptr<QuicHttpStream> stream3 = request3.CreateStream(); 2876 std::unique_ptr<QuicHttpStream> stream3 = request3.CreateStream();
2880 EXPECT_TRUE(stream3.get()); 2877 EXPECT_TRUE(stream3.get());
2881 std::unique_ptr<QuicHttpStream> stream4 = request4.CreateStream(); 2878 std::unique_ptr<QuicHttpStream> stream4 = request4.CreateStream();
2882 EXPECT_TRUE(stream4.get()); 2879 EXPECT_TRUE(stream4.get());
2883 EXPECT_TRUE(socket_data.AllReadDataConsumed()); 2880 EXPECT_TRUE(socket_data.AllReadDataConsumed());
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( 3140 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(
3144 factory_.get())); 3141 factory_.get()));
3145 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), 3142 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(),
3146 host_port_pair_.port())); 3143 host_port_pair_.port()));
3147 3144
3148 DVLOG(1) << "Create 3rd session with public reset post handshake," 3145 DVLOG(1) << "Create 3rd session with public reset post handshake,"
3149 << " will disable QUIC"; 3146 << " will disable QUIC";
3150 TestCompletionCallback callback3; 3147 TestCompletionCallback callback3;
3151 QuicStreamRequest request3(factory_.get()); 3148 QuicStreamRequest request3(factory_.get());
3152 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, 3149 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_,
3153 /*cert_verify_flags=*/0, url2_, "GET", 3150 /*cert_verify_flags=*/0, url3_, "GET",
3154 net_log_, callback3.callback())); 3151 net_log_, callback3.callback()));
3155 QuicChromiumClientSession* session3 = GetActiveSession(server3); 3152 QuicChromiumClientSession* session3 = GetActiveSession(server3);
3156 3153
3157 session3->connection()->CloseConnection( 3154 session3->connection()->CloseConnection(
3158 QUIC_PUBLIC_RESET, "test", ConnectionCloseBehavior::SILENT_CLOSE); 3155 QUIC_PUBLIC_RESET, "test", ConnectionCloseBehavior::SILENT_CLOSE);
3159 // Need to spin the loop now to ensure that 3156 // Need to spin the loop now to ensure that
3160 // QuicStreamFactory::OnSessionClosed() runs. 3157 // QuicStreamFactory::OnSessionClosed() runs.
3161 base::RunLoop run_loop3; 3158 base::RunLoop run_loop3;
3162 run_loop3.RunUntilIdle(); 3159 run_loop3.RunUntilIdle();
3163 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( 3160 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 EXPECT_TRUE(stream2.get()); 4092 EXPECT_TRUE(stream2.get());
4096 4093
4097 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); 4094 EXPECT_TRUE(socket_data1.AllReadDataConsumed());
4098 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); 4095 EXPECT_TRUE(socket_data1.AllWriteDataConsumed());
4099 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 4096 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
4100 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 4097 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
4101 } 4098 }
4102 4099
4103 } // namespace test 4100 } // namespace test
4104 } // namespace net 4101 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698