Skip to content

Commit d06e572

Browse files
committedMay 12, 2020
More tests
1 parent 92bcc94 commit d06e572

File tree

10 files changed

+84
-0
lines changed

10 files changed

+84
-0
lines changed
 

‎tests/src/python/test_qgspallabeling_tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,17 @@ def test_curved_placement_below(self):
309309
self.lyr.placementFlags = QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.MapOrientation
310310
self.checkTest()
311311

312+
def test_curved_placement_online_html(self):
313+
# Curved placement, on line
314+
self.lyr.placement = QgsPalLayerSettings.Curved
315+
self.lyr.placementFlags = QgsPalLayerSettings.OnLine
316+
format = self.lyr.format()
317+
format.setAllowHtmlFormatting(True)
318+
self.lyr.setFormat(format)
319+
self.lyr.fieldName = "'<span style=\"color: red\">aaa</span><s>aa</s><span style=\"text-decoration: overline\">a</span>'"
320+
self.lyr.isExpression = True
321+
self.checkTest()
322+
312323
def test_length_expression(self):
313324
# compare length using the ellipsoid in kms and the planimetric distance in meters
314325
self.lyr.fieldName = "round($length,5) || ' - ' || round(length($geometry),2)"

‎tests/src/python/test_qgstextrenderer.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,79 @@ def testDrawTextDataDefinedBufferColorPoint(self):
22032203
format.buffer().setSize(5)
22042204
assert self.checkRenderPoint(format, 'text_dd_buffer_color', None, text=['test'], point=QPointF(50, 200))
22052205

2206+
def testHtmlFormatting(self):
2207+
format = QgsTextFormat()
2208+
format.setFont(getTestFont('bold'))
2209+
format.setSize(60)
2210+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2211+
format.setColor(QColor(0, 255, 0))
2212+
format.setAllowHtmlFormatting(True)
2213+
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))
2214+
2215+
def testHtmlFormattingBuffer(self):
2216+
format = QgsTextFormat()
2217+
format.setFont(getTestFont('bold'))
2218+
format.setSize(60)
2219+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2220+
format.setColor(QColor(0, 255, 0))
2221+
format.setAllowHtmlFormatting(True)
2222+
format.buffer().setEnabled(True)
2223+
format.buffer().setSize(5)
2224+
format.buffer().setColor(QColor(50, 150, 200))
2225+
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))
2226+
2227+
def testHtmlFormattingShadow(self):
2228+
format = QgsTextFormat()
2229+
format.setFont(getTestFont('bold'))
2230+
format.setSize(60)
2231+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2232+
format.setColor(QColor(0, 255, 0))
2233+
format.setAllowHtmlFormatting(True)
2234+
format.shadow().setEnabled(True)
2235+
format.shadow().setOffsetDistance(5)
2236+
format.shadow().setBlurRadius(0)
2237+
format.shadow().setColor(QColor(50, 150, 200))
2238+
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))
2239+
2240+
def testHtmlFormattingBufferShadow(self):
2241+
format = QgsTextFormat()
2242+
format.setFont(getTestFont('bold'))
2243+
format.setSize(60)
2244+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2245+
format.setColor(QColor(0, 255, 0))
2246+
format.setAllowHtmlFormatting(True)
2247+
format.buffer().setEnabled(True)
2248+
format.buffer().setSize(5)
2249+
format.buffer().setColor(QColor(200, 50, 150))
2250+
format.shadow().setEnabled(True)
2251+
format.shadow().setOffsetDistance(5)
2252+
format.shadow().setBlurRadius(0)
2253+
format.shadow().setColor(QColor(50, 150, 200))
2254+
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))
2255+
2256+
def testHtmlFormattingVertical(self):
2257+
format = QgsTextFormat()
2258+
format.setFont(getTestFont('bold'))
2259+
format.setSize(30)
2260+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2261+
format.setColor(QColor(0, 255, 0))
2262+
format.setAllowHtmlFormatting(True)
2263+
format.setOrientation(QgsTextFormat.VerticalOrientation)
2264+
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))
2265+
2266+
def testHtmlFormattingBufferVertical(self):
2267+
format = QgsTextFormat()
2268+
format.setFont(getTestFont('bold'))
2269+
format.setSize(30)
2270+
format.setSizeUnit(QgsUnitTypes.RenderPoints)
2271+
format.setColor(QColor(0, 255, 0))
2272+
format.setAllowHtmlFormatting(True)
2273+
format.buffer().setEnabled(True)
2274+
format.buffer().setSize(5)
2275+
format.buffer().setColor(QColor(50, 150, 200))
2276+
format.setOrientation(QgsTextFormat.VerticalOrientation)
2277+
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))
2278+
22062279
def testTextRenderFormat(self):
22072280
format = QgsTextFormat()
22082281
format.setFont(getTestFont('bold'))
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.