QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
|
This class allows checking rendered images against comparison images. More...
#include <qgsmultirenderchecker.h>
Public Member Functions | |
QgsMultiRenderChecker () | |
Constructor for QgsMultiRenderChecker. | |
virtual | ~QgsMultiRenderChecker ()=default |
QString | controlImagePath () const |
Returns the path to the control images. | |
QString | markdownReport () const |
Returns a markdown report for this test. | |
QString | report () const |
Returns a HTML report for this test. | |
bool | runTest (const QString &testName, unsigned int mismatchCount=0) |
Test using renderer to generate the image to be compared. | |
void | setColorTolerance (unsigned int colorTolerance) |
Set tolerance for color components used by runTest() Default value is 0. | |
void | setControlName (const QString &name) |
Base directory name for the control image (with control image path suffixed) the path to the image will be constructed like this: controlImagePath + '/' + mControlName + '/' + mControlName + '.png'. | |
void | setControlPathPrefix (const QString &prefix) |
void | setExpectFail (bool expectFail) |
Sets whether the comparison is expected to fail. | |
void | setMapSettings (const QgsMapSettings &mapSettings) |
Set the map settings to use to render the image. | |
void | setRenderedImage (const QString &renderedImagePath) |
Set the path to the rendered image. | |
void | setSizeTolerance (int xTolerance, int yTolerance) |
Sets the largest allowable difference in size between the rendered and the expected image. | |
Static Public Member Functions | |
static void | drawBackground (QImage *image) |
Draws a checkboard pattern for image backgrounds, so that opacity is visible without requiring a transparent background for the image. | |
This class allows checking rendered images against comparison images.
Its main purpose is for the unit testing framework.
It will either
This image will then be compared against one or several images in a folder inside the control directory (tests/testdata/control_images/{controlName}).
There are modes for single and for multiple reference images.
If there are no subfolders in the control directory, it will assume an image with the name {controlImage}.png in the control directory itself.
For every control image there may be one or several randomly named anomaly images defining allowed anomalies. For every control image, the allowed mismatch and color tolerance values will be calculated individually.
Definition at line 56 of file qgsmultirenderchecker.h.
QgsMultiRenderChecker::QgsMultiRenderChecker | ( | ) |
Constructor for QgsMultiRenderChecker.
Definition at line 21 of file qgsmultirenderchecker.cpp.
|
virtualdefault |
QString QgsMultiRenderChecker::controlImagePath | ( | ) | const |
Returns the path to the control images.
Definition at line 186 of file qgsmultirenderchecker.cpp.
|
inlinestatic |
Draws a checkboard pattern for image backgrounds, so that opacity is visible without requiring a transparent background for the image.
Definition at line 158 of file qgsmultirenderchecker.h.
QString QgsMultiRenderChecker::markdownReport | ( | ) | const |
Returns a markdown report for this test.
The report will be empty if the test was successfully run.
Definition at line 181 of file qgsmultirenderchecker.cpp.
QString QgsMultiRenderChecker::report | ( | ) | const |
Returns a HTML report for this test.
The report will be empty if the test was successfully run.
Definition at line 176 of file qgsmultirenderchecker.cpp.
bool QgsMultiRenderChecker::runTest | ( | const QString & | testName, |
unsigned int | mismatchCount = 0 |
||
) |
Test using renderer to generate the image to be compared.
testName | - to be used as the basis for writing a file to e.g. /tmp/theTestName.png |
mismatchCount | - defaults to 0 - the number of pixels that are allowed to be different from the control image. In some cases rendering may be non-deterministic. This parameter allows you to account for that by providing a tolerance. |
Definition at line 42 of file qgsmultirenderchecker.cpp.
|
inline |
Set tolerance for color components used by runTest() Default value is 0.
colorTolerance | The maximum difference for each color component including alpha to be considered correct. |
Definition at line 105 of file qgsmultirenderchecker.h.
void QgsMultiRenderChecker::setControlName | ( | const QString & | name | ) |
Base directory name for the control image (with control image path suffixed) the path to the image will be constructed like this: controlImagePath + '/' + mControlName + '/' + mControlName + '.png'.
Definition at line 27 of file qgsmultirenderchecker.cpp.
void QgsMultiRenderChecker::setControlPathPrefix | ( | const QString & | prefix | ) |
Definition at line 32 of file qgsmultirenderchecker.cpp.
|
inline |
Sets whether the comparison is expected to fail.
Definition at line 89 of file qgsmultirenderchecker.h.
void QgsMultiRenderChecker::setMapSettings | ( | const QgsMapSettings & | mapSettings | ) |
Set the map settings to use to render the image.
mapSettings | The map settings |
Definition at line 37 of file qgsmultirenderchecker.cpp.
|
inline |
Set the path to the rendered image.
If this is not set or set to null QString, an image will be rendered based on the provided mapsettings
renderedImagePath | A path to the rendered image with which control images will be compared |
Definition at line 82 of file qgsmultirenderchecker.h.
|
inline |
Sets the largest allowable difference in size between the rendered and the expected image.
xTolerance | x tolerance in pixels |
yTolerance | y tolerance in pixels |
Definition at line 113 of file qgsmultirenderchecker.h.