#include <wx/testing.h>
Implementation of wxModalDialogHook for use in testing.
This class is used by default by wxTEST_DIALOG() macro and is not intended for direct use.
It can, however, be derived from if you wish to customize the default behaviour, see wxTEST_DIALOG_HOOK_CLASS.
Public Member Functions | |
wxTestingModalHook (const char *file=nullptr, int line=0, const char *func=nullptr) | |
Constructor used by wxTEST_DIALOG(). More... | |
void | CheckUnmetExpectations () |
Called to verify that all expectations were met. More... | |
void | AddExpectation (const wxModalExpectation &e) |
Add an expectation checked by CheckUnmetExpectations(). More... | |
Public Member Functions inherited from wxModalDialogHook | |
wxModalDialogHook () | |
Default and trivial constructor. More... | |
virtual | ~wxModalDialogHook () |
Destructor unregisters the hook if it's currently active. More... | |
void | Register () |
Register this hook as being active. More... | |
void | Unregister () |
Unregister this hook. More... | |
Protected Member Functions | |
virtual wxString | DescribeUnexpectedDialog (wxDialog *dlg) const |
Called to describe a dialog shown unexpectedly. More... | |
virtual void | ReportFailure (const wxString &msg) |
Report the given failure. More... | |
Protected Member Functions inherited from wxModalDialogHook | |
virtual int | Enter (wxDialog *dialog)=0 |
Called by wxWidgets before showing any modal dialogs. More... | |
virtual void | Exit (wxDialog *dialog) |
Called by wxWidgets after dismissing the modal dialog. More... | |
wxTestingModalHook::wxTestingModalHook | ( | const char * | file = nullptr , |
int | line = 0 , |
||
const char * | func = nullptr |
||
) |
Constructor used by wxTEST_DIALOG().
This object is created with the location of the macro containing it by wxTEST_DIALOG macro, otherwise it falls back to the location of this line itself, which is not very useful, so normally you should provide your own values.
void wxTestingModalHook::AddExpectation | ( | const wxModalExpectation & | e | ) |
Add an expectation checked by CheckUnmetExpectations().
void wxTestingModalHook::CheckUnmetExpectations | ( | ) |
Called to verify that all expectations were met.
This cannot be done in the destructor, because ReportFailure() may throw (either because it's overridden or because wx's assertions handling is, globally). And throwing from the destructor would introduce all sort of problems, including messing up the order of errors in some cases.
|
protectedvirtual |
Called to describe a dialog shown unexpectedly.
This method may be overridden to provide a better description of (unexpected) dialogs, e.g. add knowledge of custom dialogs used by the program here.
The default implementation shows the type of the dialog.
|
protectedvirtual |
Report the given failure.
This method may be overridden to change the way test failures are handled. By default they result in an assertion failure which, of course, can itself be customized.