QGIS API Documentation
2.2.0-Valmiera
|
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>
Public Member Functions | |
QgsRenderChecker () | |
~QgsRenderChecker () | |
Destructor. | |
QString | controlImagePath () const |
QString | report () |
float | matchPercent () |
unsigned int | mismatchCount () |
unsigned int | matchTarget () |
int | elapsedTime () |
void | setElapsedTimeTarget (int theTarget) |
void | 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 | setControlPathPrefix (const QString theName) |
Prefix where the control images are kept. | |
QString | imageToHash (QString theImageFile) |
Get an md5 hash that uniquely identifies an image. | |
void | setRenderedImage (QString theImageFileName) |
void | setMapRenderer (QgsMapRenderer *thepMapRenderer) |
void | setColorTolerance (unsigned int theColorTolerance) |
Set tolerance for color components used by runTest() and compareImages(). | |
bool | runTest (QString theTestName, unsigned int theMismatchCount=0) |
Test using renderer to generate the image to be compared. | |
bool | compareImages (QString theTestName, unsigned int theMismatchCount=0, QString theRenderedImageFile="") |
Test using two arbitary images (map renderer will not be used) | |
bool | isKnownAnomaly (QString theDiffImageFile) |
Get a list of all the anomalies. | |
QString | expectedImageFile () |
Protected Attributes | |
QString | mReport |
unsigned int | mMatchTarget |
QgsMapRenderer * | mpMapRenderer |
int | mElapsedTime |
QString | mRenderedImageFile |
QString | mExpectedImageFile |
Private Attributes | |
QString | mControlName |
unsigned int | mMismatchCount |
unsigned int | mColorTolerance |
int | mElapsedTimeTarget |
QString | mControlPathPrefix |
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 35 of file qgsrenderchecker.h.
QgsRenderChecker::QgsRenderChecker | ( | ) |
Definition at line 28 of file qgsrenderchecker.cpp.
|
inline |
Destructor.
Definition at line 42 of file qgsrenderchecker.h.
bool QgsRenderChecker::compareImages | ( | QString | theTestName, |
unsigned int | theMismatchCount = 0 , |
||
QString | theRenderedImageFile = "" |
||
) |
Test using two arbitary images (map renderer will not be used)
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 |
Definition at line 186 of file qgsrenderchecker.cpp.
References isKnownAnomaly(), mColorTolerance, mElapsedTime, mElapsedTimeTarget, mExpectedImageFile, mMatchTarget, mMismatchCount, mRenderedImageFile, and mReport.
Referenced by runTest().
QString QgsRenderChecker::controlImagePath | ( | ) | const |
Definition at line 43 of file qgsrenderchecker.cpp.
References mControlPathPrefix.
Referenced by isKnownAnomaly(), and setControlName().
|
inline |
Definition at line 55 of file qgsrenderchecker.h.
|
inline |
Definition at line 112 of file qgsrenderchecker.h.
QString QgsRenderChecker::imageToHash | ( | QString | theImageFile | ) |
Get an md5 hash that uniquely identifies an image.
Definition at line 58 of file qgsrenderchecker.cpp.
Referenced by isKnownAnomaly().
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.
Definition at line 71 of file qgsrenderchecker.cpp.
References controlImagePath(), imageToHash(), mControlName, mExpectedImageFile, and mReport.
Referenced by compareImages().
|
inline |
Definition at line 47 of file qgsrenderchecker.h.
|
inline |
Definition at line 53 of file qgsrenderchecker.h.
|
inline |
Definition at line 52 of file qgsrenderchecker.h.
|
inline |
Definition at line 46 of file qgsrenderchecker.h.
bool QgsRenderChecker::runTest | ( | QString | theTestName, |
unsigned int | theMismatchCount = 0 |
||
) |
Test using renderer to generate the image to be compared.
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. |
Definition at line 122 of file qgsrenderchecker.cpp.
References compareImages(), QgsMapRenderer::extent(), QgsMapRenderer::mapUnitsPerPixel(), mElapsedTime, mExpectedImageFile, mMatchTarget, mpMapRenderer, mRenderedImageFile, mReport, qgsDoubleToString(), QgsMapRenderer::render(), QgsMapRenderer::setOutputSize(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
|
inline |
Set tolerance for color components used by runTest() and compareImages().
Default value is 0.
theColorTolerance | is maximum difference for each color component including alpha to be considered correct. |
Definition at line 78 of file qgsrenderchecker.h.
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 51 of file qgsrenderchecker.cpp.
References controlImagePath(), mControlName, and mExpectedImageFile.
|
inline |
Prefix where the control images are kept.
This will be appended to controlImagePath
Definition at line 65 of file qgsrenderchecker.h.
|
inline |
Definition at line 56 of file qgsrenderchecker.h.
|
inline |
Definition at line 70 of file qgsrenderchecker.h.
|
inline |
Definition at line 69 of file qgsrenderchecker.h.
|
private |
Definition at line 127 of file qgsrenderchecker.h.
Referenced by compareImages().
|
private |
Definition at line 125 of file qgsrenderchecker.h.
Referenced by isKnownAnomaly(), and setControlName().
|
private |
Definition at line 129 of file qgsrenderchecker.h.
Referenced by controlImagePath().
|
protected |
Definition at line 119 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
|
private |
Definition at line 128 of file qgsrenderchecker.h.
Referenced by compareImages().
|
protected |
Definition at line 121 of file qgsrenderchecker.h.
Referenced by compareImages(), isKnownAnomaly(), runTest(), and setControlName().
|
protected |
Definition at line 117 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
|
private |
Definition at line 126 of file qgsrenderchecker.h.
Referenced by compareImages().
|
protected |
Definition at line 118 of file qgsrenderchecker.h.
Referenced by runTest().
|
protected |
Definition at line 120 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
|
protected |
Definition at line 112 of file qgsrenderchecker.h.
Referenced by compareImages(), isKnownAnomaly(), and runTest().