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

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

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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 29 matching lines...) Expand all
40 test_info->SetString("test_name", tests[i].second); 40 test_info->SetString("test_name", tests[i].second);
41 root.Append(test_info); 41 root.Append(test_info);
42 } 42 }
43 43
44 JSONFileValueSerializer serializer(path); 44 JSONFileValueSerializer serializer(path);
45 return serializer.Serialize(root); 45 return serializer.Serialize(root);
46 } 46 }
47 47
48 bool ReadTestNamesFromFile(const FilePath& path, 48 bool ReadTestNamesFromFile(const FilePath& path,
49 std::vector<SplitTestName>* output) { 49 std::vector<SplitTestName>* output) {
50 JSONFileValueSerializer deserializer(path); 50 JSONFileValueDeserializer deserializer(path);
51 int error_code = 0; 51 int error_code = 0;
52 std::string error_message; 52 std::string error_message;
53 scoped_ptr<base::Value> value( 53 scoped_ptr<base::Value> value(
54 deserializer.Deserialize(&error_code, &error_message)); 54 deserializer.Deserialize(&error_code, &error_message));
55 if (!value.get()) 55 if (!value.get())
56 return false; 56 return false;
57 57
58 base::ListValue* tests = nullptr; 58 base::ListValue* tests = nullptr;
59 if (!value->GetAsList(&tests)) 59 if (!value->GetAsList(&tests))
60 return false; 60 return false;
(...skipping 12 matching lines...) Expand all
73 if (!test->GetStringASCII("test_name", &test_name)) 73 if (!test->GetStringASCII("test_name", &test_name))
74 return false; 74 return false;
75 75
76 result.push_back(std::make_pair(test_case_name, test_name)); 76 result.push_back(std::make_pair(test_case_name, test_name));
77 } 77 }
78 78
79 output->swap(result); 79 output->swap(result);
80 return true; 80 return true;
81 } 81 }
82 82
83 } // namespace 83 } // 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