My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
CxxTest::QtGui Class Reference

#include <QtGui.h>

Public Member Functions

void enterGui (int &argc, char **argv)
 
void enterWorld (const WorldDescription &wd)
 
void guiEnterSuite (const char *suiteName)
 
void guiEnterTest (const char *suiteName, const char *testName)
 
void yellowBar ()
 
void redBar ()
 
void leaveGui ()
 
- Public Member Functions inherited from CxxTest::GuiListener
 GuiListener ()
 
virtual ~GuiListener ()
 
virtual void runGui (int &argc, char **argv, TestListener &listener)
 
virtual void enterGui (int &, char **)
 
virtual void leaveGui ()
 
virtual void guiEnterWorld (unsigned)
 
virtual void guiEnterSuite (const char *)
 
virtual void guiEnterTest (const char *, const char *)
 
virtual void yellowBar ()
 
virtual void redBar ()
 
void enterWorld (const WorldDescription &d)
 
void enterSuite (const SuiteDescription &d)
 
void enterTest (const TestDescription &d)
 
void leaveTest (const TestDescription &)
 
void leaveSuite (const SuiteDescription &)
 
void leaveWorld (const WorldDescription &)
 
void warning (const char *, unsigned, const char *)
 
void failedTest (const char *, unsigned, const char *)
 
void failedAssert (const char *, unsigned, const char *)
 
void failedAssertEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
void failedAssertSameData (const char *, unsigned, const char *, const char *, const char *, const void *, const void *, unsigned)
 
void failedAssertDelta (const char *, unsigned, const char *, const char *, const char *, const char *, const char *, const char *)
 
void failedAssertDiffers (const char *, unsigned, const char *, const char *, const char *)
 
void failedAssertLessThan (const char *, unsigned, const char *, const char *, const char *, const char *)
 
void failedAssertLessThanEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
void failedAssertPredicate (const char *, unsigned, const char *, const char *, const char *)
 
void failedAssertRelation (const char *, unsigned, const char *, const char *, const char *, const char *, const char *)
 
void failedAssertThrows (const char *, unsigned, const char *, const char *, bool)
 
void failedAssertThrowsNot (const char *, unsigned, const char *)
 
- Public Member Functions inherited from CxxTest::TestListener
 TestListener ()
 
virtual ~TestListener ()
 
virtual void enterWorld (const WorldDescription &)
 
virtual void enterSuite (const SuiteDescription &)
 
virtual void enterTest (const TestDescription &)
 
virtual void trace (const char *, unsigned, const char *)
 
virtual void warning (const char *, unsigned, const char *)
 
virtual void failedTest (const char *, unsigned, const char *)
 
virtual void failedAssert (const char *, unsigned, const char *)
 
virtual void failedAssertEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertSameData (const char *, unsigned, const char *, const char *, const char *, const void *, const void *, unsigned)
 
virtual void failedAssertDelta (const char *, unsigned, const char *, const char *, const char *, const char *, const char *, const char *)
 
virtual void failedAssertDiffers (const char *, unsigned, const char *, const char *, const char *)
 
virtual void failedAssertLessThan (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertLessThanEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertPredicate (const char *, unsigned, const char *, const char *, const char *)
 
virtual void failedAssertRelation (const char *, unsigned, const char *, const char *, const char *, const char *, const char *)
 
virtual void failedAssertThrows (const char *, unsigned, const char *, const char *, bool)
 
virtual void failedAssertThrowsNot (const char *, unsigned, const char *)
 
virtual void leaveTest (const TestDescription &)
 
virtual void leaveSuite (const SuiteDescription &)
 
virtual void leaveWorld (const WorldDescription &)
 

Private Member Functions

void parseCommandLine (int argc, char **argv)
 
void createApplication (int &argc, char **argv)
 
void createWindow (const WorldDescription &wd)
 
void getTotalTests ()
 
void getTotalTests (const WorldDescription &wd)
 
void createMainWindow ()
 
void createProgressBar ()
 
void createStatusBar ()
 
void setMainWidget ()
 
void showMinimized ()
 
void showNormal ()
 
void setCaption (const QString &suiteName, const QString &testName)
 
void showSuiteName (const QString &suiteName)
 
void advanceProgressBar ()
 
void showTestName (const QString &testName)
 
void showTestsDone (unsigned testsDone)
 
void setColor (int r, int g, int b)
 
void setIcon (QMessageBox::Icon icon)
 
void processEvents ()
 
void centerWindow ()
 
bool keep ()
 
void showSummary ()
 

Static Private Member Functions

static QString asString (unsigned n)
 

Private Attributes

QString _title
 
bool _startMinimized
 
bool _keep
 
unsigned _numTotalTests
 
QString _strTotalTests
 
QApplication * _application
 
QWidget * _mainWindow
 
QVBoxLayout * _layout
 
QProgressBar * _progressBar
 
QStatusBar * _statusBar
 
QLabel * _suiteName
 
QLabel * _testName
 
QLabel * _testsDone
 

Additional Inherited Members

- Protected Member Functions inherited from CxxTest::GuiListener
void yellowBarSafe ()
 
void redBarSafe ()
 

Detailed Description

Definition at line 30 of file QtGui.h.

Member Function Documentation

◆ advanceProgressBar()

void CxxTest::QtGui::advanceProgressBar ( )
inlineprivate

Definition at line 193 of file QtGui.h.

194 {
195 _progressBar->setProgress( _progressBar->progress() + 1 );
196 }
QProgressBar * _progressBar
Definition: QtGui.h:95

◆ asString()

static QString CxxTest::QtGui::asString ( unsigned  n)
inlinestaticprivate

Definition at line 208 of file QtGui.h.

209 {
210 return QString::number( n );
211 }

◆ centerWindow()

void CxxTest::QtGui::centerWindow ( )
inlineprivate

Definition at line 234 of file QtGui.h.

235 {
236 QWidget *desktop = QApplication::desktop();
237 int xCenter = desktop->x() + (desktop->width() / 2);
238 int yCenter = desktop->y() + (desktop->height() / 2);
239
240 int windowWidth = (desktop->width() * 4) / 5;
241 int windowHeight = _mainWindow->height();
242 _mainWindow->setGeometry( xCenter - (windowWidth / 2), yCenter - (windowHeight / 2), windowWidth, windowHeight );
243 }
QWidget * _mainWindow
Definition: QtGui.h:93

◆ createApplication()

void CxxTest::QtGui::createApplication ( int &  argc,
char **  argv 
)
inlineprivate

Definition at line 115 of file QtGui.h.

116 {
117 _application = new QApplication( argc, argv );
118 }
QApplication * _application
Definition: QtGui.h:92

◆ createMainWindow()

void CxxTest::QtGui::createMainWindow ( )
inlineprivate

Definition at line 145 of file QtGui.h.

146 {
147 _mainWindow = new QWidget();
148 _layout = new QVBoxLayout( _mainWindow );
149 }
QVBoxLayout * _layout
Definition: QtGui.h:94

◆ createProgressBar()

void CxxTest::QtGui::createProgressBar ( )
inlineprivate

Definition at line 151 of file QtGui.h.

152 {
153 _layout->addWidget( _progressBar = new QProgressBar( _numTotalTests, _mainWindow ) );
154 _progressBar->setProgress( 0 );
155 setColor( 0, 255, 0 );
156 setIcon( QMessageBox::Information );
157 }
unsigned _numTotalTests
Definition: QtGui.h:90
void setIcon(QMessageBox::Icon icon)
Definition: QtGui.h:220
void setColor(int r, int g, int b)
Definition: QtGui.h:213

◆ createStatusBar()

void CxxTest::QtGui::createStatusBar ( )
inlineprivate

Definition at line 159 of file QtGui.h.

160 {
161 _layout->addWidget( _statusBar = new QStatusBar( _mainWindow ) );
162 _statusBar->addWidget( _suiteName = new QLabel( _statusBar ), 2 );
163 _statusBar->addWidget( _testName = new QLabel( _statusBar ), 4 );
164 _statusBar->addWidget( _testsDone = new QLabel( _statusBar ), 1 );
165 }
QLabel * _testsDone
Definition: QtGui.h:97
QLabel * _suiteName
Definition: QtGui.h:97
QLabel * _testName
Definition: QtGui.h:97
QStatusBar * _statusBar
Definition: QtGui.h:96

◆ createWindow()

void CxxTest::QtGui::createWindow ( const WorldDescription wd)
inlineprivate

Definition at line 120 of file QtGui.h.

121 {
122 getTotalTests( wd );
127 if ( _startMinimized )
129 else
130 showNormal();
131 }
void showMinimized()
Definition: QtGui.h:172
bool _startMinimized
Definition: QtGui.h:89
void createStatusBar()
Definition: QtGui.h:159
void setMainWidget()
Definition: QtGui.h:167
void showNormal()
Definition: QtGui.h:177
void getTotalTests()
Definition: QtGui.h:133
void createProgressBar()
Definition: QtGui.h:151
void createMainWindow()
Definition: QtGui.h:145

◆ enterGui()

void CxxTest::QtGui::enterGui ( int &  argc,
char **  argv 
)
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 33 of file QtGui.h.

34 {
35 parseCommandLine( argc, argv );
36 createApplication( argc, argv );
37 }
void createApplication(int &argc, char **argv)
Definition: QtGui.h:115
void parseCommandLine(int argc, char **argv)
Definition: QtGui.h:99

◆ enterWorld()

void CxxTest::QtGui::enterWorld ( const WorldDescription wd)
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 39 of file QtGui.h.

40 {
41 createWindow( wd );
43 }
void processEvents()
Definition: QtGui.h:229
void createWindow(const WorldDescription &wd)
Definition: QtGui.h:120

◆ getTotalTests() [1/2]

void CxxTest::QtGui::getTotalTests ( )
inlineprivate

Definition at line 133 of file QtGui.h.

134 {
135 getTotalTests( tracker().world() );
136 }
TestTracker & tracker()
Definition: TestTracker.h:111

◆ getTotalTests() [2/2]

void CxxTest::QtGui::getTotalTests ( const WorldDescription wd)
inlineprivate

Definition at line 138 of file QtGui.h.

139 {
140 _numTotalTests = wd.numTotalTests();
142 _strTotalTests = wd.strTotalTests( s );
143 }
QString _strTotalTests
Definition: QtGui.h:91
char * s
Definition: ValueTraits.h:143

◆ guiEnterSuite()

void CxxTest::QtGui::guiEnterSuite ( const char *  suiteName)
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 45 of file QtGui.h.

46 {
47 showSuiteName( suiteName );
48 }
void showSuiteName(const QString &suiteName)
Definition: QtGui.h:188

◆ guiEnterTest()

void CxxTest::QtGui::guiEnterTest ( const char *  suiteName,
const char *  testName 
)
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 50 of file QtGui.h.

51 {
52 setCaption( suiteName, testName );
54 showTestName( testName );
55 showTestsDone( _progressBar->progress() );
57 }
void showTestsDone(unsigned testsDone)
Definition: QtGui.h:203
void setCaption(const QString &suiteName, const QString &testName)
Definition: QtGui.h:183
void advanceProgressBar()
Definition: QtGui.h:193
void showTestName(const QString &testName)
Definition: QtGui.h:198

◆ keep()

bool CxxTest::QtGui::keep ( )
inlineprivate

Definition at line 245 of file QtGui.h.

246 {
247 if ( !_keep )
248 return false;
249 if ( !_startMinimized )
250 return true;
251 return (_mainWindow == _application->activeWindow());
252 }
bool _keep
Definition: QtGui.h:89

◆ leaveGui()

void CxxTest::QtGui::leaveGui ( )
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 77 of file QtGui.h.

78 {
79 if ( keep() ) {
81 _application->exec();
82 }
83 else
84 _mainWindow->close( true );
85 }
void showSummary()
Definition: QtGui.h:254
bool keep()
Definition: QtGui.h:245

◆ parseCommandLine()

void CxxTest::QtGui::parseCommandLine ( int  argc,
char **  argv 
)
inlineprivate

Definition at line 99 of file QtGui.h.

100 {
101 _startMinimized = _keep = false;
102 _title = argv[0];
103
104 for ( int i = 1; i < argc; ++ i ) {
105 QString arg( argv[i] );
106 if ( arg == "-minimized" )
107 _startMinimized = true;
108 else if ( arg == "-keep" )
109 _keep = true;
110 else if ( arg == "-title" && (i + 1 < argc) )
111 _title = argv[++i];
112 }
113 }
int i
Definition: cfEzgcd.cc:132
QString _title
Definition: QtGui.h:88

◆ processEvents()

void CxxTest::QtGui::processEvents ( )
inlineprivate

Definition at line 229 of file QtGui.h.

230 {
231 _application->processEvents();
232 }

◆ redBar()

void CxxTest::QtGui::redBar ( )
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 67 of file QtGui.h.

68 {
69 if ( _startMinimized && _mainWindow->isMinimized() )
70 showNormal();
71 setColor( 255, 0, 0 );
72 setIcon( QMessageBox::Critical );
75 }

◆ setCaption()

void CxxTest::QtGui::setCaption ( const QString &  suiteName,
const QString &  testName 
)
inlineprivate

Definition at line 183 of file QtGui.h.

184 {
185 _mainWindow->setCaption( _title + " - " + suiteName + "::" + testName + "()" );
186 }

◆ setColor()

void CxxTest::QtGui::setColor ( int  r,
int  g,
int  b 
)
inlineprivate

Definition at line 213 of file QtGui.h.

214 {
215 QPalette palette = _progressBar->palette();
216 palette.setColor( QColorGroup::Highlight, QColor( r, g, b ) );
217 _progressBar->setPalette( palette );
218 }
g
Definition: cfModGcd.cc:4090
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ setIcon()

void CxxTest::QtGui::setIcon ( QMessageBox::Icon  icon)
inlineprivate

Definition at line 220 of file QtGui.h.

221 {
222#if QT_VERSION >= 0x030000
223 _mainWindow->setIcon( QMessageBox::standardIcon( icon ) );
224#else // Qt version < 3.0.0
225 _mainWindow->setIcon( QMessageBox::standardIcon( icon, QApplication::style().guiStyle() ) );
226#endif // QT_VERSION
227 }

◆ setMainWidget()

void CxxTest::QtGui::setMainWidget ( )
inlineprivate

Definition at line 167 of file QtGui.h.

168 {
169 _application->setMainWidget( _mainWindow );
170 }

◆ showMinimized()

void CxxTest::QtGui::showMinimized ( )
inlineprivate

Definition at line 172 of file QtGui.h.

173 {
174 _mainWindow->showMinimized();
175 }

◆ showNormal()

void CxxTest::QtGui::showNormal ( )
inlineprivate

Definition at line 177 of file QtGui.h.

178 {
179 _mainWindow->showNormal();
180 centerWindow();
181 }
void centerWindow()
Definition: QtGui.h:234

◆ showSuiteName()

void CxxTest::QtGui::showSuiteName ( const QString &  suiteName)
inlineprivate

Definition at line 188 of file QtGui.h.

189 {
190 _suiteName->setText( "class " + suiteName );
191 }

◆ showSummary()

void CxxTest::QtGui::showSummary ( )
inlineprivate

Definition at line 254 of file QtGui.h.

255 {
256 QString summary = _strTotalTests + (_numTotalTests == 1 ? " test" : " tests");
257 if ( tracker().failedTests() )
258 summary = "Failed " + asString( tracker().failedTests() ) + " of " + summary;
259 else
260 summary = summary + " passed";
261
262 _mainWindow->setCaption( _title + " - " + summary );
263
264 _statusBar->removeWidget( _suiteName );
265 _statusBar->removeWidget( _testName );
266 _testsDone->setText( summary );
267 }
static QString asString(unsigned n)
Definition: QtGui.h:208
unsigned failedTests() const
Definition: TestTracker.h:37

◆ showTestName()

void CxxTest::QtGui::showTestName ( const QString &  testName)
inlineprivate

Definition at line 198 of file QtGui.h.

199 {
200 _testName->setText( testName + "()" );
201 }

◆ showTestsDone()

void CxxTest::QtGui::showTestsDone ( unsigned  testsDone)
inlineprivate

Definition at line 203 of file QtGui.h.

204 {
205 _testsDone->setText( asString( testsDone ) + " of " + _strTotalTests );
206 }

◆ yellowBar()

void CxxTest::QtGui::yellowBar ( )
inlinevirtual

Reimplemented from CxxTest::GuiListener.

Definition at line 59 of file QtGui.h.

60 {
61 setColor( 255, 255, 0 );
62 setIcon( QMessageBox::Warning );
65 }

Field Documentation

◆ _application

QApplication* CxxTest::QtGui::_application
private

Definition at line 92 of file QtGui.h.

◆ _keep

bool CxxTest::QtGui::_keep
private

Definition at line 89 of file QtGui.h.

◆ _layout

QVBoxLayout* CxxTest::QtGui::_layout
private

Definition at line 94 of file QtGui.h.

◆ _mainWindow

QWidget* CxxTest::QtGui::_mainWindow
private

Definition at line 93 of file QtGui.h.

◆ _numTotalTests

unsigned CxxTest::QtGui::_numTotalTests
private

Definition at line 90 of file QtGui.h.

◆ _progressBar

QProgressBar* CxxTest::QtGui::_progressBar
private

Definition at line 95 of file QtGui.h.

◆ _startMinimized

bool CxxTest::QtGui::_startMinimized
private

Definition at line 89 of file QtGui.h.

◆ _statusBar

QStatusBar* CxxTest::QtGui::_statusBar
private

Definition at line 96 of file QtGui.h.

◆ _strTotalTests

QString CxxTest::QtGui::_strTotalTests
private

Definition at line 91 of file QtGui.h.

◆ _suiteName

QLabel* CxxTest::QtGui::_suiteName
private

Definition at line 97 of file QtGui.h.

◆ _testName

QLabel * CxxTest::QtGui::_testName
private

Definition at line 97 of file QtGui.h.

◆ _testsDone

QLabel * CxxTest::QtGui::_testsDone
private

Definition at line 97 of file QtGui.h.

◆ _title

QString CxxTest::QtGui::_title
private

Definition at line 88 of file QtGui.h.


The documentation for this class was generated from the following file: