summaryrefslogtreecommitdiff
path: root/src/msvc6/testrunner/TestRunnerModel.h
blob: ed1238077cd2c0cac89087cc77fa1db16c5c4116 (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
79
80
81
82
83
84
85
86
87
// //////////////////////////////////////////////////////////////////////////
// Header file TestRunnerModel.h for class TestRunnerModel
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2001/04/26
// //////////////////////////////////////////////////////////////////////////
#ifndef TESTRUNNERMODEL_H
#define TESTRUNNERMODEL_H

#include <deque>
#include <cppunit/Test.h>


/*! \class TestRunnerModel
 * \brief This class represents a model for the test runner.
 */
class TestRunnerModel
{
public:
  static const CString settingKey;
  static const CString settingMainDialogKey;
  static const CString settingBrowseDialogKey;

  struct Settings
  {
    bool autorunOnLaunch;
    int  col_1; // 1st column width in list view
    int  col_2; // 2nd column width in list view
    int  col_3; // 3rd column width in list view
    int  col_4; // 4th column width in list view  
  };

  typedef std::deque<CPPUNIT_NS::Test *> History;

  /*! Constructs a TestRunnerModel object.
   */
  TestRunnerModel( CPPUNIT_NS::Test *rootTest );

  /*! Destructor.
   */
  virtual ~TestRunnerModel();

  virtual void setRootTest( CPPUNIT_NS::Test *rootTest );

  void loadSettings(Settings & s);
  void saveSettings(const Settings & s);

  const History &history() const;
  void selectHistoryTest( CPPUNIT_NS::Test *test );
  CPPUNIT_NS::Test *selectedTest() const;

  CPPUNIT_NS::Test *rootTest();

protected:
  void loadHistory();
  CString loadHistoryEntry( int idx );
  CPPUNIT_NS::Test *findTestByName( CString name ) const;
  CPPUNIT_NS::Test *findTestByNameFor( const CString &name, 
                                    CPPUNIT_NS::Test *test ) const;

  void saveHistoryEntry( int idx, 
                         CString testName );

  CString getHistoryEntryName( int idx ) const;

  static std::string toAnsiString( const CString &text );

private:
  /// Prevents the use of the copy constructor.
  TestRunnerModel( const TestRunnerModel &copy );

  /// Prevents the use of the copy operator.
  TestRunnerModel &operator =( const TestRunnerModel &copy );

protected:
  History m_history;

  CPPUNIT_NS::Test *m_rootTest;
};



// Inlines methods for TestRunnerModel:
// ------------------------------------



#endif  // TESTRUNNERMODEL_H