OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef BASE_TEST_GTEST_XML_UTIL_H_ | 5 #ifndef BASE_TEST_GTEST_XML_UNITTEST_RESULT_PRINTER_H_ |
6 #define BASE_TEST_GTEST_XML_UTIL_H_ | 6 #define BASE_TEST_GTEST_XML_UNITTEST_RESULT_PRINTER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <stdio.h> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 struct TestResult; | |
18 | 17 |
19 // Generates an XML output file. Format is very close to GTest, but has | 18 // Generates an XML output file. Format is very close to GTest, but has |
20 // extensions needed by the test launcher. | 19 // extensions needed by the test launcher. |
21 class XmlUnitTestResultPrinter : public testing::EmptyTestEventListener { | 20 class XmlUnitTestResultPrinter : public testing::EmptyTestEventListener { |
22 public: | 21 public: |
23 XmlUnitTestResultPrinter(); | 22 XmlUnitTestResultPrinter(); |
24 ~XmlUnitTestResultPrinter() override; | 23 ~XmlUnitTestResultPrinter() override; |
25 | 24 |
26 // Must be called before adding as a listener. Returns true on success. | 25 // Must be called before adding as a listener. Returns true on success. |
27 bool Initialize(const FilePath& output_file_path) WARN_UNUSED_RESULT; | 26 bool Initialize(const FilePath& output_file_path) WARN_UNUSED_RESULT; |
28 | 27 |
29 private: | 28 private: |
30 // testing::EmptyTestEventListener: | 29 // testing::EmptyTestEventListener: |
31 void OnTestCaseStart(const testing::TestCase& test_case) override; | 30 void OnTestCaseStart(const testing::TestCase& test_case) override; |
32 void OnTestStart(const testing::TestInfo& test_info) override; | 31 void OnTestStart(const testing::TestInfo& test_info) override; |
33 void OnTestEnd(const testing::TestInfo& test_info) override; | 32 void OnTestEnd(const testing::TestInfo& test_info) override; |
34 void OnTestCaseEnd(const testing::TestCase& test_case) override; | 33 void OnTestCaseEnd(const testing::TestCase& test_case) override; |
35 | 34 |
36 FILE* output_file_; | 35 FILE* output_file_; |
37 | 36 |
38 DISALLOW_COPY_AND_ASSIGN(XmlUnitTestResultPrinter); | 37 DISALLOW_COPY_AND_ASSIGN(XmlUnitTestResultPrinter); |
39 }; | 38 }; |
40 | 39 |
41 // Produces a vector of test results based on GTest output file. | |
42 // Returns true iff the output file exists and has been successfully parsed. | |
43 // On successful return |crashed| is set to true if the test results | |
44 // are valid but incomplete. | |
45 bool ProcessGTestOutput(const base::FilePath& output_file, | |
46 std::vector<TestResult>* results, | |
47 bool* crashed) WARN_UNUSED_RESULT; | |
48 | |
49 } // namespace base | 40 } // namespace base |
50 | 41 |
51 #endif // BASE_TEST_GTEST_XML_UTIL_H_ | 42 #endif // BASE_TEST_GTEST_XML_UNITTEST_RESULT_PRINTER_H_ |
OLD | NEW |