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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.h » ('j') | 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 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 }; 102 };
103 103
104 class EndToEndTest : public ::testing::Test { 104 class EndToEndTest : public ::testing::Test {
105 protected: 105 protected:
106 EndToEndTest() 106 EndToEndTest()
107 : server_hostname_("localhost"), 107 : server_hostname_("localhost"),
108 server_started_(false) { 108 server_started_(false) {
109 net::IPAddressNumber ip; 109 net::IPAddressNumber ip;
110 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); 110 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip));
111 server_address_ = IPEndPoint(ip, 0); 111 server_address_ = IPEndPoint(ip, 0);
112 config_.SetDefaults();
112 113
113 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); 114 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody);
114 AddToCache("GET", "https://www.google.com/foo", 115 AddToCache("GET", "https://www.google.com/foo",
115 "HTTP/1.1", "200", "OK", kFooResponseBody); 116 "HTTP/1.1", "200", "OK", kFooResponseBody);
116 AddToCache("GET", "https://www.google.com/bar", 117 AddToCache("GET", "https://www.google.com/bar",
117 "HTTP/1.1", "200", "OK", kBarResponseBody); 118 "HTTP/1.1", "200", "OK", kBarResponseBody);
118 } 119 }
119 120
120 static void SetUpTestCase() { 121 static void SetUpTestCase() {
121 QuicInMemoryCache::GetInstance()->ResetForTests(); 122 QuicInMemoryCache::GetInstance()->ResetForTests();
122 } 123 }
123 124
124 virtual QuicTestClient* CreateQuicClient() { 125 virtual QuicTestClient* CreateQuicClient() {
125 QuicTestClient* client = new QuicTestClient(server_address_, 126 QuicTestClient* client = new QuicTestClient(server_address_,
126 server_hostname_); 127 server_hostname_,
128 config_);
127 client->Connect(); 129 client->Connect();
128 return client; 130 return client;
129 } 131 }
130 132
131 virtual bool Initialize() { 133 virtual bool Initialize() {
132 // Start the server first, because CreateQuicClient() attempts 134 // Start the server first, because CreateQuicClient() attempts
133 // to connect to the server. 135 // to connect to the server.
134 StartServer(); 136 StartServer();
135 client_.reset(CreateQuicClient()); 137 client_.reset(CreateQuicClient());
136 return client_->client()->connected(); 138 return client_->client()->connected();
137 } 139 }
138 140
139 virtual void TearDown() { 141 virtual void TearDown() {
140 StopServer(); 142 StopServer();
141 } 143 }
142 144
143 void StartServer() { 145 void StartServer() {
144 server_thread_.reset(new ServerThread(server_address_)); 146 server_thread_.reset(new ServerThread(server_address_));
145 server_thread_->Start(); 147 server_thread_->Start();
146 server_thread_->listening()->Wait(); 148 server_thread_->listening()->Wait();
147 server_address_ = IPEndPoint(server_address_.address(), 149 server_address_ = IPEndPoint(server_address_.address(),
148 server_thread_->GetPort()); 150 server_thread_->GetPort());
149 server_started_ = true; 151 server_started_ = true;
150 } 152 }
151 153
152 void StopServer() { 154 void StopServer() {
153 if (!server_started_) 155 if (!server_started_)
154 return; 156 return;
155 server_thread_->quit()->Signal(); 157 if (server_thread_.get()) {
156 server_thread_->Join(); 158 server_thread_->quit()->Signal();
159 server_thread_->Join();
160 }
157 } 161 }
158 162
159 void AddToCache(const StringPiece& method, 163 void AddToCache(const StringPiece& method,
160 const StringPiece& path, 164 const StringPiece& path,
161 const StringPiece& version, 165 const StringPiece& version,
162 const StringPiece& response_code, 166 const StringPiece& response_code,
163 const StringPiece& response_detail, 167 const StringPiece& response_detail,
164 const StringPiece& body) { 168 const StringPiece& body) {
165 BalsaHeaders request_headers, response_headers; 169 BalsaHeaders request_headers, response_headers;
166 request_headers.SetRequestFirstlineFromStringPieces(method, 170 request_headers.SetRequestFirstlineFromStringPieces(method,
(...skipping 18 matching lines...) Expand all
185 return; 189 return;
186 } 190 }
187 cache->AddResponse(request_headers, response_headers, body); 191 cache->AddResponse(request_headers, response_headers, body);
188 } 192 }
189 193
190 IPEndPoint server_address_; 194 IPEndPoint server_address_;
191 string server_hostname_; 195 string server_hostname_;
192 scoped_ptr<ServerThread> server_thread_; 196 scoped_ptr<ServerThread> server_thread_;
193 scoped_ptr<QuicTestClient> client_; 197 scoped_ptr<QuicTestClient> client_;
194 bool server_started_; 198 bool server_started_;
199 QuicConfig config_;
195 }; 200 };
196 201
197 TEST_F(EndToEndTest, SimpleRequestResponse) { 202 TEST_F(EndToEndTest, SimpleRequestResponse) {
198 // TODO(rtenneti): Delete this when NSS is supported. 203 // TODO(rtenneti): Delete this when NSS is supported.
199 if (!Aes128GcmEncrypter::IsSupported()) { 204 if (!Aes128GcmEncrypter::IsSupported()) {
200 LOG(INFO) << "AES GCM not supported. Test skipped."; 205 LOG(INFO) << "AES GCM not supported. Test skipped.";
201 return; 206 return;
202 } 207 }
203 208
204 ASSERT_TRUE(Initialize()); 209 ASSERT_TRUE(Initialize());
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 false, client_->GetOrCreateStream()); 497 false, client_->GetOrCreateStream());
493 EXPECT_DEBUG_DEATH({ 498 EXPECT_DEBUG_DEATH({
494 client_->SendData("eep", true); 499 client_->SendData("eep", true);
495 client_->WaitForResponse(); 500 client_->WaitForResponse();
496 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error()); 501 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error());
497 }, 502 },
498 "Check failed: !fin_buffered_"); 503 "Check failed: !fin_buffered_");
499 } 504 }
500 505
501 /*TEST_F(EndToEndTest, Timeout) { 506 /*TEST_F(EndToEndTest, Timeout) {
502 FLAGS_negotiated_timeout_us = 500; 507 config_.set_idle_connection_state_lifetime(
508 QuicTime::Delta::FromMicroseconds(500));
503 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: 509 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake:
504 // that's enough to validate timeout in this case. 510 // that's enough to validate timeout in this case.
505 Initialize(); 511 Initialize();
506
507 while (client_->client()->connected()) { 512 while (client_->client()->connected()) {
508 client_->client()->WaitForEvents(); 513 client_->client()->WaitForEvents();
509 } 514 }
510 }*/ 515 }*/
511 516
512 TEST_F(EndToEndTest, ResetConnection) { 517 TEST_F(EndToEndTest, ResetConnection) {
513 // TODO(rtenneti): Delete this when NSS is supported. 518 // TODO(rtenneti): Delete this when NSS is supported.
514 if (!Aes128GcmEncrypter::IsSupported()) { 519 if (!Aes128GcmEncrypter::IsSupported()) {
515 LOG(INFO) << "AES GCM not supported. Test skipped."; 520 LOG(INFO) << "AES GCM not supported. Test skipped.";
516 return; 521 return;
517 } 522 }
518 523
519 ASSERT_TRUE(Initialize()); 524 ASSERT_TRUE(Initialize());
520 525
521 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 526 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
522 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); 527 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code());
523 client_->ResetConnection(); 528 client_->ResetConnection();
524 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); 529 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar"));
525 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); 530 EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code());
526 } 531 }
527 532
528 } // namespace 533 } // namespace
529 } // namespace test 534 } // namespace test
530 } // namespace tools 535 } // namespace tools
531 } // namespace net 536 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698