Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 20, 2020
1 parent ef97e8c commit 1d33ddf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/src/python/test_qgsrandommarkersymbollayer.py
Expand Up @@ -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)
Expand Down
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 1d33ddf

Please sign in to comment.