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++ )