Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: base/test/gtest_util.cc

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | base/values.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 JSONFileValueSerializer serializer(path); 54 JSONFileValueSerializer serializer(path);
55 return serializer.Serialize(root); 55 return serializer.Serialize(root);
56 } 56 }
57 57
58 bool ReadTestNamesFromFile(const FilePath& path, 58 bool ReadTestNamesFromFile(const FilePath& path,
59 std::vector<TestIdentifier>* output) { 59 std::vector<TestIdentifier>* output) {
60 JSONFileValueDeserializer deserializer(path); 60 JSONFileValueDeserializer deserializer(path);
61 int error_code = 0; 61 int error_code = 0;
62 std::string error_message; 62 std::string error_message;
63 scoped_ptr<base::Value> value( 63 scoped_ptr<base::Value> value =
64 deserializer.Deserialize(&error_code, &error_message)); 64 deserializer.Deserialize(&error_code, &error_message);
65 if (!value.get()) 65 if (!value.get())
66 return false; 66 return false;
67 67
68 base::ListValue* tests = nullptr; 68 base::ListValue* tests = nullptr;
69 if (!value->GetAsList(&tests)) 69 if (!value->GetAsList(&tests))
70 return false; 70 return false;
71 71
72 std::vector<base::TestIdentifier> result; 72 std::vector<base::TestIdentifier> result;
73 for (base::ListValue::iterator i = tests->begin(); i != tests->end(); ++i) { 73 for (base::ListValue::iterator i = tests->begin(); i != tests->end(); ++i) {
74 base::DictionaryValue* test = nullptr; 74 base::DictionaryValue* test = nullptr;
(...skipping 15 matching lines...) Expand all
90 return false; 90 return false;
91 91
92 result.push_back(test_data); 92 result.push_back(test_data);
93 } 93 }
94 94
95 output->swap(result); 95 output->swap(result);
96 return true; 96 return true;
97 } 97 }
98 98
99 } // namespace base 99 } // namespace base
OLDNEW
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698