| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/scoped_host_mapper.h" | 5 #include "base/ref_counted.h" |
| 6 #include "net/base/host_resolver_unittest.h" |
| 6 #include "net/http/http_network_layer.h" | 7 #include "net/http/http_network_layer.h" |
| 7 #include "net/http/http_transaction_unittest.h" | 8 #include "net/http/http_transaction_unittest.h" |
| 8 #include "net/proxy/proxy_service.h" | 9 #include "net/proxy/proxy_service.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 11 | 12 |
| 12 class HttpNetworkLayerTest : public PlatformTest { | 13 class HttpNetworkLayerTest : public PlatformTest { |
| 13 public: | 14 public: |
| 14 HttpNetworkLayerTest() { | 15 HttpNetworkLayerTest() |
| 16 : host_mapper_(new net::RuleBasedHostMapper()), |
| 17 scoped_host_mapper_(host_mapper_.get()) { |
| 15 // TODO(darin): kill this exception once we have a way to test out the | 18 // TODO(darin): kill this exception once we have a way to test out the |
| 16 // HttpNetworkLayer class using loopback connections. | 19 // HttpNetworkLayer class using loopback connections. |
| 17 host_mapper_.AddRule("www.google.com", "www.google.com"); | 20 host_mapper_->AddRule("www.google.com", "www.google.com"); |
| 18 } | 21 } |
| 22 |
| 19 private: | 23 private: |
| 20 net::ScopedHostMapper host_mapper_; | 24 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; |
| 25 net::ScopedHostMapper scoped_host_mapper_; |
| 21 }; | 26 }; |
| 22 | 27 |
| 23 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { | 28 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { |
| 24 scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull()); | 29 scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull()); |
| 25 net::HttpNetworkLayer factory(proxy_service.get()); | 30 net::HttpNetworkLayer factory(proxy_service.get()); |
| 26 | 31 |
| 27 scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); | 32 scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); |
| 28 } | 33 } |
| 29 | 34 |
| 30 TEST_F(HttpNetworkLayerTest, Suspend) { | 35 TEST_F(HttpNetworkLayerTest, Suspend) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 61 int rv = trans->Start(&request_info, &callback); | 66 int rv = trans->Start(&request_info, &callback); |
| 62 if (rv == net::ERR_IO_PENDING) | 67 if (rv == net::ERR_IO_PENDING) |
| 63 rv = callback.WaitForResult(); | 68 rv = callback.WaitForResult(); |
| 64 EXPECT_EQ(net::OK, rv); | 69 EXPECT_EQ(net::OK, rv); |
| 65 | 70 |
| 66 std::string contents; | 71 std::string contents; |
| 67 rv = ReadTransaction(trans.get(), &contents); | 72 rv = ReadTransaction(trans.get(), &contents); |
| 68 EXPECT_EQ(net::OK, rv); | 73 EXPECT_EQ(net::OK, rv); |
| 69 } | 74 } |
| 70 | 75 |
| OLD | NEW |