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

Unified Diff: base/test/gtest_util.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/gtest_util.h ('k') | base/test/launcher/test_launcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/gtest_util.cc
diff --git a/base/test/gtest_util.cc b/base/test/gtest_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..47fd6397fcc6d86d6eb3c39bc10ee013b0e835d3
--- /dev/null
+++ b/base/test/gtest_util.cc
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/gtest_util.h"
+
+#include "base/files/file_path.h"
+#include "base/json/json_file_value_serializer.h"
+#include "base/values.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+std::vector<SplitTestName> GetCompiledInTests() {
+ testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();
+
+ std::vector<SplitTestName> tests;
+ for (int i = 0; i < unit_test->total_test_case_count(); ++i) {
+ const testing::TestCase* test_case = unit_test->GetTestCase(i);
+ for (int j = 0; j < test_case->total_test_count(); ++j) {
+ const testing::TestInfo* test_info = test_case->GetTestInfo(j);
+ tests.push_back(std::make_pair(test_case->name(), test_info->name()));
+ }
+ }
+ return tests;
+}
+
+bool WriteCompiledInTestsToFile(const FilePath& path) {
+ std::vector<SplitTestName> tests(GetCompiledInTests());
+
+ ListValue root;
+ for (size_t i = 0; i < tests.size(); ++i) {
+ DictionaryValue* test_info = new DictionaryValue;
+ test_info->SetString("test_case_name", tests[i].first);
+ test_info->SetString("test_name", tests[i].second);
+ root.Append(test_info);
+ }
+
+ JSONFileValueSerializer serializer(path);
+ return serializer.Serialize(root);
+}
+
+} // namespace
« no previous file with comments | « base/test/gtest_util.h ('k') | base/test/launcher/test_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698