QGIS API Documentation 3.39.0-Master (d85f3c2a281)
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
52class CORE_EXPORT QgsMultiRenderChecker
53{
54 public:
55
60
61 virtual ~QgsMultiRenderChecker() = default;
62
68 void setControlName( const QString &name );
69
75 void setFileFunctionLine( const QString &file, const QString &function, int line );
76
80 void setControlPathPrefix( const QString &prefix );
81
88 void setRenderedImage( const QString &renderedImagePath ) { mRenderedImage = renderedImagePath; }
89
95 void setExpectFail( bool expectFail ) { mExpectFail = expectFail; }
96
102 void setMapSettings( const QgsMapSettings &mapSettings );
103
111 void setColorTolerance( unsigned int colorTolerance ) { mColorTolerance = colorTolerance; }
112
118 void setSizeTolerance( int xTolerance, int yTolerance ) { mMaxSizeDifferenceX = xTolerance; mMaxSizeDifferenceY = yTolerance; }
119
133 bool runTest( const QString &testName, unsigned int mismatchCount = 0 );
134
142 QString report() const;
143
152 QString markdownReport() const;
153
157 QString controlImagePath() const;
158
163 static void drawBackground( QImage *image ) { QgsRenderChecker::drawBackground( image ); }
164
165 private:
166 QString mSourceFile;
167 QString mSourceFunction;
168 int mSourceLine = -1;
169
170 bool mResult = false;
171
172 QString mReportHeader;
173 QString mReport;
174
175 QString mMarkdownReportHeader;
176 QString mMarkdownReport;
177
178 QString mRenderedImage;
179 QString mControlName;
180 QString mControlPathPrefix;
181 unsigned int mColorTolerance = 0;
182 int mMaxSizeDifferenceX = 0;
183 int mMaxSizeDifferenceY = 0;
184 QgsMapSettings mMapSettings;
185 bool mExpectFail = false;
186
187 bool mIsCiRun = false;
188};
189
191
197class CORE_EXPORT QgsLayoutChecker : public QgsMultiRenderChecker
198{
199 public:
200
204 QgsLayoutChecker( const QString &testName, QgsLayout *layout );
205
209 void setSize( QSize size ) { mSize = size; }
210
230 bool testLayout( QString &report SIP_OUT, int page = 0, int pixelDiff = 0, bool createReferenceImage = false );
231
232 private:
233 QgsLayoutChecker() = delete;
234
235 QString mTestName;
236 QgsLayout *mLayout = nullptr;
237 QSize mSize;
238 int mDotsPerMeter;
239};
241
242
243#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