"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/src/python/test_qgspallabeling_base.py" between
QGIS-final-3_14_15.tar.gz and QGIS-final-3_14_16.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Latest release (3.14.x series).

test_qgspallabeling_base.py  (QGIS-final-3_14_15):test_qgspallabeling_base.py  (QGIS-final-3_14_16)
skipping to change at line 46 skipping to change at line 46
QgsLabelingEngineSettings, QgsLabelingEngineSettings,
QgsProject, QgsProject,
QgsMapSettings, QgsMapSettings,
QgsPalLabeling, QgsPalLabeling,
QgsPalLayerSettings, QgsPalLayerSettings,
QgsProviderRegistry, QgsProviderRegistry,
QgsStringReplacementCollection, QgsStringReplacementCollection,
QgsVectorLayer, QgsVectorLayer,
QgsVectorLayerSimpleLabeling, QgsVectorLayerSimpleLabeling,
QgsMultiRenderChecker, QgsMultiRenderChecker,
QgsUnitTypes QgsUnitTypes,
QgsVectorTileLayer,
QgsVectorTileBasicLabelingStyle,
QgsWkbTypes,
QgsVectorTileBasicLabeling
) )
from qgis.testing import start_app, unittest from qgis.testing import start_app, unittest
from qgis.testing.mocked import get_iface from qgis.testing.mocked import get_iface
from utilities import ( from utilities import (
unitTestDataPath, unitTestDataPath,
getTempfilePath, getTempfilePath,
renderMapToImage, renderMapToImage,
loadTestFonts, loadTestFonts,
skipping to change at line 278 skipping to change at line 282
def controlImagePath(self, grpprefix=''): def controlImagePath(self, grpprefix=''):
if not grpprefix: if not grpprefix:
grpprefix = self._TestGroupPrefix grpprefix = self._TestGroupPrefix
return os.path.join(self._TestDataDir, 'control_images', return os.path.join(self._TestDataDir, 'control_images',
'expected_' + grpprefix, 'expected_' + grpprefix,
self._Test, self._Test + '.png') self._Test, self._Test + '.png')
def saveControlImage(self, tmpimg=''): def saveControlImage(self, tmpimg=''):
# don't save control images for RenderVsOtherOutput (Vs) tests, since # don't save control images for RenderVsOtherOutput (Vs) tests, since
# those control images belong to a different test result # those control images belong to a different test result
if ('PAL_CONTROL_IMAGE' not in os.environ or if ('PAL_CONTROL_IMAGE' not in os.environ
'Vs' in self._TestGroup): or 'Vs' in self._TestGroup):
return return
imgpath = self.controlImagePath() imgpath = self.controlImagePath()
testdir = os.path.dirname(imgpath) testdir = os.path.dirname(imgpath)
if not os.path.exists(testdir): if not os.path.exists(testdir):
os.makedirs(testdir) os.makedirs(testdir)
imgbasepath = \ imgbasepath = \
os.path.join(testdir, os.path.join(testdir,
os.path.splitext(os.path.basename(imgpath))[0]) os.path.splitext(os.path.basename(imgpath))[0])
# remove any existing control images # remove any existing control images
for f in glob.glob(imgbasepath + '.*'): for f in glob.glob(imgbasepath + '.*'):
skipping to change at line 399 skipping to change at line 403
self.layer.setLabeling(None) self.layer.setLabeling(None)
self.assertEqual(None, self.layer.labeling()) self.assertEqual(None, self.layer.labeling())
def test_layer_pal_activated(self): def test_layer_pal_activated(self):
# Verify, via engine, that PAL labeling can be activated for layer # Verify, via engine, that PAL labeling can be activated for layer
lyr = self.defaultLayerSettings() lyr = self.defaultLayerSettings()
self.layer.setLabeling(QgsVectorLayerSimpleLabeling(lyr)) self.layer.setLabeling(QgsVectorLayerSimpleLabeling(lyr))
msg = '\nLayer labeling not activated, as reported by labelingEngine' msg = '\nLayer labeling not activated, as reported by labelingEngine'
self.assertTrue(QgsPalLabeling.staticWillUseLayer(self.layer), msg) self.assertTrue(QgsPalLabeling.staticWillUseLayer(self.layer), msg)
# also test for vector tile layer
tile_layer = QgsVectorTileLayer('x', 'y')
self.assertFalse(QgsPalLabeling.staticWillUseLayer(tile_layer))
st = QgsVectorTileBasicLabelingStyle()
st.setStyleName("st1")
st.setLayerName("place")
st.setFilterExpression("rank = 1 AND class = 'country'")
st.setGeometryType(QgsWkbTypes.PointGeometry)
labeling = QgsVectorTileBasicLabeling()
labeling.setStyles([st])
tile_layer.setLabeling(labeling)
self.assertTrue(QgsPalLabeling.staticWillUseLayer(tile_layer))
def test_write_read_settings(self): def test_write_read_settings(self):
# Verify written PAL settings are same when read from layer # Verify written PAL settings are same when read from layer
# load and write default test settings # load and write default test settings
lyr1 = self.defaultLayerSettings() lyr1 = self.defaultLayerSettings()
lyr1dict = self.settingsDict(lyr1) lyr1dict = self.settingsDict(lyr1)
# print(lyr1dict) # print(lyr1dict)
self.layer.setLabeling(QgsVectorLayerSimpleLabeling(lyr1)) self.layer.setLabeling(QgsVectorLayerSimpleLabeling(lyr1))
# read settings # read settings
lyr2 = self.layer.labeling().settings() lyr2 = self.layer.labeling().settings()
 End of changes. 3 change blocks. 
3 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)