Allow customizing unexpected dialogs description in wxTestingModalHook.

Extract creation of the message describing an unexpected dialog in a separate
virtual method in order to allow customizing it, notably in order to add more
useful description of custom application dialogs.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-20 22:07:31 +00:00
parent 6cf30c433c
commit 66640e67d6

View File

@@ -261,10 +261,8 @@ protected:
( (
wxString::Format wxString::Format
( (
"A %s dialog with title \"%s\" was shown unexpectedly," "%s was shown unexpectedly, expected %s.",
" expected %s.", DescribeUnexpectedDialog(dlg),
dlg->GetClassInfo()->GetClassName(),
dlg->GetTitle(),
expect->GetDescription() expect->GetDescription()
) )
); );
@@ -277,15 +275,30 @@ protected:
( (
wxString::Format wxString::Format
( (
"A dialog (%s with title \"%s\") was shown unexpectedly.", "%s was shown unexpectedly.",
dlg->GetClassInfo()->GetClassName(), DescribeUnexpectedDialog(dlg)
dlg->GetTitle()
) )
); );
return wxID_NONE; return wxID_NONE;
} }
protected: protected:
// 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.
virtual wxString DescribeUnexpectedDialog(wxDialog* dlg) const
{
return wxString::Format
(
"A %s with title \"%s\"",
dlg->GetClassInfo()->GetClassName(),
dlg->GetTitle()
);
}
// 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.
virtual void ReportFailure(const wxString& msg) virtual void ReportFailure(const wxString& msg)
{ {
wxFAIL_MSG( msg ); wxFAIL_MSG( msg );