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>
Detailed Description
This is a helper class for unit tests that need to write an image and compare it to an expected result or render time.
Constructor & Destructor Documentation
QgsRenderChecker::QgsRenderChecker |
( |
| ) |
|
QgsRenderChecker::~QgsRenderChecker |
( |
| ) |
|
|
inline |
Member Function Documentation
bool QgsRenderChecker::compareImages |
( |
QString |
theTestName, |
|
|
unsigned int |
theMismatchCount = 0 , |
|
|
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.
QString QgsRenderChecker::controlImagePath |
( |
| ) |
const |
int QgsRenderChecker::elapsedTime |
( |
| ) |
|
|
inline |
QString QgsRenderChecker::expectedImageFile |
( |
| ) |
|
|
inline |
QString QgsRenderChecker::imageToHash |
( |
QString |
theImageFile | ) |
|
Get an md5 hash that uniquely identifies an image.
bool QgsRenderChecker::isKnownAnomaly |
( |
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
float QgsRenderChecker::matchPercent |
( |
| ) |
|
|
inline |
unsigned int QgsRenderChecker::matchTarget |
( |
| ) |
|
|
inline |
unsigned int QgsRenderChecker::mismatchCount |
( |
| ) |
|
|
inline |
QString QgsRenderChecker::report |
( |
| ) |
|
|
inline |
bool QgsRenderChecker::runTest |
( |
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
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
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'.
void QgsRenderChecker::setControlPathPrefix |
( |
const QString |
theName | ) |
|
|
inline |
Prefix where the control images are kept.
This will be appended to controlImagePath
void QgsRenderChecker::setElapsedTimeTarget |
( |
int |
theTarget | ) |
|
|
inline |
void QgsRenderChecker::setMapRenderer |
( |
QgsMapRenderer * |
thepMapRenderer | ) |
|
void QgsRenderChecker::setMapSettings |
( |
const QgsMapSettings & |
mapSettings | ) |
|
void QgsRenderChecker::setRenderedImage |
( |
QString |
theImageFileName | ) |
|
|
inline |
Member Data Documentation
int QgsRenderChecker::mElapsedTime |
|
protected |
QString QgsRenderChecker::mExpectedImageFile |
|
protected |
unsigned int QgsRenderChecker::mMatchTarget |
|
protected |
QString QgsRenderChecker::mRenderedImageFile |
|
protected |
QString QgsRenderChecker::mReport |
|
protected |
The documentation for this class was generated from the following files: