|
26 | 26 | QgsProject,
|
27 | 27 | QgsLayoutObject,
|
28 | 28 | QgsProperty,
|
29 |
| - QgsLayoutMeasurement) |
| 29 | + QgsLayoutMeasurement, |
| 30 | + QgsLayoutItem, |
| 31 | + QgsLayoutPoint, |
| 32 | + QgsLayoutSize) |
30 | 33 | from qgis.testing import (start_app,
|
31 | 34 | unittest
|
32 | 35 | )
|
@@ -84,6 +87,24 @@ def testInitialSizeSymbolMapUnits(self):
|
84 | 87 | result, message = checker.testLayout()
|
85 | 88 | self.assertTrue(result, message)
|
86 | 89 |
|
| 90 | + # resize with non-top-left reference point |
| 91 | + legend.setResizeToContents(False) |
| 92 | + legend.setReferencePoint(QgsLayoutItem.LowerRight) |
| 93 | + legend.attemptMove(QgsLayoutPoint(120, 90)) |
| 94 | + legend.attemptResize(QgsLayoutSize(50, 60)) |
| 95 | + |
| 96 | + self.assertEqual(legend.positionWithUnits().x(), 120.0) |
| 97 | + self.assertEqual(legend.positionWithUnits().y(), 90.0) |
| 98 | + self.assertAlmostEqual(legend.pos().x(), 70, -1) |
| 99 | + self.assertAlmostEqual(legend.pos().y(), 30, -1) |
| 100 | + |
| 101 | + legend.setResizeToContents(True) |
| 102 | + legend.updateLegend() |
| 103 | + self.assertEqual(legend.positionWithUnits().x(), 120.0) |
| 104 | + self.assertEqual(legend.positionWithUnits().y(), 90.0) |
| 105 | + self.assertAlmostEqual(legend.pos().x(), 91, -1) |
| 106 | + self.assertAlmostEqual(legend.pos().y(), 71, -1) |
| 107 | + |
87 | 108 | QgsProject.instance().removeMapLayers([point_layer.id()])
|
88 | 109 |
|
89 | 110 | def testResizeWithMapContent(self):
|
|
0 commit comments