Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: chromeos/network/host_resolver_impl_chromeos_unittest.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http_stream_factory_impl_job_controller_unittest RequestHandle* to unique_ptr Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromeos/network/host_resolver_impl_chromeos.h" 5 #include "chromeos/network/host_resolver_impl_chromeos.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Run from IO message loop. 94 // Run from IO message loop.
95 void InitializeHostResolver() { 95 void InitializeHostResolver() {
96 net::HostResolver::Options options; 96 net::HostResolver::Options options;
97 host_resolver_ = 97 host_resolver_ =
98 chromeos::HostResolverImplChromeOS::CreateHostResolverForTest( 98 chromeos::HostResolverImplChromeOS::CreateHostResolverForTest(
99 base::ThreadTaskRunnerHandle::Get(), network_state_handler_.get()); 99 base::ThreadTaskRunnerHandle::Get(), network_state_handler_.get());
100 } 100 }
101 101
102 // Run from IO message loop. 102 // Run from IO message loop.
103 void Resolve(net::HostResolver::RequestInfo info) { 103 void Resolve(net::HostResolver::RequestInfo info) {
104 result_ = host_resolver_->Resolve( 104 result_ = host_resolver_->Resolve(info, net::DEFAULT_PRIORITY, &addresses_,
105 info, 105 base::Bind(&ResolveCompletionCallback),
106 net::DEFAULT_PRIORITY, 106 &request_, net_log_);
107 &addresses_,
108 base::Bind(&ResolveCompletionCallback),
109 NULL,
110 net_log_);
111 } 107 }
112 108
113 void SetDefaultIPConfigs(const std::string& default_device_path) { 109 void SetDefaultIPConfigs(const std::string& default_device_path) {
114 const std::string kTestIPv4ConfigPath("test_ip_v4_config_path"); 110 const std::string kTestIPv4ConfigPath("test_ip_v4_config_path");
115 const std::string kTestIPv6ConfigPath("test_ip_v6_config_path"); 111 const std::string kTestIPv6ConfigPath("test_ip_v6_config_path");
116 112
117 SetIPConfig(kTestIPv4ConfigPath, shill::kTypeIPv4, kTestIPv4Address); 113 SetIPConfig(kTestIPv4ConfigPath, shill::kTypeIPv4, kTestIPv4Address);
118 SetIPConfig(kTestIPv6ConfigPath, shill::kTypeIPv6, kTestIPv6Address); 114 SetIPConfig(kTestIPv6ConfigPath, shill::kTypeIPv6, kTestIPv6Address);
119 base::RunLoop().RunUntilIdle(); 115 base::RunLoop().RunUntilIdle();
120 116
(...skipping 22 matching lines...) Expand all
143 dbus::ObjectPath(path), 139 dbus::ObjectPath(path),
144 shill::kMethodProperty, 140 shill::kMethodProperty,
145 base::StringValue(method), 141 base::StringValue(method),
146 base::Bind(&DoNothingWithCallStatus)); 142 base::Bind(&DoNothingWithCallStatus));
147 } 143 }
148 144
149 std::unique_ptr<chromeos::NetworkStateHandler> network_state_handler_; 145 std::unique_ptr<chromeos::NetworkStateHandler> network_state_handler_;
150 std::unique_ptr<net::HostResolver> host_resolver_; 146 std::unique_ptr<net::HostResolver> host_resolver_;
151 base::MessageLoop io_message_loop_; 147 base::MessageLoop io_message_loop_;
152 net::BoundNetLog net_log_; 148 net::BoundNetLog net_log_;
149 std::unique_ptr<net::HostResolver::Request> request_;
153 150
154 DISALLOW_COPY_AND_ASSIGN(HostResolverImplChromeOSTest); 151 DISALLOW_COPY_AND_ASSIGN(HostResolverImplChromeOSTest);
155 }; 152 };
156 153
157 TEST_F(HostResolverImplChromeOSTest, Resolve) { 154 TEST_F(HostResolverImplChromeOSTest, Resolve) {
158 net::HostResolver::RequestInfo info( 155 net::HostResolver::RequestInfo info(
159 net::HostPortPair(net::GetHostName(), 80)); 156 net::HostPortPair(net::GetHostName(), 80));
160 info.set_address_family(net::ADDRESS_FAMILY_IPV4); 157 info.set_address_family(net::ADDRESS_FAMILY_IPV4);
161 info.set_is_my_ip_address(true); 158 info.set_is_my_ip_address(true);
162 EXPECT_EQ(net::OK, CallResolve(info)); 159 EXPECT_EQ(net::OK, CallResolve(info));
163 ASSERT_EQ(1u, addresses_.size()); 160 ASSERT_EQ(1u, addresses_.size());
164 std::string expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0); 161 std::string expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0);
165 EXPECT_EQ(expected, addresses_[0].ToString()); 162 EXPECT_EQ(expected, addresses_[0].ToString());
166 163
167 info.set_address_family(net::ADDRESS_FAMILY_IPV6); 164 info.set_address_family(net::ADDRESS_FAMILY_IPV6);
168 EXPECT_EQ(net::OK, CallResolve(info)); 165 EXPECT_EQ(net::OK, CallResolve(info));
169 ASSERT_EQ(2u, addresses_.size()); 166 ASSERT_EQ(2u, addresses_.size());
170 expected = base::StringPrintf("[%s]:%d", kTestIPv6Address, 0); 167 expected = base::StringPrintf("[%s]:%d", kTestIPv6Address, 0);
171 EXPECT_EQ(expected, addresses_[0].ToString()); 168 EXPECT_EQ(expected, addresses_[0].ToString());
172 expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0); 169 expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0);
173 EXPECT_EQ(expected, addresses_[1].ToString()); 170 EXPECT_EQ(expected, addresses_[1].ToString());
174 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698