Add test of setting size of the window client area
This commit is contained in:
parent
ebec1ff9f6
commit
3ca74039da
@ -21,6 +21,7 @@
|
|||||||
#include "wx/scopedptr.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#include "asserthelper.h"
|
#include "asserthelper.h"
|
||||||
|
#include "waitforpaint.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// tests themselves
|
// tests themselves
|
||||||
@ -51,3 +52,29 @@ TEST_CASE("wxWindow::MinClientSize", "[window][client-size]")
|
|||||||
CHECK(szw.GetWidth() >= 0);
|
CHECK(szw.GetWidth() >= 0);
|
||||||
CHECK(szw.GetHeight() >= 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<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
|
||||||
|
#endif // wxGTK 2
|
||||||
|
wxScopedPtr<wxWindow> 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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user