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 opacity 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 38 of file qgsrenderchecker.h.
QgsRenderChecker::QgsRenderChecker |
( |
| ) |
|
|
default |
bool QgsRenderChecker::compareImages |
( |
const QString & |
testName, |
|
|
unsigned int |
mismatchCount = 0 , |
|
|
const QString & |
renderedImageFile = QString() |
|
) |
| |
Test using two arbitrary images (map renderer will not be used)
- Parameters
-
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. |
renderedImageFile | to optionally override the output filename |
- Note
- : make sure to call setExpectedImage and setRenderedImage first.
Definition at line 238 of file qgsrenderchecker.cpp.
QString QgsRenderChecker::controlImagePath |
( |
| ) |
const |
Gets access to buffered dash messages.
Only will return something if you call enableDashBuffering( true ); before.
- Returns
- buffered dash messages
Definition at line 173 of file qgsrenderchecker.h.
void QgsRenderChecker::drawBackground |
( |
QImage * |
image | ) |
|
|
static |
Draws a checkboard pattern for image backgrounds, so that opacity is visible without requiring a transparent background for the image.
Definition at line 73 of file qgsrenderchecker.cpp.
int QgsRenderChecker::elapsedTime |
( |
| ) |
|
|
inline |
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 165 of file qgsrenderchecker.h.
QString QgsRenderChecker::expectedImageFile |
( |
| ) |
const |
|
inline |
Returns the path to the expected image file.
- Returns
- Path to the expected image file
Definition at line 156 of file qgsrenderchecker.h.
QString QgsRenderChecker::imageToHash |
( |
const QString & |
imageFile | ) |
|
bool QgsRenderChecker::isKnownAnomaly |
( |
const QString & |
diffImageFile | ) |
|
Gets 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 acceptable. If the render diff matches one of these anomalies we will still consider it to be acceptable.
- Returns
- a bool indicating if the diff matched one of the anomaly files
Definition at line 94 of file qgsrenderchecker.cpp.
float QgsRenderChecker::matchPercent |
( |
| ) |
|
|
inline |
unsigned int QgsRenderChecker::matchTarget |
( |
| ) |
|
|
inline |
unsigned int QgsRenderChecker::mismatchCount |
( |
| ) |
|
|
inline |
QString QgsRenderChecker::renderedImage |
( |
| ) |
|
|
inline |
QString QgsRenderChecker::report |
( |
| ) |
|
|
inline |
bool QgsRenderChecker::runTest |
( |
const QString & |
testName, |
|
|
unsigned int |
mismatchCount = 0 |
|
) |
| |
Test using renderer to generate the image to be compared.
- Parameters
-
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. |
- Note
- make sure to call setExpectedImage and setMapRenderer first
Definition at line 154 of file qgsrenderchecker.cpp.
void QgsRenderChecker::setColorTolerance |
( |
unsigned int |
colorTolerance | ) |
|
|
inline |
Set tolerance for color components used by runTest() and compareImages().
Default value is 0.
- Parameters
-
colorTolerance | is maximum difference for each color component including alpha to be considered correct. |
- Since
- QGIS 2.1
Definition at line 100 of file qgsrenderchecker.h.
void QgsRenderChecker::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 41 of file qgsrenderchecker.cpp.
void QgsRenderChecker::setControlPathPrefix |
( |
const QString & |
name | ) |
|
|
inline |
Prefix where the control images are kept.
This will be appended to controlImagePath
Definition at line 73 of file qgsrenderchecker.h.
void QgsRenderChecker::setControlPathSuffix |
( |
const QString & |
name | ) |
|
void QgsRenderChecker::setElapsedTimeTarget |
( |
int |
target | ) |
|
|
inline |
void QgsRenderChecker::setMapSettings |
( |
const QgsMapSettings & |
mapSettings | ) |
|
void QgsRenderChecker::setRenderedImage |
( |
const QString & |
imageFileName | ) |
|
|
inline |
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 |
- Since
- QGIS 2.12
Definition at line 108 of file qgsrenderchecker.h.
int QgsRenderChecker::mElapsedTime = 0 |
|
protected |
QString QgsRenderChecker::mExpectedImageFile |
|
protected |
unsigned int QgsRenderChecker::mMatchTarget = 0 |
|
protected |
QString QgsRenderChecker::mRenderedImageFile |
|
protected |
QString QgsRenderChecker::mReport |
|
protected |
The documentation for this class was generated from the following files: