Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix blending tests
  • Loading branch information
nyalldawson committed May 26, 2013
1 parent 61285a9 commit 8cf9f7b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
17 changes: 13 additions & 4 deletions tests/src/core/testqgsblendmodes.cpp
Expand Up @@ -121,15 +121,19 @@ void TestQgsBlendModes::vectorBlending()
{
//Add two vector layers
QStringList myLayers;
myLayers << mpPointsLayer->id();
myLayers << mpLinesLayer->id();
myLayers << mpPolysLayer->id();
mpMapRenderer->setLayerSet( myLayers );

//Set blending modes for both layers
mpPointsLayer->setBlendMode( QPainter::CompositionMode_Overlay );
mpPolysLayer->setBlendMode( QPainter::CompositionMode_Multiply );
mpLinesLayer->setBlendMode( QPainter::CompositionMode_Difference );
mpPolysLayer->setBlendMode( QPainter::CompositionMode_Difference );
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QVERIFY( imageCheck( "vector_blendmodes" ) );

//Reset layers
mpLinesLayer->setBlendMode( QPainter::CompositionMode_SourceOver );
mpPolysLayer->setBlendMode( QPainter::CompositionMode_SourceOver );
}

void TestQgsBlendModes::featureBlending()
Expand All @@ -144,6 +148,9 @@ void TestQgsBlendModes::featureBlending()
mpLinesLayer->setFeatureBlendMode( QPainter::CompositionMode_Plus );
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QVERIFY( imageCheck( "vector_featureblendmodes" ) );

//Reset layers
mpLinesLayer->setFeatureBlendMode( QPainter::CompositionMode_SourceOver );
}

void TestQgsBlendModes::vectorLayerTransparency()
Expand All @@ -153,12 +160,14 @@ void TestQgsBlendModes::vectorLayerTransparency()
myLayers << mpLinesLayer->id();
myLayers << mpPolysLayer->id();
mpMapRenderer->setLayerSet( myLayers );
mpLinesLayer->setFeatureBlendMode( QPainter::CompositionMode_SourceOver );

//Set feature blending modes for point layer
mpLinesLayer->setLayerTransparency( 50 );
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QVERIFY( imageCheck( "vector_layertransparency" ) );

//Reset layers
mpLinesLayer->setLayerTransparency( 0 );
}

void TestQgsBlendModes::rasterBlending()
Expand Down
15 changes: 10 additions & 5 deletions tests/src/python/test_qgsblendmodes.py
Expand Up @@ -96,14 +96,14 @@ def testVectorBlending(self):

#Add vector layers to map
myLayers = QStringList()
myLayers.append(self.mPointLayer.id())
myLayers.append(self.mLineLayer.id())
myLayers.append(self.mPolygonLayer.id())
self.mMapRenderer.setLayerSet(myLayers)
self.mMapRenderer.setExtent(self.mPointLayer.extent())

#Set blending modes for both layers
self.mPointLayer.setBlendMode(QPainter.CompositionMode_Overlay)
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_Multiply)
self.mLineLayer.setBlendMode(QPainter.CompositionMode_Difference)
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_Difference)

checker = QgsRenderChecker()
checker.setControlName("expected_vector_blendmodes")
Expand All @@ -113,6 +113,10 @@ def testVectorBlending(self):
myMessage = ('vector blending failed')
assert myResult, myMessage

#Reset layers
self.mLineLayer.setBlendMode(QPainter.CompositionMode_SourceOver)
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_SourceOver)

def testVectorFeatureBlending(self):
"""Test that feature blend modes work for vector layers."""

Expand All @@ -122,7 +126,6 @@ def testVectorFeatureBlending(self):
myLayers.append(self.mPolygonLayer.id())
self.mMapRenderer.setLayerSet(myLayers)
self.mMapRenderer.setExtent(self.mPointLayer.extent())
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_Multiply)

#Set feature blending for line layer
self.mLineLayer.setFeatureBlendMode(QPainter.CompositionMode_Plus)
Expand All @@ -135,6 +138,9 @@ def testVectorFeatureBlending(self):
myMessage = ('vector feature blending failed')
assert myResult, myMessage

#Reset layers
self.mLineLayer.setFeatureBlendMode(QPainter.CompositionMode_SourceOver)

def testVectorLayerTransparency(self):
"""Test that layer transparency works for vector layers."""

Expand All @@ -144,7 +150,6 @@ def testVectorLayerTransparency(self):
myLayers.append(self.mPolygonLayer.id())
self.mMapRenderer.setLayerSet(myLayers)
self.mMapRenderer.setExtent(self.mPointLayer.extent())
self.mPolygonLayer.setBlendMode(QPainter.CompositionMode_Multiply)

#Set feature blending for line layer
self.mLineLayer.setLayerTransparency( 50 )
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 8cf9f7b

Please sign in to comment.