This is a helper class for unit tests that need to write an image and compare it to an expected result or render time.
More...
#include <qgsrenderchecker.h>
|
static void | drawBackground (QImage *image) |
| Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a transparent background for the image. More...
|
|
This is a helper class for unit tests that need to write an image and compare it to an expected result or render time.
Definition at line 37 of file qgsrenderchecker.h.
◆ QgsRenderChecker()
QgsRenderChecker::QgsRenderChecker |
( |
| ) |
|
◆ ~QgsRenderChecker()
QgsRenderChecker::~QgsRenderChecker |
( |
| ) |
|
|
inline |
◆ compareImages()
bool QgsRenderChecker::compareImages |
( |
const QString & |
theTestName, |
|
|
unsigned int |
theMismatchCount = 0 , |
|
|
const QString & |
theRenderedImageFile = "" |
|
) |
| |
Test using two arbitary images (map renderer will not be used)
- Parameters
-
theTestName | - to be used as the basis for writing a file to e.g. /tmp/theTestName.png |
theMismatchCount | - 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. |
theRenderedImageFile | to optionally override the output filename |
- Note
- : make sure to call setExpectedImage and setRenderedImage first.
Definition at line 253 of file qgsrenderchecker.cpp.
◆ controlImagePath()
QString QgsRenderChecker::controlImagePath |
( |
| ) |
const |
◆ dartMeasurements()
Get access to buffered dash messages.
Only will return something if you call enableDashBuffering( true ); before.
- Returns
- buffered dash messages
- Note
- not available in python bindings
Definition at line 169 of file qgsrenderchecker.h.
◆ drawBackground()
void QgsRenderChecker::drawBackground |
( |
QImage * |
image | ) |
|
|
static |
Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a transparent background for the image.
Definition at line 91 of file qgsrenderchecker.cpp.
◆ elapsedTime()
int QgsRenderChecker::elapsedTime |
( |
| ) |
|
|
inline |
◆ enableDashBuffering()
void QgsRenderChecker::enableDashBuffering |
( |
bool |
enable | ) |
|
|
inline |
Call this to enable internal buffering of dash messages.
You may later call dashMessages() to get access to the buffered messages. If disabled (default) dash messages will be sent immediately.
- Parameters
-
enable | Enable or disable buffering |
Definition at line 160 of file qgsrenderchecker.h.
◆ expectedImageFile()
QString QgsRenderChecker::expectedImageFile |
( |
| ) |
const |
|
inline |
Returns the path to the expected image file.
- Returns
- Path to the expected image file
Definition at line 151 of file qgsrenderchecker.h.
◆ imageToHash()
◆ isKnownAnomaly()
bool QgsRenderChecker::isKnownAnomaly |
( |
const QString & |
theDiffImageFile | ) |
|
Get a list of all the anomalies.
An anomaly is a rendered difference file where there is some red pixel content (indicating a render check mismatch), but where the output was still acceptible. If the render diff matches one of these anomalies we will still consider it to be acceptible.
- Returns
- a bool indicating if the diff matched one of the anomaly files
Definition at line 112 of file qgsrenderchecker.cpp.
◆ matchPercent()
float QgsRenderChecker::matchPercent |
( |
| ) |
|
|
inline |
◆ matchTarget()
unsigned int QgsRenderChecker::matchTarget |
( |
| ) |
|
|
inline |
◆ mismatchCount()
unsigned int QgsRenderChecker::mismatchCount |
( |
| ) |
|
|
inline |
◆ renderedImage()
QString QgsRenderChecker::renderedImage |
( |
| ) |
|
|
inline |
◆ report()
QString QgsRenderChecker::report |
( |
| ) |
|
|
inline |
◆ runTest()
bool QgsRenderChecker::runTest |
( |
const QString & |
theTestName, |
|
|
unsigned int |
theMismatchCount = 0 |
|
) |
| |
Test using renderer to generate the image to be compared.
- Parameters
-
theTestName | - to be used as the basis for writing a file to e.g. /tmp/theTestName.png |
theMismatchCount | - 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. |
- Note
- make sure to call setExpectedImage and setMapRenderer first
Definition at line 172 of file qgsrenderchecker.cpp.
◆ setColorTolerance()
void QgsRenderChecker::setColorTolerance |
( |
unsigned int |
theColorTolerance | ) |
|
|
inline |
Set tolerance for color components used by runTest() and compareImages().
Default value is 0.
- Parameters
-
theColorTolerance | is maximum difference for each color component including alpha to be considered correct. |
- Note
- added in 2.1
Definition at line 99 of file qgsrenderchecker.h.
◆ setControlName()
void QgsRenderChecker::setControlName |
( |
const QString & |
theName | ) |
|
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 54 of file qgsrenderchecker.cpp.
◆ setControlPathPrefix()
void QgsRenderChecker::setControlPathPrefix |
( |
const QString & |
theName | ) |
|
|
inline |
Prefix where the control images are kept.
This will be appended to controlImagePath
Definition at line 70 of file qgsrenderchecker.h.
◆ setControlPathSuffix()
void QgsRenderChecker::setControlPathSuffix |
( |
const QString & |
theName | ) |
|
◆ setElapsedTimeTarget()
void QgsRenderChecker::setElapsedTimeTarget |
( |
int |
theTarget | ) |
|
|
inline |
◆ setMapRenderer()
void QgsRenderChecker::setMapRenderer |
( |
QgsMapRenderer * |
thepMapRenderer | ) |
|
◆ setMapSettings()
void QgsRenderChecker::setMapSettings |
( |
const QgsMapSettings & |
mapSettings | ) |
|
◆ setRenderedImage()
void QgsRenderChecker::setRenderedImage |
( |
const QString & |
theImageFileName | ) |
|
|
inline |
◆ setSizeTolerance()
void QgsRenderChecker::setSizeTolerance |
( |
int |
xTolerance, |
|
|
int |
yTolerance |
|
) |
| |
|
inline |
Sets the largest allowable difference in size between the rendered and the expected image.
- Parameters
-
xTolerance | x tolerance in pixels |
yTolerance | y tolerance in pixels |
- Note
- added in QGIS 2.12
Definition at line 106 of file qgsrenderchecker.h.
◆ mElapsedTime
int QgsRenderChecker::mElapsedTime |
|
protected |
◆ mExpectedImageFile
QString QgsRenderChecker::mExpectedImageFile |
|
protected |
◆ mMatchTarget
unsigned int QgsRenderChecker::mMatchTarget |
|
protected |
◆ mRenderedImageFile
QString QgsRenderChecker::mRenderedImageFile |
|
protected |
◆ mReport
The documentation for this class was generated from the following files: