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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/base/capturing_net_log.h" | 9 #include "net/base/capturing_net_log.h" |
10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 scoped_ptr<QuicSpdyCompressor> compressor_; | 320 scoped_ptr<QuicSpdyCompressor> compressor_; |
321 scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_; | 321 scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_; |
322 MockRandom random_generator_; | 322 MockRandom random_generator_; |
323 HttpServerPropertiesImpl http_server_properties; | 323 HttpServerPropertiesImpl http_server_properties; |
324 HttpNetworkSession::Params params_; | 324 HttpNetworkSession::Params params_; |
325 HttpRequestInfo request_; | 325 HttpRequestInfo request_; |
326 CapturingBoundNetLog net_log_; | 326 CapturingBoundNetLog net_log_; |
327 }; | 327 }; |
328 | 328 |
329 TEST_F(QuicNetworkTransactionTest, ForceQuic) { | 329 TEST_F(QuicNetworkTransactionTest, ForceQuic) { |
330 params_.origin_port_to_force_quic_on = 80; | 330 params_.origin_to_force_quic_on = |
| 331 HostPortPair::FromString("www.google.com:80"); |
331 | 332 |
332 QuicStreamId stream_id = 3; | 333 QuicStreamId stream_id = 3; |
333 scoped_ptr<QuicEncryptedPacket> req( | 334 scoped_ptr<QuicEncryptedPacket> req( |
334 ConstructDataPacket(1, stream_id, true, true, 0, | 335 ConstructDataPacket(1, stream_id, true, true, 0, |
335 GetRequestString("GET", "/"))); | 336 GetRequestString("GET", "/"))); |
336 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0)); | 337 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0)); |
337 | 338 |
338 MockWrite quic_writes[] = { | 339 MockWrite quic_writes[] = { |
339 MockWrite(SYNCHRONOUS, req->data(), req->length()), | 340 MockWrite(SYNCHRONOUS, req->data(), req->length()), |
340 MockWrite(SYNCHRONOUS, ack->data(), ack->length()), | 341 MockWrite(SYNCHRONOUS, ack->data(), ack->length()), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 net::NetLog::TYPE_QUIC_SESSION_STREAM_FRAME_RECEIVED, | 394 net::NetLog::TYPE_QUIC_SESSION_STREAM_FRAME_RECEIVED, |
394 net::NetLog::PHASE_NONE); | 395 net::NetLog::PHASE_NONE); |
395 EXPECT_LT(0, pos); | 396 EXPECT_LT(0, pos); |
396 | 397 |
397 int log_stream_id; | 398 int log_stream_id; |
398 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &log_stream_id)); | 399 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &log_stream_id)); |
399 EXPECT_EQ(stream_id, static_cast<QuicStreamId>(log_stream_id)); | 400 EXPECT_EQ(stream_id, static_cast<QuicStreamId>(log_stream_id)); |
400 } | 401 } |
401 | 402 |
402 TEST_F(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { | 403 TEST_F(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { |
403 params_.origin_port_to_force_quic_on = 80; | 404 params_.origin_to_force_quic_on = |
| 405 HostPortPair::FromString("www.google.com:80"); |
404 | 406 |
405 MockRead quic_reads[] = { | 407 MockRead quic_reads[] = { |
406 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), | 408 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), |
407 }; | 409 }; |
408 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), | 410 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), |
409 NULL, 0); | 411 NULL, 0); |
410 socket_factory_.AddSocketDataProvider(&quic_data); | 412 socket_factory_.AddSocketDataProvider(&quic_data); |
411 | 413 |
412 CreateSession(); | 414 CreateSession(); |
413 | 415 |
414 scoped_ptr<HttpNetworkTransaction> trans( | 416 scoped_ptr<HttpNetworkTransaction> trans( |
415 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 417 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
416 TestCompletionCallback callback; | 418 TestCompletionCallback callback; |
417 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 419 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
418 EXPECT_EQ(ERR_IO_PENDING, rv); | 420 EXPECT_EQ(ERR_IO_PENDING, rv); |
419 EXPECT_EQ(ERR_SOCKET_NOT_CONNECTED, callback.WaitForResult()); | 421 EXPECT_EQ(ERR_SOCKET_NOT_CONNECTED, callback.WaitForResult()); |
420 } | 422 } |
421 | 423 |
422 TEST_F(QuicNetworkTransactionTest, DoNotForceQuicForHttps) { | 424 TEST_F(QuicNetworkTransactionTest, DoNotForceQuicForHttps) { |
423 // Attempt to "force" quic on 443, which will not be honored. | 425 // Attempt to "force" quic on 443, which will not be honored. |
424 params_.origin_port_to_force_quic_on = 443; | 426 params_.origin_to_force_quic_on = |
| 427 HostPortPair::FromString("www.google.com:443"); |
425 | 428 |
426 MockRead http_reads[] = { | 429 MockRead http_reads[] = { |
427 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 430 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
428 MockRead("hello world"), | 431 MockRead("hello world"), |
429 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 432 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
430 MockRead(ASYNC, OK) | 433 MockRead(ASYNC, OK) |
431 }; | 434 }; |
432 | 435 |
433 StaticSocketDataProvider data(http_reads, arraysize(http_reads), NULL, 0); | 436 StaticSocketDataProvider data(http_reads, arraysize(http_reads), NULL, 0); |
434 socket_factory_.AddSocketDataProvider(&data); | 437 socket_factory_.AddSocketDataProvider(&data); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 613 |
611 CreateSession(); | 614 CreateSession(); |
612 | 615 |
613 AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START); | 616 AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START); |
614 SendRequestAndExpectHttpResponse("hello from http"); | 617 SendRequestAndExpectHttpResponse("hello from http"); |
615 ExpectBrokenAlternateProtocolMapping(); | 618 ExpectBrokenAlternateProtocolMapping(); |
616 } | 619 } |
617 | 620 |
618 } // namespace test | 621 } // namespace test |
619 } // namespace net | 622 } // namespace net |
OLD | NEW |