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

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

Issue 3035062: Revert 55400 - Cleanup in base. This moves the implementation (and a bunch of... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/test/test_launcher/test_runner.cc ('k') | chrome_frame/chrome_frame.gyp » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #include "app/app_paths.h" 13 #include "app/app_paths.h"
14 #include "app/resource_bundle.h" 14 #include "app/resource_bundle.h"
15 #include "base/command_line.h"
16 #include "base/stats_table.h" 15 #include "base/stats_table.h"
17 #include "base/file_util.h" 16 #include "base/file_util.h"
18 #include "base/path_service.h" 17 #include "base/path_service.h"
19 #include "base/process_util.h"
20 #include "base/ref_counted.h" 18 #include "base/ref_counted.h"
21 #include "base/scoped_nsautorelease_pool.h" 19 #include "base/scoped_nsautorelease_pool.h"
22 #include "base/test/test_suite.h" 20 #include "base/test/test_suite.h"
23 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
24 #include "chrome/app/scoped_ole_initializer.h" 22 #include "chrome/app/scoped_ole_initializer.h"
25 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
26 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
30 #include "chrome/test/testing_browser_process.h" 28 #include "chrome/test/testing_browser_process.h"
31 #include "net/base/mock_host_resolver.h" 29 #include "net/base/mock_host_resolver.h"
32 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
33 #include "testing/gtest/include/gtest/gtest.h"
34 31
35 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
36 #include "base/mac_util.h" 33 #include "base/mac_util.h"
37 #endif 34 #endif
38 35
39 #if defined(OS_POSIX) 36 #if defined(OS_POSIX)
40 #include "base/shared_memory.h" 37 #include "base/shared_memory.h"
41 #endif 38 #endif
42 39
43 static void RemoveSharedMemoryFile(const std::string& filename) { 40 static void RemoveSharedMemoryFile(const std::string& filename) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Make the test fail so it's harder to ignore. 74 // Make the test fail so it's harder to ignore.
78 // If you really need to make real DNS query, use 75 // If you really need to make real DNS query, use
79 // net::RuleBasedHostResolverProc and its AllowDirectLookup method. 76 // net::RuleBasedHostResolverProc and its AllowDirectLookup method.
80 EXPECT_TRUE(local) << "Making external DNS lookup of " << host; 77 EXPECT_TRUE(local) << "Making external DNS lookup of " << host;
81 78
82 return ResolveUsingPrevious(host, address_family, host_resolver_flags, 79 return ResolveUsingPrevious(host, address_family, host_resolver_flags,
83 addrlist, os_error); 80 addrlist, os_error);
84 } 81 }
85 }; 82 };
86 83
87 class ChromeTestSuite : public base::TestSuite { 84 class ChromeTestSuite : public TestSuite {
88 public: 85 public:
89 ChromeTestSuite(int argc, char** argv) 86 ChromeTestSuite(int argc, char** argv)
90 : base::TestSuite(argc, argv), 87 : TestSuite(argc, argv),
91 stats_table_(NULL), 88 stats_table_(NULL),
92 created_user_data_dir_(false) { 89 created_user_data_dir_(false) {
93 } 90 }
94 91
95 protected: 92 protected:
96 93
97 virtual void Initialize() { 94 virtual void Initialize() {
98 base::ScopedNSAutoreleasePool autorelease_pool; 95 base::ScopedNSAutoreleasePool autorelease_pool;
99 96
100 base::TestSuite::Initialize(); 97 TestSuite::Initialize();
101 98
102 chrome::RegisterChromeSchemes(); 99 chrome::RegisterChromeSchemes();
103 host_resolver_proc_ = new WarningHostResolverProc(); 100 host_resolver_proc_ = new WarningHostResolverProc();
104 scoped_host_resolver_proc_.Init(host_resolver_proc_.get()); 101 scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
105 102
106 chrome::RegisterPathProvider(); 103 chrome::RegisterPathProvider();
107 app::RegisterPathProvider(); 104 app::RegisterPathProvider();
108 g_browser_process = new TestingBrowserProcess; 105 g_browser_process = new TestingBrowserProcess;
109 106
110 // Notice a user data override, and otherwise default to using a custom 107 // Notice a user data override, and otherwise default to using a custom
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Delete the test_user_data dir recursively 165 // Delete the test_user_data dir recursively
169 // NOTE: user_data_dir will be deleted only if it was automatically 166 // NOTE: user_data_dir will be deleted only if it was automatically
170 // created. 167 // created.
171 FilePath user_data_dir; 168 FilePath user_data_dir;
172 if (created_user_data_dir_ && 169 if (created_user_data_dir_ &&
173 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) && 170 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) &&
174 !user_data_dir.empty()) { 171 !user_data_dir.empty()) {
175 file_util::Delete(user_data_dir, true); 172 file_util::Delete(user_data_dir, true);
176 file_util::Delete(user_data_dir.DirName(), false); 173 file_util::Delete(user_data_dir.DirName(), false);
177 } 174 }
178 base::TestSuite::Shutdown(); 175 TestSuite::Shutdown();
179 } 176 }
180 177
181 void SetBrowserDirectory(const FilePath& browser_dir) { 178 void SetBrowserDirectory(const FilePath& browser_dir) {
182 browser_dir_ = browser_dir; 179 browser_dir_ = browser_dir;
183 } 180 }
184 181
185 StatsTable* stats_table_; 182 StatsTable* stats_table_;
186 // The name used for the stats file so it can be cleaned up on posix during 183 // The name used for the stats file so it can be cleaned up on posix during
187 // test shutdown. 184 // test shutdown.
188 std::string stats_filename_; 185 std::string stats_filename_;
189 186
190 // Alternative path to browser binaries. 187 // Alternative path to browser binaries.
191 FilePath browser_dir_; 188 FilePath browser_dir_;
192 189
193 ScopedOleInitializer ole_initializer_; 190 ScopedOleInitializer ole_initializer_;
194 scoped_refptr<WarningHostResolverProc> host_resolver_proc_; 191 scoped_refptr<WarningHostResolverProc> host_resolver_proc_;
195 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; 192 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_;
196 193
197 // Flag indicating whether user_data_dir was automatically created or not. 194 // Flag indicating whether user_data_dir was automatically created or not.
198 bool created_user_data_dir_; 195 bool created_user_data_dir_;
199 }; 196 };
200 197
201 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 198 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
OLDNEW
« no previous file with comments | « chrome/test/test_launcher/test_runner.cc ('k') | chrome_frame/chrome_frame.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698