Provide better description of the expected message boxes.

While the example in the previous commit message, with two identical
expectations, still requires a custom description to be have unambiguous
failure messages, in other cases it's enough to show the expected message box
buttons in the error to make it possible to immediately see which expectation
failed, so include the information deduced from the expected button into the
description.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78413 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2015-01-24 22:08:54 +00:00
parent 9099ae2ded
commit 677eb37619

View File

@@ -189,6 +189,35 @@ public:
: wxExpectDismissableModal<wxMessageDialog>(id) : wxExpectDismissableModal<wxMessageDialog>(id)
{ {
} }
protected:
virtual wxString GetDefaultDescription() const
{
// It can be useful to show which buttons the expected message box was
// supposed to have, in case there could have been several of them.
wxString details;
switch ( m_id )
{
case wxID_YES:
case wxID_NO:
details = "wxYES_NO style";
break;
case wxID_CANCEL:
details = "wxCANCEL style";
break;
case wxID_OK:
details = "wxOK style";
break;
default:
details.Printf("a button with ID=%d", m_id);
break;
}
return "wxMessageDialog with " + details;
}
}; };
class wxExpectAny : public wxExpectDismissableModal<wxDialog> class wxExpectAny : public wxExpectDismissableModal<wxDialog>