| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/base/mock_host_resolver.h" | 5 #include "net/base/mock_host_resolver.h" |
| 6 #include "net/base/net_log.h" | 6 #include "net/base/net_log.h" |
| 7 #include "net/base/ssl_config_service_defaults.h" | 7 #include "net/base/ssl_config_service_defaults.h" |
| 8 #include "net/http/http_network_layer.h" | 8 #include "net/http/http_network_layer.h" |
| 9 #include "net/http/http_transaction_unittest.h" | 9 #include "net/http/http_transaction_unittest.h" |
| 10 #include "net/proxy/proxy_service.h" | 10 #include "net/proxy/proxy_service.h" |
| 11 #include "net/socket/socket_test_util.h" | 11 #include "net/socket/socket_test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class HttpNetworkLayerTest : public PlatformTest { | 19 class HttpNetworkLayerTest : public PlatformTest { |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { | 22 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { |
| 23 MockHostResolver host_resolver; | 23 MockHostResolver host_resolver; |
| 24 net::HttpNetworkLayer factory( | 24 net::HttpNetworkLayer factory( |
| 25 NULL, | 25 NULL, |
| 26 &host_resolver, | 26 &host_resolver, |
| 27 NULL /* dnsrr_resolver */, | 27 NULL /* dnsrr_resolver */, |
| 28 NULL /* ssl_host_info_factory */, |
| 28 net::ProxyService::CreateDirect(), | 29 net::ProxyService::CreateDirect(), |
| 29 new net::SSLConfigServiceDefaults, | 30 new net::SSLConfigServiceDefaults, |
| 30 NULL, | 31 NULL, |
| 31 NULL, | 32 NULL, |
| 32 NULL); | 33 NULL); |
| 33 | 34 |
| 34 scoped_ptr<net::HttpTransaction> trans; | 35 scoped_ptr<net::HttpTransaction> trans; |
| 35 int rv = factory.CreateTransaction(&trans); | 36 int rv = factory.CreateTransaction(&trans); |
| 36 EXPECT_EQ(net::OK, rv); | 37 EXPECT_EQ(net::OK, rv); |
| 37 EXPECT_TRUE(trans.get() != NULL); | 38 EXPECT_TRUE(trans.get() != NULL); |
| 38 } | 39 } |
| 39 | 40 |
| 40 TEST_F(HttpNetworkLayerTest, Suspend) { | 41 TEST_F(HttpNetworkLayerTest, Suspend) { |
| 41 MockHostResolver host_resolver; | 42 MockHostResolver host_resolver; |
| 42 net::HttpNetworkLayer factory( | 43 net::HttpNetworkLayer factory( |
| 43 NULL, | 44 NULL, |
| 44 &host_resolver, | 45 &host_resolver, |
| 45 NULL /* dnsrr_resolver */, | 46 NULL /* dnsrr_resolver */, |
| 47 NULL /* ssl_host_info_factory */, |
| 46 net::ProxyService::CreateDirect(), | 48 net::ProxyService::CreateDirect(), |
| 47 new net::SSLConfigServiceDefaults, | 49 new net::SSLConfigServiceDefaults, |
| 48 NULL, | 50 NULL, |
| 49 NULL, | 51 NULL, |
| 50 NULL); | 52 NULL); |
| 51 | 53 |
| 52 scoped_ptr<net::HttpTransaction> trans; | 54 scoped_ptr<net::HttpTransaction> trans; |
| 53 int rv = factory.CreateTransaction(&trans); | 55 int rv = factory.CreateTransaction(&trans); |
| 54 EXPECT_EQ(net::OK, rv); | 56 EXPECT_EQ(net::OK, rv); |
| 55 | 57 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 83 }; | 85 }; |
| 84 net::StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 86 net::StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 85 data_writes, arraysize(data_reads)); | 87 data_writes, arraysize(data_reads)); |
| 86 mock_socket_factory.AddSocketDataProvider(&data); | 88 mock_socket_factory.AddSocketDataProvider(&data); |
| 87 | 89 |
| 88 MockHostResolver host_resolver; | 90 MockHostResolver host_resolver; |
| 89 net::HttpNetworkLayer factory( | 91 net::HttpNetworkLayer factory( |
| 90 &mock_socket_factory, | 92 &mock_socket_factory, |
| 91 &host_resolver, | 93 &host_resolver, |
| 92 NULL /* dnsrr_resolver */, | 94 NULL /* dnsrr_resolver */, |
| 95 NULL /* ssl_host_info_factory */, |
| 93 net::ProxyService::CreateDirect(), | 96 net::ProxyService::CreateDirect(), |
| 94 new net::SSLConfigServiceDefaults, | 97 new net::SSLConfigServiceDefaults, |
| 95 NULL, | 98 NULL, |
| 96 NULL, | 99 NULL, |
| 97 NULL); | 100 NULL); |
| 98 | 101 |
| 99 TestCompletionCallback callback; | 102 TestCompletionCallback callback; |
| 100 | 103 |
| 101 scoped_ptr<net::HttpTransaction> trans; | 104 scoped_ptr<net::HttpTransaction> trans; |
| 102 int rv = factory.CreateTransaction(&trans); | 105 int rv = factory.CreateTransaction(&trans); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 | 119 |
| 117 std::string contents; | 120 std::string contents; |
| 118 rv = ReadTransaction(trans.get(), &contents); | 121 rv = ReadTransaction(trans.get(), &contents); |
| 119 EXPECT_EQ(net::OK, rv); | 122 EXPECT_EQ(net::OK, rv); |
| 120 EXPECT_EQ("hello world", contents); | 123 EXPECT_EQ("hello world", contents); |
| 121 } | 124 } |
| 122 | 125 |
| 123 } // namespace | 126 } // namespace |
| 124 | 127 |
| 125 } // namespace net | 128 } // namespace net |
| OLD | NEW |