summaryrefslogtreecommitdiff
path: root/examples/ClockerPlugIn/ClockerPlugIn.cpp
blob: d170024fd12998c207557594acb0fc4f49045ef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <cppunit/config/SourcePrefix.h>  // disabled unwanted warning on vc++ 6.0
#include <cppunit/TestResult.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/plugin/TestPlugIn.h>
#include "ClockerXmlHook.h"
#include "ClockerListener.h"
#include "ClockerModel.h"



class ClockerPlugIn : public CppUnitTestPlugIn
{
public:
  ClockerPlugIn()
    : m_dumper( nullptr )
    , m_model( nullptr )
    , m_xmlHook( nullptr )
  {
  }

  ~ClockerPlugIn()
  {
    delete m_dumper;
    delete m_model;
    delete m_xmlHook;
  }


  void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
                   const CPPUNIT_NS::PlugInParameters &parameters )
  {
    bool text = false;
    if ( parameters.getCommandLine() == "text" )
      text = true;

    m_model = new ClockerModel();
    m_dumper = new ClockerListener( m_model, text );
    m_xmlHook = new ClockerXmlHook( m_model );
  }


  void addListener( CPPUNIT_NS::TestResult *eventManager )
  {
    eventManager->addListener( m_dumper );
  }


  void removeListener( CPPUNIT_NS::TestResult *eventManager )
  {
    eventManager->removeListener( m_dumper );
  }


  void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter )
  {
    outputter->addHook( m_xmlHook );
  }


  void removeXmlOutputterHooks()
  {
  }


  void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry )
  {
  }

private:
  ClockerListener *m_dumper;
  ClockerModel *m_model;
  ClockerXmlHook *m_xmlHook;
};


CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( ClockerPlugIn );

CPPUNIT_PLUGIN_IMPLEMENT_MAIN();