xTitan
|
Macros | |
#define | spyInput xtitan::detail::SpyInput(spyGetToken(this).toUtf8(),__FUNCTION__) |
Records function call. More... | |
#define | spyCheck xtitan::detail::SpyCheck(__FILE__,__LINE__) |
Creates synchronized check point. More... | |
#define | spyAsyncCheck xtitan::detail::SpyAsyncCheck(__FILE__,__LINE__) |
Creates asynchronized check point. More... | |
Functions | |
void | spyRegisterObject (QObject *object, const QString &id) |
Register object for record/replay. More... | |
QString | spyGetToken (QObject *object) |
Get ID of a registered object. More... | |
QObject * | spyGetObject (const QString &token) |
Get a registered object by ID. More... | |
void | spyTryTestAutomation () |
Start record/replay. More... | |
bool | spyIsTesting () |
record/replay is start or not More... | |
#define spyAsyncCheck xtitan::detail::SpyAsyncCheck(__FILE__,__LINE__) |
Creates asynchronized check point.
Similar to spyCheck, except that check points can reorder. Because execution order may randomly interleave in multi-thread context, you must use this macro in concurrent functions.
To distinguish individual execution order in each threads, you must specify ID and precondition to each check points. ID should be a string. Use id() to specify ID, and pre() to specify precondition, for example:
#define spyCheck xtitan::detail::SpyCheck(__FILE__,__LINE__) |
Creates synchronized check point.
This macro creates a synchronized check point, which can record variables or function results while recording, and compares their values in each replay. After replay, if check point sequence mismatched (either by reordering, missing or duplicating), then this replay was failed.
To use this macro record variables, simply put variables with operator %, but variable type must be one of
or any other types which can implicitly convert to these types.
For example:
#define spyInput xtitan::detail::SpyInput(spyGetToken(this).toUtf8(),__FUNCTION__) |
Records function call.
This macro records function call, so that test driver can replay this function later. The function being recording MUST match following rules:
To use this macro is quite simple, just put this macro in your function (generally at first line), and concat all parameters with operator %.
Following example explains how to use spyInput:
QObject* spyGetObject | ( | const QString & | token) |
Get a registered object by ID.
[in] | token |
token
This function can retrive object which registered by spyRegisterObject.
QString spyGetToken | ( | QObject * | object) |
Get ID of a registered object.
[in] | object |
object
This function can retrive ID which registered by spyRegisterObject.
bool spyIsTesting | ( | ) |
void spyRegisterObject | ( | QObject * | object, |
const QString & | id | ||
) |
Register object for record/replay.
[in] | object | object being register |
[in] | id | unique ID for this object |
If object
is nullptr, or id
is an empty string, this function does nothing.
Objects must register by this method first before they can be recording by spyInput. A common place for this function is inside a constructor.
void spyTryTestAutomation | ( | ) |
Start record/replay.
Without calling this function, record/replay won't start. Please call this function as early as possible, e.g. in the main function.