16 #ifndef QGSRENDERCHECKER_H
17 #define QGSRENDERCHECKER_H
45 QString controlImagePath()
const;
47 QString
report() {
return mReport; };
50 return static_cast<float>( mMismatchCount ) /
51 static_cast<float>( mMatchTarget ) * 100;
62 void setControlName(
const QString theName );
68 QString imageToHash( QString theImageFile );
70 void setRenderedImage( QString theImageFileName ) { mRenderedImageFile = theImageFileName; }
72 Q_DECL_DEPRECATED
void setMapRenderer(
QgsMapRenderer * thepMapRenderer );
83 void setColorTolerance(
unsigned int theColorTolerance ) { mColorTolerance = theColorTolerance; }
94 bool runTest( QString theTestName,
unsigned int theMismatchCount = 0 );
107 bool compareImages( QString theTestName,
unsigned int theMismatchCount = 0, QString theRenderedImageFile =
"" );
115 bool isKnownAnomaly( QString theDiffImageFile );
117 QString expectedImageFile() {
return mExpectedImageFile; };
144 inline bool compareWkt( QString a, QString b,
double tolerance = 0.000001 )
146 QgsDebugMsg( QString(
"a:%1 b:%2 tol:%3" ).arg( a ).arg( b ).arg( tolerance ) );
147 QRegExp re(
"-?\\d+(?:\\.\\d+)?(?:[eE]\\d+)?" );
149 QString a0( a ), b0( b );
150 a0.replace( re,
"#" );
151 b0.replace( re,
"#" );
153 QgsDebugMsg( QString(
"a0:%1 b0:%2" ).arg( a0 ).arg( b0 ) );
158 QList<double> al, bl;
161 for ( pos = 0; ( pos = re.indexIn( a, pos ) ) != -1; pos += re.matchedLength() )
163 al << re.cap( 0 ).toDouble();
165 for ( pos = 0; ( pos = re.indexIn( b, pos ) ) != -1; pos += re.matchedLength() )
167 bl << re.cap( 0 ).toDouble();
170 if ( al.size() != bl.size() )
173 for (
int i = 0; i < al.size(); i++ )
void setColorTolerance(unsigned int theColorTolerance)
Set tolerance for color components used by runTest() and compareImages().
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.
unsigned int mMismatchCount
~QgsRenderChecker()
Destructor.
void setControlPathPrefix(const QString theName)
Prefix where the control images are kept.
unsigned int mMatchTarget
QString mControlPathPrefix
unsigned int matchTarget()
QgsMapSettings mMapSettings
QString mRenderedImageFile
unsigned int mColorTolerance
void setRenderedImage(QString theImageFileName)
QString mExpectedImageFile
unsigned int mismatchCount()
void setElapsedTimeTarget(int theTarget)
bool compareWkt(QString a, QString b, double tolerance=0.000001)
Compare two WKT strings with some tolerance.