16#ifndef QGSRENDERCHECKER_H 
   17#define QGSRENDERCHECKER_H 
   28#include <QRegularExpression> 
   33#define DUMP_BASE64_IMAGES 0 
   57    static QDir testReportDir();
 
   65    static bool shouldGenerateReport();
 
   74    QString controlImagePath() 
const;
 
   82    void setControlImagePath( 
const QString &path );
 
   92    QString report( 
bool ignoreSuccess = 
true ) 
const;
 
  103    QString markdownReport( 
bool ignoreSuccess = 
true ) 
const;
 
  110      return static_cast<float>( mMismatchCount ) /
 
  111             static_cast<float>( mMatchTarget ) * 100;
 
 
  139    void setControlName( 
const QString &name );
 
  153    void setControlPathSuffix( 
const QString &name );
 
  156    QString imageToHash( 
const QString &imageFile );
 
  161    void setRenderedImage( 
const QString &imageFileName ) { mRenderedImageFile = imageFileName; }
 
  192    void setSizeTolerance( 
int xTolerance, 
int yTolerance ) { mMaxSizeDifferenceX = xTolerance; mMaxSizeDifferenceY = yTolerance; }
 
  201      AvoidExportingRenderedImage = 1 << 0, 
 
 
  248    bool compareImages( const QString &testName, const QString &referenceImageFile, const QString &renderedImageFile, 
unsigned int mismatchCount = 0, 
QgsRenderChecker::
Flags flags = 
QgsRenderChecker::
Flags() );
 
  260    Q_DECL_DEPRECATED 
bool isKnownAnomaly( const QString &diffImageFile ) 
SIP_DEPRECATED;
 
  266    static 
void drawBackground( QImage *image );
 
  273    QString expectedImageFile()
 const { 
return mExpectedImageFile; }
 
  297    static QString sourcePath();
 
  304    unsigned int mMatchTarget = 0;
 
  305    int mElapsedTime = 0;
 
  314#if DUMP_BASE64_IMAGES 
  315    void dumpRenderedImageAsBase64();
 
  318    void performPostTestActions( 
Flags flags );
 
  320    bool mResult = 
false;
 
  321    bool mExpectFail = 
false;
 
  325    QString mControlName;
 
  326    unsigned int mMismatchCount = 0;
 
  327    unsigned int mColorTolerance = 0;
 
  328    int mMaxSizeDifferenceX = 0;
 
  329    int mMaxSizeDifferenceY = 0;
 
  330    int mElapsedTimeTarget = 0;
 
  332    QString mControlExtension = QStringLiteral( 
"png" );
 
  333    QString mControlPathPrefix;
 
  334    QString mControlPathSuffix;
 
  335    bool mIsCiRun = 
false;
 
  336    QVector<QgsDartMeasurement> mDashMessages;
 
  337    bool mBufferDashMessages = 
false;
 
  338    QString mDiffImageFile;
 
 
  353inline 
bool compareWkt( const QString &a, const QString &b, 
double tolerance = 0.000001 )
 
  355  QgsDebugMsgLevel( QStringLiteral( 
"a:%1 b:%2 tol:%3" ).arg( a, b ).arg( tolerance ), 2 );
 
  356  const thread_local QRegularExpression re( 
"-?\\d+(?:\\.\\d+)?(?:[eE]\\d+)?" );
 
  358  QString a0( a ), b0( b );
 
  359  a0.replace( re, QStringLiteral( 
"#" ) );
 
  360  b0.replace( re, QStringLiteral( 
"#" ) );
 
  367  QList<double> al, bl;
 
  370  QRegularExpressionMatch match = re.match( a );
 
  371  while ( match.hasMatch() )
 
  373    al << match.captured( 0 ).toDouble();
 
  374    pos = match.capturedStart( 0 ) + match.capturedLength( 0 );
 
  375    match = re.match( a, pos );
 
  377  match = re.match( b );
 
  378  while ( match.hasMatch() )
 
  380    bl << match.captured( 0 ).toDouble();
 
  381    pos = match.capturedStart( 0 ) + match.capturedLength( 0 );
 
  382    match = re.match( b, pos );
 
  385  if ( al.size() != bl.size() )
 
  388  for ( 
int i = 0; i < al.size(); i++ )
 
 
Emits dart measurements for display in CDash reports.
 
Contains configuration for rendering maps.
 
Allows checking rendered images against comparison images.
 
Helper class for unit tests that need to write an image and compare it to an expected result or rende...
 
void setControlExtension(const QString &extension)
Sets file extension for the control image.
 
float matchPercent() const
Returns the percent of pixels which matched the control image.
 
unsigned int matchTarget() const
Returns the total number of pixels in the control image.
 
QString mReport
HTML format report.
 
QFlags< Flag > Flags
Render checker flags.
 
Flag
Render checker flags.
 
int elapsedTime() const
Returns the total elapsed time for the rendering test.
 
QString mRenderedImageFile
 
QString mMarkdownReport
Markdown report.
 
QString renderedImage() const
Returns the path of the rendered image generated by the test.
 
void setElapsedTimeTarget(int target)
 
QVector< QgsDartMeasurement > dartMeasurements() const
Gets access to buffered dash messages.
 
void setControlPathPrefix(const QString &name)
Sets the path prefix where the control images are kept.
 
void setRenderedImage(const QString &imageFileName)
Sets the file name of the rendered image generated by the test.
 
QString mExpectedImageFile
 
void setSizeTolerance(int xTolerance, int yTolerance)
Sets the largest allowable difference in size between the rendered and the expected image.
 
void enableDashBuffering(bool enable)
Call this to enable internal buffering of dash messages.
 
unsigned int mismatchCount() const
Returns the number of pixels which did not match the control image.
 
void setExpectFail(bool expectFail)
Sets whether the comparison is expected to fail.
 
void setColorTolerance(unsigned int colorTolerance)
Set tolerance for color components used by runTest() and compareImages().
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
#define SIP_ENUM_BASETYPE(type)
 
#define QgsDebugMsgLevel(str, level)
 
bool compareWkt(const QString &a, const QString &b, double tolerance=0.000001)
Compare two WKT strings with some tolerance.
 
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)