summaryrefslogtreecommitdiff
path: root/examples/ClockerPlugIn/ClockerModel.h
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-14 19:21:01 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-06-14 19:21:01 +0000
commit73a038f1eaa268cec330d971fb550befec6f7798 (patch)
treec3eba5d793e37413889acad5b0b9f70caf89b0f6 /examples/ClockerPlugIn/ClockerModel.h
parentf39e160fba25476de7d41e2f19d756db7ee76dc7 (diff)
downloadcppunit-73a038f1eaa268cec330d971fb550befec6f7798.tar.gz
Include/cppunit/plugin/PlugInManager.
include/cppunit/plugin/PlugInManager.h: * src/cppunit/PlugInManager.cpp: added two methods to use the plug-in interface for Xml Outputter hooks. * include/cppunit/plugin/TestPlugIn.h: added two methods to the plug-in interface for Xml Outputter hooks. * include/cppunit/plugin/TestPlugInAdapter.h: * src/cppunit/plugin/TestPlugInAdapter.cpp: renamed TestPlugInDefaultImpl. Added empty implementation for Xml outputter hook methods. * include/cppunit/tools/StringTools.h: * src/cppunit/tools/StringTools.cpp: added. Functions to manipulate string (conversion, wrapping...) * include/cppunit/tools/XmlElement.h: * src/cppunit/XmlElement.cpp: renamed addNode() to addElement(). Added methods to walk and modify XmlElement (for hook). Added documentation. Use StringTools. * include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: added hook calls & management. * include/cppunit/XmlOutputterHook.h: * src/cppunit/XmlOutputterHook.cpp: added. Hook to customize XML output. * src/DllPlugInTester/DllPlugInTester.cpp: call plug-in XmlOutputterHook when writing XML output. Modified so that memory is freed before unloading the test plug-in (caused crash when freeing the XmlDocument). * examples/ReadMe.txt: * examples/ClockerPlugIn/ReadMe.txt: added details about the plug-in (usage, xml content...) * examples/ClockerPlugIn/ClockerModel.h: * examples/ClockerPlugIn/ClockerModel.cpp: extracted from ClockerListener. Represents the test hierarchy and tracked time for each test. * examples/ClockerPlugIn/ClockerListener.h: * examples/ClockerPlugIn/ClockerListener.cpp: extracted test hierarchy tracking to ClockerModel. Replaced the 'flat' view option with a 'text' option to print the timed test tree to stdout. * examples/ClockerPlugIn/ClockerPlugIn.cpp: updated to hook the XML output and use the new classes. * examples/ClockerPlugIn/ClockerXmlHook.h: * examples/ClockerPlugIn/ClockerXmlHook.cpp: added. XmlOutputterHook to includes the timed test hierarchy and test timing in the XML output. * examples/cppunittest/XmlElementTest.h: * examples/cppunittest/XmlElementTest.cpp: added new test cases. * examples/cppunittest/XmlOutputterTest.h: * examples/cppunittest/XmlOutputterTest.cpp: added tests for XmlOutputterHook.
Diffstat (limited to 'examples/ClockerPlugIn/ClockerModel.h')
-rw-r--r--examples/ClockerPlugIn/ClockerModel.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/examples/ClockerPlugIn/ClockerModel.h b/examples/ClockerPlugIn/ClockerModel.h
new file mode 100644
index 0000000..c61a4b7
--- /dev/null
+++ b/examples/ClockerPlugIn/ClockerModel.h
@@ -0,0 +1,95 @@
+// //////////////////////////////////////////////////////////////////////////
+// Header file ClockerModel.h for class ClockerModel
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/06/14
+// //////////////////////////////////////////////////////////////////////////
+#ifndef CLOCKERMODEL_H
+#define CLOCKERMODEL_H
+
+#include <cppunit/TestPath.h>
+#include <map>
+#include <stack>
+#include <string>
+#include <vector>
+
+#ifdef CLOCKER_USE_WINNTTIMER
+#include "WinNtTimer.h"
+typedef WinNtTimer Timer;
+#else
+#include "Timer.h"
+#endif
+
+
+/// Model that represents test timing.
+class ClockerModel
+{
+public:
+ /*! Constructs a ClockerModel object.
+ */
+ ClockerModel();
+
+ /// Destructor.
+ virtual ~ClockerModel();
+
+ void setExpectedTestCount( int count );
+
+ void enterTest( CppUnit::Test *test,
+ bool isSuite );
+
+ void exitTest( CppUnit::Test *test,
+ bool isSuite );
+
+ double totalElapsedTime() const;
+
+ double averageTestCaseTime() const;
+
+ double testTimeFor( CppUnit::Test *test ) const;
+
+ double testTimeFor( int testIndex ) const;
+
+ static std::string timeStringFor( double time );
+
+ bool isSuite( int testIndex ) const;
+
+ const CppUnit::TestPath &testPathFor( int testIndex ) const;
+
+ // -1 is none
+ int indexOf( CppUnit::Test *test ) const;
+
+ int childCountFor( int testIndex ) const;
+
+ int childAtFor( int testIndex,
+ int chidIndex ) const;
+
+private:
+ struct TestInfo
+ {
+ CppUnit::TestPath m_path;
+ Timer m_timer;
+ bool m_isSuite;
+ std::vector<int> m_childIndexes;
+ };
+
+ /// Prevents the use of the copy constructor.
+ ClockerModel( const ClockerModel &other );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const ClockerModel &other );
+
+private:
+ CppUnit::TestPath m_currentPath;
+
+ int m_testCaseCount;
+ double m_totalTestCaseTime;
+
+ typedef std::map<CppUnit::Test *, int> TestToIndexes;
+
+ TestToIndexes m_testToIndexes;
+ std::stack<int> m_testIndexes;
+ std::vector<TestInfo> m_tests;
+};
+
+
+
+
+#endif // CLOCKERMODEL_H