From 73a038f1eaa268cec330d971fb550befec6f7798 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Fri, 14 Jun 2002 19:21:01 +0000 Subject: 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. --- examples/ClockerPlugIn/ClockerPlugIn.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'examples/ClockerPlugIn/ClockerPlugIn.cpp') diff --git a/examples/ClockerPlugIn/ClockerPlugIn.cpp b/examples/ClockerPlugIn/ClockerPlugIn.cpp index 8943629..dbdd672 100644 --- a/examples/ClockerPlugIn/ClockerPlugIn.cpp +++ b/examples/ClockerPlugIn/ClockerPlugIn.cpp @@ -1,6 +1,9 @@ #include +#include #include +#include "ClockerXmlHook.h" #include "ClockerListener.h" +#include "ClockerModel.h" @@ -9,23 +12,29 @@ class ClockerPlugIn : public CppUnitTestPlugIn public: ClockerPlugIn() : m_dumper( NULL ) + , m_model( NULL ) + , m_xmlHook( NULL ) { } ~ClockerPlugIn() { delete m_dumper; + delete m_model; + delete m_xmlHook; } void initialize( CppUnit::TestFactoryRegistry *registry, const CppUnit::Parameters ¶meters ) { - bool flatten = false; - if ( parameters.size() > 0 && parameters[0] == "flat" ) - flatten = true; + bool text = false; + if ( parameters.size() > 0 && parameters[0] == "text" ) + text = true; - m_dumper = new ClockerListener( flatten ); + m_model = new ClockerModel(); + m_dumper = new ClockerListener( m_model, text ); + m_xmlHook = new ClockerXmlHook( m_model ); } @@ -41,12 +50,25 @@ public: } + void addXmlOutputterHooks( CppUnit::XmlOutputter *outputter ) + { + outputter->addHook( m_xmlHook ); + } + + + void removeXmlOutputterHooks() + { + } + + void uninitialize( CppUnit::TestFactoryRegistry *registry ) { } private: ClockerListener *m_dumper; + ClockerModel *m_model; + ClockerXmlHook *m_xmlHook; }; -- cgit v1.2.1