1 #ifndef __cxxtest__QtGui_h__
2 #define __cxxtest__QtGui_h__
19 #include <qapplication.h>
23 #include <qmessagebox.h>
25 #include <qprogressbar.h>
26 #include <qstatusbar.h>
62 setIcon( QMessageBox::Warning );
72 setIcon( QMessageBox::Critical );
101 _startMinimized = _keep =
false;
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" )
110 else if ( arg ==
"-title" && (i + 1 < argc) )
117 _application =
new QApplication( argc, argv );
127 if ( _startMinimized )
147 _mainWindow =
new QWidget();
148 _layout =
new QVBoxLayout( _mainWindow );
153 _layout->addWidget( _progressBar =
new QProgressBar( _numTotalTests, _mainWindow ) );
154 _progressBar->setProgress( 0 );
156 setIcon( QMessageBox::Information );
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 );
169 _application->setMainWidget( _mainWindow );
174 _mainWindow->showMinimized();
179 _mainWindow->showNormal();
183 void setCaption(
const QString &suiteName,
const QString &testName )
185 _mainWindow->setCaption( _title +
" - " + suiteName +
"::" + testName +
"()" );
190 _suiteName->setText(
"class " + suiteName );
195 _progressBar->setProgress( _progressBar->progress() + 1 );
200 _testName->setText( testName +
"()" );
205 _testsDone->setText(
asString( testsDone ) +
" of " + _strTotalTests );
210 return QString::number( n );
215 QPalette palette = _progressBar->palette();
216 palette.setColor( QColorGroup::Highlight, QColor( r, g, b ) );
217 _progressBar->setPalette( palette );
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() ) );
231 _application->processEvents();
236 QWidget *desktop = QApplication::desktop();
237 int xCenter = desktop->x() + (desktop->width() / 2);
238 int yCenter = desktop->y() + (desktop->height() / 2);
240 int windowWidth = (desktop->width() * 4) / 5;
241 int windowHeight = _mainWindow->height();
242 _mainWindow->setGeometry( xCenter - (windowWidth / 2), yCenter - (windowHeight / 2), windowWidth, windowHeight );
249 if ( !_startMinimized )
251 return (_mainWindow == _application->activeWindow());
256 QString summary = _strTotalTests + (_numTotalTests == 1 ?
" test" :
" tests");
260 summary = summary +
" passed";
262 _mainWindow->setCaption( _title +
" - " + summary );
264 _statusBar->removeWidget( _suiteName );
265 _statusBar->removeWidget( _testName );
266 _testsDone->setText( summary );
271 #endif // __cxxtest__QtGui_h__
void setColor(int r, int g, int b)
void guiEnterSuite(const char *suiteName)
void parseCommandLine(int argc, char **argv)
const CanonicalForm CFMap CFMap int &both_non_zero int n
void createWindow(const WorldDescription &wd)
QApplication * _application
unsigned failedTests() const
void createApplication(int &argc, char **argv)
void enterGui(int &argc, char **argv)
void showTestsDone(unsigned testsDone)
void showSuiteName(const QString &suiteName)
void enterWorld(const WorldDescription &wd)
void setIcon(QMessageBox::Icon icon)
static QString asString(unsigned n)
void guiEnterTest(const char *suiteName, const char *testName)
char * strTotalTests(char *) const
void getTotalTests(const WorldDescription &wd)
virtual unsigned numTotalTests(void) const =0
void showTestName(const QString &testName)
void advanceProgressBar()
QProgressBar * _progressBar
void setCaption(const QString &suiteName, const QString &testName)