QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
QgsMultiRenderChecker Class Reference

This class allows checking rendered images against comparison images. More...

#include <qgsmultirenderchecker.h>

Public Member Functions

 QgsMultiRenderChecker ()
const QString controlImagePath () const
 controlImagePath
const QString & report () const
 Returns a report for this test.
bool runTest (const QString &theTestName, unsigned int theMismatchCount=0)
 Test using renderer to generate the image to be compared.
void setColorTolerance (unsigned int theColorTolerance)
 Set tolerance for color components used by runTest() Default value is 0.
void setControlName (const QString &theName)
 Base directory name for the control image (with control image path suffixed) the path to the image will be constructed like this: controlImagePath + '/' + mControlName + '/' + mControlName + '.png'.
void setControlPathPrefix (const QString &prefix)
void setMapSettings (const QgsMapSettings &mapSettings)
 Set the map settings to use to render the image.
void setRenderedImage (const QString &renderedImagePath)
 Set the path to the rendered image.

Static Public Member Functions

static void drawBackground (QImage *image)
 Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a transparent background for the image.

Detailed Description

This class allows checking rendered images against comparison images.

Its main purpose is for the unit testing framework.

It will either

This image will then be compared against one or several images in a folder inside the control directory (tests/testdata/control_images/{controlName}).

There are modes for single and for multiple reference images.

For every control image there may be one or several randomly named anomaly images defining allowed anomalies. For every control image, the allowed mismatch and color tolerance values will be calculated individually.

Note
added in 2.8

Definition at line 51 of file qgsmultirenderchecker.h.

Constructor & Destructor Documentation

QgsMultiRenderChecker::QgsMultiRenderChecker ( )

Definition at line 20 of file qgsmultirenderchecker.cpp.

Member Function Documentation

const QString QgsMultiRenderChecker::controlImagePath ( ) const

controlImagePath

Returns

Definition at line 98 of file qgsmultirenderchecker.cpp.

static void QgsMultiRenderChecker::drawBackground ( QImage *  image)
inlinestatic

Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a transparent background for the image.

Definition at line 120 of file qgsmultirenderchecker.h.

const QString& QgsMultiRenderChecker::report ( ) const
inline

Returns a report for this test.

Returns
A report

Definition at line 109 of file qgsmultirenderchecker.h.

bool QgsMultiRenderChecker::runTest ( const QString &  theTestName,
unsigned int  theMismatchCount = 0 
)

Test using renderer to generate the image to be compared.

Parameters
theTestName- to be used as the basis for writing a file to e.g. /tmp/theTestName.png
theMismatchCount- defaults to 0 - the number of pixels that are allowed to be different from the control image. In some cases rendering may be non-deterministic. This parameter allows you to account for that by providing a tolerance.
Note
make sure to call setExpectedImage and setMapSettings first

Definition at line 40 of file qgsmultirenderchecker.cpp.

void QgsMultiRenderChecker::setColorTolerance ( unsigned int  theColorTolerance)
inline

Set tolerance for color components used by runTest() Default value is 0.

Parameters
theColorToleranceThe maximum difference for each color component including alpha to be considered correct.

Definition at line 87 of file qgsmultirenderchecker.h.

void QgsMultiRenderChecker::setControlName ( const QString &  theName)

Base directory name for the control image (with control image path suffixed) the path to the image will be constructed like this: controlImagePath + '/' + mControlName + '/' + mControlName + '.png'.

Definition at line 25 of file qgsmultirenderchecker.cpp.

void QgsMultiRenderChecker::setControlPathPrefix ( const QString &  prefix)

Definition at line 30 of file qgsmultirenderchecker.cpp.

void QgsMultiRenderChecker::setMapSettings ( const QgsMapSettings mapSettings)

Set the map settings to use to render the image.

Parameters
mapSettingsThe map settings

Definition at line 35 of file qgsmultirenderchecker.cpp.

void QgsMultiRenderChecker::setRenderedImage ( const QString &  renderedImagePath)
inline

Set the path to the rendered image.

If this is not set or set to QString::Null, an image will be rendered based on the provided mapsettings

Parameters
renderedImagePathA path to the rendered image with which control images will be compared

Definition at line 71 of file qgsmultirenderchecker.h.


The documentation for this class was generated from the following files: