Skip to content
Permalink
Browse files
Add unit test
  • Loading branch information
mhugent committed Jun 11, 2021
1 parent 6cda831 commit 79ccc064c56f12772880b2c6a235e3eb951d3d7e
Showing with 14 additions and 0 deletions.
  1. +14 −0 tests/src/python/test_qgsannotation.py
@@ -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()
@@ -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",

0 comments on commit 79ccc06

Please sign in to comment.