Skip to content

Commit

Permalink
Add test to ensure QgsRenderContext created without map settings
Browse files Browse the repository at this point in the history
has an invalid (default constructed) mapToPixel
  • Loading branch information
nyalldawson committed Sep 27, 2021
1 parent d3792a9 commit fdc3d47
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/src/python/test_qgsrendercontext.py
Expand Up @@ -67,6 +67,9 @@ def testGettersSetters(self):
c.setSymbologyReferenceScale(1000)
self.assertEqual(c.symbologyReferenceScale(), 1000)

# should have an invalid mapToPixel by default
self.assertFalse(c.mapToPixel().isValid())

def testCopyConstructor(self):
"""
Test the copy constructor
Expand Down Expand Up @@ -113,6 +116,9 @@ def testFromQPainter(self):
self.assertEqual(c.testFlag(QgsRenderContext.LosslessImageRendering), False)
self.assertAlmostEqual(c.scaleFactor(), 88 / 25.4, 3)

# should have an invalid mapToPixel by default
self.assertFalse(c.mapToPixel().isValid())

im = QImage(1000, 600, QImage.Format_RGB32)
dots_per_m = 300 / 25.4 * 1000 # 300 dpi to dots per m
im.setDotsPerMeterX(dots_per_m)
Expand Down Expand Up @@ -153,6 +159,9 @@ def testFromMapSettings(self):
self.assertEqual(ms.zRange(), QgsDoubleRange(1, 10))
self.assertEqual(rc.symbologyReferenceScale(), -1)

# should have an valid mapToPixel
self.assertTrue(rc.mapToPixel().isValid())

ms.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
ms.setZRange(QgsDoubleRange())
rc = QgsRenderContext.fromMapSettings(ms)
Expand Down

0 comments on commit fdc3d47

Please sign in to comment.