2008-02-12 10:49:22 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/controls/clientsize.cpp
|
|
|
|
// Purpose: Client vs. window size handling unit test
|
|
|
|
// Author: Vaclav Slavik
|
|
|
|
// Created: 2008-02-12
|
|
|
|
// Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "testprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/window.h"
|
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
#include "wx/scopedptr.h"
|
2008-02-12 10:49:22 -05:00
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
#include "asserthelper.h"
|
2008-02-12 10:49:22 -05:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2019-09-19 21:26:59 -04:00
|
|
|
// tests themselves
|
2008-02-12 10:49:22 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
TEST_CASE("wxWindow::ClientWindowSizeRoundTrip", "[window][client-size]")
|
2008-02-12 10:49:22 -05:00
|
|
|
{
|
2019-09-19 21:26:59 -04:00
|
|
|
wxWindow* const w = wxTheApp->GetTopWindow();
|
|
|
|
REQUIRE( w );
|
2008-02-12 10:49:22 -05:00
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
const wxSize sizeWindow = w->GetSize();
|
|
|
|
const wxSize sizeClient = w->GetClientSize();
|
2008-02-12 10:49:22 -05:00
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
INFO("client size: " << sizeClient);
|
|
|
|
CHECK( sizeWindow == w->ClientToWindowSize(sizeClient) );
|
2008-02-12 10:49:22 -05:00
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
INFO("window size: " << sizeWindow);
|
|
|
|
CHECK( sizeClient == w->WindowToClientSize(sizeWindow) );
|
2008-02-12 10:49:22 -05:00
|
|
|
}
|
|
|
|
|
2019-09-19 21:26:59 -04:00
|
|
|
TEST_CASE("wxWindow::MinClientSize", "[window][client-size]")
|
2011-05-16 10:07:40 -04:00
|
|
|
{
|
2019-09-19 21:26:59 -04:00
|
|
|
wxScopedPtr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxBORDER_THEME));
|
2011-05-16 10:07:40 -04:00
|
|
|
w->SetSize(wxSize(1,1));
|
|
|
|
const wxSize szw = w->GetClientSize();
|
2019-09-19 21:26:59 -04:00
|
|
|
CHECK(szw.GetWidth() >= 0);
|
|
|
|
CHECK(szw.GetHeight() >= 0);
|
2008-02-12 10:49:22 -05:00
|
|
|
}
|