Version: 3.3.0
wxExpectModalBase< T, E > Class Template Referenceabstract

#include <wx/testing.h>

Detailed Description

template<class T, class E = wxExpectModal<T>>
class wxExpectModalBase< T, E >

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...
 

Member Typedef Documentation

◆ DialogType

template<class T , class E = wxExpectModal<T>>
typedef T wxExpectModalBase< T, E >::DialogType

◆ ExpectationType

template<class T , class E = wxExpectModal<T>>
typedef E wxExpectModalBase< T, E >::ExpectationType

Member Function Documentation

◆ Describe()

template<class T , class E = wxExpectModal<T>>
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.

◆ GetDefaultDescription()

template<class T , class E = wxExpectModal<T>>
virtual wxString wxExpectModalBase< T, E >::GetDefaultDescription ( ) const
protectedvirtual

Returns description of the expected dialog (by default, its class).

◆ OnInvoked()

template<class T , class E = wxExpectModal<T>>
virtual int wxExpectModalBase< T, E >::OnInvoked ( DialogType dlg) const
protectedpure virtual

This method is called when ShowModal() was invoked on a dialog of type T.

Returns
Return value is used as ShowModal()'s return value.

◆ Optional()

template<class T , class E = wxExpectModal<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.