OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <memory> | 5 #include <memory> |
6 #include <ostream> | 6 #include <ostream> |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "net/base/elements_upload_data_stream.h" | 15 #include "net/base/elements_upload_data_stream.h" |
15 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
16 #include "net/base/test_completion_callback.h" | 17 #include "net/base/test_completion_callback.h" |
17 #include "net/base/upload_bytes_element_reader.h" | 18 #include "net/base/upload_bytes_element_reader.h" |
18 #include "net/base/upload_data_stream.h" | 19 #include "net/base/upload_data_stream.h" |
19 #include "net/cert/ct_policy_enforcer.h" | 20 #include "net/cert/ct_policy_enforcer.h" |
20 #include "net/cert/mock_cert_verifier.h" | 21 #include "net/cert/mock_cert_verifier.h" |
21 #include "net/cert/multi_log_ct_verifier.h" | 22 #include "net/cert/multi_log_ct_verifier.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 TEST_P(QuicEndToEndTest, LargeGetWithNoPacketLoss) { | 284 TEST_P(QuicEndToEndTest, LargeGetWithNoPacketLoss) { |
284 std::string response(10 * 1024, 'x'); | 285 std::string response(10 * 1024, 'x'); |
285 | 286 |
286 AddToCache(request_.url.PathForRequest(), 200, "OK", response); | 287 AddToCache(request_.url.PathForRequest(), 200, "OK", response); |
287 | 288 |
288 TestTransactionConsumer consumer(DEFAULT_PRIORITY, | 289 TestTransactionConsumer consumer(DEFAULT_PRIORITY, |
289 transaction_factory_.get()); | 290 transaction_factory_.get()); |
290 consumer.Start(&request_, BoundNetLog()); | 291 consumer.Start(&request_, BoundNetLog()); |
291 | 292 |
292 // Will terminate when the last consumer completes. | 293 // Will terminate when the last consumer completes. |
293 base::MessageLoop::current()->Run(); | 294 base::RunLoop().Run(); |
294 | 295 |
295 CheckResponse(consumer, "HTTP/1.1 200", response); | 296 CheckResponse(consumer, "HTTP/1.1 200", response); |
296 } | 297 } |
297 | 298 |
298 TEST_P(QuicEndToEndTest, TokenBinding) { | 299 TEST_P(QuicEndToEndTest, TokenBinding) { |
299 // Enable token binding and re-initialize the TestTransactionFactory. | 300 // Enable token binding and re-initialize the TestTransactionFactory. |
300 params_.enable_token_binding = true; | 301 params_.enable_token_binding = true; |
301 transaction_factory_.reset(new TestTransactionFactory(params_)); | 302 transaction_factory_.reset(new TestTransactionFactory(params_)); |
302 | 303 |
303 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); | 304 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); |
304 | 305 |
305 TestTransactionConsumer consumer(DEFAULT_PRIORITY, | 306 TestTransactionConsumer consumer(DEFAULT_PRIORITY, |
306 transaction_factory_.get()); | 307 transaction_factory_.get()); |
307 consumer.Start(&request_, BoundNetLog()); | 308 consumer.Start(&request_, BoundNetLog()); |
308 | 309 |
309 // Will terminate when the last consumer completes. | 310 // Will terminate when the last consumer completes. |
310 base::MessageLoop::current()->Run(); | 311 base::RunLoop().Run(); |
311 | 312 |
312 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); | 313 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); |
313 HttpRequestHeaders headers; | 314 HttpRequestHeaders headers; |
314 ASSERT_TRUE(consumer.transaction()->GetFullRequestHeaders(&headers)); | 315 ASSERT_TRUE(consumer.transaction()->GetFullRequestHeaders(&headers)); |
315 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 316 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
316 } | 317 } |
317 | 318 |
318 // crbug.com/559173 | 319 // crbug.com/559173 |
319 #if defined(THREAD_SANITIZER) | 320 #if defined(THREAD_SANITIZER) |
320 TEST_P(QuicEndToEndTest, DISABLED_LargePostWithNoPacketLoss) { | 321 TEST_P(QuicEndToEndTest, DISABLED_LargePostWithNoPacketLoss) { |
321 #else | 322 #else |
322 TEST_P(QuicEndToEndTest, LargePostWithNoPacketLoss) { | 323 TEST_P(QuicEndToEndTest, LargePostWithNoPacketLoss) { |
323 #endif | 324 #endif |
324 InitializePostRequest(1024 * 1024); | 325 InitializePostRequest(1024 * 1024); |
325 | 326 |
326 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); | 327 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); |
327 | 328 |
328 TestTransactionConsumer consumer(DEFAULT_PRIORITY, | 329 TestTransactionConsumer consumer(DEFAULT_PRIORITY, |
329 transaction_factory_.get()); | 330 transaction_factory_.get()); |
330 consumer.Start(&request_, BoundNetLog()); | 331 consumer.Start(&request_, BoundNetLog()); |
331 | 332 |
332 // Will terminate when the last consumer completes. | 333 // Will terminate when the last consumer completes. |
333 base::MessageLoop::current()->Run(); | 334 base::RunLoop().Run(); |
334 | 335 |
335 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); | 336 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); |
336 } | 337 } |
337 | 338 |
338 // crbug.com/559173 | 339 // crbug.com/559173 |
339 #if defined(THREAD_SANITIZER) | 340 #if defined(THREAD_SANITIZER) |
340 TEST_P(QuicEndToEndTest, DISABLED_LargePostWithPacketLoss) { | 341 TEST_P(QuicEndToEndTest, DISABLED_LargePostWithPacketLoss) { |
341 #else | 342 #else |
342 TEST_P(QuicEndToEndTest, LargePostWithPacketLoss) { | 343 TEST_P(QuicEndToEndTest, LargePostWithPacketLoss) { |
343 #endif | 344 #endif |
344 // FLAGS_fake_packet_loss_percentage = 30; | 345 // FLAGS_fake_packet_loss_percentage = 30; |
345 InitializePostRequest(1024 * 1024); | 346 InitializePostRequest(1024 * 1024); |
346 | 347 |
347 const char kResponseBody[] = "some really big response body"; | 348 const char kResponseBody[] = "some really big response body"; |
348 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); | 349 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); |
349 | 350 |
350 TestTransactionConsumer consumer(DEFAULT_PRIORITY, | 351 TestTransactionConsumer consumer(DEFAULT_PRIORITY, |
351 transaction_factory_.get()); | 352 transaction_factory_.get()); |
352 consumer.Start(&request_, BoundNetLog()); | 353 consumer.Start(&request_, BoundNetLog()); |
353 | 354 |
354 // Will terminate when the last consumer completes. | 355 // Will terminate when the last consumer completes. |
355 base::MessageLoop::current()->Run(); | 356 base::RunLoop().Run(); |
356 | 357 |
357 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); | 358 CheckResponse(consumer, "HTTP/1.1 200", kResponseBody); |
358 } | 359 } |
359 | 360 |
360 // crbug.com/536845 | 361 // crbug.com/536845 |
361 #if defined(THREAD_SANITIZER) | 362 #if defined(THREAD_SANITIZER) |
362 TEST_P(QuicEndToEndTest, DISABLED_UberTest) { | 363 TEST_P(QuicEndToEndTest, DISABLED_UberTest) { |
363 #else | 364 #else |
364 TEST_P(QuicEndToEndTest, UberTest) { | 365 TEST_P(QuicEndToEndTest, UberTest) { |
365 #endif | 366 #endif |
366 // FLAGS_fake_packet_loss_percentage = 30; | 367 // FLAGS_fake_packet_loss_percentage = 30; |
367 | 368 |
368 const char kResponseBody[] = "some really big response body"; | 369 const char kResponseBody[] = "some really big response body"; |
369 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); | 370 AddToCache(request_.url.PathForRequest(), 200, "OK", kResponseBody); |
370 | 371 |
371 std::vector<TestTransactionConsumer*> consumers; | 372 std::vector<TestTransactionConsumer*> consumers; |
372 size_t num_requests = 100; | 373 size_t num_requests = 100; |
373 for (size_t i = 0; i < num_requests; ++i) { | 374 for (size_t i = 0; i < num_requests; ++i) { |
374 TestTransactionConsumer* consumer = new TestTransactionConsumer( | 375 TestTransactionConsumer* consumer = new TestTransactionConsumer( |
375 DEFAULT_PRIORITY, transaction_factory_.get()); | 376 DEFAULT_PRIORITY, transaction_factory_.get()); |
376 consumers.push_back(consumer); | 377 consumers.push_back(consumer); |
377 consumer->Start(&request_, BoundNetLog()); | 378 consumer->Start(&request_, BoundNetLog()); |
378 } | 379 } |
379 | 380 |
380 // Will terminate when the last consumer completes. | 381 // Will terminate when the last consumer completes. |
381 base::MessageLoop::current()->Run(); | 382 base::RunLoop().Run(); |
382 | 383 |
383 for (size_t i = 0; i < num_requests; ++i) { | 384 for (size_t i = 0; i < num_requests; ++i) { |
384 CheckResponse(*consumers[i], "HTTP/1.1 200", kResponseBody); | 385 CheckResponse(*consumers[i], "HTTP/1.1 200", kResponseBody); |
385 } | 386 } |
386 STLDeleteElements(&consumers); | 387 STLDeleteElements(&consumers); |
387 } | 388 } |
388 | 389 |
389 } // namespace test | 390 } // namespace test |
390 } // namespace net | 391 } // namespace net |
OLD | NEW |