Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information
nyalldawson committed May 29, 2017
1 parent bcf4026 commit 32480fe8bdc4b80cf925232022abce4fe6923e39
@@ -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()
{
@@ -58,9 +58,9 @@ class TestSignalReceiver : public QObject
{
featureBlendMode = blendMode;
}
void onLayerTransparencyChanged( int layerTransparency )
void onLayerOpacityChanged( double layerOpacity )
{
transparency = layerTransparency;
opacity = layerOpacity;
}
};

@@ -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 );
}

@@ -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")
@@ -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
@@ -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')

0 comments on commit 32480fe

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