Fix executing wxPaintDC-related tests under wxGTK

First child window has fixed size so we need to create a second window
and use it for wxPaintDC tests.
This commit is contained in:
Artur Wieczorek 2023-01-04 19:59:32 +01:00
parent ccaf5728f6
commit 808bbe8341
2 changed files with 22 additions and 10 deletions

View file

@ -673,12 +673,11 @@ TEST_CASE("ClipperTestCase::wxPaintDC", "[clipper][dc][paintdc]")
winSize.x = wxMax(winSize.x, s_dcSize.x + 50);
winSize.y = wxMax(winSize.y, s_dcSize.y + 50);
wxTheApp->GetTopWindow()->SetSize(winSize);
#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().
#if defined(__WXGTK__)
// Under wxGTK we need to have two children (at least) because if there
// is one child its paint area is set to fill the whole parent frame.
std::unique_ptr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
#endif // wxGTK 2
#endif // wxGTK
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
win->SetClientSize(s_dcSize);
@ -754,6 +753,13 @@ TEST_CASE("ClipperTestCase::wxPaintDC", "[clipper][dc][paintdc]")
testWin->Refresh();
testWin->Update();
// Wait for update to be done
wxStopWatch sw;
while( sw.Time() < 50 )
{
wxYield();
}
CHECK(paintExecuted == true);
#endif // !__WXOSX__
}

View file

@ -3978,12 +3978,11 @@ TEST_CASE("ClippingBoxTestCase::wxPaintDC", "[clip][dc][paintdc]")
winSize.x = wxMax(winSize.x, s_dcSize.x + 50);
winSize.y = wxMax(winSize.y, s_dcSize.y + 50);
wxTheApp->GetTopWindow()->SetSize(winSize);
#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().
#if defined(__WXGTK__)
// Under wxGTK we need to have two children (at least) because if there
// is one child its paint area is set to fill the whole parent frame.
wxScopedPtr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
#endif // wxGTK 2
#endif // wxGTK
wxScopedPtr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
win->SetClientSize(s_dcSize);
@ -4324,6 +4323,13 @@ TEST_CASE("ClippingBoxTestCase::wxPaintDC", "[clip][dc][paintdc]")
testWin->Refresh();
testWin->Update();
// Wait for update to be done
wxStopWatch sw;
while( sw.Time() < 50 )
{
wxYield();
}
CHECK(paintExecuted == true);
#endif // !__WXOSX__
}