diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-15 21:52:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-16 03:48:28 +0200 |
commit | 3083fe569f96bf0289da1e9d0ef7da15ab22e2f6 (patch) | |
tree | 7009b2023d374e15d718cc2bd30b98295dc78263 | |
parent | 25a28cee10736e8a72b40b5ab2d11dea8d5254c3 (diff) |
Add backend tests as CPPUNIT tests
This (finally) adds backend tests as CPPUNIT tests too. In the
future they'll also be added into LibreOffice directly as a way
to test if the backend is OK, which will be useful especially
for the OpenGL backend, which draw quality depends on the driver.
Currently all the tests are ignored because of the bugs in the
backend, which need to be addressed first and tests then can
be enabled one by one.
The main reason for the test is to identify issues when drawing
is done at a wrong position, which is a very common problem. Also
other types of tests will be added in time, which will have a big
role in the refactoring of VCL that will happen in the future.
Change-Id: I92237d47d49fa0db01b73b8bc39f7a621b65961e
Reviewed-on: https://gerrit.libreoffice.org/70769
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | vcl/CppunitTest_vcl_backend_test.mk | 49 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 2 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/backendtest/VisualBackendTest.cxx | 12 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/common.cxx | 16 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/line.cxx | 4 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/pixel.cxx | 4 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/polygon.cxx | 6 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/polyline.cxx | 4 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/polyline_b2d.cxx | 50 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/polypolygon.cxx | 10 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/polypolygon_b2d.cxx | 65 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/rectangle.cxx | 8 | ||||
-rw-r--r-- | vcl/inc/test/outputdevice.hxx | 33 | ||||
-rw-r--r-- | vcl/qa/cppunit/BackendTest.cxx | 364 |
15 files changed, 595 insertions, 33 deletions
diff --git a/vcl/CppunitTest_vcl_backend_test.mk b/vcl/CppunitTest_vcl_backend_test.mk new file mode 100644 index 000000000000..f146cb6238fe --- /dev/null +++ b/vcl/CppunitTest_vcl_backend_test.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_backend_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_backend_test, \ + vcl/qa/cppunit/BackendTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_backend_test, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + svt \ + test \ + tl \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,vcl_backend_test)) +$(eval $(call gb_CppunitTest_use_ure,vcl_backend_test)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_backend_test)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_backend_test,\ + boost_headers\ +)) + +$(eval $(call gb_CppunitTest_set_include,vcl_backend_test,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_CppunitTest_use_components,vcl_backend_test,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + ucb/source/core/ucb1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_backend_test)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 242af6a996fb..5b7733f6755f 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -446,7 +446,9 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/backendtest/outputdevice/pixel \ vcl/backendtest/outputdevice/polygon \ vcl/backendtest/outputdevice/polypolygon \ + vcl/backendtest/outputdevice/polypolygon_b2d \ vcl/backendtest/outputdevice/polyline \ + vcl/backendtest/outputdevice/polyline_b2d \ vcl/backendtest/outputdevice/rectangle \ )) diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 7bfd4bed1cc9..314b54a7d520 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -209,6 +209,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_apitests \ CppunitTest_vcl_png_test \ CppunitTest_vcl_widget_definition_reader_test \ + CppunitTest_vcl_backend_test \ )) ifneq (,$(filter PDFIUM,$(BUILD_TYPE))) diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx index b06610493073..398e5e2d3643 100644 --- a/vcl/backendtest/VisualBackendTest.cxx +++ b/vcl/backendtest/VisualBackendTest.cxx @@ -186,7 +186,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestRect aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } @@ -194,7 +194,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestPixel aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } @@ -202,7 +202,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestLine aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } @@ -210,7 +210,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestPolygon aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } @@ -218,7 +218,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestPolyLine aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } @@ -226,7 +226,7 @@ public: aRectangle = aRegions[index++]; { vcl::test::OutputDeviceTestPolyPolygon aOutDevTest; - Bitmap aBitmap = aOutDevTest.setupRectangle(); + Bitmap aBitmap = aOutDevTest.setupRectangle(false); assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 8124676d93aa..d6f1d50f8456 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -225,10 +225,14 @@ OutputDeviceTestCommon::OutputDeviceTestCommon() : mpVirtualDevice(VclPtr<VirtualDevice>::Create()) {} -void OutputDeviceTestCommon::initialSetup(long nWidth, long nHeight, Color aColor) +void OutputDeviceTestCommon::initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA) { maVDRectangle = tools::Rectangle(Point(), Size (nWidth, nHeight)); mpVirtualDevice->SetOutputSizePixel(maVDRectangle.GetSize()); + if (bEnableAA) + mpVirtualDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw | AntialiasingFlags::PixelSnapHairline); + else + mpVirtualDevice->SetAntialiasing(AntialiasingFlags::NONE); mpVirtualDevice->SetBackground(Wallpaper(aColor)); mpVirtualDevice->Erase(); } @@ -253,6 +257,16 @@ TestResult OutputDeviceTestCommon::checkRectangle(Bitmap& aBitmap) return checkRectangles(aBitmap, aExpected); } +TestResult OutputDeviceTestCommon::checkRectangleAA(Bitmap& aBitmap) +{ + std::vector<Color> aExpected + { + constBackgroundColor, constBackgroundColor, constLineColor, + constBackgroundColor, constBackgroundColor, constLineColor, constBackgroundColor + }; + return checkRectangles(aBitmap, aExpected); +} + TestResult OutputDeviceTestCommon::checkFilledRectangle(Bitmap& aBitmap) { std::vector<Color> aExpected diff --git a/vcl/backendtest/outputdevice/line.cxx b/vcl/backendtest/outputdevice/line.cxx index 59a2294bfa38..ff03a777771e 100644 --- a/vcl/backendtest/outputdevice/line.cxx +++ b/vcl/backendtest/outputdevice/line.cxx @@ -31,9 +31,9 @@ void drawLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int n } // end anonymous namespace -Bitmap OutputDeviceTestLine::setupRectangle() +Bitmap OutputDeviceTestLine::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); diff --git a/vcl/backendtest/outputdevice/pixel.cxx b/vcl/backendtest/outputdevice/pixel.cxx index eef758f9851e..b231396ab7ff 100644 --- a/vcl/backendtest/outputdevice/pixel.cxx +++ b/vcl/backendtest/outputdevice/pixel.cxx @@ -39,9 +39,9 @@ void drawPixelOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int } // end anonymous namespace -Bitmap OutputDeviceTestPixel::setupRectangle() +Bitmap OutputDeviceTestPixel::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); diff --git a/vcl/backendtest/outputdevice/polygon.cxx b/vcl/backendtest/outputdevice/polygon.cxx index 785bc5dab72c..4a0fac9f92ed 100644 --- a/vcl/backendtest/outputdevice/polygon.cxx +++ b/vcl/backendtest/outputdevice/polygon.cxx @@ -30,9 +30,9 @@ void drawPolygonOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, in } // end anonymous namespace -Bitmap OutputDeviceTestPolygon::setupRectangle() +Bitmap OutputDeviceTestPolygon::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); @@ -47,7 +47,7 @@ Bitmap OutputDeviceTestPolygon::setupFilledRectangle() { initialSetup(13, 13, constBackgroundColor); - mpVirtualDevice->SetLineColor(constFillColor); + mpVirtualDevice->SetLineColor(); mpVirtualDevice->SetFillColor(constFillColor); drawPolygonOffset(*mpVirtualDevice, maVDRectangle, 2); diff --git a/vcl/backendtest/outputdevice/polyline.cxx b/vcl/backendtest/outputdevice/polyline.cxx index 49894a1a2186..53a9edab9d11 100644 --- a/vcl/backendtest/outputdevice/polyline.cxx +++ b/vcl/backendtest/outputdevice/polyline.cxx @@ -30,9 +30,9 @@ void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, i } // end anonymous namespace -Bitmap OutputDeviceTestPolyLine::setupRectangle() +Bitmap OutputDeviceTestPolyLine::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); diff --git a/vcl/backendtest/outputdevice/polyline_b2d.cxx b/vcl/backendtest/outputdevice/polyline_b2d.cxx new file mode 100644 index 000000000000..d6b9886b41ee --- /dev/null +++ b/vcl/backendtest/outputdevice/polyline_b2d.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <test/outputdevice.hxx> + +namespace vcl +{ +namespace test +{ +namespace +{ +void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset) +{ + basegfx::B2DPolygon aPolygon{ + basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Top() + nOffset), + basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Top() + nOffset), + basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Bottom() - nOffset), + basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Bottom() - nOffset), + }; + aPolygon.setClosed(true); + + rDevice.DrawPolyLine(aPolygon, 0.0); // draw hairline +} + +} // end anonymous namespace + +Bitmap OutputDeviceTestPolyLineB2D::setupRectangle(bool bEnableAA) +{ + initialSetup(13, 13, constBackgroundColor, bEnableAA); + + mpVirtualDevice->SetLineColor(constLineColor); + mpVirtualDevice->SetFillColor(); + + drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 2); + drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 5); + + return mpVirtualDevice->GetBitmapEx(maVDRectangle.TopLeft(), maVDRectangle.GetSize()) + .GetBitmap(); +} +} +} // end namespace vcl::test + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/backendtest/outputdevice/polypolygon.cxx b/vcl/backendtest/outputdevice/polypolygon.cxx index 10ebc85e2d62..f36db1e9fd65 100644 --- a/vcl/backendtest/outputdevice/polypolygon.cxx +++ b/vcl/backendtest/outputdevice/polypolygon.cxx @@ -30,9 +30,9 @@ tools::Polygon createPolygonOffset(tools::Rectangle const & rRect, int nOffset) } // end anonymous namespace -Bitmap OutputDeviceTestPolyPolygon::setupRectangle() +Bitmap OutputDeviceTestPolyPolygon::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); @@ -50,13 +50,11 @@ Bitmap OutputDeviceTestPolyPolygon::setupFilledRectangle() { initialSetup(13, 13, constBackgroundColor); - mpVirtualDevice->SetLineColor(constFillColor); + mpVirtualDevice->SetLineColor(); mpVirtualDevice->SetFillColor(constFillColor); - tools::PolyPolygon aPolyPolygon(3); + tools::PolyPolygon aPolyPolygon(1); aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 2)); - aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 4)); - aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 4)); mpVirtualDevice->DrawPolyPolygon(aPolyPolygon); diff --git a/vcl/backendtest/outputdevice/polypolygon_b2d.cxx b/vcl/backendtest/outputdevice/polypolygon_b2d.cxx new file mode 100644 index 000000000000..808e8637c3d8 --- /dev/null +++ b/vcl/backendtest/outputdevice/polypolygon_b2d.cxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <test/outputdevice.hxx> + +namespace vcl +{ +namespace test +{ +namespace +{ +basegfx::B2DPolygon createPolygonOffset(tools::Rectangle const& rRect, int nOffset) +{ + basegfx::B2DPolygon aPolygon{ + basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Top() + nOffset), + basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Top() + nOffset), + basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Bottom() - nOffset), + basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Bottom() - nOffset), + }; + aPolygon.setClosed(true); + return aPolygon; +} + +} // end anonymous namespace + +Bitmap OutputDeviceTestPolyPolygonB2D::setupRectangle(bool bEnableAA) +{ + initialSetup(13, 13, constBackgroundColor, bEnableAA); + + mpVirtualDevice->SetLineColor(constLineColor); + mpVirtualDevice->SetFillColor(); + + basegfx::B2DPolyPolygon aPolyPolygon; + aPolyPolygon.append(createPolygonOffset(maVDRectangle, 2)); + aPolyPolygon.append(createPolygonOffset(maVDRectangle, 5)); + + mpVirtualDevice->DrawPolyPolygon(aPolyPolygon); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestPolyPolygonB2D::setupFilledRectangle() +{ + initialSetup(13, 13, constBackgroundColor); + + mpVirtualDevice->SetLineColor(); + mpVirtualDevice->SetFillColor(constFillColor); + + basegfx::B2DPolyPolygon aPolyPolygon(createPolygonOffset(maVDRectangle, 2)); + + mpVirtualDevice->DrawPolyPolygon(aPolyPolygon); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} +} +} // end namespace vcl::test + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/backendtest/outputdevice/rectangle.cxx b/vcl/backendtest/outputdevice/rectangle.cxx index 199c299b2b2d..a491d67f5c52 100644 --- a/vcl/backendtest/outputdevice/rectangle.cxx +++ b/vcl/backendtest/outputdevice/rectangle.cxx @@ -27,18 +27,17 @@ Bitmap OutputDeviceTestRect::setupFilledRectangle() { initialSetup(13, 13, constBackgroundColor); - mpVirtualDevice->SetLineColor(constFillColor); + mpVirtualDevice->SetLineColor(); mpVirtualDevice->SetFillColor(constFillColor); drawRectOffset(*mpVirtualDevice, maVDRectangle, 2); - drawRectOffset(*mpVirtualDevice, maVDRectangle, 5); return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); } -Bitmap OutputDeviceTestRect::setupRectangle() +Bitmap OutputDeviceTestRect::setupRectangle(bool bEnableAA) { - initialSetup(13, 13, constBackgroundColor); + initialSetup(13, 13, constBackgroundColor, bEnableAA); mpVirtualDevice->SetLineColor(constLineColor); mpVirtualDevice->SetFillColor(); @@ -49,6 +48,7 @@ Bitmap OutputDeviceTestRect::setupRectangle() return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); } + }} // end namespace vcl::test /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx index c75720f53d69..54dccb325eda 100644 --- a/vcl/inc/test/outputdevice.hxx +++ b/vcl/inc/test/outputdevice.hxx @@ -13,6 +13,7 @@ #include <vcl/virdev.hxx> #include <vcl/bitmapaccess.hxx> +#include <vcl/bitmapex.hxx> namespace vcl { namespace test { @@ -45,9 +46,10 @@ protected: public: OutputDeviceTestCommon(); - void initialSetup(long nWidth, long nHeight, Color aColor); + void initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA = false); static TestResult checkRectangle(Bitmap& rBitmap); + static TestResult checkRectangleAA(Bitmap& rBitmap); static TestResult checkFilledRectangle(Bitmap& rBitmap); static TestResult checkLines(Bitmap& rBitmap); static TestResult checkAALines(Bitmap& rBitmap); @@ -100,7 +102,7 @@ class VCL_DLLPUBLIC OutputDeviceTestPixel : public OutputDeviceTestCommon public: OutputDeviceTestPixel() = default; - Bitmap setupRectangle(); + Bitmap setupRectangle(bool bEnableAA); }; class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon @@ -108,7 +110,7 @@ class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon public: OutputDeviceTestLine() = default; - Bitmap setupRectangle(); + Bitmap setupRectangle(bool bEnableAA); Bitmap setupDiamond(); Bitmap setupLines(); Bitmap setupAALines(); @@ -119,19 +121,27 @@ class VCL_DLLPUBLIC OutputDeviceTestPolyLine : public OutputDeviceTestCommon public: OutputDeviceTestPolyLine() = default; - Bitmap setupRectangle(); + Bitmap setupRectangle(bool bEnableAA); Bitmap setupDiamond(); Bitmap setupLines(); Bitmap setupAALines(); }; +class VCL_DLLPUBLIC OutputDeviceTestPolyLineB2D : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyLineB2D() = default; + + Bitmap setupRectangle(bool bEnableAA); +}; + class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon { public: OutputDeviceTestRect() = default; + Bitmap setupRectangle(bool bEnableAA); Bitmap setupFilledRectangle(); - Bitmap setupRectangle(); }; class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon @@ -139,8 +149,8 @@ class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon public: OutputDeviceTestPolygon() = default; + Bitmap setupRectangle(bool bEnableAA); Bitmap setupFilledRectangle(); - Bitmap setupRectangle(); Bitmap setupDiamond(); Bitmap setupLines(); Bitmap setupAALines(); @@ -151,8 +161,17 @@ class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon : public OutputDeviceTestCommon public: OutputDeviceTestPolyPolygon() = default; + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupFilledRectangle(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolyPolygonB2D : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyPolygonB2D() = default; + + Bitmap setupRectangle(bool bEnableAA); Bitmap setupFilledRectangle(); - Bitmap setupRectangle(); }; class VCL_DLLPUBLIC OutputDeviceTestGradient : public OutputDeviceTestCommon diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx new file mode 100644 index 000000000000..0dc336aa99a4 --- /dev/null +++ b/vcl/qa/cppunit/BackendTest.cxx @@ -0,0 +1,364 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <test/bootstrapfixture.hxx> + +#include <vcl/salbtype.hxx> + +#include <vcl/bitmap.hxx> +#include <tools/stream.hxx> +#include <vcl/graphicfilter.hxx> + +#include <test/outputdevice.hxx> + +class BackendTest : public test::BootstrapFixture +{ + // if enabled - check the result images with: + // "xdg-open ./workdir/CppunitTest/vcl_backend_test.test.core/" + static constexpr const bool mbExportBitmap = false; + + void exportImage(OUString const& rsFilename, Bitmap const& rBitmap) + { + if (mbExportBitmap) + { + Bitmap aBitmap(rBitmap); + aBitmap.Scale(Size(128, 128), BmpScaleFlag::Fast); + SvFileStream aStream(rsFilename, StreamMode::WRITE | StreamMode::TRUNC); + GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmap, aStream); + } + } + +public: + BackendTest() + : BootstrapFixture(true, false) + { + } + + // We need to enable tests ONE BY ONE as they fail because of backend bugs + // it is still improtant to have the test defined so we know the issues + // exist and we need to fix them. Consistent behaviour of our backends + // is of highest priority. + +#define SKIP_TEST_ASSERTS + + void testDrawRectWithRectangle() + { + vcl::test::OutputDeviceTestRect aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-01_rectangle_test-rectangle.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPixel() + { + vcl::test::OutputDeviceTestPixel aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-02_rectangle_test-pixel.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithLine() + { + vcl::test::OutputDeviceTestLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-03_rectangle_test-line.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPolygon() + { + vcl::test::OutputDeviceTestPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-04_rectangle_test-polygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPolyLine() + { + vcl::test::OutputDeviceTestPolyLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-05_rectangle_test-polyline.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPolyLineB2D() + { + vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-06_rectangle_test-polyline_b2d.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPolyPolygon() + { + vcl::test::OutputDeviceTestPolyPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-07_rectangle_test-polypolygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectWithPolyPolygonB2D() + { + vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(false); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap); + exportImage("01-08_rectangle_test-polypolygon_b2d.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithRectangle() + { + vcl::test::OutputDeviceTestRect aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-01_rectangle_AA_test-rectangle.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPixel() + { + vcl::test::OutputDeviceTestPixel aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-02_rectangle_AA_test-pixel.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithLine() + { + vcl::test::OutputDeviceTestLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-03_rectangle_AA_test-line.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPolygon() + { + vcl::test::OutputDeviceTestPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-04_rectangle_AA_test-polygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPolyLine() + { + vcl::test::OutputDeviceTestPolyLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-05_rectangle_AA_test-polyline.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPolyLineB2D() + { + vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-06_rectangle_AA_test-polyline_b2d.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPolyPolygon() + { + vcl::test::OutputDeviceTestPolyPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-07_rectangle_AA_test-polypolygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawRectAAWithPolyPolygonB2D() + { + vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupRectangle(true); + auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap); + exportImage("02-08_rectangle_AA_test-polypolygon_b2d.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawFilledRectWithRectangle() + { + vcl::test::OutputDeviceTestRect aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupFilledRectangle(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap); + exportImage("03-01_filled_rectangle_test-rectangle.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawFilledRectWithPolygon() + { + vcl::test::OutputDeviceTestPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupFilledRectangle(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap); + exportImage("03-02_filled_rectangle_test-polygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawFilledRectWithPolyPolygon() + { + vcl::test::OutputDeviceTestPolyPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupFilledRectangle(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap); + exportImage("03-03_filled_rectangle_test-polypolygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawFilledRectWithPolyPolygon2D() + { + vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupFilledRectangle(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap); + exportImage("03-04_filled_rectangle_test-polypolygon_b2d.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawDiamondWithPolygon() + { + vcl::test::OutputDeviceTestPolygon aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupDiamond(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap); + exportImage("04-01_diamond_test-polygon.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawDiamondWithLine() + { + vcl::test::OutputDeviceTestLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupDiamond(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap); + exportImage("04-02_diamond_test-line.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + + void testDrawDiamondWithPolyline() + { + vcl::test::OutputDeviceTestPolyLine aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupDiamond(); + auto eResult = vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap); + exportImage("04-03_diamond_test-polyline.png", aBitmap); + (void)eResult; +#ifndef SKIP_TEST_ASSERTS + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); +#endif + } + +#undef SKIP_TEST_ASSERTS + + CPPUNIT_TEST_SUITE(BackendTest); + CPPUNIT_TEST(testDrawRectWithRectangle); + CPPUNIT_TEST(testDrawRectWithPixel); + CPPUNIT_TEST(testDrawRectWithLine); + CPPUNIT_TEST(testDrawRectWithPolygon); + CPPUNIT_TEST(testDrawRectWithPolyLine); + CPPUNIT_TEST(testDrawRectWithPolyLineB2D); + CPPUNIT_TEST(testDrawRectWithPolyPolygon); + CPPUNIT_TEST(testDrawRectWithPolyPolygonB2D); + + CPPUNIT_TEST(testDrawRectAAWithRectangle); + CPPUNIT_TEST(testDrawRectAAWithPixel); + CPPUNIT_TEST(testDrawRectAAWithLine); + CPPUNIT_TEST(testDrawRectAAWithPolygon); + CPPUNIT_TEST(testDrawRectAAWithPolyLine); + CPPUNIT_TEST(testDrawRectAAWithPolyLineB2D); + CPPUNIT_TEST(testDrawRectAAWithPolyPolygon); + CPPUNIT_TEST(testDrawRectAAWithPolyPolygonB2D); + + CPPUNIT_TEST(testDrawFilledRectWithRectangle); + CPPUNIT_TEST(testDrawFilledRectWithPolygon); + CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon); + CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon2D); + + CPPUNIT_TEST(testDrawDiamondWithPolygon); + CPPUNIT_TEST(testDrawDiamondWithLine); + CPPUNIT_TEST(testDrawDiamondWithPolyline); + + CPPUNIT_TEST_SUITE_END(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(BackendTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |