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

Side by Side Diff: net/dns/dns_config_service_unittest.cc

Issue 10377092: [net/dns] Isolate DnsConfigWatcher from DnsConfigService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Braces. Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/dns/dns_config_service.h" 5 #include "net/dns/dns_config_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/cancelable_callback.h" 9 #include "base/cancelable_callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 11 matching lines...) Expand all
22 EXPECT_FALSE(config.Equals(last_config_)) << 22 EXPECT_FALSE(config.Equals(last_config_)) <<
23 "Config must be different from last call."; 23 "Config must be different from last call.";
24 last_config_ = config; 24 last_config_ = config;
25 if (quit_on_config_) 25 if (quit_on_config_)
26 MessageLoop::current()->Quit(); 26 MessageLoop::current()->Quit();
27 } 27 }
28 28
29 protected: 29 protected:
30 class TestDnsConfigService : public DnsConfigService { 30 class TestDnsConfigService : public DnsConfigService {
31 public: 31 public:
32 virtual void Watch(const CallbackType& callback) OVERRIDE { 32 virtual void OnDNSChanged(unsigned detail) OVERRIDE {}
33 set_callback(callback);
34 }
35 33
36 // Expose the protected methods to this test suite. 34 // Expose the protected methods to this test suite.
37 void InvalidateConfig() { 35 void InvalidateConfig() {
38 DnsConfigService::InvalidateConfig(); 36 DnsConfigService::InvalidateConfig();
39 } 37 }
40 38
41 void InvalidateHosts() { 39 void InvalidateHosts() {
42 DnsConfigService::InvalidateHosts(); 40 DnsConfigService::InvalidateHosts();
43 } 41 }
44 42
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_TRUE(last_config_.Equals(config3)); 180 EXPECT_TRUE(last_config_.Equals(config3));
183 } 181 }
184 182
185 #if defined(OS_POSIX) || defined(OS_WIN) 183 #if defined(OS_POSIX) || defined(OS_WIN)
186 // TODO(szym): This is really an integration test and can time out if HOSTS is 184 // TODO(szym): This is really an integration test and can time out if HOSTS is
187 // huge. http://crbug.com/107810 185 // huge. http://crbug.com/107810
188 TEST_F(DnsConfigServiceTest, FLAKY_GetSystemConfig) { 186 TEST_F(DnsConfigServiceTest, FLAKY_GetSystemConfig) {
189 service_.reset(); 187 service_.reset();
190 scoped_ptr<DnsConfigService> service(DnsConfigService::CreateSystemService()); 188 scoped_ptr<DnsConfigService> service(DnsConfigService::CreateSystemService());
191 189
192 service->Watch(base::Bind(&DnsConfigServiceTest::OnConfigChanged, 190 service->Read(base::Bind(&DnsConfigServiceTest::OnConfigChanged,
193 base::Unretained(this))); 191 base::Unretained(this)));
194 base::TimeDelta kTimeout = TestTimeouts::action_max_timeout(); 192 base::TimeDelta kTimeout = TestTimeouts::action_max_timeout();
195 WaitForConfig(kTimeout); 193 WaitForConfig(kTimeout);
196 ASSERT_TRUE(last_config_.IsValid()) << "Did not receive DnsConfig in " << 194 ASSERT_TRUE(last_config_.IsValid()) << "Did not receive DnsConfig in " <<
197 kTimeout.InSecondsF() << "s"; 195 kTimeout.InSecondsF() << "s";
198
199 // Restart watch to confirm it's allowed.
200 service->Watch(base::Bind(&DnsConfigServiceTest::OnConfigChanged,
201 base::Unretained(this)));
202 } 196 }
203 #endif // OS_POSIX || OS_WIN 197 #endif // OS_POSIX || OS_WIN
204 198
205 } // namespace net 199 } // namespace net
206 200
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698