#include <wx/testing.h>
Base class for the expectation of a dialog of the given type T.
Test code can derive ad hoc classes from this class directly and implement its OnInvoked() to perform the necessary actions or derive wxExpectModal<T> and implement it once if the implementation of OnInvoked() is always the same, i.e. depends just on the type T.
T must be a class derived from wxDialog and E is the derived class type, i.e. this is an example of using CRTP. The default value of E is fine in case you're using this class as a base for your wxExpectModal<> specialization anyhow but also if you don't use either Optional() or Describe() methods, as the derived class type is only needed for them.
The library provides specialization of this class for several standard dialogs, including wxMessageDialog and wxFileDialog.
Public Types | |
typedef T | DialogType |
typedef E | ExpectationType |
Public Member Functions | |
ExpectationType | Optional () const |
Returns a copy of the expectation where the expected dialog is marked as optional. More... | |
ExpectationType | Describe (const wxString &description) const |
Sets a description shown in the error message if the expectation fails. More... | |
Protected Member Functions | |
virtual wxString | GetDefaultDescription () const |
Returns description of the expected dialog (by default, its class). More... | |
virtual int | OnInvoked (DialogType *dlg) const =0 |
This method is called when ShowModal() was invoked on a dialog of type T. More... | |
typedef T wxExpectModalBase< T, E >::DialogType |
typedef E wxExpectModalBase< T, E >::ExpectationType |
ExpectationType wxExpectModalBase< T, E >::Describe | ( | const wxString & | description | ) | const |
Sets a description shown in the error message if the expectation fails.
Using this method with unique descriptions for the different dialogs is recommended to make it easier to find out which one of the expected dialogs exactly was not shown.
|
protectedvirtual |
Returns description of the expected dialog (by default, its class).
|
protectedpure virtual |
This method is called when ShowModal() was invoked on a dialog of type T.
ExpectationType wxExpectModalBase< T, E >::Optional | ( | ) | const |
Returns a copy of the expectation where the expected dialog is marked as optional.
Optional dialogs aren't required to appear, it's not an error if they don't.