Skip to content
Permalink
Browse files

Add unit test

  • Loading branch information
nyalldawson committed May 19, 2020
1 parent ef97e8c commit 1d33ddfdc9a5cac7b4a5d8ad9a943cbb18a3b572
@@ -171,6 +171,34 @@ def testMultipart(self):
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('randommarkerfill_multipoly', 'randommarkerfill_multipoly', rendered_image))

def testMultiLayer(self):
"""
Test rendering a multi-layer symbol including a random marker fill symbol
"""
s = QgsFillSymbol()
s.deleteSymbolLayer(0)

simple_fill = QgsSimpleFillSymbolLayer(color=QColor(255, 255, 255))
s.appendSymbolLayer(simple_fill.clone())

random_fill = QgsRandomMarkerFillSymbolLayer(12, seed=481523)
marker = QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayer.Triangle, 4)
marker.setColor(QColor(255, 0, 0))
marker.setStrokeStyle(Qt.NoPen)
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
random_fill.setSubSymbol(marker_symbol)

s.appendSymbolLayer(random_fill.clone())

simple_fill = QgsSimpleFillSymbolLayer(color=QColor(100, 150, 200, 150))
s.appendSymbolLayer(simple_fill.clone())

g = QgsGeometry.fromWkt(
'MultiPolygon(((0 0, 5 0, 5 10, 0 10, 0 0),(1 1, 1 9, 4 9, 4 1, 1 1)), ((6 0, 10 0, 10 5, 6 5, 6 0)), ((8 6, 10 6, 10 10, 8 10, 8 6)))')
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('randommarkerfill_multilayer', 'randommarkerfill_multilayer', rendered_image))

def renderGeometry(self, symbol, geom, buffer=20):
f = QgsFeature()
f.setGeometry(geom)
Binary file not shown.

0 comments on commit 1d33ddf

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