summaryrefslogtreecommitdiffstats
path: root/vcl/inc/test/outputdevice.hxx
blob: b8ad0b67fc6b3af08c2ce131067dde66dcb4633a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* -*- 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>

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;
    tools::Rectangle maVDRectangle;

    static const Color constBackgroundColor;
    static const Color constLineColor;
    static const Color constFillColor;

public:
    OutputDeviceTestCommon();

    OUString getRenderBackendName() const;

    void initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA = false, bool bAlphaVirtualDevice = false);

    static TestResult checkRectangle(Bitmap& rBitmap);
    static TestResult checkRectangleAA(Bitmap& rBitmap);
    static TestResult checkFilledRectangle(Bitmap& rBitmap, bool useLineColor);
    static TestResult checkLines(Bitmap& rBitmap);
    static TestResult checkAALines(Bitmap& rBitmap);
    static TestResult checkDiamond(Bitmap& rBitmap);

    static TestResult checkInvertRectangle(Bitmap& rBitmap);
    static TestResult checkInvertN50Rectangle(Bitmap& aBitmap);
    static TestResult checkInvertTrackFrameRectangle(Bitmap& aBitmap);

    static TestResult checkRectangles(Bitmap& rBitmap, std::vector<Color>& aExpectedColors);
    static TestResult checkRectangle(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor);

    static TestResult checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor);
    static TestResult checkChecker(Bitmap& rBitmap, sal_Int32 nStartX, sal_Int32 nEndX,
                                   sal_Int32 nStartY, sal_Int32 nEndY, std::vector<Color> const & rExpected);

    static void createDiamondPoints(tools::Rectangle rRect, int nOffset,
                                    Point& rPoint1, Point& rPoint2,
                                    Point& rPoint3, Point& rPoint4);

    static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect,
                                Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2,
                                Point& rVerticalLinePoint1, Point& rVerticalLinePoint2,
                                Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2);
    // tools
    static tools::Rectangle alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2);

    static TestResult checkBezier(Bitmap& rBitmap);
};

class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestBitmap() = default;

    Bitmap setupDrawTransformedBitmap();
    Bitmap setupDrawBitmap();
    Bitmap setupDrawBitmapExWithAlpha();
    Bitmap setupDrawMask();
    BitmapEx setupDrawBlend();

    static TestResult checkTransformedBitmap(Bitmap& rBitmap);
    static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
    static TestResult checkMask(Bitmap& rBitmap);
    static TestResult checkBlend(BitmapEx& 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(bool bEnableAA);
};

class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestLine() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();

    Bitmap setupDashedLine();
    static TestResult checkDashedLine(Bitmap& rBitmap);
};

class VCL_DLLPUBLIC OutputDeviceTestPolyLine : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyLine() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();
};

class VCL_DLLPUBLIC OutputDeviceTestPolyLineB2D : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyLineB2D() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupDiamond();
    Bitmap setupBezier();
    Bitmap setupAABezier();
};

class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestRect() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupInvert_NONE();
    Bitmap setupInvert_N50();
    Bitmap setupInvert_TrackFrame();
};

class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolygon() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();
};

class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyPolygon() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
};

class VCL_DLLPUBLIC OutputDeviceTestPolyPolygonB2D : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyPolygonB2D() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
};

class VCL_DLLPUBLIC OutputDeviceTestGradient : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestGradient() = default;

    Bitmap setupLinearGradient();
    Bitmap setupRadialGradient();
};

class VCL_DLLPUBLIC OutputDeviceTestClip : public OutputDeviceTestCommon
{
public:
    Bitmap setupClipRectangle();
    Bitmap setupClipPolygon();
    Bitmap setupClipPolyPolygon();
    Bitmap setupClipB2DPolyPolygon();

    static TestResult checkClip(Bitmap& rBitmap);
};


}} // end namespace vcl::test

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */