~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/include/cppunit/XmlOutputter.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H
 
2
#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H
 
3
 
 
4
#include <cppunit/Portability.h>
 
5
 
 
6
#if CPPUNIT_NEED_DLL_DECL
 
7
#pragma warning( push )
 
8
#pragma warning( disable: 4251 )  // X needs to have dll-interface to be used by clients of class Z
 
9
#endif
 
10
 
 
11
#include <cppunit/Outputter.h>
 
12
#include <cppunit/portability/CppUnitDeque.h>
 
13
#include <cppunit/portability/CppUnitMap.h>
 
14
#include <iostream>
 
15
 
 
16
 
 
17
CPPUNIT_NS_BEGIN
 
18
 
 
19
 
 
20
class Test;
 
21
class TestFailure;
 
22
class TestResultCollector;
 
23
class XmlDocument;
 
24
class XmlElement;
 
25
class XmlOutputterHook;
 
26
 
 
27
 
 
28
/*! \brief Outputs a TestResultCollector in XML format.
 
29
 * \ingroup WritingTestResult
 
30
 *
 
31
 * Save the test result as a XML stream. 
 
32
 *
 
33
 * Additional datas can be added to the XML document using XmlOutputterHook. 
 
34
 * Hook are not owned by the XmlOutputter. They should be valid until 
 
35
 * destruction of the XmlOutputter. They can be removed with removeHook().
 
36
 *
 
37
 * \see XmlDocument, XmlElement, XmlOutputterHook.
 
38
 */
 
39
class CPPUNIT_API XmlOutputter : public Outputter
 
40
{
 
41
public:
 
42
  /*! \brief Constructs a XmlOutputter object.
 
43
   * \param result Result of the test run.
 
44
   * \param stream Stream used to output the XML output.
 
45
   * \param encoding Encoding used in the XML file (default is Latin-1). 
 
46
   */
 
47
  XmlOutputter( TestResultCollector *result,
 
48
                std::ostream &stream,
 
49
                std::string encoding = std::string("ISO-8859-1") );
 
50
 
 
51
  /// Destructor.
 
52
  virtual ~XmlOutputter();
 
53
 
 
54
  /*! \brief Adds the specified hook to the outputter.
 
55
   * \param hook Hook to add. Must not be \c NULL.
 
56
   */
 
57
  virtual void addHook( XmlOutputterHook *hook );
 
58
 
 
59
  /*! \brief Removes the specified hook from the outputter.
 
60
   * \param hook Hook to remove.
 
61
   */
 
62
  virtual void removeHook( XmlOutputterHook *hook );
 
63
 
 
64
  /*! \brief Writes the specified result as an XML document to the stream.
 
65
   *
 
66
   * Refer to examples/cppunittest/XmlOutputterTest.cpp for example
 
67
   * of use and XML document structure.
 
68
   */
 
69
  virtual void write();
 
70
 
 
71
  /*! \brief Sets the XSL style sheet used.
 
72
   *
 
73
   * \param styleSheet Name of the style sheet used. If empty, then no style sheet
 
74
   *                   is used (default).
 
75
   */
 
76
  virtual void setStyleSheet( const std::string &styleSheet );
 
77
 
 
78
 
 
79
  typedef CppUnitMap<Test *,TestFailure*, std::less<Test*> > FailedTests;
 
80
 
 
81
  /*! \brief Sets the root element and adds its children.
 
82
   *
 
83
   * Set the root element of the XML Document and add its child elements.
 
84
   *
 
85
   * For all hooks, call beginDocument() just after creating the root element (it
 
86
   * is empty at this time), and endDocument() once all the datas have been added
 
87
   * to the root element.
 
88
   */
 
89
  virtual void setRootNode();
 
90
 
 
91
  virtual void addFailedTests( FailedTests &failedTests,
 
92
                               XmlElement *rootNode );
 
93
 
 
94
  virtual void addSuccessfulTests( FailedTests &failedTests,
 
95
                                   XmlElement *rootNode );
 
96
 
 
97
  /*! \brief Adds the statics element to the root node.
 
98
   * 
 
99
   * Creates a new element containing statistics data and adds it to the root element.
 
100
   * Then, for all hooks, call statisticsAdded().
 
101
   * \param rootNode Root element.
 
102
   */
 
103
  virtual void addStatistics( XmlElement *rootNode );
 
104
 
 
105
  /*! \brief Adds a failed test to the failed tests node.
 
106
   * Creates a new element containing datas about the failed test, and adds it to 
 
107
   * the failed tests element.
 
108
   * Then, for all hooks, call failTestAdded().
 
109
   */
 
110
  virtual void addFailedTest( Test *test,
 
111
                              TestFailure *failure,
 
112
                              int testNumber,
 
113
                              XmlElement *testsNode );
 
114
 
 
115
  virtual void addFailureLocation( TestFailure *failure,
 
116
                                   XmlElement *testElement );
 
117
 
 
118
 
 
119
  /*! \brief Adds a successful test to the successful tests node.
 
120
   * Creates a new element containing datas about the successful test, and adds it to 
 
121
   * the successful tests element.
 
122
   * Then, for all hooks, call successfulTestAdded().
 
123
   */
 
124
  virtual void addSuccessfulTest( Test *test, 
 
125
                                  int testNumber,
 
126
                                  XmlElement *testsNode );
 
127
protected:
 
128
  virtual void fillFailedTestsMap( FailedTests &failedTests );
 
129
 
 
130
protected:
 
131
  typedef CppUnitDeque<XmlOutputterHook *> Hooks;
 
132
 
 
133
  TestResultCollector *m_result;
 
134
  std::ostream &m_stream;
 
135
  std::string m_encoding;
 
136
  std::string m_styleSheet;
 
137
  XmlDocument *m_xml;
 
138
  Hooks m_hooks;
 
139
 
 
140
private:
 
141
  /// Prevents the use of the copy constructor.
 
142
  XmlOutputter( const XmlOutputter &copy );
 
143
 
 
144
  /// Prevents the use of the copy operator.
 
145
  void operator =( const XmlOutputter &copy );
 
146
 
 
147
private:
 
148
};
 
149
 
 
150
 
 
151
CPPUNIT_NS_END
 
152
 
 
153
#if CPPUNIT_NEED_DLL_DECL
 
154
#pragma warning( pop )
 
155
#endif
 
156
 
 
157
 
 
158
#endif  // CPPUNIT_XMLTESTRESULTOUTPUTTER_H