Add tests for atlas legend clipping

This commit is contained in:
Alessandro Pasotti 2023-09-22 11:35:58 +02:00
parent d156fbabfc
commit bbfefcfc81
3 changed files with 1460 additions and 1 deletions

View File

@ -49,7 +49,8 @@ from qgis.core import (
QgsSymbol,
QgsVectorLayer,
QgsReadWriteContext,
QgsTextFormat
QgsTextFormat,
QgsFeatureRequest,
)
import unittest
from qgis.testing import start_app, QgisTestCase
@ -1131,6 +1132,36 @@ class TestQgsLayoutItemLegend(QgisTestCase, LayoutItemTestCase):
)
)
def test_atlas_legend_clipping(self):
"""Test issue GH #54654"""
p = QgsProject()
self.assertTrue(p.read(os.path.join(TEST_DATA_DIR, 'layouts', 'atlas_legend_clipping.qgs')))
layout = p.layoutManager().layoutByName('layout1')
layer = list(p.mapLayers().values())[0]
feature = layer.getFeature(3)
req = QgsFeatureRequest()
req.setFilterExpression('value = 11')
feature = next(layer.getFeatures(req))
layout.reportContext().setFeature(feature)
legend = layout.items()[0]
legend.setStyleFont(QgsLegendStyle.Title, QgsFontUtils.getStandardTestFont('Bold', 20))
legend.setStyleFont(QgsLegendStyle.Group, QgsFontUtils.getStandardTestFont('Bold', 20))
legend.setStyleFont(QgsLegendStyle.Subgroup, QgsFontUtils.getStandardTestFont('Bold', 20))
legend.setStyleFont(QgsLegendStyle.Symbol, QgsFontUtils.getStandardTestFont('Bold', 20))
legend.setStyleFont(QgsLegendStyle.SymbolLabel,
QgsFontUtils.getStandardTestFont('Bold', 20))
legend.refresh()
self.assertTrue(
self.render_layout_check(
'atlas_legend_clipping', layout
)
)
def test_filter_by_map_content_rendering_different_layers_in_atlas(self):
point_path = os.path.join(TEST_DATA_DIR, 'points.shp')
point_layer = QgsVectorLayer(point_path, 'points', 'ogr')

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load Diff