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

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

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

Powered by Google App Engine
This is Rietveld 408576698