summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/backendtest/outputdevice/common.cxx11
-rw-r--r--vcl/backendtest/outputdevice/polyline_b2d.cxx52
-rw-r--r--vcl/inc/test/outputdevice.hxx3
-rw-r--r--vcl/qa/cppunit/BackendTest.cxx27
4 files changed, 93 insertions, 0 deletions
diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx
index 919f8f6e623b..a9a8eee977d5 100644
--- a/vcl/backendtest/outputdevice/common.cxx
+++ b/vcl/backendtest/outputdevice/common.cxx
@@ -442,6 +442,17 @@ void OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(tools::R
rDiagonalLinePoint2 = Point(rRect.Right() - 1, rRect.Bottom() - 1);
}
+TestResult OutputDeviceTestCommon::checkBezier(Bitmap& rBitmap)
+{
+ std::vector<Color> aExpected
+ {
+ constBackgroundColor, constBackgroundColor
+ };
+ // Check the bezier doesn't go over to the margins first
+ // TODO extend the check with more exact assert
+ return checkRectangles(rBitmap, aExpected);
+}
+
}} // end namespace vcl::test
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/backendtest/outputdevice/polyline_b2d.cxx b/vcl/backendtest/outputdevice/polyline_b2d.cxx
index 43b814b2915e..3674fa5d172c 100644
--- a/vcl/backendtest/outputdevice/polyline_b2d.cxx
+++ b/vcl/backendtest/outputdevice/polyline_b2d.cxx
@@ -72,6 +72,58 @@ Bitmap OutputDeviceTestPolyLineB2D::setupDiamond()
return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
}
+
+Bitmap OutputDeviceTestPolyLineB2D::setupBezier()
+{
+ initialSetup(21, 21, constBackgroundColor, false);
+
+ mpVirtualDevice->SetLineColor(constLineColor);
+ mpVirtualDevice->SetFillColor();
+
+ basegfx::B2DPolygon aPolygon;
+ addDiamondPoints(maVDRectangle, 8, aPolygon);
+ aPolygon.setClosed(true);
+
+ double minX = maVDRectangle.Left() + 4;
+ double maxX = maVDRectangle.Right() - 4;
+ double minY = maVDRectangle.Top() + 4;
+ double maxY = maVDRectangle.Bottom() - 4;
+
+ aPolygon.setControlPoints(0, { minX, minY }, { maxX, minY });
+ aPolygon.setControlPoints(1, { maxX, minY }, { maxX, maxY });
+ aPolygon.setControlPoints(2, { maxX, maxY }, { minX, maxY });
+ aPolygon.setControlPoints(3, { minX, maxY }, { minX, minY });
+
+ mpVirtualDevice->DrawPolyLine(aPolygon);
+
+ return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
+}
+
+Bitmap OutputDeviceTestPolyLineB2D::setupAABezier()
+{
+ initialSetup(21, 21, constBackgroundColor, true);
+
+ mpVirtualDevice->SetLineColor(constLineColor);
+ mpVirtualDevice->SetFillColor();
+
+ basegfx::B2DPolygon aPolygon;
+ addDiamondPoints(maVDRectangle, 8, aPolygon);
+ aPolygon.setClosed(true);
+
+ double minX = maVDRectangle.Left() + 4;
+ double maxX = maVDRectangle.Right() - 4;
+ double minY = maVDRectangle.Top() + 4;
+ double maxY = maVDRectangle.Bottom() - 4;
+
+ aPolygon.setControlPoints(0, { minX, minY }, { maxX, minY });
+ aPolygon.setControlPoints(1, { maxX, minY }, { maxX, maxY });
+ aPolygon.setControlPoints(2, { maxX, maxY }, { minX, maxY });
+ aPolygon.setControlPoints(3, { minX, maxY }, { minX, minY });
+
+ mpVirtualDevice->DrawPolyLine(aPolygon);
+
+ return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
+}
}
} // end namespace vcl::test
diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx
index 63ad2042fac3..e00dfaad67ce 100644
--- a/vcl/inc/test/outputdevice.hxx
+++ b/vcl/inc/test/outputdevice.hxx
@@ -74,6 +74,7 @@ public:
// tools
static tools::Rectangle alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2);
+ static TestResult checkBezier(Bitmap& rBitmap);
};
class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon
@@ -140,6 +141,8 @@ public:
Bitmap setupRectangle(bool bEnableAA);
Bitmap setupDiamond();
+ Bitmap setupBezier();
+ Bitmap setupAABezier();
};
class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 70eeabb1d6b5..9836972539b8 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -370,6 +370,30 @@ public:
#endif
}
+ void testDrawBezierWithPolylineB2D()
+ {
+ vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
+ Bitmap aBitmap = aOutDevTest.setupBezier();
+ auto eResult = vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap);
+ exportImage("06-01_bezier_test-polyline_b2d.png", aBitmap);
+ (void)eResult;
+#ifndef SKIP_TEST_ASSERTS
+ CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+#endif
+ }
+
+ void testDrawBezierAAWithPolylineB2D()
+ {
+ vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
+ Bitmap aBitmap = aOutDevTest.setupAABezier();
+ auto eResult = vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap);
+ exportImage("07-01_bezier_AA_test-polyline_b2d.png", aBitmap);
+ (void)eResult;
+#ifndef SKIP_TEST_ASSERTS
+ CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+#endif
+ }
+
#undef SKIP_TEST_ASSERTS
CPPUNIT_TEST_SUITE(BackendTest);
@@ -405,6 +429,9 @@ public:
CPPUNIT_TEST(testDrawInvertN50WithRectangle);
CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle);
+ CPPUNIT_TEST(testDrawBezierWithPolylineB2D);
+ CPPUNIT_TEST(testDrawBezierAAWithPolylineB2D);
+
CPPUNIT_TEST_SUITE_END();
};