QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
55class CORE_EXPORT QgsMultiRenderChecker
56{
57 public:
58
63
64 virtual ~QgsMultiRenderChecker() = default;
65
71 void setControlName( const QString &name );
72
78 void setFileFunctionLine( const QString &file, const QString &function, int line );
79
83 void setControlPathPrefix( const QString &prefix );
84
91 void setRenderedImage( const QString &renderedImagePath ) { mRenderedImage = renderedImagePath; }
92
98 void setExpectFail( bool expectFail ) { mExpectFail = expectFail; }
99
105 void setMapSettings( const QgsMapSettings &mapSettings );
106
114 void setColorTolerance( unsigned int colorTolerance ) { mColorTolerance = colorTolerance; }
115
121 void setSizeTolerance( int xTolerance, int yTolerance ) { mMaxSizeDifferenceX = xTolerance; mMaxSizeDifferenceY = yTolerance; }
122
136 bool runTest( const QString &testName, unsigned int mismatchCount = 0 );
137
145 QString report() const;
146
155 QString markdownReport() const;
156
160 QString controlImagePath() const;
161
166 static void drawBackground( QImage *image ) { QgsRenderChecker::drawBackground( image ); }
167
168 private:
169 QString mSourceFile;
170 QString mSourceFunction;
171 int mSourceLine = -1;
172
173 bool mResult = false;
174
175 QString mReportHeader;
176 QString mReport;
177
178 QString mMarkdownReportHeader;
179 QString mMarkdownReport;
180
181 QString mRenderedImage;
182 QString mControlName;
183 QString mControlPathPrefix;
184 unsigned int mColorTolerance = 0;
185 int mMaxSizeDifferenceX = 0;
186 int mMaxSizeDifferenceY = 0;
187 QgsMapSettings mMapSettings;
188 bool mExpectFail = false;
189
190 bool mIsCiRun = false;
191};
192
194
200class CORE_EXPORT QgsLayoutChecker : public QgsMultiRenderChecker
201{
202 public:
203
207 QgsLayoutChecker( const QString &testName, QgsLayout *layout );
208
212 void setSize( QSize size ) { mSize = size; }
213
233 bool testLayout( QString &report SIP_OUT, int page = 0, int pixelDiff = 0, bool createReferenceImage = false );
234
235 private:
236 QgsLayoutChecker() = delete;
237
238 QString mTestName;
239 QgsLayout *mLayout = nullptr;
240 QSize mSize;
241 int mDotsPerMeter;
242};
244
245
246#endif // QGSMULTIRENDERCHECKER_H
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
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