summaryrefslogtreecommitdiff
path: root/examples/ClockerPlugIn
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-20 20:54:36 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-20 20:54:36 +0000
commitf05089dffe81419786776b60bc2dc13d2a421a5c (patch)
tree8451a33146a505c999a28288fe4574e98f268238 /examples/ClockerPlugIn
parentc4995a9e022ed586cf4e3f166738dfe01bf51c16 (diff)
downloadcppunit-f05089dffe81419786776b60bc2dc13d2a421a5c.tar.gz
THANKS: updated
THANKS: updated * src/cppunit/DynamicLibraryManager.cpp: bugfix: did not pass library name to exception. * include/cppunit/TestPath.h: * src/cppunit/TestPath.cpp: changed into value object. * src/cppunit/BeosDynamicLibraryManager.cpp: integrated patch from Shibu Yoshiki for BeOS ('cuppa' project team). * src/DllPlugInTester/CommandLineParser.h: * src/DllPlugInTester/CommandLineParser.cpp: added. Command line parsing. * src/DllPlugInTester/DllPlugInTester.cpp: full command line support with parameters for plug-ins. * src/DllPlugInTester/makefile.am: * examples/simple/makefile.am: * examples/cppunittest/makefile.am: integrated Jeffrey Morgan patch, Unix side should be working again. * examples/ReadMe.txt: added. Brief description of each example. * examples/cppunittest/CppUnitTestPlugIn.cpp: * examples/cppunittest/CppUnitTestPlugIn.dsp: added. New project to build CppUnit's test suite as a test plug-in. * examples/cppunittest/CppUnitTestSuite.cpp: updated. Use new helper macros to create the test suite hierarchy. * examples/simple/simple_plugin.opt: added. Contains debug tab settings. * examples/ClockerPlugIn/ClockerListener.cpp: * examples/ClockerPlugIn/ClockerListener.h: * examples/ClockerPlugIn/Timer.cpp: * examples/ClockerPlugIn/Timer.h: * examples/ClockerPlugIn/WinNtTimer.cpp: * examples/ClockerPlugIn/WinNtTimer.h: * examples/ClockerPlugIn/ClockerPlugIn.cpp: * examples/ClockerPlugIn/ClockerPlugIn.dsp: added. test listener plug-in that times tests. * examples/DumperPlugIn/DumperListener.cpp: * examples/DumperPlugIn/DumperListener.h: * examples/DumperPlugIn/DumperPlugIn.cpp: * examples/DumperPlugIn/DumperPlugIn.dsp: added. test listener plug-in that dump the test tree.
Diffstat (limited to 'examples/ClockerPlugIn')
-rw-r--r--examples/ClockerPlugIn/ClockerListener.cpp192
-rw-r--r--examples/ClockerPlugIn/ClockerListener.h96
-rw-r--r--examples/ClockerPlugIn/ClockerPlugIn.cpp55
-rw-r--r--examples/ClockerPlugIn/ClockerPlugIn.dsp209
-rw-r--r--examples/ClockerPlugIn/Makefile.am4
-rw-r--r--examples/ClockerPlugIn/ReadMe.txt14
-rw-r--r--examples/ClockerPlugIn/Timer.cpp28
-rw-r--r--examples/ClockerPlugIn/Timer.h32
-rw-r--r--examples/ClockerPlugIn/WinNtTimer.cpp77
-rw-r--r--examples/ClockerPlugIn/WinNtTimer.h36
10 files changed, 743 insertions, 0 deletions
diff --git a/examples/ClockerPlugIn/ClockerListener.cpp b/examples/ClockerPlugIn/ClockerListener.cpp
new file mode 100644
index 0000000..fafbaf8
--- /dev/null
+++ b/examples/ClockerPlugIn/ClockerListener.cpp
@@ -0,0 +1,192 @@
+// //////////////////////////////////////////////////////////////////////////
+// Implementation file ClockerListener.cpp for class ClockerListener
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+#include <cppunit/Test.h>
+#include <iostream>
+#include "ClockerListener.h"
+#include <stdio.h>
+
+
+ClockerListener::ClockerListener( bool flatten )
+ : m_flatten( flatten )
+ , m_testCount( 0 )
+ , m_totalTestCaseTime( 0 )
+{
+}
+
+
+ClockerListener::~ClockerListener()
+{
+}
+
+
+void
+ClockerListener::startTestRun( CppUnit::Test *test,
+ CppUnit::TestResult *eventManager )
+{
+ m_tests.reserve( test->countTestCases() *2 );
+}
+
+
+void
+ClockerListener::startTest( CppUnit::Test *test )
+{
+ enterTest( test, false );
+ ++m_testCount;
+}
+
+
+void
+ClockerListener::endTest( CppUnit::Test *test )
+{
+ exitTest( test, false );
+}
+
+
+void
+ClockerListener::startSuite( CppUnit::Test *suite )
+{
+ enterTest( suite, true );
+}
+
+
+void
+ClockerListener::endSuite( CppUnit::Test *suite )
+{
+ exitTest( suite, true );
+}
+
+
+void
+ClockerListener::endTestRun( CppUnit::Test *test,
+ CppUnit::TestResult *eventManager )
+{
+ printStatistics();
+}
+
+
+void
+ClockerListener::enterTest( CppUnit::Test *test,
+ bool isSuite )
+{
+ m_currentPath.add( test );
+
+ int testIndex = m_tests.size();
+ if ( !m_testIndexes.empty() )
+ m_tests[ m_testIndexes.top() ].m_childIndexes.push_back( testIndex );
+ m_testIndexes.push( testIndex );
+
+ TestInfo info;
+ info.m_timer.start();
+ info.m_path = m_currentPath;
+ info.m_isSuite = isSuite;
+
+ m_tests.push_back( info );
+}
+
+
+void
+ClockerListener::exitTest( CppUnit::Test *test,
+ bool isSuite )
+{
+ m_tests[ m_testIndexes.top() ].m_timer.finish();
+ m_totalTestCaseTime += m_tests.back().m_timer.elapsedTime();
+
+ m_currentPath.up();
+ m_testIndexes.pop();
+}
+
+
+void
+ClockerListener::printStatistics() const
+{
+ printTest( m_tests[0], "" );
+ std::cout << std::endl;
+ std::cout << "Total elapsed time: ";
+ printTestTime( m_tests[0].m_timer.elapsedTime() );
+ std::cout << ", average test case time: ";
+ double average = 0;
+ if ( m_testCount > 0 )
+ average = m_totalTestCaseTime / m_testCount;
+ printTestTime( average );
+}
+
+
+void
+ClockerListener::printTest( const TestInfo &info,
+ const std::string &indentString ) const
+{
+ std::string indent = indentString;
+ const int indentLength = 3;
+
+ if ( !m_flatten )
+ printTestIndent( indentString, indentLength );
+
+ printTestTime( info.m_timer.elapsedTime() );
+
+ if ( m_flatten )
+ printFlattenedTestName( info );
+ else
+ printTestName( info );
+
+ std::cout << std::endl;
+
+ if ( info.m_childIndexes.empty() )
+ indent+= std::string( indentLength, ' ' );
+ else
+ indent+= "|" + std::string( indentLength -1, ' ' );
+
+ for ( int index =0; index < info.m_childIndexes.size(); ++index )
+ printTest( m_tests[ info.m_childIndexes[ index ] ], indent );
+}
+
+
+void
+ClockerListener::printTestIndent( const std::string &indent,
+ const int indentLength ) const
+{
+ if ( indent.empty() )
+ return;
+
+ std::cout << " ";
+ std::cout << indent.substr( 0, indent.length() - indentLength ) ;
+ std::cout << "+" << std::string( indentLength -1, '-' );
+}
+
+
+void
+ClockerListener::printTestTime( double elapsedSeconds ) const
+{
+ char buffer[320];
+ const char *format;
+ if ( elapsedSeconds < 1 )
+ format = "(%2.3fs) ";
+ else if ( elapsedSeconds < 10 )
+ format = "(%3.2fs) ";
+ else if (elapsedSeconds < 100 )
+ format = "(%4.1fs) ";
+ else
+ format = "(%5fs) ";
+
+ ::sprintf( buffer, format, elapsedSeconds );
+
+ std::cout << buffer;
+}
+
+
+void
+ClockerListener::printFlattenedTestName( const TestInfo &info ) const
+{
+ std::cout << info.m_path.toString();
+ if ( info.m_isSuite )
+ std::cout << "/";
+}
+
+
+void
+ClockerListener::printTestName( const TestInfo &info ) const
+{
+ std::cout << info.m_path.getChildTest()->getName();
+}
diff --git a/examples/ClockerPlugIn/ClockerListener.h b/examples/ClockerPlugIn/ClockerListener.h
new file mode 100644
index 0000000..b256380
--- /dev/null
+++ b/examples/ClockerPlugIn/ClockerListener.h
@@ -0,0 +1,96 @@
+// //////////////////////////////////////////////////////////////////////////
+// Header file ClockerListener.h for class ClockerListener
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+#ifndef CLOCKERLISTENER_H
+#define CLOCKERLISTENER_H
+
+#include <cppunit/TestListener.h>
+#include <cppunit/TestPath.h>
+#include <stack>
+#include <vector>
+
+#ifdef CLOCKER_USE_WINNTTIMER
+#include "WinNtTimer.h"
+typedef WinNtTimer Timer;
+#else
+#include "Timer.h"
+#endif
+
+/// TestListener that prints a flatten or hierarchical view of the test tree.
+class ClockerListener : public CppUnit::TestListener
+{
+public:
+ ClockerListener( bool flatten );
+
+ virtual ~ClockerListener();
+
+ void startTestRun( CppUnit::Test *test,
+ CppUnit::TestResult *eventManager );
+
+ void startTest( CppUnit::Test *test );
+
+ void endTest( CppUnit::Test *test );
+
+ void startSuite( CppUnit::Test *suite );
+
+ void endSuite( CppUnit::Test *suite );
+
+ void endTestRun( CppUnit::Test *test,
+ CppUnit::TestResult *eventManager );
+
+private:
+ struct TestInfo
+ {
+ CppUnit::TestPath m_path;
+ Timer m_timer;
+ bool m_isSuite;
+ std::vector<int> m_childIndexes;
+ };
+
+ void enterTest( CppUnit::Test *test,
+ bool isSuite );
+
+ void exitTest( CppUnit::Test *test,
+ bool isSuite );
+
+ void printStatistics() const;
+
+ void printTest( const TestInfo &info,
+ const std::string &indentString ) const;
+
+ void printTestIndent( const std::string &indent,
+ const int indentLength ) const;
+
+ void printTestTime( double elapsedSeconds ) const;
+
+ void printFlattenedTestName( const TestInfo &info ) const;
+
+ void printTestName( const TestInfo &info ) const;
+
+ /// Prevents the use of the copy constructor.
+ ClockerListener( const ClockerListener &other );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const ClockerListener &other );
+
+private:
+ bool m_flatten;
+ CppUnit::TestPath m_currentPath;
+
+ int m_testCount;
+ double m_totalTestCaseTime;
+
+ std::stack<int> m_testIndexes;
+ std::vector<TestInfo> m_tests;
+};
+
+
+
+// Inlines methods for ClockerListener:
+// -----------------------------------
+
+
+
+#endif // CLOCKERLISTENER_H
diff --git a/examples/ClockerPlugIn/ClockerPlugIn.cpp b/examples/ClockerPlugIn/ClockerPlugIn.cpp
new file mode 100644
index 0000000..8943629
--- /dev/null
+++ b/examples/ClockerPlugIn/ClockerPlugIn.cpp
@@ -0,0 +1,55 @@
+#include <cppunit/TestResult.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include "ClockerListener.h"
+
+
+
+class ClockerPlugIn : public CppUnitTestPlugIn
+{
+public:
+ ClockerPlugIn()
+ : m_dumper( NULL )
+ {
+ }
+
+ ~ClockerPlugIn()
+ {
+ delete m_dumper;
+ }
+
+
+ void initialize( CppUnit::TestFactoryRegistry *registry,
+ const CppUnit::Parameters &parameters )
+ {
+ bool flatten = false;
+ if ( parameters.size() > 0 && parameters[0] == "flat" )
+ flatten = true;
+
+ m_dumper = new ClockerListener( flatten );
+ }
+
+
+ void addListener( CppUnit::TestResult *eventManager )
+ {
+ eventManager->addListener( m_dumper );
+ }
+
+
+ void removeListener( CppUnit::TestResult *eventManager )
+ {
+ eventManager->removeListener( m_dumper );
+ }
+
+
+ void uninitialize( CppUnit::TestFactoryRegistry *registry )
+ {
+ }
+
+private:
+ ClockerListener *m_dumper;
+};
+
+
+CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( ClockerPlugIn );
+
+CPPUNIT_TESTPLUGIN_MAIN(); \ No newline at end of file
diff --git a/examples/ClockerPlugIn/ClockerPlugIn.dsp b/examples/ClockerPlugIn/ClockerPlugIn.dsp
new file mode 100644
index 0000000..98e206a
--- /dev/null
+++ b/examples/ClockerPlugIn/ClockerPlugIn.dsp
@@ -0,0 +1,209 @@
+# Microsoft Developer Studio Project File - Name="ClockerPlugIn" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=ClockerPlugIn - Win32 Debug NtTimer
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ClockerPlugIn.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ClockerPlugIn.mak" CFG="ClockerPlugIn - Win32 Debug NtTimer"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ClockerPlugIn - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ClockerPlugIn - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ClockerPlugIn - Win32 Debug NtTimer" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CLOCKERPLUGIN_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40c /d "NDEBUG"
+# ADD RSC /l 0x40c /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunit_dll.lib /nologo /dll /machine:I386 /out:"../../lib/ClockerPlugIn.dll" /libpath:"../../lib/"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CLOCKERPLUGIN_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x40c /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInd.dll" /pdbtype:sept /libpath:"../../lib/"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug NtTimer"
+# PROP BASE Intermediate_Dir "Debug NtTimer"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugNtTimer"
+# PROP Intermediate_Dir "DebugNtTimer"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /D "CLOCKER_USE_WINNTTIMER" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x40c /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInd.dll" /pdbtype:sept /libpath:"../../lib/"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInNtd.dll" /pdbtype:sept /libpath:"../../lib/"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ClockerPlugIn - Win32 Release"
+# Name "ClockerPlugIn - Win32 Debug"
+# Name "ClockerPlugIn - Win32 Debug NtTimer"
+# Begin Source File
+
+SOURCE=.\ClockerListener.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClockerListener.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClockerPlugIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Makefile.am
+# End Source File
+# Begin Source File
+
+SOURCE=.\Timer.cpp
+
+!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Timer.h
+
+!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\WinNtTimer.cpp
+
+!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
+
+# PROP BASE Exclude_From_Build 1
+# PROP Intermediate_Dir "DebugNtTimer"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\WinNtTimer.h
+
+!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
+
+# PROP BASE Exclude_From_Build 1
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/examples/ClockerPlugIn/Makefile.am b/examples/ClockerPlugIn/Makefile.am
new file mode 100644
index 0000000..2d828c4
--- /dev/null
+++ b/examples/ClockerPlugIn/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = WinNtTimer.h Timer.h ClockerListener.h \
+ Timer.cpp ClockerListener.cpp WinNtTimer.cpp \
+ ClockerPlugIn.cpp ClockerPlugIn.dsp
+
diff --git a/examples/ClockerPlugIn/ReadMe.txt b/examples/ClockerPlugIn/ReadMe.txt
new file mode 100644
index 0000000..6893fc6
--- /dev/null
+++ b/examples/ClockerPlugIn/ReadMe.txt
@@ -0,0 +1,14 @@
+A plug-ins that track tests and test suites running time. A demonstration of TestListener and
+test plug-in.
+
+Don't use this to profile your application, use a Profiler.
+
+Usage:
+
+The plug-in accept the option "flat" to generate a flattened view of the test tree.
+
+DllPlugInRunnerd.exe ClockerPlugInd.dll
+or
+DllPlugInRunnerd.exe ClockerPlugInd.dll=flat
+
+
diff --git a/examples/ClockerPlugIn/Timer.cpp b/examples/ClockerPlugIn/Timer.cpp
new file mode 100644
index 0000000..6719817
--- /dev/null
+++ b/examples/ClockerPlugIn/Timer.cpp
@@ -0,0 +1,28 @@
+// //////////////////////////////////////////////////////////////////////////
+// Implementation file Timer.cpp for class Timer
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+
+#include "Timer.h"
+
+
+void
+Timer::start()
+{
+ m_beginTime = clock();
+}
+
+
+void
+Timer::finish()
+{
+ m_elapsedTime = double(clock() - m_beginTime) / CLOCKS_PER_SEC;
+}
+
+
+double
+Timer::elapsedTime() const
+{
+ return m_elapsedTime;
+}
diff --git a/examples/ClockerPlugIn/Timer.h b/examples/ClockerPlugIn/Timer.h
new file mode 100644
index 0000000..e2b3449
--- /dev/null
+++ b/examples/ClockerPlugIn/Timer.h
@@ -0,0 +1,32 @@
+// //////////////////////////////////////////////////////////////////////////
+// Header file Timer.h for class Timer
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+#ifndef TIMER_H
+#define TIMER_H
+
+#include <time.h>
+
+/// A Timer.
+class Timer
+{
+public:
+ void start();
+ void finish();
+
+ double elapsedTime() const;
+
+private:
+ clock_t m_beginTime;
+ double m_elapsedTime;
+};
+
+
+
+// Inlines methods for Timer:
+// --------------------------
+
+
+
+#endif // TIMER_H
diff --git a/examples/ClockerPlugIn/WinNtTimer.cpp b/examples/ClockerPlugIn/WinNtTimer.cpp
new file mode 100644
index 0000000..87546a2
--- /dev/null
+++ b/examples/ClockerPlugIn/WinNtTimer.cpp
@@ -0,0 +1,77 @@
+// //////////////////////////////////////////////////////////////////////////
+// Implementation file WinNtTimer.cpp for class WinNtTimer
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+
+#include "WinNtTimer.h"
+
+
+/*! Returns time spent in the thread.
+ * @param rquadTime Receive the time spent in the thread (user+kernel time)
+ * in unit of 100 nano-seconds.
+ * In pratice, the effective resolution is 10ms !!!
+ *
+ * @return \c true if sucess, \c false otherwise.
+ */
+static bool
+GetThreadSpentTime( LONGLONG &rquadTime )
+{
+ FILETIME timeCreation;
+ FILETIME timeExit;
+ FILETIME timeKernel;
+ FILETIME timeUser;
+ if ( !::GetThreadTimes( ::GetCurrentThread(),
+ &timeCreation,
+ &timeExit,
+ &timeKernel,
+ &timeUser) )
+ {
+ rquadTime = 0;
+ return false;
+ }
+
+ LARGE_INTEGER lintKernel;
+ lintKernel.LowPart = timeKernel.dwLowDateTime;
+ lintKernel.HighPart = timeKernel.dwHighDateTime;
+
+ LARGE_INTEGER lintUser;
+ lintUser.LowPart = timeUser.dwLowDateTime;
+ lintUser.HighPart = timeUser.dwHighDateTime;
+
+ rquadTime = lintKernel.QuadPart + lintUser.QuadPart;
+
+ return true;
+}
+
+
+
+void
+WinNtTimer::start()
+{
+ m_isValid = GetThreadSpentTime( m_beginTime );
+
+}
+
+
+void
+WinNtTimer::finish()
+{
+ LONGLONG quadTimeEnd;
+ LONGLONG quadProcessedElapse;
+ m_isValid = m_isValid && GetThreadSpentTime( quadTimeEnd );
+ if ( m_isValid )
+ {
+ quadProcessedElapse = quadTimeEnd - m_beginTime;
+ m_elapsedTime = double(quadProcessedElapse) / 10000000;
+ }
+ else
+ m_elapsedTime = -1;
+}
+
+
+double
+WinNtTimer::elapsedTime() const
+{
+ return m_elapsedTime;
+}
diff --git a/examples/ClockerPlugIn/WinNtTimer.h b/examples/ClockerPlugIn/WinNtTimer.h
new file mode 100644
index 0000000..fa871b9
--- /dev/null
+++ b/examples/ClockerPlugIn/WinNtTimer.h
@@ -0,0 +1,36 @@
+// //////////////////////////////////////////////////////////////////////////
+// Header file WinNtTimer.h for class WinNtTimer
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2002/04/19
+// //////////////////////////////////////////////////////////////////////////
+#ifndef WINNTTIMER_H
+#define WINNTTIMER_H
+
+#include <windows.h>
+#include <winnt.h>
+#include <winbase.h>
+
+
+/// A Timer.
+class WinNtTimer
+{
+public:
+ void start();
+ void finish();
+
+ double elapsedTime() const;
+
+private:
+ LONGLONG m_beginTime;
+ double m_elapsedTime;
+ bool m_isValid;
+};
+
+
+
+// Inlines methods for Timer:
+// --------------------------
+
+
+
+#endif // WINNTTIMER_H