Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / base / test / gtest_xml_util.h
blob79527e5f94aaa6805964644082dbd0c1bfd96ae3
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
3 // found in the LICENSE file.
5 #ifndef BASE_TEST_GTEST_XML_UTIL_H_
6 #define BASE_TEST_GTEST_XML_UTIL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace base {
16 class FilePath;
17 struct TestResult;
19 // Generates an XML output file. Format is very close to GTest, but has
20 // extensions needed by the test launcher.
21 class XmlUnitTestResultPrinter : public testing::EmptyTestEventListener {
22 public:
23 XmlUnitTestResultPrinter();
24 virtual ~XmlUnitTestResultPrinter();
26 // Must be called before adding as a listener. Returns true on success.
27 bool Initialize(const FilePath& output_file_path) WARN_UNUSED_RESULT;
29 private:
30 // testing::EmptyTestEventListener:
31 virtual void OnTestCaseStart(const testing::TestCase& test_case) OVERRIDE;
32 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE;
33 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE;
34 virtual void OnTestCaseEnd(const testing::TestCase& test_case) OVERRIDE;
36 FILE* output_file_;
38 DISALLOW_COPY_AND_ASSIGN(XmlUnitTestResultPrinter);
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;
49 } // namespace base
51 #endif // BASE_TEST_GTEST_XML_UTIL_H_