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

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

Issue 63019: Adjustments in chrome_test_suite external dns lookups detection code: (Closed)
Patch Set: Created 11 years, 8 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
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 "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include "base/stats_table.h" 10 #include "base/stats_table.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #if defined(OS_MACOSX) 12 #if defined(OS_MACOSX)
13 #include "base/mac_util.h" 13 #include "base/mac_util.h"
14 #endif 14 #endif
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/scoped_nsautorelease_pool.h" 17 #include "base/scoped_nsautorelease_pool.h"
18 #include "base/test_suite.h" 18 #include "base/test_suite.h"
19 #include "chrome/app/scoped_ole_initializer.h" 19 #include "chrome/app/scoped_ole_initializer.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/resource_bundle.h" 23 #include "chrome/common/resource_bundle.h"
24 #include "chrome/test/testing_browser_process.h" 24 #include "chrome/test/testing_browser_process.h"
25 #include "net/base/host_resolver_unittest.h" 25 #include "net/base/host_resolver_unittest.h"
26 #include "net/base/net_util.h"
26 27
27 // In many cases it may be not obvious that a test makes a real DNS lookup. 28 // In many cases it may be not obvious that a test makes a real DNS lookup.
28 // We generally don't want to rely on external DNS servers for our tests, 29 // We generally don't want to rely on external DNS servers for our tests,
29 // so this mapper catches external queries. 30 // so this mapper catches external queries.
30 class WarningHostMapper : public net::HostMapper { 31 class WarningHostMapper : public net::HostMapper {
31 public: 32 public:
32 virtual std::string Map(const std::string& host) { 33 virtual std::string Map(const std::string& host) {
33 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"}; 34 const char* kLocalHostNames[] = {"localhost", "127.0.0.1"};
34 bool local = false; 35 bool local = false;
35 for (size_t i = 0; i < arraysize(kLocalHostNames); i++) 36 for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
36 if (host == kLocalHostNames[i]) { 37 if (host == kLocalHostNames[i]) {
37 local = true; 38 local = true;
38 break; 39 break;
39 } 40 }
40 41
42 if (host == net::GetHostName())
43 local = true;
Finnur 2009/04/06 19:32:42 nit: This you can do before the for loop and put t
44
41 // Make the test fail so it's harder to ignore. 45 // Make the test fail so it's harder to ignore.
42 // If you really need to make real DNS query, use net::RuleBasedHostMapper 46 // If you really need to make real DNS query, use net::RuleBasedHostMapper
43 // and its AllowDirectLookup method. 47 // and its AllowDirectLookup method.
44 EXPECT_TRUE(local) << "Making external DNS lookup of " << host; 48 EXPECT_TRUE(local) << "Making external DNS lookup of " << host;
45 49
46 return MapUsingPrevious(host); 50 return MapUsingPrevious(host);
47 } 51 }
48 }; 52 };
49 53
50 class ChromeTestSuite : public TestSuite { 54 class ChromeTestSuite : public TestSuite {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 TestSuite::Shutdown(); 120 TestSuite::Shutdown();
117 } 121 }
118 122
119 StatsTable* stats_table_; 123 StatsTable* stats_table_;
120 ScopedOleInitializer ole_initializer_; 124 ScopedOleInitializer ole_initializer_;
121 scoped_refptr<WarningHostMapper> host_mapper_; 125 scoped_refptr<WarningHostMapper> host_mapper_;
122 net::ScopedHostMapper scoped_host_mapper_; 126 net::ScopedHostMapper scoped_host_mapper_;
123 }; 127 };
124 128
125 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 129 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
OLDNEW
« chrome/test/in_process_browser_test.cc ('K') | « chrome/test/in_process_browser_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698