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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 22 matching lines...) Expand all
33 DictionaryValue* test_info = new DictionaryValue; 33 DictionaryValue* test_info = new DictionaryValue;
34 test_info->SetString("test_case_name", tests[i].first); 34 test_info->SetString("test_case_name", tests[i].first);
35 test_info->SetString("test_name", tests[i].second); 35 test_info->SetString("test_name", tests[i].second);
36 root.Append(test_info); 36 root.Append(test_info);
37 } 37 }
38 38
39 JSONFileValueSerializer serializer(path); 39 JSONFileValueSerializer serializer(path);
40 return serializer.Serialize(root); 40 return serializer.Serialize(root);
41 } 41 }
42 42
43 bool ReadTestNamesFromFile(const FilePath& path,
44 std::vector<SplitTestName>* output) {
45 JSONFileValueSerializer deserializer(path);
46 int error_code = 0;
47 std::string error_message;
48 scoped_ptr<base::Value> value(
49 deserializer.Deserialize(&error_code, &error_message));
50 if (!value.get())
51 return false;
52
53 base::ListValue* tests = nullptr;
54 if (!value->GetAsList(&tests))
55 return false;
56
57 std::vector<base::SplitTestName> result;
58 for (base::ListValue::iterator i = tests->begin(); i != tests->end(); ++i) {
59 base::DictionaryValue* test = nullptr;
60 if (!(*i)->GetAsDictionary(&test))
61 return false;
62
63 std::string test_case_name;
64 if (!test->GetStringASCII("test_case_name", &test_case_name))
65 return false;
66
67 std::string test_name;
68 if (!test->GetStringASCII("test_name", &test_name))
69 return false;
70
71 result.push_back(std::make_pair(test_case_name, test_name));
72 }
73
74 output->swap(result);
75 return true;
76 }
77
43 } // namespace 78 } // namespace
OLDNEW
« no previous file with comments | « base/test/gtest_util.h ('k') | base/test/launcher/test_launcher.h » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698