QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsmultirenderchecker.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmultirenderchecker.h
3 --------------------------------------
4 Date : 6.11.2014
5 Copyright : (C) 2014 Matthias Kuhn
6 Email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMULTIRENDERCHECKER_H
17#define QGSMULTIRENDERCHECKER_H
18
19#include "qgis_core.h"
20#include "qgsrenderchecker.h"
21
22class QgsLayout;
23
56class CORE_EXPORT QgsMultiRenderChecker
57{
58 public:
59
64
65 virtual ~QgsMultiRenderChecker() = default;
66
72 void setControlName( const QString &name );
73
74 void setControlPathPrefix( const QString &prefix );
75
82 void setRenderedImage( const QString &renderedImagePath ) { mRenderedImage = renderedImagePath; }
83
89 void setExpectFail( bool expectFail ) { mExpectFail = expectFail; }
90
96 void setMapSettings( const QgsMapSettings &mapSettings );
97
105 void setColorTolerance( unsigned int colorTolerance ) { mColorTolerance = colorTolerance; }
106
113 void setSizeTolerance( int xTolerance, int yTolerance ) { mMaxSizeDifferenceX = xTolerance; mMaxSizeDifferenceY = yTolerance; }
114
128 bool runTest( const QString &testName, unsigned int mismatchCount = 0 );
129
137 QString report() const;
138
147 QString markdownReport() const;
148
152 QString controlImagePath() const;
153
158 static void drawBackground( QImage *image ) { QgsRenderChecker::drawBackground( image ); }
159
160 private:
161 bool mResult = false;
162 QString mReport;
163 QString mMarkdownReport;
164 QString mRenderedImage;
165 QString mControlName;
166 QString mControlPathPrefix;
167 unsigned int mColorTolerance = 0;
168 int mMaxSizeDifferenceX = 0;
169 int mMaxSizeDifferenceY = 0;
170 QgsMapSettings mMapSettings;
171 bool mExpectFail = false;
172
173 bool mIsCiRun = false;
174};
175
177
184class CORE_EXPORT QgsLayoutChecker : public QgsMultiRenderChecker
185{
186 public:
187
191 QgsLayoutChecker( const QString &testName, QgsLayout *layout );
192
196 void setSize( QSize size ) { mSize = size; }
197
217 bool testLayout( QString &report SIP_OUT, int page = 0, int pixelDiff = 0, bool createReferenceImage = false );
218
219 private:
220 QgsLayoutChecker() = delete;
221
222 QString mTestName;
223 QgsLayout *mLayout = nullptr;
224 QSize mSize;
225 int mDotsPerMeter;
226};
228
229
230#endif // QGSMULTIRENDERCHECKER_H
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
The QgsMapSettings class contains configuration for rendering of the map.
This class allows checking rendered images against comparison images.
void setRenderedImage(const QString &renderedImagePath)
Set the path to the rendered image.
static void drawBackground(QImage *image)
Draws a checkboard pattern for image backgrounds, so that opacity is visible without requiring a tran...
virtual ~QgsMultiRenderChecker()=default
void setColorTolerance(unsigned int colorTolerance)
Set tolerance for color components used by runTest() Default value is 0.
void setExpectFail(bool expectFail)
Sets whether the comparison is expected to fail.
void setSizeTolerance(int xTolerance, int yTolerance)
Sets the largest allowable difference in size between the rendered and the expected image.
static void drawBackground(QImage *image)
Draws a checkboard pattern for image backgrounds, so that opacity is visible without requiring a tran...
#define SIP_OUT
Definition qgis_sip.h:58