| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/launcher/unit_test_launcher.h" | 5 #include "base/test/launcher/unit_test_launcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 struct GTestCallbackState { | 115 struct GTestCallbackState { |
| 116 TestLauncher* test_launcher; | 116 TestLauncher* test_launcher; |
| 117 std::vector<std::string> test_names; | 117 std::vector<std::string> test_names; |
| 118 FilePath output_file; | 118 FilePath output_file; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 virtual bool ShouldRunTest(const testing::TestCase* test_case, | 121 virtual bool ShouldRunTest(const testing::TestCase* test_case, |
| 122 const testing::TestInfo* test_info) OVERRIDE { | 122 const testing::TestInfo* test_info) override { |
| 123 DCHECK(thread_checker_.CalledOnValidThread()); | 123 DCHECK(thread_checker_.CalledOnValidThread()); |
| 124 | 124 |
| 125 // There is no additional logic to disable specific tests. | 125 // There is no additional logic to disable specific tests. |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 virtual size_t RunTests(TestLauncher* test_launcher, | 129 virtual size_t RunTests(TestLauncher* test_launcher, |
| 130 const std::vector<std::string>& test_names) OVERRIDE { | 130 const std::vector<std::string>& test_names) override { |
| 131 DCHECK(thread_checker_.CalledOnValidThread()); | 131 DCHECK(thread_checker_.CalledOnValidThread()); |
| 132 | 132 |
| 133 std::vector<std::string> batch; | 133 std::vector<std::string> batch; |
| 134 for (size_t i = 0; i < test_names.size(); i++) { | 134 for (size_t i = 0; i < test_names.size(); i++) { |
| 135 batch.push_back(test_names[i]); | 135 batch.push_back(test_names[i]); |
| 136 | 136 |
| 137 if (batch.size() >= batch_limit_) { | 137 if (batch.size() >= batch_limit_) { |
| 138 RunBatch(test_launcher, batch); | 138 RunBatch(test_launcher, batch); |
| 139 batch.clear(); | 139 batch.clear(); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 RunBatch(test_launcher, batch); | 143 RunBatch(test_launcher, batch); |
| 144 | 144 |
| 145 return test_names.size(); | 145 return test_names.size(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual size_t RetryTests( | 148 virtual size_t RetryTests( |
| 149 TestLauncher* test_launcher, | 149 TestLauncher* test_launcher, |
| 150 const std::vector<std::string>& test_names) OVERRIDE { | 150 const std::vector<std::string>& test_names) override { |
| 151 MessageLoop::current()->PostTask( | 151 MessageLoop::current()->PostTask( |
| 152 FROM_HERE, | 152 FROM_HERE, |
| 153 Bind(&UnitTestLauncherDelegate::RunSerially, | 153 Bind(&UnitTestLauncherDelegate::RunSerially, |
| 154 Unretained(this), | 154 Unretained(this), |
| 155 test_launcher, | 155 test_launcher, |
| 156 test_names)); | 156 test_names)); |
| 157 return test_names.size(); | 157 return test_names.size(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void RunSerially(TestLauncher* test_launcher, | 160 void RunSerially(TestLauncher* test_launcher, |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 CommandLine::Init(argc, NULL); | 577 CommandLine::Init(argc, NULL); |
| 578 return LaunchUnitTestsInternal( | 578 return LaunchUnitTestsInternal( |
| 579 run_test_suite, | 579 run_test_suite, |
| 580 SysInfo::NumberOfProcessors(), | 580 SysInfo::NumberOfProcessors(), |
| 581 use_job_objects, | 581 use_job_objects, |
| 582 Bind(&InitGoogleTestWChar, &argc, argv)); | 582 Bind(&InitGoogleTestWChar, &argc, argv)); |
| 583 } | 583 } |
| 584 #endif // defined(OS_WIN) | 584 #endif // defined(OS_WIN) |
| 585 | 585 |
| 586 } // namespace base | 586 } // namespace base |
| OLD | NEW |