NifTK
16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
|
Test class to ensure the atomic transition from one object state to another. More...
Public Types | |
typedef ItkSignalCollector::Signals | ItkSignals |
typedef QtSignalCollector::Signal | QtSignal |
typedef QtSignalCollector::Signals | QtSignals |
Public Member Functions | |
mitkClassMacroItkParent (AtomicStateTransitionTester, itk::Object) mitkNewMacro1Param(AtomicStateTransitionTester | |
virtual TestObject | GetTestObject () const |
Gets the object whose state consistency is being tested. More... | |
virtual TestObjectState::Pointer | GetInitialState () const |
Gets the initial state of the test object. More... | |
virtual TestObjectState::Pointer | GetNextState () const |
Gets the next state of the test object. More... | |
virtual TestObjectState::Pointer | GetExpectedState () const |
Gets the expected state of the test object. More... | |
virtual void | SetExpectedState (typename TestObjectState::Pointer _arg) |
Sets the expected state of the test object. More... | |
virtual void | Clear () |
Clears the collected signals and resets the states. More... | |
void | Connect (itk::Object *itkObject, const itk::EventObject &event) |
Connects this object to the specified events of itkObject. The consistency of the test object will be checked after these ITK events. More... | |
void | Connect (const itk::EventObject &event) |
Connects this object to the specified events of the test object. The consistency of the test object will be checked after these ITK events. The function assumes that the test object is an itk::Object. More... | |
void | Connect (const QObject *qObject, const char *signal=0) |
Connects this object to the specified signals of the given object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject. More... | |
void | Connect (const char *signal) |
Connects this object to the specified signals of the test object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject. More... | |
const ItkSignals & | GetItkSignals () const |
Returns the collected ITK signals. More... | |
ItkSignals | GetItkSignals (const itk::Object *itkObject, const itk::EventObject &event=itk::AnyEvent()) const |
Returns a set of the collected ITK signals that are sent from the given object, and are of the given type or its subtype. More... | |
ItkSignals | GetItkSignals (const itk::EventObject &event) const |
Returns a set of the collected ITK signals that are of the given type or its subtype. More... | |
const QtSignals & | GetQtSignals () const |
Gets the Qt signals collected by this object. More... | |
QtSignals | GetQtSignals (const QObject *object, const char *signal=0) |
Returns a set of the collected Qt signals that are of the given type. More... | |
QtSignals | GetQtSignals (const char *signal) |
Returns a set of the collected Qt signals that are sent from the given object, and are of the given type. More... | |
Public Attributes | |
TestObject typedef ItkSignalCollector::Signal | ItkSignal |
Protected Member Functions | |
AtomicStateTransitionTester (TestObject testObject) | |
Constructs an AtomicStateTransitionTester object. More... | |
virtual | ~AtomicStateTransitionTester () |
Destructs an AtomicStateTransitionTester object. More... | |
virtual void | OnItkSignalReceived (const itk::Object *object, const itk::EventObject &event) |
Handler for the ITK signals. Checks the consistency of the test object. More... | |
virtual void | OnQtSignalReceived (const QObject *object, const char *signal) |
Handler for the Qt signals. Checks the consistency of the test object. More... | |
virtual void | PrintSelf (std::ostream &os, itk::Indent indent) const |
Prints the collected signals to the given stream or to the standard output if no stream is given. More... | |
Test class to ensure the atomic transition from one object state to another.
The state of the tested object must change at most once during the execution of a public function.
Pattern of use:
typedef niftk::AtomicStateTransitionTester<Viewer, ViewerState> ViewerStateTester; ViewerStateTester::Pointer viewerStateTester = ViewerStateTester::New(viewer);
Connect the object to the ITK or Qt events sent out from this object or some of its aggregated objects:
viewer->Connect(viewer->GetAxialWindow(), mitk::FocusEvent()); ... viewer->SomePublicFunction(...);
Check the received signals if needed:
QVERIFY( viewerStateTester->GetItkSignals( mitk::FocusEvent() ).size() == 1 );
viewerStateTester->Clear(); viewer->AnotherPublicFunction(...); ...
typedef ItkSignalCollector::Signals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::ItkSignals |
typedef QtSignalCollector::Signal niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::QtSignal |
typedef QtSignalCollector::Signals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::QtSignals |
|
protected |
Constructs an AtomicStateTransitionTester object.
We collect the ITK signals using an ItkSignalCollector object.
If the tested object is a QObject then let us discover its public signals and connect this object to them.
Note: The SIGNAL macro preprends a '2' before the signals and '1' before slots. So that the connect mechanism works, we have to imitate this behaviour here.
|
protectedvirtual |
Destructs an AtomicStateTransitionTester object.
|
virtual |
Clears the collected signals and resets the states.
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect | ( | itk::Object * | itkObject, |
const itk::EventObject & | event | ||
) |
Connects this object to the specified events of itkObject. The consistency of the test object will be checked after these ITK events.
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect | ( | const itk::EventObject & | event | ) |
Connects this object to the specified events of the test object. The consistency of the test object will be checked after these ITK events. The function assumes that the test object is an itk::Object.
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect | ( | const QObject * | qObject, |
const char * | signal = 0 |
||
) |
Connects this object to the specified signals of the given object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject.
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect | ( | const char * | signal | ) |
Connects this object to the specified signals of the test object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject.
|
virtual |
Gets the expected state of the test object.
|
virtual |
Gets the initial state of the test object.
|
inline |
Returns the collected ITK signals.
|
inline |
Returns a set of the collected ITK signals that are sent from the given object, and are of the given type or its subtype.
|
inline |
Returns a set of the collected ITK signals that are of the given type or its subtype.
|
virtual |
Gets the next state of the test object.
|
inline |
Gets the Qt signals collected by this object.
|
inline |
Returns a set of the collected Qt signals that are of the given type.
|
inline |
Returns a set of the collected Qt signals that are sent from the given object, and are of the given type.
|
virtual |
Gets the object whose state consistency is being tested.
niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::mitkClassMacroItkParent | ( | AtomicStateTransitionTester< TestObject, TestObjectState > | , |
itk::Object | |||
) |
|
inlineprotectedvirtual |
Handler for the ITK signals. Checks the consistency of the test object.
Implements niftk::ItkSignalListener.
|
inlineprotectedvirtual |
Handler for the Qt signals. Checks the consistency of the test object.
Implements niftk::QtSignalListener.
|
protectedvirtual |
Prints the collected signals to the given stream or to the standard output if no stream is given.
|
virtual |
Sets the expected state of the test object.
TestObject typedef ItkSignalCollector::Signal niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::ItkSignal |