OLD | NEW |
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 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/scoped_nsautorelease_pool.h" | 13 #include "base/scoped_nsautorelease_pool.h" |
14 #include "base/test_suite.h" | 14 #include "base/test_suite.h" |
15 #include "chrome/app/scoped_ole_initializer.h" | 15 #include "chrome/app/scoped_ole_initializer.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #if defined(OS_WIN) || defined(OS_LINUX) | |
20 // TODO(port): Remove the #ifdef when ResourceBundle is ported. | |
21 #include "chrome/common/resource_bundle.h" | 19 #include "chrome/common/resource_bundle.h" |
22 #endif | |
23 #include "chrome/test/testing_browser_process.h" | 20 #include "chrome/test/testing_browser_process.h" |
24 | 21 |
25 class ChromeTestSuite : public TestSuite { | 22 class ChromeTestSuite : public TestSuite { |
26 public: | 23 public: |
27 ChromeTestSuite(int argc, char** argv) : TestSuite(argc, argv) { | 24 ChromeTestSuite(int argc, char** argv) : TestSuite(argc, argv) { |
28 } | 25 } |
29 | 26 |
30 protected: | 27 protected: |
31 | 28 |
32 virtual void Initialize() { | 29 virtual void Initialize() { |
(...skipping 10 matching lines...) Expand all Loading... |
43 // uses it, in order to ensure consistency. | 40 // uses it, in order to ensure consistency. |
44 std::wstring user_data_dir = | 41 std::wstring user_data_dir = |
45 CommandLine::ForCurrentProcess()->GetSwitchValue( | 42 CommandLine::ForCurrentProcess()->GetSwitchValue( |
46 switches::kUserDataDir); | 43 switches::kUserDataDir); |
47 if (user_data_dir.empty() && | 44 if (user_data_dir.empty() && |
48 PathService::Get(base::DIR_EXE, &user_data_dir)) | 45 PathService::Get(base::DIR_EXE, &user_data_dir)) |
49 file_util::AppendToPath(&user_data_dir, L"test_user_data"); | 46 file_util::AppendToPath(&user_data_dir, L"test_user_data"); |
50 if (!user_data_dir.empty()) | 47 if (!user_data_dir.empty()) |
51 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); | 48 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); |
52 | 49 |
53 #if defined(OS_WIN) || defined(OS_LINUX) | |
54 // TODO(port): Remove the #ifdef when ResourceBundle is ported. | |
55 // | |
56 // Force unittests to run using en-us so if we test against string | 50 // Force unittests to run using en-us so if we test against string |
57 // output, it'll pass regardless of the system language. | 51 // output, it'll pass regardless of the system language. |
58 ResourceBundle::InitSharedInstance(L"en-us"); | 52 ResourceBundle::InitSharedInstance(L"en-us"); |
59 ResourceBundle::GetSharedInstance().LoadThemeResources(); | 53 ResourceBundle::GetSharedInstance().LoadThemeResources(); |
60 #endif | |
61 | 54 |
62 // initialize the global StatsTable for unit_tests | 55 // initialize the global StatsTable for unit_tests |
63 std::string statsfile = "unit_tests"; | 56 std::string statsfile = "unit_tests"; |
64 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId()); | 57 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId()); |
65 statsfile += pid_string; | 58 statsfile += pid_string; |
66 stats_table_ = new StatsTable(statsfile, 20, 200); | 59 stats_table_ = new StatsTable(statsfile, 20, 200); |
67 StatsTable::set_current(stats_table_); | 60 StatsTable::set_current(stats_table_); |
68 } | 61 } |
69 | 62 |
70 virtual void Shutdown() { | 63 virtual void Shutdown() { |
71 #if defined(OS_WIN) || defined(OS_LINUX) | |
72 // TODO(port): Remove the #ifdef when ResourceBundle is ported. | 64 // TODO(port): Remove the #ifdef when ResourceBundle is ported. |
73 ResourceBundle::CleanupSharedInstance(); | 65 ResourceBundle::CleanupSharedInstance(); |
74 #endif | |
75 | 66 |
76 delete g_browser_process; | 67 delete g_browser_process; |
77 g_browser_process = NULL; | 68 g_browser_process = NULL; |
78 | 69 |
79 // Tear down shared StatsTable; prevents unit_tests from leaking it. | 70 // Tear down shared StatsTable; prevents unit_tests from leaking it. |
80 StatsTable::set_current(NULL); | 71 StatsTable::set_current(NULL); |
81 delete stats_table_; | 72 delete stats_table_; |
82 | 73 |
83 TestSuite::Shutdown(); | 74 TestSuite::Shutdown(); |
84 } | 75 } |
85 | 76 |
86 StatsTable* stats_table_; | 77 StatsTable* stats_table_; |
87 ScopedOleInitializer ole_initializer_; | 78 ScopedOleInitializer ole_initializer_; |
88 }; | 79 }; |
89 | 80 |
90 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ | 81 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ |
OLD | NEW |