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

Side by Side Diff: base/test/test_suite.cc

Issue 314173005: Revert of Convert installer_util_unittests, sbox_integration_tests, sbox_validation_tests, sbox_unittests to … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/installer/util/run_all_unittests.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/test/test_suite.h" 5 #include "base/test/test_suite.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base_paths.h" 8 #include "base/base_paths.h"
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) { 84 int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
85 TestSuite test_suite(argc, argv); 85 TestSuite test_suite(argc, argv);
86 return base::LaunchUnitTests( 86 return base::LaunchUnitTests(
87 argc, argv, Bind(&TestSuite::Run, Unretained(&test_suite))); 87 argc, argv, Bind(&TestSuite::Run, Unretained(&test_suite)));
88 } 88 }
89 89
90 } // namespace base 90 } // namespace base
91 91
92 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { 92 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
93 PreInitialize(true); 93 PreInitialize(argc, argv, true);
94 InitializeFromCommandLine(argc, argv);
95 } 94 }
96 95
97 #if defined(OS_WIN)
98 TestSuite::TestSuite(int argc, wchar_t** argv)
99 : initialized_command_line_(false) {
100 PreInitialize(true);
101 InitializeFromCommandLine(argc, argv);
102 }
103 #endif // defined(OS_WIN)
104
105 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) 96 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager)
106 : initialized_command_line_(false) { 97 : initialized_command_line_(false) {
107 PreInitialize(create_at_exit_manager); 98 PreInitialize(argc, argv, create_at_exit_manager);
108 InitializeFromCommandLine(argc, argv);
109 } 99 }
110 100
111 TestSuite::~TestSuite() { 101 TestSuite::~TestSuite() {
112 if (initialized_command_line_) 102 if (initialized_command_line_)
113 CommandLine::Reset(); 103 CommandLine::Reset();
114 } 104 }
115 105
116 void TestSuite::InitializeFromCommandLine(int argc, char** argv) { 106 void TestSuite::PreInitialize(int argc, char** argv,
117 initialized_command_line_ = CommandLine::Init(argc, argv); 107 bool create_at_exit_manager) {
118 testing::InitGoogleTest(&argc, argv);
119 testing::InitGoogleMock(&argc, argv);
120
121 #if defined(OS_IOS)
122 InitIOSRunHook(this, argc, argv);
123 #endif
124 }
125
126 #if defined(OS_WIN)
127 void TestSuite::InitializeFromCommandLine(int argc, wchar_t** argv) {
128 // Windows CommandLine::Init ignores argv anyway.
129 initialized_command_line_ = CommandLine::Init(argc, NULL);
130 testing::InitGoogleTest(&argc, argv);
131 testing::InitGoogleMock(&argc, argv);
132 }
133 #endif // defined(OS_WIN)
134
135 void TestSuite::PreInitialize(bool create_at_exit_manager) {
136 #if defined(OS_WIN) 108 #if defined(OS_WIN)
137 testing::GTEST_FLAG(catch_exceptions) = false; 109 testing::GTEST_FLAG(catch_exceptions) = false;
138 base::TimeTicks::SetNowIsHighResNowIfSupported(); 110 base::TimeTicks::SetNowIsHighResNowIfSupported();
139 #endif 111 #endif
140 base::EnableTerminationOnHeapCorruption(); 112 base::EnableTerminationOnHeapCorruption();
113 initialized_command_line_ = CommandLine::Init(argc, argv);
114 testing::InitGoogleTest(&argc, argv);
115 testing::InitGoogleMock(&argc, argv);
141 #if defined(OS_LINUX) && defined(USE_AURA) 116 #if defined(OS_LINUX) && defined(USE_AURA)
142 // When calling native char conversion functions (e.g wrctomb) we need to 117 // When calling native char conversion functions (e.g wrctomb) we need to
143 // have the locale set. In the absence of such a call the "C" locale is the 118 // have the locale set. In the absence of such a call the "C" locale is the
144 // default. In the gtk code (below) gtk_init() implicitly sets a locale. 119 // default. In the gtk code (below) gtk_init() implicitly sets a locale.
145 setlocale(LC_ALL, ""); 120 setlocale(LC_ALL, "");
146 #endif // defined(OS_LINUX) && defined(USE_AURA) 121 #endif // defined(OS_LINUX) && defined(USE_AURA)
147 122
148 // On Android, AtExitManager is created in 123 // On Android, AtExitManager is created in
149 // testing/android/native_test_wrapper.cc before main() is called. 124 // testing/android/native_test_wrapper.cc before main() is called.
150 #if !defined(OS_ANDROID) 125 #if !defined(OS_ANDROID)
151 if (create_at_exit_manager) 126 if (create_at_exit_manager)
152 at_exit_manager_.reset(new base::AtExitManager); 127 at_exit_manager_.reset(new base::AtExitManager);
153 #endif 128 #endif
154 129
130 #if defined(OS_IOS)
131 InitIOSRunHook(this, argc, argv);
132 #endif
133
155 // Don't add additional code to this function. Instead add it to 134 // Don't add additional code to this function. Instead add it to
156 // Initialize(). See bug 6436. 135 // Initialize(). See bug 6436.
157 } 136 }
158 137
159 138
160 // static 139 // static
161 bool TestSuite::IsMarkedMaybe(const testing::TestInfo& test) { 140 bool TestSuite::IsMarkedMaybe(const testing::TestInfo& test) {
162 return strncmp(test.name(), "MAYBE_", 6) == 0; 141 return strncmp(test.name(), "MAYBE_", 6) == 0;
163 } 142 }
164 143
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ResetCommandLine(); 307 ResetCommandLine();
329 #if !defined(OS_IOS) 308 #if !defined(OS_IOS)
330 AddTestLauncherResultPrinter(); 309 AddTestLauncherResultPrinter();
331 #endif // !defined(OS_IOS) 310 #endif // !defined(OS_IOS)
332 311
333 TestTimeouts::Initialize(); 312 TestTimeouts::Initialize();
334 } 313 }
335 314
336 void TestSuite::Shutdown() { 315 void TestSuite::Shutdown() {
337 } 316 }
OLDNEW
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/installer/util/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698