16 #ifndef QGSRENDERCHECKER_H    17 #define QGSRENDERCHECKER_H    19 #include "qgis_core.h"    47     QString controlImagePath() 
const;
    53       return static_cast<float>( mMismatchCount ) /
    54              static_cast<float>( mMatchTarget ) * 100;
    67     void setControlName( 
const QString &name );
    75     void setControlPathSuffix( 
const QString &name );
    78     QString imageToHash( 
const QString &imageFile );
    80     void setRenderedImage( 
const QString &imageFileName ) { mRenderedImageFile = imageFileName; }
   108     void setSizeTolerance( 
int xTolerance, 
int yTolerance ) { mMaxSizeDifferenceX = xTolerance; mMaxSizeDifferenceY = yTolerance; }
   120     bool runTest( 
const QString &testName, 
unsigned int mismatchCount = 0 );
   133     bool compareImages( 
const QString &testName, 
unsigned int mismatchCount = 0, 
const QString &renderedImageFile = QString() );
   143     bool isKnownAnomaly( 
const QString &diffImageFile );
   149     static void drawBackground( QImage *image );
   177     unsigned int mMatchTarget = 0;
   178     int mElapsedTime = 0;
   186     QString mControlName;
   187     unsigned int mMismatchCount = 0;
   188     unsigned int mColorTolerance = 0;
   189     int mMaxSizeDifferenceX = 0;
   190     int mMaxSizeDifferenceY = 0;
   191     int mElapsedTimeTarget = 0;
   193     QString mControlPathPrefix;
   194     QString mControlPathSuffix;
   195     QVector<QgsDartMeasurement> mDashMessages;
   196     bool mBufferDashMessages = 
false;
   208 inline bool compareWkt( 
const QString &a, 
const QString &b, 
double tolerance = 0.000001 )
   210   QgsDebugMsg( QStringLiteral( 
"a:%1 b:%2 tol:%3" ).arg( a, b ).arg( tolerance ) );
   211   QRegExp re( 
"-?\\d+(?:\\.\\d+)?(?:[eE]\\d+)?" );
   213   QString a0( a ), b0( b );
   214   a0.replace( re, QStringLiteral( 
"#" ) );
   215   b0.replace( re, QStringLiteral( 
"#" ) );
   217   QgsDebugMsg( QStringLiteral( 
"a0:%1 b0:%2" ).arg( a0, b0 ) );
   222   QList<double> al, bl;
   225   for ( pos = 0; ( pos = re.indexIn( a, pos ) ) != -1; pos += re.matchedLength() )
   227     al << re.cap( 0 ).toDouble();
   229   for ( pos = 0; ( pos = re.indexIn( b, pos ) ) != -1; pos += re.matchedLength() )
   231     bl << re.cap( 0 ).toDouble();
   234   if ( al.size() != bl.size() )
   237   for ( 
int i = 0; i < al.size(); i++ )
 
void enableDashBuffering(bool enable)
Call this to enable internal buffering of dash messages. 
 
QString expectedImageFile() const
Returns the path to the expected image file. 
 
void setRenderedImage(const QString &imageFileName)
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
QString renderedImage()
The path of the rendered image can be retrieved through that method. 
 
This is a helper class for unit tests that need to write an image and compare it to an expected resul...
 
void setSizeTolerance(int xTolerance, int yTolerance)
Sets the largest allowable difference in size between the rendered and the expected image...
 
The QgsMapSettings class contains configuration for rendering of the map. 
 
void setControlPathPrefix(const QString &name)
Prefix where the control images are kept. 
 
bool compareWkt(const QString &a, const QString &b, double tolerance=0.000001)
Compare two WKT strings with some tolerance. 
 
unsigned int matchTarget()
 
QString mRenderedImageFile
 
QVector< QgsDartMeasurement > dartMeasurements() const
Gets access to buffered dash messages. 
 
QString mExpectedImageFile
 
void setColorTolerance(unsigned int colorTolerance)
Set tolerance for color components used by runTest() and compareImages(). 
 
void setElapsedTimeTarget(int target)
 
unsigned int mismatchCount()