From 4e16f01de94d3205c92c3a7bda5bfdb5ae329e54 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 26 Jul 2021 18:51:25 +0200 Subject: [PATCH] Run all clipping region tests against wxSVGFileDC --- tests/graphics/clippingbox.cpp | 332 ++++++++++++++++++++++++++++++--- 1 file changed, 306 insertions(+), 26 deletions(-) diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index 6cfdd88cac..d91fb93a53 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -3401,6 +3401,312 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(Cairo)", "[clip][dc][gcdc][cairo]") #endif // wxUSE_CAIRO #endif // wxUSE_GRAPHICS_CONTEXT +#if wxUSE_SVG +TEST_CASE("ClippingBoxTestCase::wxSVGFileDC", "[clip][dc][svgdc]") +{ + wxBitmap bmp; // We need wxNullBitmap because we can't check the output + TestFile tf; + wxSVGFileDC dc(tf.GetName(), s_dcSize.x, s_dcSize.y); + dc.SetBackground(wxBrush(s_bgColour, wxBRUSHSTYLE_SOLID)); + dc.Clear(); + + SECTION("InitialState") + { + InitialState(dc, bmp); + } + + SECTION("InitialStateWithTransformedDC 1") + { + InitialStateWithTransformedDC(dc, bmp, false, false); + } + + SECTION("InitialStateWithTransformedDC 2") + { + InitialStateWithTransformedDC(dc, bmp, true, false); + } + + SECTION("InitialStateWithTransformedDC Transform Matrix") + { + InitialStateWithTransformedDC(dc, bmp, true, true); + } + + SECTION("InitialStateWithRotatedDC") + { + InitialStateWithRotatedDC(dc, bmp); + } + + SECTION("SameRegionRepeatRotatedDC") + { + SameRegionRepeatRotatedDC(dc); + } + + SECTION("OneRegion") + { + OneRegion(dc, bmp); + } + + SECTION("OneLargeRegion") + { + OneLargeRegion(dc, bmp); + } + + SECTION("OneOuterRegion") + { + OneOuterRegion(dc, bmp); + } + + SECTION("OneRegionNegDim") + { + OneRegionNegDim(dc, bmp); + } + + SECTION("OneRegionAndReset") + { + OneRegionAndReset(dc, bmp); + } + + SECTION("OneRegionAndEmpty") + { + OneRegionAndEmpty(dc, bmp); + } + + SECTION("OneRegionOverTransformedDC 1") + { + OneRegionOverTransformedDC(dc, bmp, false, false); + } + + SECTION("OneRegionOverTransformedDC 2") + { + OneRegionOverTransformedDC(dc, bmp, true, false); + } + + SECTION("OneRegionOverTransformedDC Transform Matrix") + { + OneRegionOverTransformedDC(dc, bmp, true, true); + } + + SECTION("OneRegionOverRotatedDC") + { + OneRegionOverRotatedDC(dc); + } + + SECTION("OneRegionAndDCTransformation 1") + { + OneRegionAndDCTransformation(dc, bmp, false, false); + } + + SECTION("OneRegionAndDCTransformation 2") + { + OneRegionAndDCTransformation(dc, bmp, true, false); + } + + SECTION("OneRegionAndDCTransformation Transform Matrix") + { + OneRegionAndDCTransformation(dc, bmp, true, true); + } + + SECTION("TwoRegionsOverlapping") + { + TwoRegionsOverlapping(dc, bmp); + } + + SECTION("TwoRegionsOverlappingNegDim") + { + TwoRegionsOverlappingNegDim(dc, bmp); + } + + SECTION("TwoRegionsNonOverlapping") + { + TwoRegionsNonOverlapping(dc, bmp); + } + + SECTION("TwoRegionsNonOverlappingNegDim") + { + TwoRegionsNonOverlappingNegDim(dc, bmp); + } + + SECTION("OneDevRegion 1") + { + OneDevRegion(dc, bmp, false, false); + } + + SECTION("OneDevRegion 2") + { + OneDevRegion(dc, bmp, true, false); + } + + SECTION("OneDevRegion Transform Matrix") + { + OneDevRegion(dc, bmp, true, true); + } + + SECTION("OneLargeDevRegion 1") + { + OneLargeDevRegion(dc, bmp, false, false); + } + + SECTION("OneLargeDevRegion 2") + { + OneLargeDevRegion(dc, bmp, true, false); + } + + SECTION("OneLargeDevRegion Transform Matrix") + { + OneLargeDevRegion(dc, bmp, true, true); + } + + SECTION("OneOuterDevRegion") + { + OneOuterDevRegion(dc, bmp, false); + } + + SECTION("OneOuterDevRegion Transform Matrix") + { + OneOuterDevRegion(dc, bmp, true); + } + + SECTION("OneDevRegionNegDim 1") + { + OneDevRegionNegDim(dc, bmp, false, false); + } + + SECTION("OneDevRegionNegDim 2") + { + OneDevRegionNegDim(dc, bmp, true, false); + } + + SECTION("OneDevRegionNegDim Transform Matrix") + { + OneDevRegionNegDim(dc, bmp, true, true); + } + + SECTION("OneDevRegionNonRect 1") + { + OneDevRegionNonRect(dc, bmp, false, false); + } + + SECTION("OneDevRegionNonRect 2") + { + OneDevRegionNonRect(dc, bmp, true, false); + } + + SECTION("OneDevRegionNonRect Transform Matrix") + { + OneDevRegionNonRect(dc, bmp, true, true); + } + + SECTION("OneDevRegionAndReset 1") + { + OneDevRegionAndReset(dc, bmp, false, false); + } + + SECTION("OneDevRegionAndReset 2") + { + OneDevRegionAndReset(dc, bmp, true, false); + } + + SECTION("OneDevRegionAndReset Transform Matrix") + { + OneDevRegionAndReset(dc, bmp, true, true); + } + + SECTION("OneDevRegionAndEmpty") + { + OneDevRegionAndEmpty(dc, bmp, false); + } + + SECTION("OneDevRegionAndEmpty Transform Matrix") + { + OneDevRegionAndEmpty(dc, bmp, true); + } + + SECTION("OneDevRegionOverTransformedDC 1") + { + OneDevRegionOverTransformedDC(dc, bmp, false, false); + } + + SECTION("OneDevRegionOverTransformedDC 2") + { + OneDevRegionOverTransformedDC(dc, bmp, true, false); + } + + SECTION("OneDevRegionOverTransformedDC Transform Matrix") + { + OneDevRegionOverTransformedDC(dc, bmp, true, true); + } + + SECTION("OneDevRegionOverRotatedDC") + { + OneDevRegionOverRotatedDC(dc); + } + + SECTION("OneDevRegionAndDCTransformation 1") + { + OneDevRegionAndDCTransformation(dc, bmp, false, false); + } + + SECTION("OneDevRegionAndDCTransformation 2") + { + OneDevRegionAndDCTransformation(dc, bmp, true, false); + } + + SECTION("OneDevRegionAndDCTransformation Transform Matrix") + { + OneDevRegionAndDCTransformation(dc, bmp, true, true); + } + + SECTION("TwoDevRegionsOverlapping 1") + { + TwoDevRegionsOverlapping(dc, bmp, false, false); + } + + SECTION("TwoDevRegionsOverlapping 2") + { + TwoDevRegionsOverlapping(dc, bmp, true, false); + } + + SECTION("TwoDevRegionsOverlapping Transform Matrix") + { + TwoDevRegionsOverlapping(dc, bmp, true, true); + } + + SECTION("TwoDevRegionsOverlappingNegDim 1") + { + TwoDevRegionsOverlappingNegDim(dc, bmp, false, false); + } + + SECTION("TwoDevRegionsOverlappingNegDim 2") + { + TwoDevRegionsOverlappingNegDim(dc, bmp, true, false); + } + + SECTION("TwoDevRegionsOverlappingNegDim Transform Matrix") + { + TwoDevRegionsOverlappingNegDim(dc, bmp, true, true); + } + + SECTION("TwoDevRegionsNonOverlapping") + { + TwoDevRegionsNonOverlapping(dc, bmp, false); + } + + SECTION("TwoDevRegionsNonOverlapping Transform Matrix") + { + TwoDevRegionsNonOverlapping(dc, bmp, true); + } + + SECTION("TwoDevRegionsNonOverlappingNegDim") + { + TwoDevRegionsNonOverlappingNegDim(dc, bmp, false); + } + + SECTION("TwoDevRegionsNonOverlappingNegDim Transform Matrix") + { + TwoDevRegionsNonOverlappingNegDim(dc, bmp, true); + } +} +#endif // wxUSE_SVG + #if wxUSE_GRAPHICS_CONTEXT // ======================== // wxGraphicsContext tests @@ -4186,29 +4492,3 @@ TEST_CASE("ClippingBoxTestCaseGC::CairoRenderer", "[clip][gc][cairo]") #endif // wxUSE_GRAPHICS_CAIRO #endif // wxUSE_GRAPHICS_CONTEXT - -#if wxUSE_SVG - -// We can't reuse the existing tests for wxSVGFileDC as we can't check its -// output, but we can still at least check the behaviour of GetClippingBox(). -TEST_CASE("ClippingBoxTestCaseSVGDC", "[clip][svgdc]") -{ - TestFile tf; - wxSVGFileDC dc(tf.GetName(), s_dcSize.x, s_dcSize.y); - - wxRect rect; - dc.GetClippingBox(rect); - CHECK( rect == wxRect(s_dcSize) ); - - const wxRect rectClip(10, 20, 80, 75); - dc.SetClippingRegion(rectClip); - - dc.GetClippingBox(rect); - CHECK( rect == rectClip ); - - dc.DestroyClippingRegion(); - dc.GetClippingBox(rect); - CHECK( rect == wxRect(s_dcSize) ); -} - -#endif // wxUSE_SVG