OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 // In many cases it may be not obvious that a test makes a real DNS lookup. | 53 // In many cases it may be not obvious that a test makes a real DNS lookup. |
54 // We generally don't want to rely on external DNS servers for our tests, | 54 // We generally don't want to rely on external DNS servers for our tests, |
55 // so this host resolver procedure catches external queries. | 55 // so this host resolver procedure catches external queries. |
56 class WarningHostResolverProc : public net::HostResolverProc { | 56 class WarningHostResolverProc : public net::HostResolverProc { |
57 public: | 57 public: |
58 WarningHostResolverProc() : HostResolverProc(NULL) {} | 58 WarningHostResolverProc() : HostResolverProc(NULL) {} |
59 | 59 |
60 virtual int Resolve(const std::string& host, | 60 virtual int Resolve(const std::string& host, |
61 net::AddressFamily address_family, | 61 net::AddressFamily address_family, |
| 62 net::HostResolverFlags host_resolver_flags, |
62 net::AddressList* addrlist) { | 63 net::AddressList* addrlist) { |
63 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"}; | 64 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"}; |
64 bool local = false; | 65 bool local = false; |
65 | 66 |
66 if (host == net::GetHostName()) { | 67 if (host == net::GetHostName()) { |
67 local = true; | 68 local = true; |
68 } else { | 69 } else { |
69 for (size_t i = 0; i < arraysize(kLocalHostNames); i++) | 70 for (size_t i = 0; i < arraysize(kLocalHostNames); i++) |
70 if (host == kLocalHostNames[i]) { | 71 if (host == kLocalHostNames[i]) { |
71 local = true; | 72 local = true; |
72 break; | 73 break; |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 // Make the test fail so it's harder to ignore. | 77 // Make the test fail so it's harder to ignore. |
77 // If you really need to make real DNS query, use | 78 // If you really need to make real DNS query, use |
78 // net::RuleBasedHostResolverProc and its AllowDirectLookup method. | 79 // net::RuleBasedHostResolverProc and its AllowDirectLookup method. |
79 EXPECT_TRUE(local) << "Making external DNS lookup of " << host; | 80 EXPECT_TRUE(local) << "Making external DNS lookup of " << host; |
80 | 81 |
81 return ResolveUsingPrevious(host, address_family, addrlist); | 82 return ResolveUsingPrevious(host, address_family, host_resolver_flags, |
| 83 addrlist); |
82 } | 84 } |
83 }; | 85 }; |
84 | 86 |
85 class ChromeTestSuite : public TestSuite { | 87 class ChromeTestSuite : public TestSuite { |
86 public: | 88 public: |
87 ChromeTestSuite(int argc, char** argv) | 89 ChromeTestSuite(int argc, char** argv) |
88 : TestSuite(argc, argv), | 90 : TestSuite(argc, argv), |
89 stats_table_(NULL) { | 91 stats_table_(NULL) { |
90 } | 92 } |
91 | 93 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 184 |
183 // Alternative path to browser binaries. | 185 // Alternative path to browser binaries. |
184 FilePath browser_dir_; | 186 FilePath browser_dir_; |
185 | 187 |
186 ScopedOleInitializer ole_initializer_; | 188 ScopedOleInitializer ole_initializer_; |
187 scoped_refptr<WarningHostResolverProc> host_resolver_proc_; | 189 scoped_refptr<WarningHostResolverProc> host_resolver_proc_; |
188 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; | 190 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; |
189 }; | 191 }; |
190 | 192 |
191 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ | 193 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ |
OLD | NEW |