Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 11, 2021
1 parent 6cda831 commit 79ccc06
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/src/python/test_qgsannotation.py
Expand Up @@ -135,6 +135,19 @@ def testHtmlAnnotation(self):
im = self.renderAnnotation(clone, QPointF(20, 30))
self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))

def testHtmlAnnotationSetHtmlSource(self):
""" test rendering html annotation where the html is set directly (not from file)"""
a = QgsHtmlAnnotation()
a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
a.setFrameOffsetFromReferencePointMm(QPointF(70 / 3.7795275, 90 / 3.7795275))
htmlFile = open( TEST_DATA_DIR + "/test_html.html" )
htmlText = htmlFile.read()
a.setHtmlSource( htmlText )
im = self.renderAnnotation(a, QPointF(20, 30))
self.assertTrue(self.imageCheck('html_annotation_html_source', 'html_annotation', im))

def testHtmlAnnotationInLayout(self):
""" test rendering a svg annotation"""
a = QgsHtmlAnnotation()
Expand All @@ -146,6 +159,7 @@ def testHtmlAnnotationInLayout(self):
a.setSourceFile(html)
self.assertTrue(self.renderAnnotationInLayout('html_annotation_in_layout', a))


def testHtmlAnnotationWithFeature(self):
""" test rendering a html annotation with a feature"""
layer = QgsVectorLayer("Point?crs=EPSG:3111&field=station:string&field=suburb:string",
Expand Down

0 comments on commit 79ccc06

Please sign in to comment.