Utils::CalitkoMocks::TesterApplication Class Reference

#include <TesterApplication.h> [code]

Inherits QCoreApplication.

Inheritance diagram for Utils::CalitkoMocks::TesterApplication:

Inheritance graph
[legend]
Collaboration diagram for Utils::CalitkoMocks::TesterApplication:

Collaboration graph
[legend]
List of all members.

Detailed Description

Extends QCoreApplication to support tests requiring an event loop.

QCoreApplication::exec() is not supposed to be interrupted by unhandled exceptions, however, we will throw CppUnit exceptions from within QCoreApplication::processEvents() if a test that needs the event loop fails.

We solve the problem by reimplementing notify() to catch all CppUnit exceptions, store them and exit(1) the event loop. Our new implementation of exec() checks the stored exception and rethrows it so that CppUnit can report the failed test.

Todo:
Move to its own module?

Definition at line 45 of file TesterApplication.h.

Public Member Functions

 TesterApplication (int &argc, char **argv)
bool notify (QObject *receiver, QEvent *event)
 Adds exception handling to QCoreApplication::notify().

Static Public Member Functions

static int exec (int maxTime)
 Executes the application main loop and rethrows CppUnit exceptions.

Private Slots

void timeout ()

Private Attributes

auto_ptr< CPPUNIT_NS::Exception > cppUnitException
QTimer timeoutTimer


Constructor & Destructor Documentation

TesterApplication::TesterApplication int &  argc,
char **  argv
 

Definition at line 27 of file TesterApplication.cpp.


Member Function Documentation

int TesterApplication::exec int  maxTime  )  [static]
 

Executes the application main loop and rethrows CppUnit exceptions.

Definition at line 36 of file TesterApplication.cpp.

bool TesterApplication::notify QObject receiver,
QEvent *  event
 

Adds exception handling to QCoreApplication::notify().

Definition at line 63 of file TesterApplication.cpp.

void TesterApplication::timeout  )  [private, slot]
 

Definition at line 74 of file TesterApplication.cpp.


Member Data Documentation

auto_ptr<CPPUNIT_NS::Exception> Utils::CalitkoMocks::TesterApplication::cppUnitException [private]
 

Definition at line 58 of file TesterApplication.h.

QTimer Utils::CalitkoMocks::TesterApplication::timeoutTimer [private]
 

Definition at line 59 of file TesterApplication.h.


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