Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add unit test for scaling layout view with layouts in pixels
  • Loading branch information
nyalldawson committed Jul 25, 2017
1 parent cd2c62e commit cbc5782
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/src/python/test_qgslayoutview.py
Expand Up @@ -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
Expand Down Expand Up @@ -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.