From 808bbe8341eac20afd17278f8d251fff30c45b8f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek <7330332+a-wi@users.noreply.github.com> Date: Wed, 4 Jan 2023 19:59:32 +0100 Subject: [PATCH] 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. --- tests/graphics/clipper.cpp | 16 +++++++++++----- tests/graphics/clippingbox.cpp | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/graphics/clipper.cpp b/tests/graphics/clipper.cpp index f8e0ac8fd8..49ed6abb63 100644 --- a/tests/graphics/clipper.cpp +++ b/tests/graphics/clipper.cpp @@ -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 w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); -#endif // wxGTK 2 +#endif // wxGTK std::unique_ptr 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__ } diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index afcf63bccb..9740e00351 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -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 w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); -#endif // wxGTK 2 +#endif // wxGTK wxScopedPtr 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__ }