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

Side by Side Diff: chrome/test/base/chrome_test_suite.cc

Issue 8873001: Revert 113470 - Makes tests either use mock compositor or mock WebGraphicsContext3D depending upo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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/common/chrome_switches.cc ('k') | chrome/test/ui/ui_test.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/test/base/chrome_test_suite.h" 5 #include "chrome/test/base/chrome_test_suite.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/metrics/stats_table.h" 10 #include "base/metrics/stats_table.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_content_browser_client.h" 16 #include "chrome/browser/chrome_content_browser_client.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_content_client.h" 18 #include "chrome/common/chrome_content_client.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/test/base/testing_browser_process.h" 21 #include "chrome/test/base/testing_browser_process.h"
22 #include "content/public/common/content_paths.h" 22 #include "content/public/common/content_paths.h"
23 #include "net/base/mock_host_resolver.h" 23 #include "net/base/mock_host_resolver.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/base/ui_base_paths.h" 28 #include "ui/base/ui_base_paths.h"
29 #include "ui/gfx/test/gfx_test_utils.h"
29 30
30 #if defined(OS_MACOSX) 31 #if defined(OS_MACOSX)
31 #include "base/mac/mac_util.h" 32 #include "base/mac/mac_util.h"
32 #include "base/mac/scoped_nsautorelease_pool.h" 33 #include "base/mac/scoped_nsautorelease_pool.h"
33 #include "chrome/browser/chrome_browser_application_mac.h" 34 #include "chrome/browser/chrome_browser_application_mac.h"
34 #endif 35 #endif
35 36
36 #if defined(OS_POSIX) 37 #if defined(OS_POSIX)
37 #include "base/shared_memory.h" 38 #include "base/shared_memory.h"
38 #endif 39 #endif
39 40
40 #if defined(USE_WEBKIT_COMPOSITOR)
41 #include "ui/gfx/compositor/compositor_setup.h"
42 #else
43 #include "ui/gfx/test/gfx_test_utils.h"
44 #endif
45
46 namespace { 41 namespace {
47 42
48 void RemoveSharedMemoryFile(const std::string& filename) { 43 void RemoveSharedMemoryFile(const std::string& filename) {
49 // Stats uses SharedMemory under the hood. On posix, this results in a file 44 // Stats uses SharedMemory under the hood. On posix, this results in a file
50 // on disk. 45 // on disk.
51 #if defined(OS_POSIX) 46 #if defined(OS_POSIX)
52 base::SharedMemory memory; 47 base::SharedMemory memory;
53 memory.Delete(filename); 48 memory.Delete(filename);
54 #endif 49 #endif
55 } 50 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Force unittests to run using en-US so if we test against string 186 // Force unittests to run using en-US so if we test against string
192 // output, it'll pass regardless of the system language. 187 // output, it'll pass regardless of the system language.
193 ResourceBundle::InitSharedInstance("en-US"); 188 ResourceBundle::InitSharedInstance("en-US");
194 FilePath resources_pack_path; 189 FilePath resources_pack_path;
195 PathService::Get(base::DIR_MODULE, &resources_pack_path); 190 PathService::Get(base::DIR_MODULE, &resources_pack_path);
196 resources_pack_path = 191 resources_pack_path =
197 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); 192 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
198 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); 193 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path);
199 194
200 // Mock out the compositor on platforms that use it. 195 // Mock out the compositor on platforms that use it.
201 #if defined(USE_WEBKIT_COMPOSITOR)
202 ui::SetupTestCompositor();
203 #else
204 ui::gfx_test_utils::SetupTestCompositor(); 196 ui::gfx_test_utils::SetupTestCompositor();
205 #endif
206 197
207 stats_filename_ = base::StringPrintf("unit_tests-%d", 198 stats_filename_ = base::StringPrintf("unit_tests-%d",
208 base::GetCurrentProcId()); 199 base::GetCurrentProcId());
209 RemoveSharedMemoryFile(stats_filename_); 200 RemoveSharedMemoryFile(stats_filename_);
210 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); 201 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200));
211 base::StatsTable::set_current(stats_table_.get()); 202 base::StatsTable::set_current(stats_table_.get());
212 203
213 testing::TestEventListeners& listeners = 204 testing::TestEventListeners& listeners =
214 testing::UnitTest::GetInstance()->listeners(); 205 testing::UnitTest::GetInstance()->listeners();
215 listeners.Append(new ChromeTestSuiteInitializer); 206 listeners.Append(new ChromeTestSuiteInitializer);
216 } 207 }
217 208
218 void ChromeTestSuite::Shutdown() { 209 void ChromeTestSuite::Shutdown() {
219 ResourceBundle::CleanupSharedInstance(); 210 ResourceBundle::CleanupSharedInstance();
220 211
221 #if defined(OS_MACOSX) 212 #if defined(OS_MACOSX)
222 base::mac::SetOverrideAppBundle(NULL); 213 base::mac::SetOverrideAppBundle(NULL);
223 #endif 214 #endif
224 215
225 base::StatsTable::set_current(NULL); 216 base::StatsTable::set_current(NULL);
226 stats_table_.reset(); 217 stats_table_.reset();
227 RemoveSharedMemoryFile(stats_filename_); 218 RemoveSharedMemoryFile(stats_filename_);
228 219
229 base::TestSuite::Shutdown(); 220 base::TestSuite::Shutdown();
230 } 221 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698