Skip to content

Commit

Permalink
[unit tests] Fix blend modes test
Browse files Browse the repository at this point in the history
 * 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 14, 2014
1 parent 9ae9de3 commit 9d9f7c1
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 8 deletions.
7 changes: 4 additions & 3 deletions tests/src/core/testqgsblendmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
15 changes: 10 additions & 5 deletions tests/src/python/test_qgsblendmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
QgsMapLayerRegistry,
QgsMapRenderer,
QgsCoordinateReferenceSystem,
QgsRenderChecker,
QgsMultiRenderChecker,
QgsRasterLayer,
QgsRasterDataProvider,
QgsMultiBandColorRenderer,
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9d9f7c1

Please sign in to comment.