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

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

Issue 113725: We don't need stats table in unit tests. (Closed)
Patch Set: Created 11 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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) 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 <string> 10 #include <string>
11 11
12 #include "app/app_paths.h" 12 #include "app/app_paths.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "base/stats_table.h"
15 #include "base/file_util.h" 14 #include "base/file_util.h"
16 #if defined(OS_MACOSX) 15 #if defined(OS_MACOSX)
17 #include "base/mac_util.h" 16 #include "base/mac_util.h"
18 #endif 17 #endif
19 #include "base/path_service.h" 18 #include "base/path_service.h"
20 #include "base/ref_counted.h" 19 #include "base/ref_counted.h"
21 #include "base/scoped_nsautorelease_pool.h" 20 #include "base/scoped_nsautorelease_pool.h"
22 #include "base/test_suite.h" 21 #include "base/test_suite.h"
23 #include "chrome/app/scoped_ole_initializer.h" 22 #include "chrome/app/scoped_ole_initializer.h"
24 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 FilePath path; 97 FilePath path;
99 PathService::Get(base::DIR_EXE, &path); 98 PathService::Get(base::DIR_EXE, &path);
100 path = path.AppendASCII(MAC_BROWSER_APP_NAME); 99 path = path.AppendASCII(MAC_BROWSER_APP_NAME);
101 mac_util::SetOverrideAppBundlePath(path); 100 mac_util::SetOverrideAppBundlePath(path);
102 #endif 101 #endif
103 102
104 // Force unittests to run using en-us so if we test against string 103 // Force unittests to run using en-us so if we test against string
105 // output, it'll pass regardless of the system language. 104 // output, it'll pass regardless of the system language.
106 ResourceBundle::InitSharedInstance(L"en-us"); 105 ResourceBundle::InitSharedInstance(L"en-us");
107 ResourceBundle::GetSharedInstance().LoadThemeResources(); 106 ResourceBundle::GetSharedInstance().LoadThemeResources();
108
109 // initialize the global StatsTable for unit_tests
110 std::string statsfile = "unit_tests";
111 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId());
112 statsfile += pid_string;
113 stats_table_ = new StatsTable(statsfile, 20, 200);
114 StatsTable::set_current(stats_table_);
115 } 107 }
116 108
117 virtual void Shutdown() { 109 virtual void Shutdown() {
118 ResourceBundle::CleanupSharedInstance(); 110 ResourceBundle::CleanupSharedInstance();
119 111
120 #if defined(OS_MACOSX) 112 #if defined(OS_MACOSX)
121 mac_util::SetOverrideAppBundle(NULL); 113 mac_util::SetOverrideAppBundle(NULL);
122 #endif 114 #endif
123 115
124 delete g_browser_process; 116 delete g_browser_process;
125 g_browser_process = NULL; 117 g_browser_process = NULL;
126 118
127 // Tear down shared StatsTable; prevents unit_tests from leaking it.
128 StatsTable::set_current(NULL);
129 delete stats_table_;
130
131 // Delete the test_user_data dir recursively 119 // Delete the test_user_data dir recursively
132 FilePath user_data_dir; 120 FilePath user_data_dir;
133 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) && 121 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) &&
134 !user_data_dir.empty()) { 122 !user_data_dir.empty()) {
135 file_util::Delete(user_data_dir, true); 123 file_util::Delete(user_data_dir, true);
136 file_util::Delete(user_data_dir.DirName(), false); 124 file_util::Delete(user_data_dir.DirName(), false);
137 } 125 }
138 TestSuite::Shutdown(); 126 TestSuite::Shutdown();
139 } 127 }
140 128
141 StatsTable* stats_table_;
142 ScopedOleInitializer ole_initializer_; 129 ScopedOleInitializer ole_initializer_;
143 scoped_refptr<WarningHostMapper> host_mapper_; 130 scoped_refptr<WarningHostMapper> host_mapper_;
144 net::ScopedHostMapper scoped_host_mapper_; 131 net::ScopedHostMapper scoped_host_mapper_;
145 }; 132 };
146 133
147 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 134 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698