|
Quantum GIS API Documentation
master-ce49b66
|
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>
Collaboration diagram for QgsRenderChecker:Public Member Functions | |
| QgsRenderChecker () | |
| ~QgsRenderChecker () | |
| Destructor. | |
| bool | compareImages (QString theTestName, unsigned int theMismatchCount=0, QString theRenderedImageFile="") |
| Test using two arbitary images (map renderer will not be used) | |
| QString | controlImagePath () const |
| int | elapsedTime () |
| QString | imageToHash (QString theImageFile) |
| Get an md5 hash that uniquely identifies an image. | |
| bool | isKnownAnomaly (QString theDiffImageFile) |
| Get a list of all teh anomalies. | |
| float | matchPercent () |
| unsigned int | matchTarget () |
| unsigned int | mismatchCount () |
| QString | report () |
| bool | runTest (QString theTestName, unsigned int theMismatchCount=0) |
| Test using renderer to generate the image to be compared. | |
| 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. | |
| void | setElapsedTimeTarget (int theTarget) |
| void | setMapRenderer (QgsMapRenderer *thepMapRenderer) |
| void | setRenderedImage (QString theImageFileName) |
Private Attributes | |
| QString | mControlName |
| QString | mControlPathPrefix |
| int | mElapsedTime |
| int | mElapsedTimeTarget |
| QString | mExpectedImageFile |
| unsigned int | mMatchTarget |
| unsigned int | mMismatchCount |
| QgsMapRenderer * | mpMapRenderer |
| QString | mRenderedImageFile |
| QString | mReport |
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 29 of file qgsrenderchecker.h.
Definition at line 27 of file qgsrenderchecker.cpp.
| QgsRenderChecker::~QgsRenderChecker | ( | ) | [inline] |
Destructor.
Definition at line 36 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 169 of file qgsrenderchecker.cpp.
References isKnownAnomaly(), mElapsedTime, mElapsedTimeTarget, mExpectedImageFile, mMatchTarget, mMismatchCount, mRenderedImageFile, and mReport.
Referenced by runTest().
| QString QgsRenderChecker::controlImagePath | ( | ) | const |
Definition at line 41 of file qgsrenderchecker.cpp.
References mControlPathPrefix.
Referenced by isKnownAnomaly(), and setControlName().
| int QgsRenderChecker::elapsedTime | ( | ) | [inline] |
Definition at line 49 of file qgsrenderchecker.h.
| QString QgsRenderChecker::imageToHash | ( | QString | theImageFile | ) |
Get an md5 hash that uniquely identifies an image.
Definition at line 56 of file qgsrenderchecker.cpp.
Referenced by isKnownAnomaly().
| bool QgsRenderChecker::isKnownAnomaly | ( | QString | theDiffImageFile | ) |
Get a list of all teh 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 69 of file qgsrenderchecker.cpp.
References controlImagePath(), imageToHash(), mControlName, mExpectedImageFile, and mReport.
Referenced by compareImages().
| float QgsRenderChecker::matchPercent | ( | ) | [inline] |
Definition at line 41 of file qgsrenderchecker.h.
| unsigned int QgsRenderChecker::matchTarget | ( | ) | [inline] |
Definition at line 47 of file qgsrenderchecker.h.
| unsigned int QgsRenderChecker::mismatchCount | ( | ) | [inline] |
Definition at line 46 of file qgsrenderchecker.h.
| QString QgsRenderChecker::report | ( | ) | [inline] |
Definition at line 40 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 120 of file qgsrenderchecker.cpp.
References compareImages(), mElapsedTime, mExpectedImageFile, mMatchTarget, mpMapRenderer, mRenderedImageFile, mReport, QgsMapRenderer::render(), and QgsMapRenderer::setOutputSize().
| 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 49 of file qgsrenderchecker.cpp.
References controlImagePath(), mControlName, and mExpectedImageFile.
| void QgsRenderChecker::setControlPathPrefix | ( | const QString | theName | ) | [inline] |
Prefix where the control images are kept.
This will be appended to controlImagePath
Definition at line 59 of file qgsrenderchecker.h.
| void QgsRenderChecker::setElapsedTimeTarget | ( | int | theTarget | ) | [inline] |
Definition at line 50 of file qgsrenderchecker.h.
| void QgsRenderChecker::setMapRenderer | ( | QgsMapRenderer * | thepMapRenderer | ) | [inline] |
Definition at line 64 of file qgsrenderchecker.h.
| void QgsRenderChecker::setRenderedImage | ( | QString | theImageFileName | ) | [inline] |
Definition at line 63 of file qgsrenderchecker.h.
QString QgsRenderChecker::mControlName [private] |
Definition at line 102 of file qgsrenderchecker.h.
Referenced by isKnownAnomaly(), and setControlName().
QString QgsRenderChecker::mControlPathPrefix [private] |
Definition at line 109 of file qgsrenderchecker.h.
Referenced by controlImagePath().
int QgsRenderChecker::mElapsedTime [private] |
Definition at line 106 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
int QgsRenderChecker::mElapsedTimeTarget [private] |
Definition at line 107 of file qgsrenderchecker.h.
Referenced by compareImages().
QString QgsRenderChecker::mExpectedImageFile [private] |
Definition at line 101 of file qgsrenderchecker.h.
Referenced by compareImages(), isKnownAnomaly(), runTest(), and setControlName().
unsigned int QgsRenderChecker::mMatchTarget [private] |
Definition at line 105 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
unsigned int QgsRenderChecker::mMismatchCount [private] |
Definition at line 104 of file qgsrenderchecker.h.
Referenced by compareImages().
QgsMapRenderer* QgsRenderChecker::mpMapRenderer [private] |
Definition at line 108 of file qgsrenderchecker.h.
Referenced by runTest().
QString QgsRenderChecker::mRenderedImageFile [private] |
Definition at line 103 of file qgsrenderchecker.h.
Referenced by compareImages(), and runTest().
QString QgsRenderChecker::mReport [private] |
Definition at line 100 of file qgsrenderchecker.h.
Referenced by compareImages(), isKnownAnomaly(), and runTest().