Skip to content
Permalink
Browse files

Add unit test for scaling layout view with layouts in pixels

  • Loading branch information
nyalldawson committed Jul 22, 2017
1 parent cd2c62e commit cbc5782cd87177c9fe3f59877a8d2d4ba65dd2b3
Showing with 13 additions and 0 deletions.
  1. +13 −0 tests/src/python/test_qgslayoutview.py
@@ -14,6 +14,7 @@

import qgis # NOQA

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

def testLayoutScalePixels(self):
p = QgsProject()
l = QgsLayout(p)
l.setUnits(QgsUnitTypes.LayoutPixels)
view = QgsLayoutView()
view.setCurrentLayout(l)
view.setZoomLevel(1)
# should be no transform, since 100% with pixel units should be pixel-pixel
self.assertEqual(view.transform().m11(), 1)
view.setZoomLevel(0.5)
self.assertEqual(view.transform().m11(), 0.5)


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

0 comments on commit cbc5782

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