Skip to content
Permalink
Browse files

[unit tests] Fix blend modes test

 * Switched to QgsMultiRenderChecker and added control images for precise
 * Add a minimal color tolerance for slight render inconsistencies
  • Loading branch information
m-kuhn committed Nov 12, 2014
1 parent 9ae9de3 commit 9d9f7c18aa87dd042cafdda90fb19f027deafb39
@@ -30,7 +30,7 @@
#include <qgsmultibandcolorrenderer.h>
#include <qgsrasterlayer.h>
//qgis test includes
#include "qgsrenderchecker.h"
#include "qgsmultirenderchecker.h"

/** \ingroup UnitTests
* This is a unit test for layer blend modes
@@ -214,10 +214,11 @@ bool TestQgsBlendModes::imageCheck( QString theTestType )
{
//use the QgsRenderChecker test utility class to
//ensure the rendered output matches our control image
QgsRenderChecker myChecker;
QgsMultiRenderChecker myChecker;
myChecker.setControlName( "expected_" + theTestType );
myChecker.setMapSettings( mMapSettings );
bool myResultFlag = myChecker.runTest( theTestType, 1500 );
myChecker.setColorTolerance( 1 );
bool myResultFlag = myChecker.runTest( theTestType );
mReport += myChecker.report();
return myResultFlag;
}
@@ -34,7 +34,7 @@
QgsMapLayerRegistry,
QgsMapRenderer,
QgsCoordinateReferenceSystem,
QgsRenderChecker,
QgsMultiRenderChecker,
QgsRasterLayer,
QgsRasterDataProvider,
QgsMultiBandColorRenderer,
@@ -112,9 +112,10 @@ def testVectorBlending(self):
self.mLineLayer.setBlendMode(QPainter.CompositionMode_Difference)
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_Difference)

checker = QgsRenderChecker()
checker = QgsMultiRenderChecker()
checker.setControlName("expected_vector_blendmodes")
checker.setMapSettings(self.mapSettings)
checker.setColorTolerance( 1 )

myResult = checker.runTest("vector_blendmodes", 1500);
myMessage = ('vector blending failed')
@@ -137,9 +138,10 @@ def testVectorFeatureBlending(self):
#Set feature blending for line layer
self.mLineLayer.setFeatureBlendMode(QPainter.CompositionMode_Plus)

checker = QgsRenderChecker()
checker = QgsMultiRenderChecker()
checker.setControlName("expected_vector_featureblendmodes")
checker.setMapSettings(self.mapSettings)
checker.setColorTolerance( 1 )

myResult = checker.runTest("vector_featureblendmodes", 1500);
myMessage = ('vector feature blending failed')
@@ -161,9 +163,10 @@ def testVectorLayerTransparency(self):
#Set feature blending for line layer
self.mLineLayer.setLayerTransparency( 50 )

checker = QgsRenderChecker()
checker = QgsMultiRenderChecker()
checker.setControlName("expected_vector_layertransparency")
checker.setMapSettings(self.mapSettings)
checker.setColorTolerance( 1 )

myResult = checker.runTest("vector_layertransparency", 1500);
myMessage = ('vector layer transparency failed')
@@ -180,9 +183,11 @@ def testRasterBlending(self):

#Set blending mode for top layer
self.mRasterLayer1.setBlendMode(QPainter.CompositionMode_Plus)
checker = QgsRenderChecker()
checker = QgsMultiRenderChecker()
checker.setControlName("expected_raster_blendmodes")
checker.setMapSettings(self.mapSettings)
checker.setColorTolerance( 1 )
checker.setColorTolerance( 1 )

myResult = checker.runTest("raster_blendmodes", 1500);
myMessage = ('raster blending failed')
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 9d9f7c1

Please sign in to comment.
You can’t perform that action at this time.