| OLD | NEW |
| 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 <sys/epoll.h> | 7 #include <sys/epoll.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1010 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
| 1011 // Expect the default rtt of 100ms. | 1011 // Expect the default rtt of 100ms. |
| 1012 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli), | 1012 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli), |
| 1013 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1013 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
| 1014 // Ensure the bandwidth is valid. | 1014 // Ensure the bandwidth is valid. |
| 1015 client_sent_packet_manager.BandwidthEstimate(); | 1015 client_sent_packet_manager.BandwidthEstimate(); |
| 1016 server_sent_packet_manager.BandwidthEstimate(); | 1016 server_sent_packet_manager.BandwidthEstimate(); |
| 1017 server_thread_->Resume(); | 1017 server_thread_->Resume(); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 TEST_P(EndToEndTest, 0ByteConnectionId) { |
| 1021 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic, |
| 1022 true); |
| 1023 client_config_.SetBytesForConnectionIdToSend(0); |
| 1024 ASSERT_TRUE(Initialize()); |
| 1025 |
| 1026 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1027 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1028 |
| 1029 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
| 1030 client_->client()->session()->connection()); |
| 1031 EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID, |
| 1032 header->public_header.connection_id_length); |
| 1033 } |
| 1034 |
| 1035 TEST_P(EndToEndTest, 1ByteConnectionId) { |
| 1036 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic, |
| 1037 true); |
| 1038 client_config_.SetBytesForConnectionIdToSend(1); |
| 1039 ASSERT_TRUE(Initialize()); |
| 1040 |
| 1041 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1042 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1043 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
| 1044 client_->client()->session()->connection()); |
| 1045 EXPECT_EQ(PACKET_1BYTE_CONNECTION_ID, |
| 1046 header->public_header.connection_id_length); |
| 1047 } |
| 1048 |
| 1049 TEST_P(EndToEndTest, 4ByteConnectionId) { |
| 1050 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic, |
| 1051 true); |
| 1052 client_config_.SetBytesForConnectionIdToSend(4); |
| 1053 ASSERT_TRUE(Initialize()); |
| 1054 |
| 1055 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1056 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1057 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
| 1058 client_->client()->session()->connection()); |
| 1059 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID, |
| 1060 header->public_header.connection_id_length); |
| 1061 } |
| 1062 |
| 1063 TEST_P(EndToEndTest, 8ByteConnectionId) { |
| 1064 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic, |
| 1065 true); |
| 1066 client_config_.SetBytesForConnectionIdToSend(8); |
| 1067 ASSERT_TRUE(Initialize()); |
| 1068 |
| 1069 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1070 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1071 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
| 1072 client_->client()->session()->connection()); |
| 1073 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, |
| 1074 header->public_header.connection_id_length); |
| 1075 } |
| 1076 |
| 1077 TEST_P(EndToEndTest, 15ByteConnectionId) { |
| 1078 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic, |
| 1079 true); |
| 1080 client_config_.SetBytesForConnectionIdToSend(15); |
| 1081 ASSERT_TRUE(Initialize()); |
| 1082 |
| 1083 // Our server is permissive and allows for out of bounds values. |
| 1084 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1085 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1086 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
| 1087 client_->client()->session()->connection()); |
| 1088 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, |
| 1089 header->public_header.connection_id_length); |
| 1090 } |
| 1091 |
| 1020 TEST_P(EndToEndTest, ResetConnection) { | 1092 TEST_P(EndToEndTest, ResetConnection) { |
| 1021 ASSERT_TRUE(Initialize()); | 1093 ASSERT_TRUE(Initialize()); |
| 1022 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1094 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1023 | 1095 |
| 1024 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1096 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1025 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1097 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1026 client_->ResetConnection(); | 1098 client_->ResetConnection(); |
| 1027 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1099 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 1028 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1100 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1029 } | 1101 } |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 const QuicSentPacketManager& server_sent_packet_manager = | 1437 const QuicSentPacketManager& server_sent_packet_manager = |
| 1366 *GetSentPacketManagerFromFirstServerSession(); | 1438 *GetSentPacketManagerFromFirstServerSession(); |
| 1367 EXPECT_TRUE(server_sent_packet_manager.using_pacing()); | 1439 EXPECT_TRUE(server_sent_packet_manager.using_pacing()); |
| 1368 EXPECT_TRUE(client_sent_packet_manager.using_pacing()); | 1440 EXPECT_TRUE(client_sent_packet_manager.using_pacing()); |
| 1369 } | 1441 } |
| 1370 | 1442 |
| 1371 } // namespace | 1443 } // namespace |
| 1372 } // namespace test | 1444 } // namespace test |
| 1373 } // namespace tools | 1445 } // namespace tools |
| 1374 } // namespace net | 1446 } // namespace net |
| OLD | NEW |