diff --git a/tests/window/clientsize.cpp b/tests/window/clientsize.cpp index 7a76956cb8..f95cc2e2aa 100644 --- a/tests/window/clientsize.cpp +++ b/tests/window/clientsize.cpp @@ -21,6 +21,7 @@ #include "wx/scopedptr.h" #include "asserthelper.h" +#include "waitforpaint.h" // ---------------------------------------------------------------------------- // tests themselves @@ -51,3 +52,29 @@ TEST_CASE("wxWindow::MinClientSize", "[window][client-size]") CHECK(szw.GetWidth() >= 0); CHECK(szw.GetHeight() >= 0); } + +TEST_CASE("wxWindow::SetClientSize", "[window][client-size]") +{ +#if defined(__WXGTK__) && !defined(__WXGTK3__) + // Under wxGTK2 we need to have two children (at least) because if there + // is exactly one child its size is set to fill the whole parent frame + // and the window cannot be resized - see wxTopLevelWindowBase::Layout(). + wxScopedPtr w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); +#endif // wxGTK 2 + wxScopedPtr w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + + wxRect reqSize = wxTheApp->GetTopWindow()->GetClientRect(); + reqSize.Deflate(25); + w->SetClientSize(reqSize.GetSize()); + + // Wait for the first paint event to be sure + // that window really has its final size. + WaitForPaint waitForPaint(w.get()); + w->Show(); + waitForPaint.YieldUntilPainted(); + + // Check if client size has been set as required. + wxRect r = w->GetClientRect(); + CHECK(r.width == reqSize.width); + CHECK(r.height == reqSize.height); +}