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 net::ProxyService::CreateDirect(), | 28 net::ProxyService::CreateDirect(), |
28 new net::SSLConfigServiceDefaults, | 29 new net::SSLConfigServiceDefaults, |
29 NULL, | 30 NULL, |
30 NULL, | 31 NULL, |
31 NULL); | 32 NULL); |
32 | 33 |
33 scoped_ptr<net::HttpTransaction> trans; | 34 scoped_ptr<net::HttpTransaction> trans; |
34 int rv = factory.CreateTransaction(&trans); | 35 int rv = factory.CreateTransaction(&trans); |
35 EXPECT_EQ(net::OK, rv); | 36 EXPECT_EQ(net::OK, rv); |
36 EXPECT_TRUE(trans.get() != NULL); | 37 EXPECT_TRUE(trans.get() != NULL); |
37 } | 38 } |
38 | 39 |
39 TEST_F(HttpNetworkLayerTest, Suspend) { | 40 TEST_F(HttpNetworkLayerTest, Suspend) { |
40 MockHostResolver host_resolver; | 41 MockHostResolver host_resolver; |
41 net::HttpNetworkLayer factory( | 42 net::HttpNetworkLayer factory( |
42 NULL, | 43 NULL, |
43 &host_resolver, | 44 &host_resolver, |
| 45 NULL /* dnsrr_resolver */, |
44 net::ProxyService::CreateDirect(), | 46 net::ProxyService::CreateDirect(), |
45 new net::SSLConfigServiceDefaults, | 47 new net::SSLConfigServiceDefaults, |
46 NULL, | 48 NULL, |
47 NULL, | 49 NULL, |
48 NULL); | 50 NULL); |
49 | 51 |
50 scoped_ptr<net::HttpTransaction> trans; | 52 scoped_ptr<net::HttpTransaction> trans; |
51 int rv = factory.CreateTransaction(&trans); | 53 int rv = factory.CreateTransaction(&trans); |
52 EXPECT_EQ(net::OK, rv); | 54 EXPECT_EQ(net::OK, rv); |
53 | 55 |
(...skipping 26 matching lines...) Expand all Loading... |
80 "User-Agent: Foo/1.0\r\n\r\n"), | 82 "User-Agent: Foo/1.0\r\n\r\n"), |
81 }; | 83 }; |
82 net::StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 84 net::StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
83 data_writes, arraysize(data_reads)); | 85 data_writes, arraysize(data_reads)); |
84 mock_socket_factory.AddSocketDataProvider(&data); | 86 mock_socket_factory.AddSocketDataProvider(&data); |
85 | 87 |
86 MockHostResolver host_resolver; | 88 MockHostResolver host_resolver; |
87 net::HttpNetworkLayer factory( | 89 net::HttpNetworkLayer factory( |
88 &mock_socket_factory, | 90 &mock_socket_factory, |
89 &host_resolver, | 91 &host_resolver, |
| 92 NULL /* dnsrr_resolver */, |
90 net::ProxyService::CreateDirect(), | 93 net::ProxyService::CreateDirect(), |
91 new net::SSLConfigServiceDefaults, | 94 new net::SSLConfigServiceDefaults, |
92 NULL, | 95 NULL, |
93 NULL, | 96 NULL, |
94 NULL); | 97 NULL); |
95 | 98 |
96 TestCompletionCallback callback; | 99 TestCompletionCallback callback; |
97 | 100 |
98 scoped_ptr<net::HttpTransaction> trans; | 101 scoped_ptr<net::HttpTransaction> trans; |
99 int rv = factory.CreateTransaction(&trans); | 102 int rv = factory.CreateTransaction(&trans); |
(...skipping 13 matching lines...) Expand all Loading... |
113 | 116 |
114 std::string contents; | 117 std::string contents; |
115 rv = ReadTransaction(trans.get(), &contents); | 118 rv = ReadTransaction(trans.get(), &contents); |
116 EXPECT_EQ(net::OK, rv); | 119 EXPECT_EQ(net::OK, rv); |
117 EXPECT_EQ("hello world", contents); | 120 EXPECT_EQ("hello world", contents); |
118 } | 121 } |
119 | 122 |
120 } // namespace | 123 } // namespace |
121 | 124 |
122 } // namespace net | 125 } // namespace net |
OLD | NEW |