Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 29, 2017
1 parent bcf4026 commit 32480fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions tests/src/core/testqgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class TestSignalReceiver : public QObject
: QObject( 0 )
, rendererChanged( false )
, featureBlendMode( QPainter::CompositionMode( 0 ) )
, transparency( 0 )
, opacity( 1.0 )
{}
bool rendererChanged;
QPainter::CompositionMode featureBlendMode;
int transparency;
double opacity;
public slots:
void onRendererChanged()
{
Expand All @@ -58,9 +58,9 @@ class TestSignalReceiver : public QObject
{
featureBlendMode = blendMode;
}
void onLayerTransparencyChanged( int layerTransparency )
void onLayerOpacityChanged( double layerOpacity )
{
transparency = layerTransparency;
opacity = layerOpacity;
}
};

Expand Down Expand Up @@ -296,12 +296,12 @@ void TestQgsVectorLayer::QgsVectorLayersetLayerTransparency()
{
QgsVectorLayer *vLayer = static_cast< QgsVectorLayer * >( mpPointsLayer );
TestSignalReceiver receiver;
QObject::connect( vLayer, SIGNAL( layerTransparencyChanged( int ) ),
&receiver, SLOT( onLayerTransparencyChanged( int ) ) );
QObject::connect( vLayer, &QgsVectorLayer::opacityChanged,
&receiver, &TestSignalReceiver::onLayerOpacityChanged );

QCOMPARE( receiver.transparency, 0 );
QCOMPARE( receiver.opacity, 1.0 );
vLayer->setOpacity( 0.5 );
QCOMPARE( receiver.transparency, 50 );
QCOMPARE( receiver.opacity, 0.5 );
QCOMPARE( vLayer->opacity(), 0.5 );
}

Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_qgsblendmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ def testVectorFeatureBlending(self):
# Reset layers
self.mLineLayer.setFeatureBlendMode(QPainter.CompositionMode_SourceOver)

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

# Add vector layers to map
myLayers = [self.mLineLayer, self.mPolygonLayer]
self.mapSettings.setLayers(myLayers)
self.mapSettings.setExtent(self.extent)

# Set feature blending for line layer
self.mLineLayer.setLayerTransparency(50)
self.mLineLayer.setOpacity(0.5)

checker = QgsMultiRenderChecker()
checker.setControlName("expected_vector_layertransparency")
Expand Down
18 changes: 9 additions & 9 deletions tests/src/python/test_qgsvectorlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,17 +1764,17 @@ def testAggregate(self):
self.assertTrue(ok)
self.assertEqual(val, 'this is a test')

def onLayerTransparencyChanged(self, tr):
self.transparencyTest = tr
def onLayerOpacityChanged(self, tr):
self.opacityTest = tr

def test_setLayerTransparency(self):
def test_setLayerOpacity(self):
layer = createLayerWithOnePoint()

self.transparencyTest = 0
layer.layerTransparencyChanged.connect(self.onLayerTransparencyChanged)
layer.setLayerTransparency(50)
self.assertEqual(self.transparencyTest, 50)
self.assertEqual(layer.layerTransparency(), 50)
self.opacityTest = 0
layer.opacityChanged.connect(self.onLayerOpacityChanged)
layer.setOpacity(0.5)
self.assertEqual(self.opacityTest, 0.5)
self.assertEqual(layer.opacity(), 0.5)

def onRendererChanged(self):
self.rendererChanged = True
Expand Down Expand Up @@ -2197,7 +2197,7 @@ def testClone(self):
layer.setCustomProperty('MyKey0', 'MyValue0')
layer.setCustomProperty('MyKey1', 'MyValue1')

layer.setLayerTransparency(33)
layer.setOpacity(0.66)
layer.setProviderEncoding('latin9')
layer.setDisplayExpression('MyDisplayExpression')
layer.setMapTipTemplate('MyMapTipTemplate')
Expand Down

0 comments on commit 32480fe

Please sign in to comment.