From 66640e67d640fef231cd572054c10ffbda118c1b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 20 Sep 2014 22:07:31 +0000 Subject: [PATCH] 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 --- include/wx/testing.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/wx/testing.h b/include/wx/testing.h index fd72cf7fdc..9e4335297b 100644 --- a/include/wx/testing.h +++ b/include/wx/testing.h @@ -261,10 +261,8 @@ protected: ( wxString::Format ( - "A %s dialog with title \"%s\" was shown unexpectedly," - " expected %s.", - dlg->GetClassInfo()->GetClassName(), - dlg->GetTitle(), + "%s was shown unexpectedly, expected %s.", + DescribeUnexpectedDialog(dlg), expect->GetDescription() ) ); @@ -277,15 +275,30 @@ protected: ( wxString::Format ( - "A dialog (%s with title \"%s\") was shown unexpectedly.", - dlg->GetClassInfo()->GetClassName(), - dlg->GetTitle() + "%s was shown unexpectedly.", + DescribeUnexpectedDialog(dlg) ) ); return wxID_NONE; } 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) { wxFAIL_MSG( msg );