Skip to content
Permalink
Browse files

More tests

  • Loading branch information
nyalldawson committed May 12, 2020
1 parent 92bcc94 commit d06e5722fdec1e677ee64fca10ef17e166cdf6de
@@ -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)"
@@ -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'))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit d06e572

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