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/test/gtest_util.h" | 5 #include "base/test/gtest_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
11 #include "base/values.h" | 13 #include "base/values.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 namespace base { | 16 namespace base { |
15 | 17 |
16 TestIdentifier::TestIdentifier() { | 18 TestIdentifier::TestIdentifier() { |
17 } | 19 } |
18 | 20 |
(...skipping 21 matching lines...) Expand all Loading... |
40 } | 42 } |
41 } | 43 } |
42 return tests; | 44 return tests; |
43 } | 45 } |
44 | 46 |
45 bool WriteCompiledInTestsToFile(const FilePath& path) { | 47 bool WriteCompiledInTestsToFile(const FilePath& path) { |
46 std::vector<TestIdentifier> tests(GetCompiledInTests()); | 48 std::vector<TestIdentifier> tests(GetCompiledInTests()); |
47 | 49 |
48 ListValue root; | 50 ListValue root; |
49 for (size_t i = 0; i < tests.size(); ++i) { | 51 for (size_t i = 0; i < tests.size(); ++i) { |
50 DictionaryValue* test_info = new DictionaryValue; | 52 std::unique_ptr<class base::DictionaryValue> test_info(new DictionaryValue); |
51 test_info->SetString("test_case_name", tests[i].test_case_name); | 53 test_info->SetString("test_case_name", tests[i].test_case_name); |
52 test_info->SetString("test_name", tests[i].test_name); | 54 test_info->SetString("test_name", tests[i].test_name); |
53 test_info->SetString("file", tests[i].file); | 55 test_info->SetString("file", tests[i].file); |
54 test_info->SetInteger("line", tests[i].line); | 56 test_info->SetInteger("line", tests[i].line); |
55 root.Append(test_info); | 57 root.Append(std::move(test_info)); |
56 } | 58 } |
57 | 59 |
58 JSONFileValueSerializer serializer(path); | 60 JSONFileValueSerializer serializer(path); |
59 return serializer.Serialize(root); | 61 return serializer.Serialize(root); |
60 } | 62 } |
61 | 63 |
62 bool ReadTestNamesFromFile(const FilePath& path, | 64 bool ReadTestNamesFromFile(const FilePath& path, |
63 std::vector<TestIdentifier>* output) { | 65 std::vector<TestIdentifier>* output) { |
64 JSONFileValueDeserializer deserializer(path); | 66 JSONFileValueDeserializer deserializer(path); |
65 int error_code = 0; | 67 int error_code = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
94 return false; | 96 return false; |
95 | 97 |
96 result.push_back(test_data); | 98 result.push_back(test_data); |
97 } | 99 } |
98 | 100 |
99 output->swap(result); | 101 output->swap(result); |
100 return true; | 102 return true; |
101 } | 103 } |
102 | 104 |
103 } // namespace base | 105 } // namespace base |
OLD | NEW |