#include <WxGuiTestHelper.h>
Public Member Functions | |
WxGuiTestHelper () | |
Constructor. | |
virtual | ~WxGuiTestHelper () |
Destructor. | |
Static Public Member Functions | |
static void | AddTestFailure (const wxString &file, const int line, const wxString &shortDescription, const wxString &message) |
static void | BreakTestToShowCurrentGui () |
Break test and show current GUI and query user for continuation. | |
static wxMenu * | FindPopupMenu (const wxString &key) |
Look for with key specified pop-up menu in cached pop-up menu map. | |
static wxWindow * | FindPopupMenuEvtHandlerWdw (const wxString &key) |
Look for with key specified pop-up menu event handler window in cached pop-up menu map. | |
static wxString | FindPopupMenuKey (wxMenu *menu) |
Look for key of given pop-up menu in cached pop-up menu map. | |
static int | FlushEventQueue () |
Flushes event queue in wxWidgets main loop. | |
static bool | GetCheckForProvokedWarnings () |
Get flag indicating check for unexpected warnings. | |
static bool | GetDisableTestInteractivity () |
static bool | GetInteractive () |
Returns the current value of s_interactive. | |
static bool | GetPopupWarningForFailingAssert () |
Get flag indicating if failing assertions should pop-up the default warning dialog allowing to break debugging. | |
static bool | GetShowModalDialogsNonModalFlag () |
Get flag indicating modal dialogs should be shown non-modal. | |
static bool | GetShowPopupMenusFlag () |
Get flag indicating popup menu showing. | |
static bool | IsGuiLessUnitTestFlag () |
Get flag indicating if no GUI should be shown at all. | |
static bool | IsProvokedWarning (const wxString &caption, const wxString &message) |
In testing mode check if this warning is a provoked one to test for some non-functional case, or some unfulfilled condition leading to a warning. | |
static bool | PopupMenu (wxWindow *wdw, wxMenu *menu, const wxPoint &pos, const wxString &cacheMapKey, bool isGuiLessUnitTest) |
Pop up menus conditionally using global s_isGuiLessUnitTest flag. | |
static bool | PopupMenu (wxWindow *wdw, wxMenu *menu, const wxPoint &pos, const wxString &cacheMapKey) |
Pop up menus conditionally using global s_isGuiLessUnitTest flag. | |
static void | SetCheckForProvokedWarnings (bool check) |
Set flag indicating check for unexpected warnings. | |
static void | SetDisableTestInteractivity (bool disable) |
static void | SetInteractive (bool interactive) |
static void | SetIsGuiLessUnitTestFlag (bool isGuiLess) |
Set flag indicating if no GUI should be shown at all. | |
static void | SetPopupWarningForFailingAssert (bool popup) |
Set flag indicating if failing assertions should pop-up the default warning dialog allowing to break debugging. | |
static void | SetShowModalDialogsNonModalFlag (bool showNonModal) |
Set flag indicating modal dialogs should be shown non-modal. | |
static void | SetShowPopupMenusFlag (bool showPopupMenus) |
Set flag indicating popup menu showing. | |
static void | SetWarningAsserter (WarningAsserterInterface *warningAsserter) |
Set warning asserter to be used in testing mode. | |
static int | Show (wxWindow *wdw, bool show, bool isModal, bool isGuiLessUnitTest) |
Show frames, dialogs conditionally using isGuiLessUnitTest flag. | |
static int | Show (wxWindow *wdw, bool show, bool isModal) |
Show frames, dialogs conditionally using global s_isGuiLessUnitTest flag. |
Mainly to (a) configure the behaviour of WxGuiTestApp class (e.g. showing modal dialogs non-modal), and (b) facilitate the usage of some common features (e.g. flushing the event queue, or making the test temporary interactive for manual visual checks during GUI test implementation).
GUI events are run by pushing them onto a wxEventHandler's event queue using wxPostEvent and, once the events for a test have been set up in sequence, calling (via wxTestApp::MainLoop, which makes sure that the AUT can't start a real event loop with calls from functions like wxDialog::ShowModal) wxProcessEvents. When s_interactive is true, wxTestApp::MainLoop will call wxApp::MainLoop instead, allowing the AUT to respond to regular events. Note that functions which launch a platform event loop (e.g., wxMessageBox) evade this system, so test dummies are needed for those functions.
The flag s_isGuiLessUnitTest (and getter/setter method) can be used to prevent any showing of dialogs -- if the actual call to someDialog->Show() is diverted to Show() method of this class! Thus, it only works for own code, and wxMessageBox as well as wxWidgets standard dialogs are of course an exception.
Finally, s_showModalDialogsNonModal (and getter/setter method) can be used to show modal dialogs non-modal. This is critical for unit tests, as modal dialogs have their own message processing loop, blocking for some user input.
"Temporary interactive tests" are provided in two different shapes:
Of course, some additonal more complex functionality requires its own classes and is therefore not accessible via this class, e.g.:
Finally, the occurence of unexpected or unprovoked warnings via App::DisplayWarning() method calls can be detected based on calling WxGuiTestHelper::IsProvokedWarning() at the beginning of the aforementioned method in the application under test (AUT): such a warning means the test case has failed.
Definition at line 98 of file WxGuiTestHelper.h.
wxTst::WxGuiTestHelper::WxGuiTestHelper | ( | ) |
wxTst::WxGuiTestHelper::~WxGuiTestHelper | ( | ) | [virtual] |
void wxTst::WxGuiTestHelper::AddTestFailure | ( | const wxString & | file, | |
const int | line, | |||
const wxString & | shortDescription, | |||
const wxString & | message | |||
) | [static] |
void wxTst::WxGuiTestHelper::BreakTestToShowCurrentGui | ( | ) | [static] |
Break test and show current GUI and query user for continuation.
Using a standard wxMessageBox the user can inspect the current GUI without interaction. Testing is continued when confirming the popup message. In fact, only windows/dialogs/frames really "shown" (cf. s_isGuiLessUnitTest flag) can be shown.
Definition at line 203 of file WxGuiTestHelper.cpp.
References GetDisableTestInteractivity().
wxMenu * wxTst::WxGuiTestHelper::FindPopupMenu | ( | const wxString & | key | ) | [static] |
Look for with key specified pop-up menu in cached pop-up menu map.
key | string specifying pop-up menu (used during PopupMenu() method) |
Definition at line 286 of file WxGuiTestHelper.cpp.
wxWindow * wxTst::WxGuiTestHelper::FindPopupMenuEvtHandlerWdw | ( | const wxString & | key | ) | [static] |
Look for with key specified pop-up menu event handler window in cached pop-up menu map.
Only used for capturing & replay!
key | string specifying pop-up menu event handler window (used during PopupMenu() method) |
Definition at line 314 of file WxGuiTestHelper.cpp.
wxString wxTst::WxGuiTestHelper::FindPopupMenuKey | ( | wxMenu * | menu | ) | [static] |
Look for key of given pop-up menu in cached pop-up menu map.
Only used for capturing & replay!
menu | pop-up menu to look up map key |
Definition at line 295 of file WxGuiTestHelper.cpp.
int wxTst::WxGuiTestHelper::FlushEventQueue | ( | ) | [static] |
Flushes event queue in wxWidgets main loop.
As this functionality requires changing some of the flags, they will be stored temporarily and set back at the end to their initial values.
Definition at line 69 of file WxGuiTestHelper.cpp.
References wxTst::WarningAsserterInterface::FailAssert().
bool wxTst::WxGuiTestHelper::GetCheckForProvokedWarnings | ( | ) | [static] |
Get flag indicating check for unexpected warnings.
Definition at line 364 of file WxGuiTestHelper.cpp.
Referenced by IsProvokedWarning().
bool wxTst::WxGuiTestHelper::GetDisableTestInteractivity | ( | ) | [static] |
Definition at line 268 of file WxGuiTestHelper.cpp.
Referenced by BreakTestToShowCurrentGui(), and wxTst::TempInteractive::ShowCurrentGui().
bool wxTst::WxGuiTestHelper::GetInteractive | ( | ) | [static] |
Returns the current value of s_interactive.
Definition at line 221 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
bool wxTst::WxGuiTestHelper::GetPopupWarningForFailingAssert | ( | ) | [static] |
Get flag indicating if failing assertions should pop-up the default warning dialog allowing to break debugging.
Definition at line 280 of file WxGuiTestHelper.cpp.
bool wxTst::WxGuiTestHelper::GetShowModalDialogsNonModalFlag | ( | ) | [static] |
Get flag indicating modal dialogs should be shown non-modal.
Again, this is "only" used in Show() method which should be employed for all own code with the need for showing a dialog.
Definition at line 244 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
bool wxTst::WxGuiTestHelper::GetShowPopupMenusFlag | ( | ) | [static] |
Get flag indicating popup menu showing.
This is "only" used in PopupMenu() method which should be employed for all own code with the need of popping up a menu.
Definition at line 256 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
bool wxTst::WxGuiTestHelper::IsGuiLessUnitTestFlag | ( | ) | [static] |
Get flag indicating if no GUI should be shown at all.
Definition at line 232 of file WxGuiTestHelper.cpp.
bool wxTst::WxGuiTestHelper::IsProvokedWarning | ( | const wxString & | caption, | |
const wxString & | message | |||
) | [static] |
In testing mode check if this warning is a provoked one to test for some non-functional case, or some unfulfilled condition leading to a warning.
Allow detection of unexpected/unprovoked warnings which means a failing test case. Internally ProvokedWarningRegistry is used.
caption | caption of occured warning | |
message | message of occured warning |
Definition at line 323 of file WxGuiTestHelper.cpp.
References AddTestFailure(), wxTst::ProvokedWarningRegistry::FindRegisteredWarning(), GetCheckForProvokedWarnings(), wxTst::ProvokedWarningRegistry::GetInstance(), wxTst::ProvokedWarningRegistry::IsRegisteredAndInTime(), and wxTst::ProvokedWarningRegistry::SetWarningAsDetected().
bool wxTst::WxGuiTestHelper::PopupMenu | ( | wxWindow * | wdw, | |
wxMenu * | menu, | |||
const wxPoint & | pos, | |||
const wxString & | cacheMapKey, | |||
bool | isGuiLessUnitTest | |||
) | [static] |
Pop up menus conditionally using global s_isGuiLessUnitTest flag.
wdw | parent component to pop up menu | |
menu | menu to pop up | |
pos | position of menu | |
cacheMapKey | key under which the pop-up menu is cached for subsequent finding in test code | |
isGuiLessUnitTest | "overwriting" global s_isGuiLessUnitTest flag |
Definition at line 175 of file WxGuiTestHelper.cpp.
bool wxTst::WxGuiTestHelper::PopupMenu | ( | wxWindow * | wdw, | |
wxMenu * | menu, | |||
const wxPoint & | pos, | |||
const wxString & | cacheMapKey | |||
) | [static] |
Pop up menus conditionally using global s_isGuiLessUnitTest flag.
wdw | parent component to pop up menu | |
menu | menu to pop up | |
pos | position of menu | |
cacheMapKey | key under which the pop-up menu is cached for subsequent finding in test code |
Definition at line 167 of file WxGuiTestHelper.cpp.
void wxTst::WxGuiTestHelper::SetCheckForProvokedWarnings | ( | bool | check | ) | [static] |
Set flag indicating check for unexpected warnings.
check | if true, means unexpected warnings will lead to test case failure in CheckForProvokedWarning() method |
Definition at line 358 of file WxGuiTestHelper.cpp.
void wxTst::WxGuiTestHelper::SetDisableTestInteractivity | ( | bool | disable | ) | [static] |
Definition at line 262 of file WxGuiTestHelper.cpp.
void wxTst::WxGuiTestHelper::SetInteractive | ( | bool | interactive | ) | [static] |
Definition at line 215 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
void wxTst::WxGuiTestHelper::SetIsGuiLessUnitTestFlag | ( | bool | isGuiLess | ) | [static] |
Set flag indicating if no GUI should be shown at all.
This is "only" used in Show() method which should be employed for all own code with the need for showing a dialog.
isGuiLess | if true, no GUI should be shown at all |
Definition at line 226 of file WxGuiTestHelper.cpp.
void wxTst::WxGuiTestHelper::SetPopupWarningForFailingAssert | ( | bool | popup | ) | [static] |
Set flag indicating if failing assertions should pop-up the default warning dialog allowing to break debugging.
Is only used when testing in debug mode. For real test automation the associated flag s_popupWarningForFailingAssert should be set to false; as well as s_disableTestInteractivity should be set to true.
popup | if true, failing assertions pop-up the warning message box |
Definition at line 274 of file WxGuiTestHelper.cpp.
void wxTst::WxGuiTestHelper::SetShowModalDialogsNonModalFlag | ( | bool | showNonModal | ) | [static] |
Set flag indicating modal dialogs should be shown non-modal.
Again, this is "only" used in Show() method which should be employed for all own code with the need for showing a dialog.
showNonModal | if true, modal dialogs are shown non-modal |
Definition at line 238 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
void wxTst::WxGuiTestHelper::SetShowPopupMenusFlag | ( | bool | showPopupMenus | ) | [static] |
Set flag indicating popup menu showing.
This is "only" used in PopupMenu() method which should be employed for all own code with the need of popping up a menu.
showPopupMenus | if true, pop-up menus are actually shown |
Definition at line 250 of file WxGuiTestHelper.cpp.
Referenced by wxTst::CRCapture::Show(), and wxTst::TempInteractive::ShowCurrentGui().
void wxTst::WxGuiTestHelper::SetWarningAsserter | ( | WarningAsserterInterface * | warningAsserter | ) | [static] |
Set warning asserter to be used in testing mode.
warningAsserter | asserter to be used in testing mode |
Definition at line 370 of file WxGuiTestHelper.cpp.
int wxTst::WxGuiTestHelper::Show | ( | wxWindow * | wdw, | |
bool | show, | |||
bool | isModal, | |||
bool | isGuiLessUnitTest | |||
) | [static] |
Show frames, dialogs conditionally using isGuiLessUnitTest flag.
wdw | dialog or frame handle | |
show | true, if wdw should be shown (taking isGuiLessUnitTest into accout) | |
isModal | for dialogs intended to be shown in modal style (taking s_showModalDialogsNonModal into account) | |
isGuiLessUnitTest | "overwriting" global s_isGuiLessUnitTest flag |
Definition at line 105 of file WxGuiTestHelper.cpp.
int wxTst::WxGuiTestHelper::Show | ( | wxWindow * | wdw, | |
bool | show, | |||
bool | isModal | |||
) | [static] |
Show frames, dialogs conditionally using global s_isGuiLessUnitTest flag.
wdw | dialog or frame pointer | |
show | true, if wdw should be shown (taking s_isGuiLessUnitTest into accout) | |
isModal | for dialogs intended to be shown in modal style (taking s_showModalDialogsNonModal into account) |
Definition at line 98 of file WxGuiTestHelper.cpp.