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

Side by Side Diff: components/cronet/stale_host_resolver_unittest.cc

Issue 2963643002: Fix Cronet tests. (Closed)
Patch Set: Oops Created 3 years, 5 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
« no previous file with comments | « no previous file | components/cronet/url_request_context_config_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/cronet/stale_host_resolver.h" 5 #include "components/cronet/stale_host_resolver.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/scoped_task_environment.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "components/cronet/url_request_context_config.h" 16 #include "components/cronet/url_request_context_config.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/network_change_notifier.h" 18 #include "net/base/network_change_notifier.h"
19 #include "net/cert/cert_verifier.h" 19 #include "net/cert/cert_verifier.h"
20 #include "net/dns/host_resolver_proc.h" 20 #include "net/dns/host_resolver_proc.h"
21 #include "net/http/http_network_session.h" 21 #include "net/http/http_network_session.h"
22 #include "net/log/net_log.h" 22 #include "net/log/net_log.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return net::OK; 75 return net::OK;
76 } 76 }
77 77
78 protected: 78 protected:
79 ~MockHostResolverProc() override {} 79 ~MockHostResolverProc() override {}
80 }; 80 };
81 81
82 class StaleHostResolverTest : public testing::Test { 82 class StaleHostResolverTest : public testing::Test {
83 protected: 83 protected:
84 StaleHostResolverTest() 84 StaleHostResolverTest()
85 : mock_proc_(new MockHostResolverProc()), 85 : scoped_task_environment_(
86 resolver_(nullptr), 86 base::test::ScopedTaskEnvironment::MainThreadType::IO),
87 resolve_pending_(false), 87 mock_proc_(new MockHostResolverProc()), resolver_(nullptr),
pauljensen 2017/06/27 22:50:11 This indentation is wacky...I guess the formater h
mmenke 2017/06/28 12:36:39 Done. Also merged and re-enabled tests.
88 resolve_complete_(false) {} 88 resolve_pending_(false), resolve_complete_(false) {}
89 89
90 ~StaleHostResolverTest() override {} 90 ~StaleHostResolverTest() override {}
91 91
92 void SetStaleDelay(int stale_delay_sec) { 92 void SetStaleDelay(int stale_delay_sec) {
93 DCHECK(!resolver_); 93 DCHECK(!resolver_);
94 94
95 options_.delay = base::TimeDelta::FromSeconds(stale_delay_sec); 95 options_.delay = base::TimeDelta::FromSeconds(stale_delay_sec);
96 } 96 }
97 97
98 void SetStaleUsability(int max_expired_time_sec, 98 void SetStaleUsability(int max_expired_time_sec,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 250 }
251 251
252 bool resolve_complete() const { return resolve_complete_; } 252 bool resolve_complete() const { return resolve_complete_; }
253 int resolve_error() const { return resolve_error_; } 253 int resolve_error() const { return resolve_error_; }
254 const net::AddressList& resolve_addresses() const { 254 const net::AddressList& resolve_addresses() const {
255 return resolve_addresses_; 255 return resolve_addresses_;
256 } 256 }
257 257
258 private: 258 private:
259 // Needed for HostResolver to run HostResolverProc callbacks. 259 // Needed for HostResolver to run HostResolverProc callbacks.
260 base::MessageLoopForIO message_loop_for_io_; 260 base::test::ScopedTaskEnvironment scoped_task_environment_;
261
261 scoped_refptr<MockHostResolverProc> mock_proc_; 262 scoped_refptr<MockHostResolverProc> mock_proc_;
262 263
263 net::HostResolver* resolver_; 264 net::HostResolver* resolver_;
264 StaleHostResolver::StaleOptions options_; 265 StaleHostResolver::StaleOptions options_;
265 std::unique_ptr<StaleHostResolver> stale_resolver_; 266 std::unique_ptr<StaleHostResolver> stale_resolver_;
266 267
267 base::TimeTicks now_; 268 base::TimeTicks now_;
268 std::unique_ptr<net::HostResolver::Request> request_; 269 std::unique_ptr<net::HostResolver::Request> request_;
269 bool resolve_pending_; 270 bool resolve_pending_;
270 bool resolve_complete_; 271 bool resolve_complete_;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 500
500 EXPECT_TRUE(resolve_complete()); 501 EXPECT_TRUE(resolve_complete());
501 EXPECT_EQ(net::OK, resolve_error()); 502 EXPECT_EQ(net::OK, resolve_error());
502 EXPECT_EQ(1u, resolve_addresses().size()); 503 EXPECT_EQ(1u, resolve_addresses().size());
503 EXPECT_EQ(kCacheAddress, resolve_addresses()[0].ToStringWithoutPort()); 504 EXPECT_EQ(kCacheAddress, resolve_addresses()[0].ToStringWithoutPort());
504 } 505 }
505 506
506 } // namespace 507 } // namespace
507 508
508 } // namespace cronet 509 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | components/cronet/url_request_context_config_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698