Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 12, 2020
1 parent 92bcc94 commit d06e572
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/src/python/test_qgspallabeling_tests.py
Expand Up @@ -309,6 +309,17 @@ def test_curved_placement_below(self):
self.lyr.placementFlags = QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.MapOrientation
self.checkTest()

def test_curved_placement_online_html(self):
# Curved placement, on line
self.lyr.placement = QgsPalLayerSettings.Curved
self.lyr.placementFlags = QgsPalLayerSettings.OnLine
format = self.lyr.format()
format.setAllowHtmlFormatting(True)
self.lyr.setFormat(format)
self.lyr.fieldName = "'<span style=\"color: red\">aaa</span><s>aa</s><span style=\"text-decoration: overline\">a</span>'"
self.lyr.isExpression = True
self.checkTest()

def test_length_expression(self):
# compare length using the ellipsoid in kms and the planimetric distance in meters
self.lyr.fieldName = "round($length,5) || ' - ' || round(length($geometry),2)"
Expand Down
73 changes: 73 additions & 0 deletions tests/src/python/test_qgstextrenderer.py
Expand Up @@ -2203,6 +2203,79 @@ def testDrawTextDataDefinedBufferColorPoint(self):
format.buffer().setSize(5)
assert self.checkRenderPoint(format, 'text_dd_buffer_color', None, text=['test'], point=QPointF(50, 200))

def testHtmlFormatting(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(60)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
assert self.checkRenderPoint(format, 'text_html_formatting', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testHtmlFormattingBuffer(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(60)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
format.buffer().setEnabled(True)
format.buffer().setSize(5)
format.buffer().setColor(QColor(50, 150, 200))
assert self.checkRenderPoint(format, 'text_html_formatting_buffer', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testHtmlFormattingShadow(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(60)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
format.shadow().setEnabled(True)
format.shadow().setOffsetDistance(5)
format.shadow().setBlurRadius(0)
format.shadow().setColor(QColor(50, 150, 200))
assert self.checkRenderPoint(format, 'text_html_formatting_shadow', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testHtmlFormattingBufferShadow(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(60)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
format.buffer().setEnabled(True)
format.buffer().setSize(5)
format.buffer().setColor(QColor(200, 50, 150))
format.shadow().setEnabled(True)
format.shadow().setOffsetDistance(5)
format.shadow().setBlurRadius(0)
format.shadow().setColor(QColor(50, 150, 200))
assert self.checkRenderPoint(format, 'text_html_formatting_buffer_shadow', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testHtmlFormattingVertical(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(30)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
format.setOrientation(QgsTextFormat.VerticalOrientation)
assert self.checkRenderPoint(format, 'text_html_formatting_vertical', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testHtmlFormattingBufferVertical(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
format.setSize(30)
format.setSizeUnit(QgsUnitTypes.RenderPoints)
format.setColor(QColor(0, 255, 0))
format.setAllowHtmlFormatting(True)
format.buffer().setEnabled(True)
format.buffer().setSize(5)
format.buffer().setColor(QColor(50, 150, 200))
format.setOrientation(QgsTextFormat.VerticalOrientation)
assert self.checkRenderPoint(format, 'text_html_formatting_buffer_vertical', None, text=['<s>t</s><span style="text-decoration: overline">e</span><span style="color: red">s<span style="text-decoration: underline">t</span></span>'], point=QPointF(50, 200))

def testTextRenderFormat(self):
format = QgsTextFormat()
format.setFont(getTestFont('bold'))
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 d06e572

Please sign in to comment.