Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/task_scheduler/task_scheduler.h" | |
| 6 #include "base/test/launcher/unit_test_launcher.h" | 7 #include "base/test/launcher/unit_test_launcher.h" |
| 7 #include "base/test/test_suite.h" | 8 #include "base/test/test_suite.h" |
| 8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "media/base/media.h" | 10 #include "media/base/media.h" |
| 10 | 11 |
| 11 class TestSuiteNoAtExit : public base::TestSuite { | 12 class TestSuiteNoAtExit : public base::TestSuite { |
| 12 public: | 13 public: |
| 13 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} | 14 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
| 14 ~TestSuiteNoAtExit() override {} | 15 ~TestSuiteNoAtExit() override {} |
| 15 | 16 |
| 16 protected: | 17 protected: |
| 17 void Initialize() override; | 18 void Initialize() override; |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 void TestSuiteNoAtExit::Initialize() { | 21 void TestSuiteNoAtExit::Initialize() { |
| 21 // Run TestSuite::Initialize first so that logging is initialized. | 22 // Run TestSuite::Initialize first so that logging is initialized. |
| 22 base::TestSuite::Initialize(); | 23 base::TestSuite::Initialize(); |
| 23 | 24 |
| 24 // Run this here instead of main() to ensure an AtExitManager is already | 25 // Run this here instead of main() to ensure an AtExitManager is already |
| 25 // present. | 26 // present. |
| 26 media::InitializeMediaLibrary(); | 27 media::InitializeMediaLibrary(); |
| 28 | |
| 29 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(1); | |
|
gab
2017/02/23 21:37:09
For tests see base::test::ScopedTaskScheduler, als
DaleCurtis
2017/02/23 23:07:06
Thanks! Switched, though I think this omits a bit
gab
2017/02/24 01:09:05
You can use ScopedAsyncTaskScheduler if you want t
| |
| 27 } | 30 } |
| 28 | 31 |
| 29 int main(int argc, char** argv) { | 32 int main(int argc, char** argv) { |
| 30 TestSuiteNoAtExit test_suite(argc, argv); | 33 TestSuiteNoAtExit test_suite(argc, argv); |
| 31 | 34 |
| 32 // Always run the perf tests serially, to avoid distorting | 35 // Always run the perf tests serially, to avoid distorting |
| 33 // perf measurements with randomness resulting from running | 36 // perf measurements with randomness resulting from running |
| 34 // in parallel. | 37 // in parallel. |
| 35 return base::LaunchUnitTestsSerially( | 38 return base::LaunchUnitTestsSerially( |
| 36 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, | 39 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, |
| 37 base::Unretained(&test_suite))); | 40 base::Unretained(&test_suite))); |
| 38 } | 41 } |
| OLD | NEW |