16 #ifndef QGSRENDERCHECKER_H 17 #define QGSRENDERCHECKER_H 46 QString controlImagePath()
const;
48 QString
report() {
return mReport; };
51 return static_cast<float>( mMismatchCount ) /
52 static_cast<float>( mMatchTarget ) * 100;
64 void setControlName(
const QString &theName );
74 QString imageToHash( QString theImageFile );
76 void setRenderedImage( QString theImageFileName ) { mRenderedImageFile = theImageFileName; }
87 Q_DECL_DEPRECATED
void setMapRenderer(
QgsMapRenderer * thepMapRenderer );
98 void setColorTolerance(
unsigned int theColorTolerance ) { mColorTolerance = theColorTolerance; }
109 bool runTest( QString theTestName,
unsigned int theMismatchCount = 0 );
122 bool compareImages( QString theTestName,
unsigned int theMismatchCount = 0, QString theRenderedImageFile =
"" );
130 bool isKnownAnomaly( QString theDiffImageFile );
135 static void drawBackground( QImage* image );
173 QString mControlName;
174 unsigned int mMismatchCount;
175 unsigned int mColorTolerance;
176 int mElapsedTimeTarget;
178 QString mControlPathPrefix;
179 QString mControlPathSuffix;
180 QVector<QgsDartMeasurement> mDashMessages;
181 bool mBufferDashMessages;
192 inline bool compareWkt( QString a, QString b,
double tolerance = 0.000001 )
194 QgsDebugMsg( QString(
"a:%1 b:%2 tol:%3" ).arg( a ).arg( b ).arg( tolerance ) );
195 QRegExp re(
"-?\\d+(?:\\.\\d+)?(?:[eE]\\d+)?" );
197 QString a0( a ), b0( b );
198 a0.replace( re,
"#" );
199 b0.replace( re,
"#" );
201 QgsDebugMsg( QString(
"a0:%1 b0:%2" ).arg( a0 ).arg( b0 ) );
206 QList<double> al, bl;
209 for ( pos = 0; ( pos = re.indexIn( a, pos ) ) != -1; pos += re.matchedLength() )
211 al << re.cap( 0 ).toDouble();
213 for ( pos = 0; ( pos = re.indexIn( b, pos ) ) != -1; pos += re.matchedLength() )
215 bl << re.cap( 0 ).toDouble();
218 if ( al.size() != bl.size() )
221 for (
int i = 0; i < al.size(); i++ )
void setControlPathSuffix(const QString &theName)
void setColorTolerance(unsigned int theColorTolerance)
Set tolerance for color components used by runTest() and compareImages().
void enableDashBuffering(bool enable)
Call this to enable internal buffering of dash messages.
This is a helper class for unit tests that need to write an image and compare it to an expected resul...
A non GUI class for rendering a map layer set onto a QPainter.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
The QgsMapSettings class contains configuration for rendering of the map.
~QgsRenderChecker()
Destructor.
unsigned int mMatchTarget
const QString & renderedImage()
The path of the rendered image can be retrieved through that method.
unsigned int matchTarget()
QString mRenderedImageFile
void setControlPathPrefix(const QString &theName)
Prefix where the control images are kept.
void setRenderedImage(QString theImageFileName)
QString mExpectedImageFile
unsigned int mismatchCount()
const QVector< QgsDartMeasurement > & dartMeasurements() const
Get access to buffered dash messages.
const QString & expectedImageFile() const
Returns the path to the expected image file.
void setElapsedTimeTarget(int theTarget)
bool compareWkt(QString a, QString b, double tolerance=0.000001)
Compare two WKT strings with some tolerance.