initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
80
libs/wxWidgets-3.3.1/tests/window/clientsize.cpp
Normal file
80
libs/wxWidgets-3.3.1/tests/window/clientsize.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/window.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "asserthelper.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxWindow::ClientWindowSizeRoundTrip", "[window][client-size]")
|
||||
{
|
||||
wxWindow* const w = wxTheApp->GetTopWindow();
|
||||
REQUIRE( w );
|
||||
|
||||
const wxSize sizeWindow = w->GetSize();
|
||||
const wxSize sizeClient = w->GetClientSize();
|
||||
|
||||
INFO("client size: " << sizeClient);
|
||||
CHECK( sizeWindow == w->ClientToWindowSize(sizeClient) );
|
||||
|
||||
INFO("window size: " << sizeWindow);
|
||||
CHECK( sizeClient == w->WindowToClientSize(sizeWindow) );
|
||||
}
|
||||
|
||||
TEST_CASE("wxWindow::MinClientSize", "[window][client-size]")
|
||||
{
|
||||
std::unique_ptr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxBORDER_THEME));
|
||||
w->SetSize(wxSize(1,1));
|
||||
const wxSize szw = w->GetClientSize();
|
||||
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().
|
||||
std::unique_ptr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
|
||||
#endif // wxGTK 2
|
||||
std::unique_ptr<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);
|
||||
}
|
||||
108
libs/wxWidgets-3.3.1/tests/window/setsize.cpp
Normal file
108
libs/wxWidgets-3.3.1/tests/window/setsize.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/window/setsize.cpp
|
||||
// Purpose: Tests for SetSize() and related wxWindow methods
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-05-25
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/window.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "asserthelper.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Helper class overriding DoGetBestSize() for testing purposes.
|
||||
class MyWindow : public wxWindow
|
||||
{
|
||||
public:
|
||||
MyWindow(wxWindow* parent)
|
||||
: wxWindow(parent, wxID_ANY)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const override { return wxSize(50, 250); }
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxWindow::SetSize", "[window][size]")
|
||||
{
|
||||
std::unique_ptr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
|
||||
|
||||
SECTION("Simple")
|
||||
{
|
||||
const wxSize size(127, 35);
|
||||
w->SetSize(size);
|
||||
CHECK( size == w->GetSize() );
|
||||
}
|
||||
|
||||
SECTION("With min size")
|
||||
{
|
||||
w->SetMinSize(wxSize(100, 100));
|
||||
|
||||
const wxSize size(200, 50);
|
||||
w->SetSize(size);
|
||||
CHECK( size == w->GetSize() );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("wxWindow::GetBestSize", "[window][size][best-size]")
|
||||
{
|
||||
std::unique_ptr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
|
||||
|
||||
CHECK( wxSize(50, 250) == w->GetBestSize() );
|
||||
|
||||
w->SetMinSize(wxSize(100, 100));
|
||||
CHECK( wxSize(100, 250) == w->GetBestSize() );
|
||||
|
||||
w->SetMaxSize(wxSize(200, 200));
|
||||
CHECK( wxSize(100, 200) == w->GetBestSize() );
|
||||
}
|
||||
|
||||
TEST_CASE("wxWindow::MovePreservesSize", "[window][size][move]")
|
||||
{
|
||||
std::unique_ptr<wxWindow>
|
||||
w(new wxFrame(wxTheApp->GetTopWindow(), wxID_ANY, "Test child frame"));
|
||||
|
||||
// Unfortunately showing the window is asynchronous, at least when using
|
||||
// X11, so we have to wait for some time before retrieving its true
|
||||
// geometry. And it's not clear how long should we wait, so we do it until
|
||||
// we get the first paint event -- by then the window really should have
|
||||
// its final size.
|
||||
WaitForPaint waitForPaint(w.get());
|
||||
|
||||
w->Show();
|
||||
|
||||
waitForPaint.YieldUntilPainted();
|
||||
|
||||
const wxRect rectOrig = w->GetRect();
|
||||
|
||||
// Check that moving the window doesn't change its size.
|
||||
w->Move(rectOrig.GetPosition() + wxPoint(100, 100));
|
||||
CHECK( w->GetSize() == rectOrig.GetSize() );
|
||||
}
|
||||
Reference in New Issue
Block a user