summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-08-22 18:10:02 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-08-23 09:52:43 +0900
commit3e6052ce1b9a24f82358e574de32919fa2b6499f (patch)
tree9e81e23f724a4be0938b61d866e777399f40e794 /vcl/inc
parent129c0d6363e58f6d32dc9583edb6a0edd07521f9 (diff)
vcl: Adds backend tests to check for correct rendering
Collection of test that check rendering of VCL backend. This works by rendering primitives to the VirtualDevice, outputing the result to a Bitmap and checking the rendering by comparing pixels. This should warn when the primitive is drawn to a wrong position or if it is the wrong size or color. It also test some rendering tricks like XOR drawing. Currently this is not implemented as a CPPUnit test but separately, as its own executable file so we can check the results visually. The idea is also to add the tests into LO for the user to test or automatically to test the backend on first start (especially useful to test the OpenGL backend as some drivers could have unexpected behaviour). Change-Id: I2a565b9986ca68850e2752466e3cd5fc71991ba6
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/test/outputdevice.hxx172
1 files changed, 172 insertions, 0 deletions
diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx
new file mode 100644
index 000000000000..cc90b000b10d
--- /dev/null
+++ b/vcl/inc/test/outputdevice.hxx
@@ -0,0 +1,172 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_OUTDEVTESTS_HXX
+#define INCLUDED_VCL_OUTDEVTESTS_HXX
+
+#include <vcl/virdev.hxx>
+#include <vcl/bitmapaccess.hxx>
+
+namespace vcl {
+namespace test {
+
+/** Rendering test result.
+ *
+ * Test either "Passed", "Failed" or "PassedWithQuirks" which means
+ * the test passed but at least one rendering quirk was detected.
+ */
+enum class TestResult
+{
+ Failed,
+ PassedWithQuirks,
+ Passed
+};
+
+/** Common subclass for output device rendering tests.
+ */
+class VCL_DLLPUBLIC OutputDeviceTestCommon
+{
+protected:
+
+ ScopedVclPtr<VirtualDevice> mpVirtualDevice;
+ Rectangle maVDRectangle;
+
+ static const Color constBackgroundColor;
+ static const Color constLineColor;
+ static const Color constFillColor;
+
+public:
+ OutputDeviceTestCommon();
+
+ void initialSetup(long nWidth, long nHeight, Color aColor);
+
+ static TestResult checkRectangle(Bitmap& rBitmap);
+ static TestResult checkFilledRectangle(Bitmap& rBitmap);
+ static TestResult checkLines(Bitmap& rBitmap);
+ static TestResult checkAALines(Bitmap& rBitmap);
+ static TestResult checkDiamond(Bitmap& rBitmap);
+
+ static TestResult checkRectangles(Bitmap& rBitmap, std::vector<Color>& aExpectedColors);
+
+ static void createDiamondPoints(Rectangle rRect, int nOffset,
+ Point& rPoint1, Point& rPoint2,
+ Point& rPoint3, Point& rPoint4);
+
+ static void createHorizontalVerticalDiagonalLinePoints(Rectangle rRect,
+ Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2,
+ Point& rVerticalLinePoint1, Point& rVerticalLinePoint2,
+ Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2);
+ // tools
+ static Rectangle alignToCenter(Rectangle aRect1, Rectangle aRect2);
+
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestBitmap() = default;
+
+ Bitmap setupDrawTransformedBitmap();
+ Bitmap setupDrawBitmap();
+ Bitmap setupDrawBitmapExWithAlpha();
+ Bitmap setupDrawMask();
+
+ static TestResult checkBitmap(Bitmap& rBitmap);
+ static TestResult checkTransformedBitmap(Bitmap& rBitmap);
+ static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
+ static TestResult checkMask(Bitmap& rBitmap);
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestAnotherOutDev() = default;
+
+ Bitmap setupDrawOutDev();
+ Bitmap setupXOR();
+
+ static TestResult checkDrawOutDev(Bitmap& rBitmap);
+ static TestResult checkXOR(Bitmap& rBitmap);
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestPixel : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestPixel() = default;
+
+ Bitmap setupRectangle();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestLine() = default;
+
+ Bitmap setupRectangle();
+ Bitmap setupDiamond();
+ Bitmap setupLines();
+ Bitmap setupAALines();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestPolyLine : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestPolyLine() = default;
+
+ Bitmap setupRectangle();
+ Bitmap setupDiamond();
+ Bitmap setupLines();
+ Bitmap setupAALines();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestRect() = default;
+
+ Bitmap setupFilledRectangle();
+ Bitmap setupRectangle();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestPolygon() = default;
+
+ Bitmap setupFilledRectangle();
+ Bitmap setupRectangle();
+ Bitmap setupDiamond();
+ Bitmap setupLines();
+ Bitmap setupAALines();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestPolyPolygon() = default;
+
+ Bitmap setupFilledRectangle();
+ Bitmap setupRectangle();
+};
+
+class VCL_DLLPUBLIC OutputDeviceTestGradient : public OutputDeviceTestCommon
+{
+public:
+ OutputDeviceTestGradient() = default;
+
+ Bitmap setupLinearGradient();
+ Bitmap setupRadialGradient();
+};
+
+}} // end namespace vcl::test
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */