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

Side by Side Diff: chrome/test/unit/chrome_test_suite.h

Issue 302010: Add a mechanism to disable IPv6.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address darin's comments Created 11 years, 2 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) 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 #ifndef CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 5 #ifndef CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
6 #define CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 6 #define CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 18 matching lines...) Expand all
29 #include "net/base/mock_host_resolver.h" 29 #include "net/base/mock_host_resolver.h"
30 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
31 31
32 // In many cases it may be not obvious that a test makes a real DNS lookup. 32 // In many cases it may be not obvious that a test makes a real DNS lookup.
33 // We generally don't want to rely on external DNS servers for our tests, 33 // We generally don't want to rely on external DNS servers for our tests,
34 // so this host resolver procedure catches external queries. 34 // so this host resolver procedure catches external queries.
35 class WarningHostResolverProc : public net::HostResolverProc { 35 class WarningHostResolverProc : public net::HostResolverProc {
36 public: 36 public:
37 WarningHostResolverProc() : HostResolverProc(NULL) {} 37 WarningHostResolverProc() : HostResolverProc(NULL) {}
38 38
39 virtual int Resolve(const std::string& host, net::AddressList* addrlist) { 39 virtual int Resolve(const std::string& host,
40 net::AddressFamily address_family,
41 net::AddressList* addrlist) {
40 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"}; 42 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"};
41 bool local = false; 43 bool local = false;
42 44
43 if (host == net::GetHostName()) { 45 if (host == net::GetHostName()) {
44 local = true; 46 local = true;
45 } else { 47 } else {
46 for (size_t i = 0; i < arraysize(kLocalHostNames); i++) 48 for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
47 if (host == kLocalHostNames[i]) { 49 if (host == kLocalHostNames[i]) {
48 local = true; 50 local = true;
49 break; 51 break;
50 } 52 }
51 } 53 }
52 54
53 // Make the test fail so it's harder to ignore. 55 // Make the test fail so it's harder to ignore.
54 // If you really need to make real DNS query, use 56 // If you really need to make real DNS query, use
55 // net::RuleBasedHostResolverProc and its AllowDirectLookup method. 57 // net::RuleBasedHostResolverProc and its AllowDirectLookup method.
56 EXPECT_TRUE(local) << "Making external DNS lookup of " << host; 58 EXPECT_TRUE(local) << "Making external DNS lookup of " << host;
57 59
58 return ResolveUsingPrevious(host, addrlist); 60 return ResolveUsingPrevious(host, address_family, addrlist);
59 } 61 }
60 }; 62 };
61 63
62 class ChromeTestSuite : public TestSuite { 64 class ChromeTestSuite : public TestSuite {
63 public: 65 public:
64 ChromeTestSuite(int argc, char** argv) 66 ChromeTestSuite(int argc, char** argv)
65 : TestSuite(argc, argv), 67 : TestSuite(argc, argv),
66 stats_table_(NULL) { 68 stats_table_(NULL) {
67 } 69 }
68 70
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 TestSuite::Shutdown(); 142 TestSuite::Shutdown();
141 } 143 }
142 144
143 StatsTable* stats_table_; 145 StatsTable* stats_table_;
144 ScopedOleInitializer ole_initializer_; 146 ScopedOleInitializer ole_initializer_;
145 scoped_refptr<WarningHostResolverProc> host_resolver_proc_; 147 scoped_refptr<WarningHostResolverProc> host_resolver_proc_;
146 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; 148 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_;
147 }; 149 };
148 150
149 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 151 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698