Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proxy/proxy_service_mojo.h" | 5 #include "net/proxy/proxy_service_mojo.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 TestClosure on_delete_closure_; | 151 TestClosure on_delete_closure_; |
| 152 scoped_ptr<ProxyService> proxy_service_; | 152 scoped_ptr<ProxyService> proxy_service_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 TEST_F(ProxyServiceMojoTest, Basic) { | 155 TEST_F(ProxyServiceMojoTest, Basic) { |
| 156 ProxyInfo info; | 156 ProxyInfo info; |
| 157 TestCompletionCallback callback; | 157 TestCompletionCallback callback; |
| 158 EXPECT_EQ(ERR_IO_PENDING, | 158 EXPECT_EQ(ERR_IO_PENDING, |
| 159 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, | 159 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, |
| 160 callback.callback(), nullptr, nullptr, | 160 callback.callback(), nullptr, nullptr, |
| 161 BoundNetLog())); | 161 "", BoundNetLog())); |
|
bengr
2016/02/16 20:00:14
std::string(). Ditto for line 183, 214, and 243.
| |
| 162 | 162 |
| 163 // Proxy script fetcher should have a fetch triggered by the first | 163 // Proxy script fetcher should have a fetch triggered by the first |
| 164 // |ResolveProxy()| request. | 164 // |ResolveProxy()| request. |
| 165 EXPECT_TRUE(fetcher_->has_pending_request()); | 165 EXPECT_TRUE(fetcher_->has_pending_request()); |
| 166 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); | 166 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); |
| 167 fetcher_->NotifyFetchCompletion(OK, kSimplePacScript); | 167 fetcher_->NotifyFetchCompletion(OK, kSimplePacScript); |
| 168 | 168 |
| 169 EXPECT_EQ(OK, callback.WaitForResult()); | 169 EXPECT_EQ(OK, callback.WaitForResult()); |
| 170 EXPECT_EQ("PROXY foo:1234", info.ToPacString()); | 170 EXPECT_EQ("PROXY foo:1234", info.ToPacString()); |
| 171 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); | 171 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); |
| 172 proxy_service_.reset(); | 172 proxy_service_.reset(); |
| 173 on_delete_closure_.WaitForResult(); | 173 on_delete_closure_.WaitForResult(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(ProxyServiceMojoTest, DnsResolution) { | 176 TEST_F(ProxyServiceMojoTest, DnsResolution) { |
| 177 ProxyInfo info; | 177 ProxyInfo info; |
| 178 TestCompletionCallback callback; | 178 TestCompletionCallback callback; |
| 179 BoundTestNetLog bound_net_log; | 179 BoundTestNetLog bound_net_log; |
| 180 EXPECT_EQ(ERR_IO_PENDING, | 180 EXPECT_EQ(ERR_IO_PENDING, |
| 181 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, | 181 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, |
| 182 callback.callback(), nullptr, nullptr, | 182 callback.callback(), nullptr, nullptr, |
| 183 bound_net_log.bound())); | 183 "", bound_net_log.bound())); |
| 184 | 184 |
| 185 // Proxy script fetcher should have a fetch triggered by the first | 185 // Proxy script fetcher should have a fetch triggered by the first |
| 186 // |ResolveProxy()| request. | 186 // |ResolveProxy()| request. |
| 187 EXPECT_TRUE(fetcher_->has_pending_request()); | 187 EXPECT_TRUE(fetcher_->has_pending_request()); |
| 188 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); | 188 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); |
| 189 fetcher_->NotifyFetchCompletion(OK, kDnsResolvePacScript); | 189 fetcher_->NotifyFetchCompletion(OK, kDnsResolvePacScript); |
| 190 | 190 |
| 191 EXPECT_EQ(OK, callback.WaitForResult()); | 191 EXPECT_EQ(OK, callback.WaitForResult()); |
| 192 EXPECT_EQ("QUIC bar:4321", info.ToPacString()); | 192 EXPECT_EQ("QUIC bar:4321", info.ToPacString()); |
| 193 EXPECT_EQ(1u, mock_host_resolver_.num_resolve()); | 193 EXPECT_EQ(1u, mock_host_resolver_.num_resolve()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 204 })); | 204 })); |
| 205 } | 205 } |
| 206 | 206 |
| 207 TEST_F(ProxyServiceMojoTest, Error) { | 207 TEST_F(ProxyServiceMojoTest, Error) { |
| 208 ProxyInfo info; | 208 ProxyInfo info; |
| 209 TestCompletionCallback callback; | 209 TestCompletionCallback callback; |
| 210 BoundTestNetLog bound_net_log; | 210 BoundTestNetLog bound_net_log; |
| 211 EXPECT_EQ(ERR_IO_PENDING, | 211 EXPECT_EQ(ERR_IO_PENDING, |
| 212 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, | 212 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, |
| 213 callback.callback(), nullptr, nullptr, | 213 callback.callback(), nullptr, nullptr, |
| 214 bound_net_log.bound())); | 214 "", bound_net_log.bound())); |
| 215 | 215 |
| 216 // Proxy script fetcher should have a fetch triggered by the first | 216 // Proxy script fetcher should have a fetch triggered by the first |
| 217 // |ResolveProxy()| request. | 217 // |ResolveProxy()| request. |
| 218 EXPECT_TRUE(fetcher_->has_pending_request()); | 218 EXPECT_TRUE(fetcher_->has_pending_request()); |
| 219 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); | 219 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); |
| 220 fetcher_->NotifyFetchCompletion(OK, kThrowingPacScript); | 220 fetcher_->NotifyFetchCompletion(OK, kThrowingPacScript); |
| 221 | 221 |
| 222 network_delegate_.event_waiter().WaitForEvent( | 222 network_delegate_.event_waiter().WaitForEvent( |
| 223 TestNetworkDelegate::PAC_SCRIPT_ERROR); | 223 TestNetworkDelegate::PAC_SCRIPT_ERROR); |
| 224 | 224 |
| 225 EXPECT_EQ(OK, callback.WaitForResult()); | 225 EXPECT_EQ(OK, callback.WaitForResult()); |
| 226 EXPECT_EQ("DIRECT", info.ToPacString()); | 226 EXPECT_EQ("DIRECT", info.ToPacString()); |
| 227 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); | 227 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); |
| 228 | 228 |
| 229 TestNetLogEntry::List entries; | 229 TestNetLogEntry::List entries; |
| 230 bound_net_log.GetEntries(&entries); | 230 bound_net_log.GetEntries(&entries); |
| 231 CheckCapturedNetLogEntries(entries); | 231 CheckCapturedNetLogEntries(entries); |
| 232 entries.clear(); | 232 entries.clear(); |
| 233 net_log_.GetEntries(&entries); | 233 net_log_.GetEntries(&entries); |
| 234 CheckCapturedNetLogEntries(entries); | 234 CheckCapturedNetLogEntries(entries); |
| 235 } | 235 } |
| 236 | 236 |
| 237 TEST_F(ProxyServiceMojoTest, ErrorOnInitialization) { | 237 TEST_F(ProxyServiceMojoTest, ErrorOnInitialization) { |
| 238 ProxyInfo info; | 238 ProxyInfo info; |
| 239 TestCompletionCallback callback; | 239 TestCompletionCallback callback; |
| 240 EXPECT_EQ(ERR_IO_PENDING, | 240 EXPECT_EQ(ERR_IO_PENDING, |
| 241 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, | 241 proxy_service_->ResolveProxy(GURL("http://foo"), LOAD_NORMAL, &info, |
| 242 callback.callback(), nullptr, nullptr, | 242 callback.callback(), nullptr, nullptr, |
| 243 BoundNetLog())); | 243 "", BoundNetLog())); |
| 244 | 244 |
| 245 // Proxy script fetcher should have a fetch triggered by the first | 245 // Proxy script fetcher should have a fetch triggered by the first |
| 246 // |ResolveProxy()| request. | 246 // |ResolveProxy()| request. |
| 247 EXPECT_TRUE(fetcher_->has_pending_request()); | 247 EXPECT_TRUE(fetcher_->has_pending_request()); |
| 248 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); | 248 EXPECT_EQ(GURL(kPacUrl), fetcher_->pending_request_url()); |
| 249 fetcher_->NotifyFetchCompletion(OK, kThrowingOnLoadPacScript); | 249 fetcher_->NotifyFetchCompletion(OK, kThrowingOnLoadPacScript); |
| 250 | 250 |
| 251 network_delegate_.event_waiter().WaitForEvent( | 251 network_delegate_.event_waiter().WaitForEvent( |
| 252 TestNetworkDelegate::PAC_SCRIPT_ERROR); | 252 TestNetworkDelegate::PAC_SCRIPT_ERROR); |
| 253 | 253 |
| 254 EXPECT_EQ(OK, callback.WaitForResult()); | 254 EXPECT_EQ(OK, callback.WaitForResult()); |
| 255 EXPECT_EQ("DIRECT", info.ToPacString()); | 255 EXPECT_EQ("DIRECT", info.ToPacString()); |
| 256 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); | 256 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); |
| 257 | 257 |
| 258 TestNetLogEntry::List entries; | 258 TestNetLogEntry::List entries; |
| 259 net_log_.GetEntries(&entries); | 259 net_log_.GetEntries(&entries); |
| 260 CheckCapturedNetLogEntries(entries); | 260 CheckCapturedNetLogEntries(entries); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace net | 263 } // namespace net |
| OLD | NEW |