From ee55427c286e6c54306d2417a90321b1931c9404 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Sep 2020 15:52:40 +0200 Subject: [PATCH] Make it simpler to write useful tests comparing windows Allow creating wxWindowPtr from wxScopedPtr<> too, to avoid having to use .get() in the test code, and add CHECK_SAME_WINDOW() macro which gives more useful information about the windows in case of failure. --- tests/testwindow.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/testwindow.h b/tests/testwindow.h index 64b455b261..00f8003ec5 100644 --- a/tests/testwindow.h +++ b/tests/testwindow.h @@ -9,6 +9,7 @@ #ifndef _WX_TESTS_TESTWINDOW_H_ #define _WX_TESTS_TESTWINDOW_H_ +#include "wx/scopedptr.h" #include "wx/window.h" // We need to wrap wxWindow* in a class as specializing StringMaker for @@ -17,6 +18,8 @@ class wxWindowPtr { public: explicit wxWindowPtr(wxWindow* win) : m_win(win) {} + template + explicit wxWindowPtr(const wxScopedPtr& win) : m_win(win.get()) {} wxString Dump() const { @@ -44,7 +47,9 @@ private: // Macro providing more information about the current focus if comparison // fails. -#define CHECK_FOCUS_IS(w) CHECK(wxWindowPtr(wxWindow::FindFocus()) == wxWindowPtr(w)) +#define CHECK_SAME_WINDOW(w1, w2) CHECK(wxWindowPtr(w1) == wxWindowPtr(w2)) + +#define CHECK_FOCUS_IS(w) CHECK_SAME_WINDOW(wxWindow::FindFocus(), w) namespace Catch {