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

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

Issue 28214: Add a macutil for the main app bundle and override... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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) 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)
13 #include "base/mac_util.h"
14 #endif
12 #include "base/path_service.h" 15 #include "base/path_service.h"
13 #include "base/scoped_nsautorelease_pool.h" 16 #include "base/scoped_nsautorelease_pool.h"
14 #include "base/test_suite.h" 17 #include "base/test_suite.h"
15 #include "chrome/app/scoped_ole_initializer.h" 18 #include "chrome/app/scoped_ole_initializer.h"
16 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
17 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/resource_bundle.h" 22 #include "chrome/common/resource_bundle.h"
20 #include "chrome/test/testing_browser_process.h" 23 #include "chrome/test/testing_browser_process.h"
21 24
(...skipping 18 matching lines...) Expand all
40 // uses it, in order to ensure consistency. 43 // uses it, in order to ensure consistency.
41 std::wstring user_data_dir = 44 std::wstring user_data_dir =
42 CommandLine::ForCurrentProcess()->GetSwitchValue( 45 CommandLine::ForCurrentProcess()->GetSwitchValue(
43 switches::kUserDataDir); 46 switches::kUserDataDir);
44 if (user_data_dir.empty() && 47 if (user_data_dir.empty() &&
45 PathService::Get(base::DIR_EXE, &user_data_dir)) 48 PathService::Get(base::DIR_EXE, &user_data_dir))
46 file_util::AppendToPath(&user_data_dir, L"test_user_data"); 49 file_util::AppendToPath(&user_data_dir, L"test_user_data");
47 if (!user_data_dir.empty()) 50 if (!user_data_dir.empty())
48 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); 51 PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
49 52
53 #if defined(OS_MACOSX)
54 FilePath path;
55 PathService::Get(base::DIR_EXE, &path);
56 path = path.AppendASCII("Chromium.app");
57 mac_util::SetOverrideAppBundlePath(path);
58 #endif
59
50 // Force unittests to run using en-us so if we test against string 60 // Force unittests to run using en-us so if we test against string
51 // output, it'll pass regardless of the system language. 61 // output, it'll pass regardless of the system language.
52 ResourceBundle::InitSharedInstance(L"en-us"); 62 ResourceBundle::InitSharedInstance(L"en-us");
53 ResourceBundle::GetSharedInstance().LoadThemeResources(); 63 ResourceBundle::GetSharedInstance().LoadThemeResources();
54 64
55 // initialize the global StatsTable for unit_tests 65 // initialize the global StatsTable for unit_tests
56 std::string statsfile = "unit_tests"; 66 std::string statsfile = "unit_tests";
57 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId()); 67 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId());
58 statsfile += pid_string; 68 statsfile += pid_string;
59 stats_table_ = new StatsTable(statsfile, 20, 200); 69 stats_table_ = new StatsTable(statsfile, 20, 200);
60 StatsTable::set_current(stats_table_); 70 StatsTable::set_current(stats_table_);
61 } 71 }
62 72
63 virtual void Shutdown() { 73 virtual void Shutdown() {
64 // TODO(port): Remove the #ifdef when ResourceBundle is ported. 74 // TODO(port): Remove the #ifdef when ResourceBundle is ported.
65 ResourceBundle::CleanupSharedInstance(); 75 ResourceBundle::CleanupSharedInstance();
66 76
77 #if defined(OS_MACOSX)
78 mac_util::SetOverrideAppBundle(NULL);
79 #endif
80
67 delete g_browser_process; 81 delete g_browser_process;
68 g_browser_process = NULL; 82 g_browser_process = NULL;
69 83
70 // Tear down shared StatsTable; prevents unit_tests from leaking it. 84 // Tear down shared StatsTable; prevents unit_tests from leaking it.
71 StatsTable::set_current(NULL); 85 StatsTable::set_current(NULL);
72 delete stats_table_; 86 delete stats_table_;
73 87
74 TestSuite::Shutdown(); 88 TestSuite::Shutdown();
75 } 89 }
76 90
77 StatsTable* stats_table_; 91 StatsTable* stats_table_;
78 ScopedOleInitializer ole_initializer_; 92 ScopedOleInitializer ole_initializer_;
79 }; 93 };
80 94
81 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ 95 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698