OLD | NEW |
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/at_exit.h" | |
6 #include "base/command_line.h" | |
7 #include "base/logging.h" | |
8 #include "base/test/test_suite.h" | 5 #include "base/test/test_suite.h" |
9 #include "media/base/media.h" | 6 #include "media/base/media.h" |
10 | 7 |
11 class TestSuiteNoAtExit : public base::TestSuite { | 8 class TestSuiteNoAtExit : public base::TestSuite { |
12 public: | 9 public: |
13 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv, false) {} | 10 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
14 virtual ~TestSuiteNoAtExit() {} | 11 virtual ~TestSuiteNoAtExit() {} |
| 12 protected: |
| 13 virtual void Initialize(); |
15 }; | 14 }; |
16 | 15 |
| 16 void TestSuiteNoAtExit::Initialize() { |
| 17 // Run TestSuite::Initialize first so that logging is initialized. |
| 18 base::TestSuite::Initialize(); |
| 19 // Run this here instead of main() to ensure an AtExitManager is already |
| 20 // present. |
| 21 media::InitializeMediaLibraryForTesting(); |
| 22 } |
| 23 |
17 int main(int argc, char** argv) { | 24 int main(int argc, char** argv) { |
18 // By default command-line parsing happens only in TestSuite::Run(), but | |
19 // that's too late to get VLOGs and so on from | |
20 // InitializeMediaLibraryForTesting() below. Instead initialize logging | |
21 // explicitly here (and have it get re-initialized by TestSuite::Run()). | |
22 CommandLine::Init(argc, argv); | |
23 CHECK(logging::InitLogging( | |
24 NULL, | |
25 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | |
26 logging::DONT_LOCK_LOG_FILE, | |
27 logging::APPEND_TO_OLD_LOG_FILE, | |
28 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS)); | |
29 base::AtExitManager exit_manager; | |
30 | |
31 media::InitializeMediaLibraryForTesting(); | |
32 | |
33 return TestSuiteNoAtExit(argc, argv).Run(); | 25 return TestSuiteNoAtExit(argc, argv).Run(); |
34 } | 26 } |
OLD | NEW |