Ensure that we never return negative client size.
wxMSW could return negative client size for tiny windows with borders, this was unexpected and shouldn't happen so explicitly ensure it does not. Also add a unit test to check that this problem doesn't exist in other ports. Closes #13184. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,10 +37,12 @@ public:
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( ClientSizeTestCase );
|
||||
CPPUNIT_TEST( ClientToWindow );
|
||||
CPPUNIT_TEST( ClientSizeNotNegative );
|
||||
CPPUNIT_TEST( WindowToClient );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ClientToWindow();
|
||||
void ClientSizeNotNegative();
|
||||
void WindowToClient();
|
||||
|
||||
wxWindow *m_win;
|
||||
@@ -78,6 +80,18 @@ void ClientSizeTestCase::ClientToWindow()
|
||||
m_win->ClientToWindowSize(m_win->GetClientSize()));
|
||||
}
|
||||
|
||||
void ClientSizeTestCase::ClientSizeNotNegative()
|
||||
{
|
||||
wxWindow* w = new wxWindow(wxTheApp->GetTopWindow(), -1,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxBORDER_THEME);
|
||||
w->SetSize(wxSize(1,1));
|
||||
const wxSize szw = w->GetClientSize();
|
||||
CPPUNIT_ASSERT(szw.GetWidth() >= 0);
|
||||
CPPUNIT_ASSERT(szw.GetHeight() >= 0);
|
||||
w->Destroy();
|
||||
}
|
||||
|
||||
void ClientSizeTestCase::WindowToClient()
|
||||
{
|
||||
CPPUNIT_ASSERT(m_win->GetClientSize() ==
|
||||
|
Reference in New Issue
Block a user