From 677eb37619fa3d14073f0457c90525ab8e42062a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Jan 2015 22:08:54 +0000 Subject: [PATCH] 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 --- include/wx/testing.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/wx/testing.h b/include/wx/testing.h index 4a92939b78..5167480463 100644 --- a/include/wx/testing.h +++ b/include/wx/testing.h @@ -189,6 +189,35 @@ public: : wxExpectDismissableModal(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