Skip to content

Commit cbc5782

Browse files
committedJul 25, 2017
Add unit test for scaling layout view with layouts in pixels
1 parent cd2c62e commit cbc5782

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎tests/src/python/test_qgslayoutview.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import qgis # NOQA
1616

17+
from qgis.core import QgsProject, QgsLayout, QgsUnitTypes
1718
from qgis.gui import QgsLayoutView
1819
from qgis.PyQt.QtCore import QRectF
1920
from qgis.PyQt.QtGui import QTransform
@@ -58,6 +59,18 @@ def testScaleSafe(self):
5859
view.scaleSafe(0.5)
5960
self.assertAlmostEqual(view.transform().m11(), scale)
6061

62+
def testLayoutScalePixels(self):
63+
p = QgsProject()
64+
l = QgsLayout(p)
65+
l.setUnits(QgsUnitTypes.LayoutPixels)
66+
view = QgsLayoutView()
67+
view.setCurrentLayout(l)
68+
view.setZoomLevel(1)
69+
# should be no transform, since 100% with pixel units should be pixel-pixel
70+
self.assertEqual(view.transform().m11(), 1)
71+
view.setZoomLevel(0.5)
72+
self.assertEqual(view.transform().m11(), 0.5)
73+
6174

6275
if __name__ == '__main__':
6376
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.