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

Side by Side Diff: net/tools/quic/end_to_end_test.cc

Issue 121883003: Add an end-to-end test which verifies that QUIC 13 does not generate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Uploading again Created 6 years, 11 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 | Annotate | Revision Log
« 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 <stddef.h> 5 #include <stddef.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 StringPiece response_code, 245 StringPiece response_code,
246 StringPiece response_detail, 246 StringPiece response_detail,
247 StringPiece body) { 247 StringPiece body) {
248 QuicInMemoryCache::GetInstance()->AddSimpleResponse( 248 QuicInMemoryCache::GetInstance()->AddSimpleResponse(
249 method, path, version, response_code, response_detail, body); 249 method, path, version, response_code, response_detail, body);
250 } 250 }
251 251
252 void SetPacketLossPercentage(int32 loss) { 252 void SetPacketLossPercentage(int32 loss) {
253 // TODO(rtenneti): enable when we can do random packet loss tests in 253 // TODO(rtenneti): enable when we can do random packet loss tests in
254 // chrome's tree. 254 // chrome's tree.
255 // client_writer_->set_fake_packet_loss_percentage(loss); 255 if (loss != 0 && loss != 100)
256 // server_writer_->set_fake_packet_loss_percentage(loss); 256 return;
257 client_writer_->set_fake_packet_loss_percentage(loss);
258 server_writer_->set_fake_packet_loss_percentage(loss);
257 } 259 }
258 260
259 void SetPacketSendDelay(QuicTime::Delta delay) { 261 void SetPacketSendDelay(QuicTime::Delta delay) {
260 // TODO(rtenneti): enable when we can do random packet send delay tests in 262 // TODO(rtenneti): enable when we can do random packet send delay tests in
261 // chrome's tree. 263 // chrome's tree.
262 // client_writer_->set_fake_packet_delay(delay); 264 // client_writer_->set_fake_packet_delay(delay);
263 // server_writer_->set_fake_packet_delay(delay); 265 // server_writer_->set_fake_packet_delay(delay);
264 } 266 }
265 267
266 void SetReorderPercentage(int32 reorder) { 268 void SetReorderPercentage(int32 reorder) {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 for (int i = 0; i < max_streams; ++i) { 774 for (int i = 0; i < max_streams; ++i) {
773 EXPECT_LT(0, client_->SendRequest("/large_response")); 775 EXPECT_LT(0, client_->SendRequest("/large_response"));
774 } 776 }
775 777
776 // WaitForEvents waits 50ms and returns true if there are outstanding 778 // WaitForEvents waits 50ms and returns true if there are outstanding
777 // requests. 779 // requests.
778 while (client_->client()->WaitForEvents() == true) { 780 while (client_->client()->WaitForEvents() == true) {
779 } 781 }
780 } 782 }
781 783
784 TEST_P(EndToEndTest, StreamCancelErrorTest) {
785 ASSERT_TRUE(Initialize());
786 string small_body;
787 GenerateBody(&small_body, 256);
788
789 AddToCache("GET", "/small_response", "HTTP/1.1", "200", "OK", small_body);
790
791 client_->client()->WaitForCryptoHandshakeConfirmed();
792
793 QuicSession* session = client_->client()->session();
794 // Lose the request.
795 SetPacketLossPercentage(100);
796 EXPECT_LT(0, client_->SendRequest("/small_response"));
797 client_->client()->WaitForEvents();
798 // Transmit the cancel, and ensure the connection is torn down properly.
799 SetPacketLossPercentage(0);
800 QuicStreamId stream_id = negotiated_version_ > QUIC_VERSION_12 ? 5 : 3;
801 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED);
802
803 // WaitForEvents waits 50ms and returns true if there are outstanding
804 // requests.
805 while (client_->client()->WaitForEvents() == true) {
806 }
807 if (negotiated_version_ > QUIC_VERSION_12) {
808 // It should be completely fine to RST a stream before any data has bee
809 // received for that stream.
810 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
811 } else {
812 // Check that the connection is always properly closed
813 // from a stream being RST before headers are decompressed.
814 EXPECT_EQ(QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED,
815 client_->connection_error());
816 }
817 }
818
782 class WrongAddressWriter : public QuicTestWriter { 819 class WrongAddressWriter : public QuicTestWriter {
783 public: 820 public:
784 WrongAddressWriter() { 821 WrongAddressWriter() {
785 IPAddressNumber ip; 822 IPAddressNumber ip;
786 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); 823 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip));
787 self_address_ = IPEndPoint(ip, 0); 824 self_address_ = IPEndPoint(ip, 0);
788 } 825 }
789 826
790 virtual WriteResult WritePacket( 827 virtual WriteResult WritePacket(
791 const char* buffer, size_t buf_len, 828 const char* buffer, size_t buf_len,
(...skipping 27 matching lines...) Expand all
819 client_->SendSynchronousRequest("/bar"); 856 client_->SendSynchronousRequest("/bar");
820 857
821 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 858 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
822 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); 859 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error());
823 } 860 }
824 861
825 } // namespace 862 } // namespace
826 } // namespace test 863 } // namespace test
827 } // namespace tools 864 } // namespace tools
828 } // namespace net 865 } // 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