Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
qMRMLTestingSetup Class Reference

Sets up a widget test based on the command-line arguments of the test function. More...

#include <Libs/MRML/Widgets/qMRMLTestingSetup.h>

Public Member Functions

QString errorString () const
 
int eventPlaybackDelay () const
 
bool interactive () const
 True if interactive mode is requested (-I).
 
bool isValid () const
 Returns false if an option has a missing or invalid value. See errorString() for details.
 
QString positionalArgument (int index, const QString &defaultValue=QString()) const
 Returns the positional argument at the given index, or defaultValue if there is no such argument.
 
QStringList positionalArguments () const
 Arguments that are not testing options, in their original order.
 
 qMRMLTestingSetup (int argc, char *argv[])
 

Protected Member Functions

void applySettings () const
 
void parse (const QStringList &arguments)
 

Protected Attributes

QString ErrorString
 
int EventPlaybackDelay { -1 }
 
bool Interactive { false }
 
QStringList PositionalArguments
 

Detailed Description

Sets up a widget test based on the command-line arguments of the test function.

The constructor parses the arguments and applies the testing settings that they specify, such as the QtTesting event playback delay (this changes application-wide testing state).

Options are recognized anywhere on the command line and they are not included in positionalArguments():

  • -I: interactive mode. The test should not quit or play back recorded events automatically.
  • --event-playback-delay <ms>: delay between played back QtTesting events, in milliseconds. Zero delay makes tests run faster, while the QtTesting default delay allows watching the playback.

Example:

int qMRMLSliceWidgetEventTranslatorPlayerTest1(int argc, char* argv[])
{
QApplication app(argc, argv);
qMRMLTestingSetup testingSetup(argc, argv);
CHECK_BOOL(testingSetup.isValid(), true);
QString sourceDirectory = testingSetup.positionalArgument(0);
...
if (!testingSetup.interactive())
{
QTimer::singleShot(0, &etpWidget, SLOT(play()));
}
qMRMLTestingSetup(int argc, char *argv[])

Definition at line 52 of file qMRMLTestingSetup.h.

Constructor & Destructor Documentation

◆ qMRMLTestingSetup()

qMRMLTestingSetup::qMRMLTestingSetup ( int argc,
char * argv[] )

Parse arguments of a test function and apply the specified testing settings. The first argument (argv[0]) is the test name and it is ignored. If the arguments are invalid then the error is logged and settings are not applied.

Member Function Documentation

◆ applySettings()

void qMRMLTestingSetup::applySettings ( ) const
protected

Apply testing settings that are specified in the options (currently the QtTesting event playback delay). Settings that are not specified are not changed.

◆ errorString()

QString qMRMLTestingSetup::errorString ( ) const

◆ eventPlaybackDelay()

int qMRMLTestingSetup::eventPlaybackDelay ( ) const

Delay between played back QtTesting events, in milliseconds. Returns -1 if the delay is not specified.

◆ interactive()

bool qMRMLTestingSetup::interactive ( ) const

True if interactive mode is requested (-I).

◆ isValid()

bool qMRMLTestingSetup::isValid ( ) const

Returns false if an option has a missing or invalid value. See errorString() for details.

◆ parse()

void qMRMLTestingSetup::parse ( const QStringList & arguments)
protected

◆ positionalArgument()

QString qMRMLTestingSetup::positionalArgument ( int index,
const QString & defaultValue = QString() ) const

Returns the positional argument at the given index, or defaultValue if there is no such argument.

◆ positionalArguments()

QStringList qMRMLTestingSetup::positionalArguments ( ) const

Arguments that are not testing options, in their original order.

Member Data Documentation

◆ ErrorString

QString qMRMLTestingSetup::ErrorString
protected

Definition at line 85 of file qMRMLTestingSetup.h.

◆ EventPlaybackDelay

int qMRMLTestingSetup::EventPlaybackDelay { -1 }
protected

Definition at line 83 of file qMRMLTestingSetup.h.

◆ Interactive

bool qMRMLTestingSetup::Interactive { false }
protected

Definition at line 82 of file qMRMLTestingSetup.h.

◆ PositionalArguments

QStringList qMRMLTestingSetup::PositionalArguments
protected

Definition at line 84 of file qMRMLTestingSetup.h.


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