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/test_results_tracker.h" | 5 #include "base/test/launcher/test_results_tracker.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
11 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
12 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
13 #include "base/json/string_escape.h" | 15 #include "base/json/string_escape.h" |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 global_tags_.insert(tag); | 221 global_tags_.insert(tag); |
220 } | 222 } |
221 | 223 |
222 bool TestResultsTracker::SaveSummaryAsJSON(const FilePath& path) const { | 224 bool TestResultsTracker::SaveSummaryAsJSON(const FilePath& path) const { |
223 scoped_ptr<DictionaryValue> summary_root(new DictionaryValue); | 225 scoped_ptr<DictionaryValue> summary_root(new DictionaryValue); |
224 | 226 |
225 scoped_ptr<ListValue> global_tags(new ListValue); | 227 scoped_ptr<ListValue> global_tags(new ListValue); |
226 for (const auto& global_tag : global_tags_) { | 228 for (const auto& global_tag : global_tags_) { |
227 global_tags->AppendString(global_tag); | 229 global_tags->AppendString(global_tag); |
228 } | 230 } |
229 summary_root->Set("global_tags", global_tags.Pass()); | 231 summary_root->Set("global_tags", std::move(global_tags)); |
230 | 232 |
231 scoped_ptr<ListValue> all_tests(new ListValue); | 233 scoped_ptr<ListValue> all_tests(new ListValue); |
232 for (const auto& test : all_tests_) { | 234 for (const auto& test : all_tests_) { |
233 all_tests->AppendString(test); | 235 all_tests->AppendString(test); |
234 } | 236 } |
235 summary_root->Set("all_tests", all_tests.Pass()); | 237 summary_root->Set("all_tests", std::move(all_tests)); |
236 | 238 |
237 scoped_ptr<ListValue> disabled_tests(new ListValue); | 239 scoped_ptr<ListValue> disabled_tests(new ListValue); |
238 for (const auto& disabled_test : disabled_tests_) { | 240 for (const auto& disabled_test : disabled_tests_) { |
239 disabled_tests->AppendString(disabled_test); | 241 disabled_tests->AppendString(disabled_test); |
240 } | 242 } |
241 summary_root->Set("disabled_tests", disabled_tests.Pass()); | 243 summary_root->Set("disabled_tests", std::move(disabled_tests)); |
242 | 244 |
243 scoped_ptr<ListValue> per_iteration_data(new ListValue); | 245 scoped_ptr<ListValue> per_iteration_data(new ListValue); |
244 | 246 |
245 for (int i = 0; i <= iteration_; i++) { | 247 for (int i = 0; i <= iteration_; i++) { |
246 scoped_ptr<DictionaryValue> current_iteration_data(new DictionaryValue); | 248 scoped_ptr<DictionaryValue> current_iteration_data(new DictionaryValue); |
247 | 249 |
248 for (PerIterationData::ResultsMap::const_iterator j = | 250 for (PerIterationData::ResultsMap::const_iterator j = |
249 per_iteration_data_[i].results.begin(); | 251 per_iteration_data_[i].results.begin(); |
250 j != per_iteration_data_[i].results.end(); | 252 j != per_iteration_data_[i].results.end(); |
251 ++j) { | 253 ++j) { |
(...skipping 25 matching lines...) Expand all Loading... |
277 test_result_value->SetBoolean("losless_snippet", lossless_snippet); | 279 test_result_value->SetBoolean("losless_snippet", lossless_snippet); |
278 | 280 |
279 // Also include the raw version (base64-encoded so that it can be safely | 281 // Also include the raw version (base64-encoded so that it can be safely |
280 // JSON-serialized - there are no guarantees about character encoding | 282 // JSON-serialized - there are no guarantees about character encoding |
281 // of the snippet). This can be very useful piece of information when | 283 // of the snippet). This can be very useful piece of information when |
282 // debugging a test failure related to character encoding. | 284 // debugging a test failure related to character encoding. |
283 std::string base64_output_snippet; | 285 std::string base64_output_snippet; |
284 Base64Encode(test_result.output_snippet, &base64_output_snippet); | 286 Base64Encode(test_result.output_snippet, &base64_output_snippet); |
285 test_result_value->SetString("output_snippet_base64", | 287 test_result_value->SetString("output_snippet_base64", |
286 base64_output_snippet); | 288 base64_output_snippet); |
287 test_results->Append(test_result_value.Pass()); | 289 test_results->Append(std::move(test_result_value)); |
288 } | 290 } |
289 | 291 |
290 current_iteration_data->SetWithoutPathExpansion(j->first, | 292 current_iteration_data->SetWithoutPathExpansion(j->first, |
291 test_results.Pass()); | 293 std::move(test_results)); |
292 } | 294 } |
293 per_iteration_data->Append(current_iteration_data.Pass()); | 295 per_iteration_data->Append(std::move(current_iteration_data)); |
294 summary_root->Set("per_iteration_data", per_iteration_data.Pass()); | 296 summary_root->Set("per_iteration_data", std::move(per_iteration_data)); |
295 } | 297 } |
296 | 298 |
297 JSONFileValueSerializer serializer(path); | 299 JSONFileValueSerializer serializer(path); |
298 return serializer.Serialize(*summary_root); | 300 return serializer.Serialize(*summary_root); |
299 } | 301 } |
300 | 302 |
301 TestResultsTracker::TestStatusMap | 303 TestResultsTracker::TestStatusMap |
302 TestResultsTracker::GetTestStatusMapForCurrentIteration() const { | 304 TestResultsTracker::GetTestStatusMapForCurrentIteration() const { |
303 TestStatusMap tests_by_status; | 305 TestStatusMap tests_by_status; |
304 GetTestStatusForIteration(iteration_, &tests_by_status); | 306 GetTestStatusForIteration(iteration_, &tests_by_status); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 TestResultsTracker::AggregateTestResult::~AggregateTestResult() { | 359 TestResultsTracker::AggregateTestResult::~AggregateTestResult() { |
358 } | 360 } |
359 | 361 |
360 TestResultsTracker::PerIterationData::PerIterationData() { | 362 TestResultsTracker::PerIterationData::PerIterationData() { |
361 } | 363 } |
362 | 364 |
363 TestResultsTracker::PerIterationData::~PerIterationData() { | 365 TestResultsTracker::PerIterationData::~PerIterationData() { |
364 } | 366 } |
365 | 367 |
366 } // namespace base | 368 } // namespace base |
OLD | NEW |