[Mockpp-commits] mockpp/3party/cxxtest/cxxtest Descriptions.cpp,NONE,1.1 Descriptions.h,NONE,1.1 Dum
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31329/3party/cxxtest/cxxtest Added Files: Descriptions.cpp Descriptions.h DummyDescriptions.cpp DummyDescriptions.h ErrorFormatter.h ErrorPrinter.h Flags.h GlobalFixture.cpp GlobalFixture.h Gui.h LinkedList.cpp LinkedList.h Mock.h ParenPrinter.h QtGui.h RealDescriptions.cpp RealDescriptions.h Root.cpp SelfTest.h StdHeaders.h StdioFilePrinter.h StdioPrinter.h StdValueTraits.h TeeListener.h TestListener.h TestRunner.h TestSuite.cpp TestSuite.h TestTracker.cpp TestTracker.h ValueTraits.cpp ValueTraits.h Win32Gui.h X11Gui.h YesNoRunner.h Log Message: new --- NEW FILE: TestSuite.cpp --- #ifndef __cxxtest__TestSuite_cpp__ #define __cxxtest__TestSuite_cpp__ #include <cxxtest/TestSuite.h> namespace CxxTest { // // TestSuite members // TestSuite::~TestSuite() {} void TestSuite::setUp() {} void TestSuite::tearDown() {} // // Test-aborting stuff // static bool currentAbortTestOnFail = false; bool abortTestOnFail() { return currentAbortTestOnFail; } void setAbortTestOnFail( bool value ) { currentAbortTestOnFail = value; } void doAbortTest() { # if defined(_CXXTEST_HAVE_EH) if ( currentAbortTestOnFail ) throw AbortTest(); # endif // _CXXTEST_HAVE_EH } // // Max dump size // static unsigned currentMaxDumpSize = CXXTEST_MAX_DUMP_SIZE; unsigned maxDumpSize() { return currentMaxDumpSize; } void setMaxDumpSize( unsigned value ) { currentMaxDumpSize = value; } // // Some non-template functions // void doTrace( const char *file, unsigned line, const char *message ) { tracker().trace( file, line, message ); } void doWarn( const char *file, unsigned line, const char *message ) { tracker().warning( file, line, message ); } void doFailTest( const char *file, unsigned line, const char *message ) { tracker().failedTest( file, line, message ); TS_ABORT(); } void doFailAssert( const char *file, unsigned line, const char *expression, const char *message ) { if ( message ) tracker().failedTest( file, line, message ); tracker().failedAssert( file, line, expression ); TS_ABORT(); } bool sameData( const void *x, const void *y, unsigned size ) { if ( size == 0 ) return true; if ( x == y ) return true; if ( !x || !y ) return false; const char *cx = (const char *)x; const char *cy = (const char *)y; while ( size -- ) if ( *cx++ != *cy++ ) return false; return true; } void doAssertSameData( const char *file, unsigned line, const char *xExpr, const void *x, const char *yExpr, const void *y, const char *sizeExpr, unsigned size, const char *message ) { if ( !sameData( x, y, size ) ) { if ( message ) tracker().failedTest( file, line, message ); tracker().failedAssertSameData( file, line, xExpr, yExpr, sizeExpr, x, y, size ); TS_ABORT(); } } void doFailAssertThrows( const char *file, unsigned line, const char *expr, const char *type, bool otherThrown, const char *message ) { if ( message ) tracker().failedTest( file, line, message ); tracker().failedAssertThrows( file, line, expr, type, otherThrown ); TS_ABORT(); } void doFailAssertThrowsNot( const char *file, unsigned line, const char *expression, const char *message ) { if ( message ) tracker().failedTest( file, line, message ); tracker().failedAssertThrowsNot( file, line, expression ); TS_ABORT(); } }; #endif // __cxxtest__TestSuite_cpp__ --- NEW FILE: QtGui.h --- #ifndef __cxxtest__QtGui_h__ #define __cxxtest__QtGui_h__ // // The QtGui displays a simple progress bar using the Qt Toolkit. It // has been tested with versions 2.x and 3.x. // // Apart from normal Qt command-line arguments, it accepts the following options: // -minimized Start minimized, pop up on error // -keep Don't close the window at the end // -title TITLE Set the window caption // // If both are -minimized and -keep specified, GUI will only keep the // window if it's in focus. // #include <cxxtest/Gui.h> #include <qapplication.h> #include <qglobal.h> #include <qlabel.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpixmap.h> #include <qprogressbar.h> #include <qstatusbar.h> namespace CxxTest { class QtGui : public GuiListener { public: void enterGui( int &argc, char **argv ) { parseCommandLine( argc, argv ); createApplication( argc, argv ); } void enterWorld( const WorldDescription &wd ) { createWindow( wd ); processEvents(); } void guiEnterSuite( const char *suiteName ) { showSuiteName( suiteName ); } void guiEnterTest( const char *suiteName, const char *testName ) { setCaption( suiteName, testName ); advanceProgressBar(); showTestName( testName ); showTestsDone( _progressBar->progress() ); processEvents(); } void yellowBar() { setColor( 255, 255, 0 ); setIcon( QMessageBox::Warning ); getTotalTests(); processEvents(); } void redBar() { if ( _startMinimized && _mainWindow->isMinimized() ) showNormal(); setColor( 255, 0, 0 ); setIcon( QMessageBox::Critical ); getTotalTests(); processEvents(); } void leaveGui() { if ( keep() ) { showSummary(); _application->exec(); } else _mainWindow->close( true ); } private: QString _title; bool _startMinimized, _keep; unsigned _numTotalTests; QString _strTotalTests; QApplication *_application; QWidget *_mainWindow; QVBoxLayout *_layout; QProgressBar *_progressBar; QStatusBar *_statusBar; QLabel *_suiteName, *_testName, *_testsDone; void parseCommandLine( int argc, char **argv ) { _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]; } } void createApplication( int &argc, char **argv ) { _application = new QApplication( argc, argv ); } void createWindow( const WorldDescription &wd ) { getTotalTests( wd ); createMainWindow(); createProgressBar(); createStatusBar(); setMainWidget(); if ( _startMinimized ) showMinimized(); else showNormal(); } void getTotalTests() { getTotalTests( tracker().world() ); } void getTotalTests( const WorldDescription &wd ) { _numTotalTests = wd.numTotalTests(); char s[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; _strTotalTests = wd.strTotalTests( s ); } void createMainWindow() { _mainWindow = new QWidget(); _layout = new QVBoxLayout( _mainWindow ); } void createProgressBar() { _layout->addWidget( _progressBar = new QProgressBar( _numTotalTests, _mainWindow ) ); _progressBar->setProgress( 0 ); setColor( 0, 255, 0 ); setIcon( QMessageBox::Information ); } void createStatusBar() { _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 ); } void setMainWidget() { _application->setMainWidget( _mainWindow ); } void showMinimized() { _mainWindow->showMinimized(); } void showNormal() { _mainWindow->showNormal(); centerWindow(); } void setCaption( const QString &suiteName, const QString &testName ) { _mainWindow->setCaption( _title + " - " + suiteName + "::" + testName + "()" ); } void showSuiteName( const QString &suiteName ) { _suiteName->setText( "class " + suiteName ); } void advanceProgressBar() { _progressBar->setProgress( _progressBar->progress() + 1 ); } void showTestName( const QString &testName ) { _testName->setText( testName + "()" ); } void showTestsDone( unsigned testsDone ) { _testsDone->setText( asString( testsDone ) + " of " + _strTotalTests ); } static QString asString( unsigned n ) { return QString::number( n ); } void setColor( int r, int g, int b ) { QPalette palette = _progressBar->palette(); palette.setColor( QColorGroup::Highlight, QColor( r, g, b ) ); _progressBar->setPalette( palette ); } void setIcon( QMessageBox::Icon icon ) { #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 } void processEvents() { _application->processEvents(); } void centerWindow() { 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 ); } bool keep() { if ( !_keep ) return false; if ( !_startMinimized ) return true; return (_mainWindow == _application->activeWindow()); } void showSummary() { 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 ); } }; }; #endif // __cxxtest__QtGui_h__ --- NEW FILE: TestTracker.h --- #ifndef __cxxtest__TestTracker_h__ #define __cxxtest__TestTracker_h__ // // The TestTracker tracks running tests // The actual work is done in CountingListenerProxy, // but this way avoids cyclic references TestListener<->CountingListenerProxy // #include <cxxtest/TestListener.h> #include <cxxtest/DummyDescriptions.h> namespace CxxTest { class TestListener; class TestTracker : public TestListener { public: virtual ~TestTracker(); static TestTracker &tracker(); const TestDescription *fixTest( const TestDescription *d ) const; const SuiteDescription *fixSuite( const SuiteDescription *d ) const; const WorldDescription *fixWorld( const WorldDescription *d ) const; const TestDescription &test() const { return *_test; } const SuiteDescription &suite() const { return *_suite; } const WorldDescription &world() const { return *_world; } bool testFailed() const { return (testFailedAsserts() > 0); } bool suiteFailed() const { return (suiteFailedTests() > 0); } bool worldFailed() const { return (failedSuites() > 0); } unsigned warnings() const { return _warnings; } unsigned failedTests() const { return _failedTests; } unsigned testFailedAsserts() const { return _testFailedAsserts; } unsigned suiteFailedTests() const { return _suiteFailedTests; } unsigned failedSuites() const { return _failedSuites; } void enterWorld( const WorldDescription &wd ); void enterSuite( const SuiteDescription &sd ); void enterTest( const TestDescription &td ); void leaveTest( const TestDescription &td ); void leaveSuite( const SuiteDescription &sd ); void leaveWorld( const WorldDescription &wd ); void trace( const char *file, unsigned line, const char *expression ); void warning( const char *file, unsigned line, const char *expression ); void failedTest( const char *file, unsigned line, const char *expression ); void failedAssert( const char *file, unsigned line, const char *expression ); void failedAssertEquals( const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y ); void failedAssertSameData( const char *file, unsigned line, const char *xStr, const char *yStr, const char *sizeStr, const void *x, const void *y, unsigned size ); void failedAssertDelta( const char *file, unsigned line, const char *xStr, const char *yStr, const char *dStr, const char *x, const char *y, const char *d ); void failedAssertDiffers( const char *file, unsigned line, const char *xStr, const char *yStr, const char *value ); void failedAssertLessThan( const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y ); void failedAssertLessThanEquals( const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y ); void failedAssertPredicate( const char *file, unsigned line, const char *predicate, const char *xStr, const char *x ); void failedAssertRelation( const char *file, unsigned line, const char *relation, const char *xStr, const char *yStr, const char *x, const char *y ); void failedAssertThrows( const char *file, unsigned line, const char *expression, const char *type, bool otherThrown ); void failedAssertThrowsNot( const char *file, unsigned line, const char *expression ); private: TestTracker( const TestTracker & ); TestTracker &operator=( const TestTracker & ); static bool _created; TestListener _dummyListener; DummyWorldDescription _dummyWorld; unsigned _warnings, _failedTests, _testFailedAsserts, _suiteFailedTests, _failedSuites; TestListener *_l; const WorldDescription *_world; const SuiteDescription *_suite; const TestDescription *_test; const TestDescription &dummyTest() const; const SuiteDescription &dummySuite() const; const WorldDescription &dummyWorld() const; void setWorld( const WorldDescription *w ); void setSuite( const SuiteDescription *s ); void setTest( const TestDescription *t ); void countWarning(); void countFailure(); friend class TestRunner; TestTracker(); void initialize(); void setListener( TestListener *l ); }; inline TestTracker &tracker() { return TestTracker::tracker(); } }; #endif // __cxxtest__TestTracker_h__ --- NEW FILE: LinkedList.h --- #ifndef __cxxtest__LinkedList_h__ #define __cxxtest__LinkedList_h__ #include <cxxtest/Flags.h> namespace CxxTest { struct List; class Link; struct List { Link *_head; Link *_tail; void initialize(); Link *head(); const Link *head() const; Link *tail(); const Link *tail() const; bool empty() const; unsigned size() const; Link *nth( unsigned n ); void activateAll(); void leaveOnly( const Link &link ); }; class Link { public: Link(); virtual ~Link(); bool active() const; void setActive( bool value = true ); Link *justNext(); Link *justPrev(); Link *next(); Link *prev(); const Link *next() const; const Link *prev() const; virtual bool setUp() = 0; virtual bool tearDown() = 0; void attach( List &l ); void detach( List &l ); private: Link *_next; Link *_prev; bool _active; Link( const Link & ); Link &operator=( const Link & ); }; } #endif // __cxxtest__LinkedList_h__ --- NEW FILE: LinkedList.cpp --- #ifndef __cxxtest__LinkedList_cpp__ #define __cxxtest__LinkedList_cpp__ #include <cxxtest/LinkedList.h> namespace CxxTest { List GlobalFixture::_list = { 0, 0 }; List RealSuiteDescription::_suites = { 0, 0 }; void List::initialize() { _head = _tail = 0; } Link *List::head() { Link *l = _head; while ( l && !l->active() ) l = l->next(); return l; } const Link *List::head() const { Link *l = _head; while ( l && !l->active() ) l = l->next(); return l; } Link *List::tail() { Link *l = _tail; while ( l && !l->active() ) l = l->prev(); return l; } const Link *List::tail() const { Link *l = _tail; while ( l && !l->active() ) l = l->prev(); return l; } bool List::empty() const { return (_head == 0); } unsigned List::size() const { unsigned count = 0; for ( const Link *l = head(); l != 0; l = l->next() ) ++ count; return count; } Link *List::nth( unsigned n ) { Link *l = head(); while ( n -- ) l = l->next(); return l; } void List::activateAll() { for ( Link *l = _head; l != 0; l = l->justNext() ) l->setActive( true ); } void List::leaveOnly( const Link &link ) { for ( Link *l = head(); l != 0; l = l->next() ) if ( l != &link ) l->setActive( false ); } Link::Link() : _next( 0 ), _prev( 0 ), _active( true ) { } Link::~Link() { } bool Link::active() const { return _active; } void Link::setActive( bool value ) { _active = value; } Link * Link::justNext() { return _next; } Link * Link::justPrev() { return _prev; } Link * Link::next() { Link *l = _next; while ( l && !l->_active ) l = l->_next; return l; } Link * Link::prev() { Link *l = _prev; while ( l && !l->_active ) l = l->_prev; return l; } const Link * Link::next() const { Link *l = _next; while ( l && !l->_active ) l = l->_next; return l; } const Link * Link::prev() const { Link *l = _prev; while ( l && !l->_active ) l = l->_prev; return l; } void Link::attach( List &l ) { if ( l._tail ) l._tail->_next = this; _prev = l._tail; _next = 0; if ( l._head == 0 ) l._head = this; l._tail = this; } void Link::detach( List &l ) { if ( _prev ) _prev->_next = _next; else l._head = _next; if ( _next ) _next->_prev = _prev; else l._tail = _prev; } }; #endif // __cxxtest__LinkedList_cpp__ --- NEW FILE: ErrorPrinter.h --- #ifndef __cxxtest__ErrorPrinter_h__ #define __cxxtest__ErrorPrinter_h__ // // The ErrorPrinter is a simple TestListener that // just prints "OK" if everything goes well, otherwise // reports the error in the format of compiler messages. // The ErrorPrinter uses std::cout // #include <cxxtest/Flags.h> #ifndef _CXXTEST_HAVE_STD # define _CXXTEST_HAVE_STD #endif // _CXXTEST_HAVE_STD #include <cxxtest/ErrorFormatter.h> #include <cxxtest/StdValueTraits.h> #ifdef _CXXTEST_OLD_STD # include <iostream.h> #else // !_CXXTEST_OLD_STD # include <iostream> #endif // _CXXTEST_OLD_STD namespace CxxTest { class ErrorPrinter : public ErrorFormatter { public: ErrorPrinter( CXXTEST_STD(ostream) &o = CXXTEST_STD(cout), const char *preLine = ":", const char *postLine = "" ) : ErrorFormatter( new Adapter(o), preLine, postLine ) {} virtual ~ErrorPrinter() { delete outputStream(); } private: class Adapter : public OutputStream { CXXTEST_STD(ostream) &_o; public: Adapter( CXXTEST_STD(ostream) &o ) : _o(o) {} void flush() { _o.flush(); } OutputStream &operator<<( const char *s ) { _o << s; return *this; } OutputStream &operator<<( Manipulator m ) { return OutputStream::operator<<( m ); } OutputStream &operator<<( unsigned i ) { char s[1 + 3 * sizeof(unsigned)]; numberToString( i, s ); _o << s; return *this; } }; }; } #endif // __cxxtest__ErrorPrinter_h__ --- NEW FILE: Win32Gui.h --- #ifndef __cxxtest__Win32Gui_h__ #define __cxxtest__Win32Gui_h__ // // The Win32Gui displays a simple progress bar using the Win32 API. // // It accepts the following command line options: // -minimized Start minimized, pop up on error // -keep Don't close the window at the end // -title TITLE Set the window caption // // If both -minimized and -keep are specified, GUI will only keep the // window if it's in focus. // // N.B. If you're wondering why this class doesn't use any standard // library or STL (<string> would have been nice) it's because it only // uses "straight" Win32 API. // #include <cxxtest/Gui.h> #include <windows.h> #include <commctrl.h> namespace CxxTest { class Win32Gui : public GuiListener { public: void enterGui( int &argc, char **argv ) { parseCommandLine( argc, argv ); } void enterWorld( const WorldDescription &wd ) { getTotalTests( wd ); _testsDone = 0; startGuiThread(); } void guiEnterSuite( const char *suiteName ) { showSuiteName( suiteName ); reset( _suiteStart ); } void guiEnterTest( const char *suiteName, const char *testName ) { ++ _testsDone; setTestCaption( suiteName, testName ); showTestName( testName ); showTestsDone(); progressBarMessage( PBM_STEPIT ); reset( _testStart ); } void yellowBar() { setColor( 255, 255, 0 ); setIcon( IDI_WARNING ); getTotalTests(); } void redBar() { if ( _startMinimized ) showMainWindow( SW_SHOWNORMAL ); setColor( 255, 0, 0 ); setIcon( IDI_ERROR ); getTotalTests(); } void leaveGui() { if ( keep() ) { showSummary(); WaitForSingleObject( _gui, INFINITE ); } DestroyWindow( _mainWindow ); } private: const char *_title; bool _startMinimized, _keep; HANDLE _gui; WNDCLASSEX _windowClass; HWND _mainWindow, _progressBar, _statusBar; HANDLE _canStartTests; unsigned _numTotalTests, _testsDone; char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; enum { STATUS_SUITE_NAME, STATUS_SUITE_TIME, STATUS_TEST_NAME, STATUS_TEST_TIME, STATUS_TESTS_DONE, STATUS_WORLD_TIME, STATUS_TOTAL_PARTS }; int _statusWidths[STATUS_TOTAL_PARTS]; unsigned _statusOffsets[STATUS_TOTAL_PARTS]; unsigned _statusTotal; char _statusTestsDone[sizeof("1000000000 of (100%)") + WorldDescription::MAX_STRLEN_TOTAL_TESTS]; DWORD _worldStart, _suiteStart, _testStart; char _timeString[sizeof("00:00:00")]; void parseCommandLine( int argc, char **argv ) { _startMinimized = _keep = false; _title = argv[0]; for ( int i = 1; i < argc; ++ i ) { if ( !lstrcmpA( argv[i], "-minimized" ) ) _startMinimized = true; else if ( !lstrcmpA( argv[i], "-keep" ) ) _keep = true; else if ( !lstrcmpA( argv[i], "-title" ) && (i + 1 < argc) ) _title = argv[++i]; } } void getTotalTests() { getTotalTests( tracker().world() ); } void getTotalTests( const WorldDescription &wd ) { _numTotalTests = wd.numTotalTests(); wd.strTotalTests( _strTotalTests ); } void startGuiThread() { _canStartTests = CreateEvent( NULL, TRUE, FALSE, NULL ); DWORD threadId; _gui = CreateThread( NULL, 0, &(Win32Gui::guiThread), (LPVOID)this, 0, &threadId ); WaitForSingleObject( _canStartTests, INFINITE ); } static DWORD WINAPI guiThread( LPVOID parameter ) { ((Win32Gui *)parameter)->gui(); return 0; } void gui() { registerWindowClass(); createMainWindow(); initCommonControls(); createProgressBar(); createStatusBar(); centerMainWindow(); showMainWindow(); startTimer(); startTests(); messageLoop(); } void registerWindowClass() { _windowClass.cbSize = sizeof(_windowClass); _windowClass.style = CS_HREDRAW | CS_VREDRAW; _windowClass.lpfnWndProc = &(Win32Gui::windowProcedure); _windowClass.cbClsExtra = 0; _windowClass.cbWndExtra = sizeof(LONG); _windowClass.hInstance = (HINSTANCE)NULL; _windowClass.hIcon = (HICON)NULL; _windowClass.hCursor = (HCURSOR)NULL; _windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); _windowClass.lpszMenuName = NULL; _windowClass.lpszClassName = TEXT("CxxTest Window Class"); _windowClass.hIconSm = (HICON)NULL; RegisterClassEx( &_windowClass ); } void createMainWindow() { _mainWindow = createWindow( _windowClass.lpszClassName, WS_OVERLAPPEDWINDOW ); } void initCommonControls() { HMODULE dll = LoadLibraryA( "comctl32.dll" ); if ( !dll ) return; typedef void (WINAPI *FUNC)( void ); FUNC func = (FUNC)GetProcAddress( dll, "InitCommonControls" ); if ( !func ) return; func(); } void createProgressBar() { _progressBar = createWindow( PROGRESS_CLASS, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, _mainWindow ); #ifdef PBM_SETRANGE32 progressBarMessage( PBM_SETRANGE32, 0, _numTotalTests ); #else // No PBM_SETRANGE32, use PBM_SETRANGE progressBarMessage( PBM_SETRANGE, 0, MAKELPARAM( 0, (WORD)_numTotalTests ) ); #endif // PBM_SETRANGE32 progressBarMessage( PBM_SETPOS, 0 ); progressBarMessage( PBM_SETSTEP, 1 ); greenBar(); UpdateWindow( _progressBar ); } void createStatusBar() { _statusBar = createWindow( STATUSCLASSNAME, WS_CHILD | WS_VISIBLE, _mainWindow ); setRatios( 4, 1, 3, 1, 3, 1 ); } void setRatios( unsigned suiteNameRatio, unsigned suiteTimeRatio, unsigned testNameRatio, unsigned testTimeRatio, unsigned testsDoneRatio, unsigned worldTimeRatio ) { _statusTotal = 0; _statusOffsets[STATUS_SUITE_NAME] = (_statusTotal += suiteNameRatio); _statusOffsets[STATUS_SUITE_TIME] = (_statusTotal += suiteTimeRatio); _statusOffsets[STATUS_TEST_NAME] = (_statusTotal += testNameRatio); _statusOffsets[STATUS_TEST_TIME] = (_statusTotal += testTimeRatio); _statusOffsets[STATUS_TESTS_DONE] = (_statusTotal += testsDoneRatio); _statusOffsets[STATUS_WORLD_TIME] = (_statusTotal += worldTimeRatio); } HWND createWindow( LPCTSTR className, DWORD style, HWND parent = (HWND)NULL ) { return CreateWindow( className, NULL, style, 0, 0, 0, 0, parent, (HMENU)NULL, (HINSTANCE)NULL, (LPVOID)this ); } void progressBarMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 ) { SendMessage( _progressBar, message, wParam, lParam ); } void centerMainWindow() { RECT screen; getScreenArea( screen ); LONG screenWidth = screen.right - screen.left; LONG screenHeight = screen.bottom - screen.top; LONG xCenter = (screen.right + screen.left) / 2; LONG yCenter = (screen.bottom + screen.top) / 2; LONG windowWidth = (screenWidth * 4) / 5; LONG windowHeight = screenHeight / 10; LONG minimumHeight = 2 * (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYFRAME )); if ( windowHeight < minimumHeight ) windowHeight = minimumHeight; SetWindowPos( _mainWindow, HWND_TOP, xCenter - (windowWidth / 2), yCenter - (windowHeight / 2), windowWidth, windowHeight, 0 ); } void getScreenArea( RECT &area ) { if ( !getScreenAreaWithoutTaskbar( area ) ) getWholeScreenArea( area ); } bool getScreenAreaWithoutTaskbar( RECT &area ) { return (SystemParametersInfo( SPI_GETWORKAREA, sizeof(RECT), &area, 0 ) != 0); } void getWholeScreenArea( RECT &area ) { area.left = area.top = 0; area.right = GetSystemMetrics( SM_CXSCREEN ); area.bottom = GetSystemMetrics( SM_CYSCREEN ); } void showMainWindow() { showMainWindow( _startMinimized ? SW_MINIMIZE : SW_SHOWNORMAL ); UpdateWindow( _mainWindow ); } void showMainWindow( int mode ) { ShowWindow( _mainWindow, mode ); } enum { TIMER_ID = 1, TIMER_DELAY = 1000 }; void startTimer() { reset( _worldStart ); reset( _suiteStart ); reset( _testStart ); SetTimer( _mainWindow, TIMER_ID, TIMER_DELAY, 0 ); } void reset( DWORD &tick ) { tick = GetTickCount(); } void startTests() { SetEvent( _canStartTests ); } void messageLoop() { MSG message; while ( BOOL haveMessage = GetMessage( &message, NULL, 0, 0 ) ) if ( haveMessage != -1 ) DispatchMessage( &message ); } static LRESULT CALLBACK windowProcedure( HWND window, UINT message, WPARAM wParam, LPARAM lParam ) { if ( message == WM_CREATE ) setUp( window, (LPCREATESTRUCT)lParam ); Win32Gui *that = (Win32Gui *)GetWindowLong( window, GWL_USERDATA ); return that->handle( window, message, wParam, lParam ); } static void setUp( HWND window, LPCREATESTRUCT create ) { SetWindowLong( window, GWL_USERDATA, (LONG)create->lpCreateParams ); } LRESULT handle( HWND window, UINT message, WPARAM wParam, LPARAM lParam ) { switch ( message ) { case WM_SIZE: resizeControls(); break; case WM_TIMER: updateTime(); break; case WM_CLOSE: case WM_DESTROY: case WM_QUIT: ExitProcess( 0 ); default: return DefWindowProc( window, message, wParam, lParam ); } return 0; } void resizeControls() { RECT r; GetClientRect( _mainWindow, &r ); LONG width = r.right - r.left; LONG height = r.bottom - r.top; GetClientRect( _statusBar, &r ); LONG statusHeight = r.bottom - r.top; LONG resizeGripWidth = statusHeight; LONG progressHeight = height - statusHeight; SetWindowPos( _progressBar, HWND_TOP, 0, 0, width, progressHeight, 0 ); SetWindowPos( _statusBar, HWND_TOP, 0, progressHeight, width, statusHeight, 0 ); setStatusParts( width - resizeGripWidth ); } void setStatusParts( LONG width ) { for ( unsigned i = 0; i < STATUS_TOTAL_PARTS; ++ i ) _statusWidths[i] = (width * _statusOffsets[i]) / _statusTotal; statusBarMessage( SB_SETPARTS, STATUS_TOTAL_PARTS, _statusWidths ); } void statusBarMessage( UINT message, WPARAM wParam = 0, const void *lParam = 0 ) { SendMessage( _statusBar, message, wParam, (LPARAM)lParam ); } void greenBar() { setColor( 0, 255, 0 ); setIcon( IDI_INFORMATION ); } #ifdef PBM_SETBARCOLOR void setColor( BYTE red, BYTE green, BYTE blue ) { progressBarMessage( PBM_SETBARCOLOR, 0, RGB( red, green, blue ) ); } #else // !PBM_SETBARCOLOR void setColor( BYTE, BYTE, BYTE ) { } #endif // PBM_SETBARCOLOR void setIcon( LPCTSTR icon ) { SendMessage( _mainWindow, WM_SETICON, ICON_BIG, (LPARAM)loadStandardIcon( icon ) ); } HICON loadStandardIcon( LPCTSTR icon ) { return LoadIcon( (HINSTANCE)NULL, icon ); } void setTestCaption( const char *suiteName, const char *testName ) { setCaption( suiteName, "::", testName, "()" ); } void setCaption( const char *a = "", const char *b = "", const char *c = "", const char *d = "" ) { unsigned length = lstrlenA( _title ) + sizeof( " - " ) + lstrlenA( a ) + lstrlenA( b ) + lstrlenA( c ) + lstrlenA( d ); char *name = allocate( length ); lstrcpyA( name, _title ); lstrcatA( name, " - " ); lstrcatA( name, a ); lstrcatA( name, b ); lstrcatA( name, c ); lstrcatA( name, d ); SetWindowTextA( _mainWindow, name ); deallocate( name ); } void showSuiteName( const char *suiteName ) { setStatusPart( STATUS_SUITE_NAME, suiteName ); } void showTestName( const char *testName ) { setStatusPart( STATUS_TEST_NAME, testName ); } void showTestsDone() { wsprintfA( _statusTestsDone, "%u of %s (%u%%)", _testsDone, _strTotalTests, (_testsDone * 100) / _numTotalTests ); setStatusPart( STATUS_TESTS_DONE, _statusTestsDone ); } void updateTime() { setStatusTime( STATUS_WORLD_TIME, _worldStart ); setStatusTime( STATUS_SUITE_TIME, _suiteStart ); setStatusTime( STATUS_TEST_TIME, _testStart ); } void setStatusTime( unsigned part, DWORD start ) { unsigned total = (GetTickCount() - start) / 1000; unsigned hours = total / 3600; unsigned minutes = (total / 60) % 60; unsigned seconds = total % 60; if ( hours ) wsprintfA( _timeString, "%u:%02u:%02u", hours, minutes, seconds ); else wsprintfA( _timeString, "%02u:%02u", minutes, seconds ); setStatusPart( part, _timeString ); } bool keep() { if ( !_keep ) return false; if ( !_startMinimized ) return true; return (_mainWindow == GetForegroundWindow()); } void showSummary() { stopTimer(); setSummaryStatusBar(); setSummaryCaption(); } void setStatusPart( unsigned part, const char *text ) { statusBarMessage( SB_SETTEXTA, part, text ); } void stopTimer() { KillTimer( _mainWindow, TIMER_ID ); setStatusTime( STATUS_WORLD_TIME, _worldStart ); } void setSummaryStatusBar() { setRatios( 0, 0, 0, 0, 1, 1 ); resizeControls(); const char *tests = (_numTotalTests == 1) ? "test" : "tests"; if ( tracker().failedTests() ) wsprintfA( _statusTestsDone, "Failed %u of %s %s", tracker().failedTests(), _strTotalTests, tests ); else wsprintfA( _statusTestsDone, "%s %s passed", _strTotalTests, tests ); setStatusPart( STATUS_TESTS_DONE, _statusTestsDone ); } void setSummaryCaption() { setCaption( _statusTestsDone ); } char *allocate( unsigned length ) { return (char *)HeapAlloc( GetProcessHeap(), 0, length ); } void deallocate( char *data ) { HeapFree( GetProcessHeap(), 0, data ); } }; }; #endif // __cxxtest__Win32Gui_h__ --- NEW FILE: TestRunner.h --- #ifndef __cxxtest_TestRunner_h__ #define __cxxtest_TestRunner_h__ // // TestRunner is the class that runs all the tests. // To use it, create an object that implements the TestListener // interface and call TestRunner::runAllTests( myListener ); // #include <cxxtest/TestListener.h> #include <cxxtest/RealDescriptions.h> #include <cxxtest/TestSuite.h> #include <cxxtest/TestTracker.h> namespace CxxTest { class TestRunner { public: static void runAllTests( TestListener &listener ) { tracker().setListener( &listener ); _TS_TRY { TestRunner().runWorld(); } _TS_LAST_CATCH( { tracker().failedTest( __FILE__, __LINE__, "Exception thrown from world" ); } ); tracker().setListener( 0 ); } static void runAllTests( TestListener *listener ) { if ( listener ) { listener->warning( __FILE__, __LINE__, "Deprecated; Use runAllTests( TestListener & )" ); runAllTests( *listener ); } } private: void runWorld() { RealWorldDescription wd; WorldGuard sg; tracker().enterWorld( wd ); if ( wd.setUp() ) { for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) if ( sd->active() ) runSuite( *sd ); wd.tearDown(); } tracker().leaveWorld( wd ); } void runSuite( SuiteDescription &sd ) { StateGuard sg; tracker().enterSuite( sd ); if ( sd.setUp() ) { for ( TestDescription *td = sd.firstTest(); td; td = td->next() ) if ( td->active() ) runTest( *td ); sd.tearDown(); } tracker().leaveSuite( sd ); } void runTest( TestDescription &td ) { StateGuard sg; tracker().enterTest( td ); if ( td.setUp() ) { td.run(); td.tearDown(); } tracker().leaveTest( td ); } class StateGuard { #ifdef _CXXTEST_HAVE_EH bool _abortTestOnFail; #endif // _CXXTEST_HAVE_EH unsigned _maxDumpSize; public: StateGuard() { #ifdef _CXXTEST_HAVE_EH _abortTestOnFail = abortTestOnFail(); #endif // _CXXTEST_HAVE_EH _maxDumpSize = maxDumpSize(); } ~StateGuard() { #ifdef _CXXTEST_HAVE_EH setAbortTestOnFail( _abortTestOnFail ); #endif // _CXXTEST_HAVE_EH setMaxDumpSize( _maxDumpSize ); } }; class WorldGuard : public StateGuard { public: WorldGuard() : StateGuard() { #ifdef _CXXTEST_HAVE_EH setAbortTestOnFail( CXXTEST_DEFAULT_ABORT ); #endif // _CXXTEST_HAVE_EH setMaxDumpSize( CXXTEST_MAX_DUMP_SIZE ); } }; }; // // For --no-static-init // void initialize(); }; #endif // __cxxtest_TestRunner_h__ --- NEW FILE: TestListener.h --- #ifndef __cxxtest__TestListener_h__ #define __cxxtest__TestListener_h__ // // TestListener is the base class for all "listeners", // i.e. classes that receive notifications of the // testing process. // // The names of the parameters are in comments to avoid // "unused parameter" warnings. // #include <cxxtest/Descriptions.h> namespace CxxTest { class TestListener { public: TestListener() {} virtual ~TestListener() {} virtual void enterWorld( const WorldDescription & /*desc*/ ) {} virtual void enterSuite( const SuiteDescription & /*desc*/ ) {} virtual void enterTest( const TestDescription & /*desc*/ ) {} virtual void trace( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) {} virtual void warning( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) {} virtual void failedTest( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) {} virtual void failedAssert( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) {} virtual void failedAssertEquals( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) {} virtual void failedAssertSameData( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*sizeStr*/, const void * /*x*/, const void * /*y*/, unsigned /*size*/ ) {} virtual void failedAssertDelta( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*dStr*/, const char * /*x*/, const char * /*y*/, const char * /*d*/ ) {} virtual void failedAssertDiffers( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*value*/ ) {} virtual void failedAssertLessThan( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) {} virtual void failedAssertLessThanEquals( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) {} virtual void failedAssertPredicate( const char * /*file*/, unsigned /*line*/, const char * /*predicate*/, const char * /*xStr*/, const char * /*x*/ ) {} virtual void failedAssertRelation( const char * /*file*/, unsigned /*line*/, const char * /*relation*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) {} virtual void failedAssertThrows( const char * /*file*/, unsigned /*line*/, const char * /*expression*/, const char * /*type*/, bool /*otherThrown*/ ) {} virtual void failedAssertThrowsNot( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) {} virtual void leaveTest( const TestDescription & /*desc*/ ) {} virtual void leaveSuite( const SuiteDescription & /*desc*/ ) {} virtual void leaveWorld( const WorldDescription & /*desc*/ ) {} }; } #endif // __cxxtest__TestListener_h__ --- NEW FILE: Descriptions.h --- #ifndef __cxxtest__Descriptions_h__ #define __cxxtest__Descriptions_h__ // // TestDescription, SuiteDescription and WorldDescription // hold information about tests so they can be run and reported. // #include <cxxtest/LinkedList.h> namespace CxxTest { class TestSuite; class TestDescription : public Link { public: virtual ~TestDescription(); virtual const char *file() const = 0; virtual unsigned line() const = 0; virtual const char *testName() const = 0; virtual const char *suiteName() const = 0; virtual void run() = 0; virtual const TestDescription *next() const = 0; virtual TestDescription *next() = 0; }; class SuiteDescription : public Link { public: virtual ~SuiteDescription(); virtual const char *file() const = 0; virtual unsigned line() const = 0; virtual const char *suiteName() const = 0; virtual TestSuite *suite() const = 0; virtual unsigned numTests() const = 0; virtual const TestDescription &testDescription( unsigned /*i*/ ) const = 0; virtual TestDescription *firstTest() = 0; virtual const TestDescription *firstTest() const = 0; virtual SuiteDescription *next() = 0; virtual const SuiteDescription *next() const = 0; virtual void activateAllTests() = 0; virtual bool leaveOnly( const char * /*testName*/ ) = 0; }; class WorldDescription : public Link { public: virtual ~WorldDescription(); virtual unsigned numSuites( void ) const = 0; virtual unsigned numTotalTests( void ) const = 0; virtual const SuiteDescription &suiteDescription( unsigned /*i*/ ) const = 0; enum { MAX_STRLEN_TOTAL_TESTS = 32 }; char *strTotalTests( char * /*buffer*/ ) const; virtual SuiteDescription *firstSuite() = 0; virtual const SuiteDescription *firstSuite() const = 0; virtual void activateAllTests() = 0; virtual bool leaveOnly( const char * /*suiteName*/, const char * /*testName*/ = 0 ) = 0; }; } #endif // __cxxtest__Descriptions_h__ --- NEW FILE: GlobalFixture.cpp --- #ifndef __cxxtest__GlobalFixture_cpp__ #define __cxxtest__GlobalFixture_cpp__ #include <cxxtest/GlobalFixture.h> namespace CxxTest { bool GlobalFixture::setUpWorld() { return true; } bool GlobalFixture::tearDownWorld() { return true; } bool GlobalFixture::setUp() { return true; } bool GlobalFixture::tearDown() { return true; } GlobalFixture::GlobalFixture() { attach( _list ); } GlobalFixture::~GlobalFixture() { detach( _list ); } GlobalFixture *GlobalFixture::firstGlobalFixture() { return (GlobalFixture *)_list.head(); } GlobalFixture *GlobalFixture::lastGlobalFixture() { return (GlobalFixture *)_list.tail(); } GlobalFixture *GlobalFixture::nextGlobalFixture() { return (GlobalFixture *)next(); } GlobalFixture *GlobalFixture::prevGlobalFixture() { return (GlobalFixture *)prev(); } } #endif // __cxxtest__GlobalFixture_cpp__ --- NEW FILE: Root.cpp --- #ifndef __cxxtest__Root_cpp__ #define __cxxtest__Root_cpp__ // // This file holds the "root" of CxxTest, i.e. // the parts that must be in a source file file. // #include <cxxtest/Descriptions.cpp> #include <cxxtest/DummyDescriptions.cpp> #include <cxxtest/GlobalFixture.cpp> #include <cxxtest/LinkedList.cpp> #include <cxxtest/RealDescriptions.cpp> #include <cxxtest/TestSuite.cpp> #include <cxxtest/TestTracker.cpp> #include <cxxtest/ValueTraits.cpp> #endif // __cxxtest__Root_cpp__ --- NEW FILE: Gui.h --- #ifndef __CXXTEST__GUI_H #define __CXXTEST__GUI_H // // GuiListener is a simple base class for the differes GUIs // GuiTuiRunner<GuiT, TuiT> combines a GUI with a text-mode error formatter // #include <cxxtest/TeeListener.h> namespace CxxTest { class GuiListener : public TestListener { public: GuiListener() : _state( GREEN_BAR ) {} virtual ~GuiListener() {} virtual void runGui( int &argc, char **argv, TestListener &listener ) { enterGui( argc, argv ); TestRunner::runAllTests( listener ); leaveGui(); } virtual void enterGui( int & /*argc*/, char ** /*argv*/ ) {} virtual void leaveGui() {} // // The easy way is to implement these functions: // virtual void guiEnterWorld( unsigned /*numTotalTests*/ ) {} virtual void guiEnterSuite( const char * /*suiteName*/ ) {} virtual void guiEnterTest( const char * /*suiteName*/, const char * /*testName*/ ) {} virtual void yellowBar() {} virtual void redBar() {} // // The hard way is this: // void enterWorld( const WorldDescription &d ) { guiEnterWorld( d.numTotalTests() ); } void enterSuite( const SuiteDescription &d ) { guiEnterSuite( d.suiteName() ); } void enterTest( const TestDescription &d ) { guiEnterTest( d.suiteName(), d.testName() ); } void leaveTest( const TestDescription & ) {} void leaveSuite( const SuiteDescription & ) {} void leaveWorld( const WorldDescription & ) {} void warning( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) { yellowBarSafe(); } void failedTest( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) { redBarSafe(); } void failedAssert( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) { redBarSafe(); } void failedAssertEquals( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) { redBarSafe(); } void failedAssertSameData( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*sizeStr*/, const void * /*x*/, const void * /*y*/, unsigned /*size*/ ) { redBarSafe(); } void failedAssertDelta( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*dStr*/, const char * /*x*/, const char * /*y*/, const char * /*d*/ ) { redBarSafe(); } void failedAssertDiffers( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*value*/ ) { redBarSafe(); } void failedAssertLessThan( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) { redBarSafe(); } void failedAssertLessThanEquals( const char * /*file*/, unsigned /*line*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) { redBarSafe(); } void failedAssertPredicate( const char * /*file*/, unsigned /*line*/, const char * /*predicate*/, const char * /*xStr*/, const char * /*x*/ ) { redBarSafe(); } void failedAssertRelation( const char * /*file*/, unsigned /*line*/, const char * /*relation*/, const char * /*xStr*/, const char * /*yStr*/, const char * /*x*/, const char * /*y*/ ) { redBarSafe(); } void failedAssertThrows( const char * /*file*/, unsigned /*line*/, const char * /*expression*/, const char * /*type*/, bool /*otherThrown*/ ) { redBarSafe(); } void failedAssertThrowsNot( const char * /*file*/, unsigned /*line*/, const char * /*expression*/ ) { redBarSafe(); } protected: void yellowBarSafe() { if ( _state < YELLOW_BAR ) { yellowBar(); _state = YELLOW_BAR; } } void redBarSafe() { if ( _state < RED_BAR ) { redBar(); _state = RED_BAR; } } private: enum { GREEN_BAR, YELLOW_BAR, RED_BAR } _state; }; template<class GuiT, class TuiT> class GuiTuiRunner : public TeeListener { int &_argc; char **_argv; GuiT _gui; TuiT _tui; public: GuiTuiRunner( int &argc, char **argv ) : _argc( argc ), _argv( argv ) { setFirst( _gui ); setSecond( _tui ); } int run() { _gui.runGui( _argc, _argv, *this ); return tracker().failedTests(); } }; }; #endif //__CXXTEST__GUI_H --- NEW FILE: X11Gui.h --- #ifndef __cxxtest__X11Gui_h__ #define __cxxtest__X11Gui_h__ // // X11Gui displays a simple progress bar using X11 // // It accepts the following command-line arguments: // -title <title> - Sets the application title // -fn or -font <font> - Sets the font // -bg or -background <color> - Sets the background color (default=Grey) // -fg or -foreground <color> - Sets the text color (default=Black) // -green/-yellow/-red <color> - Sets the colors of the bar // #include <cxxtest/Gui.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <stdio.h> #include <stdlib.h> #include <string.h> namespace CxxTest { class X11Gui : public GuiListener { public: void enterGui( int &argc, char **argv ) { parseCommandLine( argc, argv ); } void enterWorld( const WorldDescription &wd ) { openDisplay(); if ( _display ) { createColors(); createWindow(); createGc(); createFont(); centerWindow(); initializeEvents(); initializeBar( wd ); processEvents(); } } void guiEnterTest( const char *suiteName, const char *testName ) { if ( _display ) { ++ _testsDone; setWindowName( suiteName, testName ); redraw(); } } void yellowBar() { if ( _display ) { _barColor = getColor( _yellowName ); getTotalTests(); processEvents(); } } void redBar() { if ( _display ) { _barColor = getColor( _redName ); getTotalTests(); processEvents(); } } void leaveGui() { if ( _display ) { freeFontInfo(); destroyGc(); destroyWindow(); closeDisplay(); } } private: const char *_programName; Display *_display; Window _window; unsigned _numTotalTests, _testsDone; char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; const char *_foregroundName, *_backgroundName; const char *_greenName, *_yellowName, *_redName; unsigned long _foreground, _background, _barColor; int _width, _height; GC _gc; const char *_fontName; XID _fontId; XFontStruct *_fontInfo; int _textHeight, _textDescent; long _eventMask; Colormap _colormap; void parseCommandLine( int &argc, char **argv ) { _programName = argv[0]; _fontName = 0; _foregroundName = "Black"; _backgroundName = "Grey"; _greenName = "Green"; _yellowName = "Yellow"; _redName = "Red"; for ( int i = 1; i + 1 < argc; ++ i ) { if ( !strcmp( argv[i], "-title" ) ) _programName = argv[++ i]; else if ( !strcmp( argv[i], "-fn" ) || !strcmp( argv[i], "-font" ) ) _fontName = argv[++ i]; else if ( !strcmp( argv[i], "-fg" ) || !strcmp( argv[i], "-foreground" ) ) _foregroundName = argv[++ i]; else if ( !strcmp( argv[i], "-bg" ) || !strcmp( argv[i], "-background" ) ) _b... [truncated message content] |