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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 DCHECK(thread_checker_.CalledOnValidThread()); | 111 DCHECK(thread_checker_.CalledOnValidThread()); |
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 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 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 size_t RetryTests(TestLauncher* test_launcher, |
149 TestLauncher* test_launcher, | 149 const std::vector<std::string>& test_names) override { |
150 const std::vector<std::string>& test_names) OVERRIDE { | |
151 MessageLoop::current()->PostTask( | 150 MessageLoop::current()->PostTask( |
152 FROM_HERE, | 151 FROM_HERE, |
153 Bind(&UnitTestLauncherDelegate::RunSerially, | 152 Bind(&UnitTestLauncherDelegate::RunSerially, |
154 Unretained(this), | 153 Unretained(this), |
155 test_launcher, | 154 test_launcher, |
156 test_names)); | 155 test_names)); |
157 return test_names.size(); | 156 return test_names.size(); |
158 } | 157 } |
159 | 158 |
160 void RunSerially(TestLauncher* test_launcher, | 159 void RunSerially(TestLauncher* test_launcher, |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 CommandLine::Init(argc, NULL); | 576 CommandLine::Init(argc, NULL); |
578 return LaunchUnitTestsInternal( | 577 return LaunchUnitTestsInternal( |
579 run_test_suite, | 578 run_test_suite, |
580 SysInfo::NumberOfProcessors(), | 579 SysInfo::NumberOfProcessors(), |
581 use_job_objects, | 580 use_job_objects, |
582 Bind(&InitGoogleTestWChar, &argc, argv)); | 581 Bind(&InitGoogleTestWChar, &argc, argv)); |
583 } | 582 } |
584 #endif // defined(OS_WIN) | 583 #endif // defined(OS_WIN) |
585 | 584 |
586 } // namespace base | 585 } // namespace base |
OLD | NEW |