Loading...
Searching...
No Matches
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 | guiEnterWorld (unsigned)
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 | trace (const char *, unsigned, const char *)

## 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 | ( |  | ) |

inline private

Definition at line 193 of file QtGui.h.

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

## asString()

QString CxxTest::QtGui::asString | ( | unsigned | n | ) |

inline static private

Definition at line 208 of file QtGui.h.

{
return QString::number( n );
}

## centerWindow()

void CxxTest::QtGui::centerWindow | ( |  | ) |

inline private

Definition at line 234 of file QtGui.h.

{
QWidget *desktop = QApplication::desktop();
int xCenter = desktop->x() + (desktop->width() / 2);
int yCenter = desktop->y() + (desktop->height() / 2);
int windowWidth = (desktop->width() * 4) / 5;
int windowHeight = _mainWindow->height();
_mainWindow->setGeometry( xCenter - (windowWidth / 2), yCenter - (windowHeight / 2), windowWidth, windowHeight );
}
CxxTest::QtGui::_mainWindow
QWidget * _mainWindow
Definition QtGui.h:93

## createApplication()

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

inline private

Definition at line 115 of file QtGui.h.

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

## createMainWindow()

void CxxTest::QtGui::createMainWindow | ( |  | ) |

inline private

Definition at line 145 of file QtGui.h.

{
_mainWindow = new QWidget();
_layout = new QVBoxLayout( _mainWindow );
}
CxxTest::QtGui::_layout
QVBoxLayout * _layout
Definition QtGui.h:94

## createProgressBar()

void CxxTest::QtGui::createProgressBar | ( |  | ) |

inline private

Definition at line 151 of file QtGui.h.

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

## createStatusBar()

void CxxTest::QtGui::createStatusBar | ( |  | ) |

inline private

Definition at line 159 of file QtGui.h.

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

## createWindow()

void CxxTest::QtGui::createWindow | ( | const WorldDescription & | wd | ) |

inline private

Definition at line 120 of file QtGui.h.

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

## enterGui()

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

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 33 of file QtGui.h.

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

## enterWorld()

void CxxTest::QtGui::enterWorld | ( | const WorldDescription & | wd | ) |

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 39 of file QtGui.h.

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

## getTotalTests() [1/2]

void CxxTest::QtGui::getTotalTests | ( |  | ) |

inline private

Definition at line 133 of file QtGui.h.

{
getTotalTests( tracker().world() );
}
CxxTest::tracker
TestTracker & tracker()
Definition TestTracker.h:111

## getTotalTests() [2/2]

void CxxTest::QtGui::getTotalTests | ( | const WorldDescription & | wd | ) |

inline private

Definition at line 138 of file QtGui.h.

{
_numTotalTests = wd.numTotalTests();
char s[WorldDescription::MAX_STRLEN_TOTAL_TESTS];
_strTotalTests = wd.strTotalTests( s );
}
CxxTest::QtGui::_strTotalTests
QString _strTotalTests
Definition QtGui.h:91
CxxTest::WorldDescription::MAX_STRLEN_TOTAL_TESTS
@ MAX_STRLEN_TOTAL_TESTS
Definition Descriptions.h:62
CxxTest::s
char * s
Definition ValueTraits.h:143

## guiEnterSuite()

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

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 45 of file QtGui.h.

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

## guiEnterTest()

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

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 50 of file QtGui.h.

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

## keep()

bool CxxTest::QtGui::keep | ( |  | ) |

inline private

Definition at line 245 of file QtGui.h.

{
if ( !_keep )
return false;
if ( !_startMinimized )
return true;
return (_mainWindow == _application->activeWindow());
}
CxxTest::QtGui::_keep
bool _keep
Definition QtGui.h:89

## leaveGui()

void CxxTest::QtGui::leaveGui | ( |  | ) |

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 77 of file QtGui.h.

{
if ( keep() ) {
showSummary();
_application->exec();
}
else
_mainWindow->close( true );
}
CxxTest::QtGui::showSummary
void showSummary()
Definition QtGui.h:254
CxxTest::QtGui::keep
bool keep()
Definition QtGui.h:245

## parseCommandLine()

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

inline private

Definition at line 99 of file QtGui.h.

{
_startMinimized = _keep = false;
_title = argv[0];
for ( int i = 1; i < argc; ++ i ) {
QString arg( argv[i] );
if ( arg == "-minimized" )
_startMinimized = true;
else if ( arg == "-keep" )
_keep = true;
else if ( arg == "-title" && (i + 1 < argc) )
_title = argv[++i];
}
}
i
int i
Definition cfEzgcd.cc:132
CxxTest::QtGui::_title
QString _title
Definition QtGui.h:88

## processEvents()

void CxxTest::QtGui::processEvents | ( |  | ) |

inline private

Definition at line 229 of file QtGui.h.

{
_application->processEvents();
}

## redBar()

void CxxTest::QtGui::redBar | ( |  | ) |

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 67 of file QtGui.h.

{
if ( _startMinimized && _mainWindow->isMinimized() )
showNormal();
setColor( 255, 0, 0 );
setIcon( QMessageBox::Critical );
getTotalTests();
processEvents();
}

## setCaption()

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

inline private

Definition at line 183 of file QtGui.h.

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

## setColor()

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

inline private

Definition at line 213 of file QtGui.h.

{
QPalette palette = _progressBar->palette();
palette.setColor( QColorGroup::Highlight, QColor( r, g, b ) );
_progressBar->setPalette( palette );
}
g
g
Definition cfModGcd.cc:4098
b
CanonicalForm b
Definition cfModGcd.cc:4111

## setIcon()

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

inline private

Definition at line 220 of file QtGui.h.

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

## setMainWidget()

void CxxTest::QtGui::setMainWidget | ( |  | ) |

inline private

Definition at line 167 of file QtGui.h.

{
_application->setMainWidget( _mainWindow );
}

## showMinimized()

void CxxTest::QtGui::showMinimized | ( |  | ) |

inline private

Definition at line 172 of file QtGui.h.

{
_mainWindow->showMinimized();
}

## showNormal()

void CxxTest::QtGui::showNormal | ( |  | ) |

inline private

Definition at line 177 of file QtGui.h.

{
_mainWindow->showNormal();
centerWindow();
}
CxxTest::QtGui::centerWindow
void centerWindow()
Definition QtGui.h:234

## showSuiteName()

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

inline private

Definition at line 188 of file QtGui.h.

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

## showSummary()

void CxxTest::QtGui::showSummary | ( |  | ) |

inline private

Definition at line 254 of file QtGui.h.

{
QString summary = _strTotalTests + (_numTotalTests == 1 ? " test" : " tests");
if ( tracker().failedTests() )
summary = "Failed " + asString( tracker().failedTests() ) + " of " + summary;
else
summary = summary + " passed";
_mainWindow->setCaption( _title + " - " + summary );
_statusBar->removeWidget( _suiteName );
_statusBar->removeWidget( _testName );
_testsDone->setText( summary );
}
CxxTest::QtGui::asString
static QString asString(unsigned n)
Definition QtGui.h:208

## showTestName()

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

inline private

Definition at line 198 of file QtGui.h.

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

## showTestsDone()

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

inline private

Definition at line 203 of file QtGui.h.

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

## yellowBar()

void CxxTest::QtGui::yellowBar | ( |  | ) |

inline virtual

Reimplemented from CxxTest::GuiListener.

Definition at line 59 of file QtGui.h.

{
setColor( 255, 255, 0 );
setIcon( QMessageBox::Warning );
getTotalTests();
processEvents();
}

## 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:

- libpolys/tests/cxxtest/QtGui.h