Skip to content

Commit

Permalink
Update labeling canvas and server unit tests and output new control i…
Browse files Browse the repository at this point in the history
…mages
  • Loading branch information
dakcarto committed Feb 21, 2014
1 parent b979774 commit c4a60de
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 8 deletions.
13 changes: 11 additions & 2 deletions tests/src/python/test_qgspallabeling_base.py
Expand Up @@ -61,6 +61,7 @@
PALREPORTS = {}


# noinspection PyPep8Naming,PyShadowingNames
class TestQgsPalLabeling(TestCase):

_TestDataDir = unitTestDataPath()
Expand All @@ -82,6 +83,7 @@ def setUpClass(cls):

# verify that spatialite provider is available
msg = '\nSpatialite provider not found, SKIPPING TEST SUITE'
# noinspection PyArgumentList
res = 'spatialite' in QgsProviderRegistry.instance().providerList()
assert res, msg

Expand All @@ -92,16 +94,20 @@ def setUpClass(cls):
cls._TestImage = ''

# initialize class MapRegistry, Canvas, MapRenderer, Map and PAL
# noinspection PyArgumentList
cls._MapRegistry = QgsMapLayerRegistry.instance()
""":type: QgsMapLayerRegistry"""
# set color to match render test comparisons background
cls._Canvas.setCanvasColor(QColor(152, 219, 249))
cls._Map = cls._Canvas.map()
cls._Map.resize(QSize(600, 400))
cls._MapRenderer = cls._Canvas.mapRenderer()
""":type: QgsMapRenderer"""
cls._CRS = QgsCoordinateReferenceSystem()
# default for labeling test data sources: WGS 84 / UTM zone 13N
cls._CRS.createFromSrid(32613)
cls._MapRenderer.setDestinationCrs(cls._CRS)
cls._MapRenderer.setProjectionsEnabled(False)
# use platform's native logical output dpi for QgsMapRenderer on launch

cls.setDefaultEngineSettings()
Expand Down Expand Up @@ -140,7 +146,9 @@ def loadFeatureLayer(cls, table):
vlayer.loadNamedStyle(os.path.join(cls._PalDataDir,
'{0}.qml'.format(table)))
cls._MapRegistry.addMapLayer(vlayer)
cls._MapRenderer.setLayerSet([vlayer.id()])
# place new layer on top of render stack
render_lyrs = [vlayer.id()] + list(cls._MapRenderer.layerSet())
cls._MapRenderer.setLayerSet(render_lyrs)

# zoom to aoi
cls._MapRenderer.setExtent(cls.aoiExtent())
Expand Down Expand Up @@ -234,6 +242,7 @@ def renderCheck(self, mismatch=0, imgpath='', grpprefix=''):
chk.setControlPathPrefix('expected_' + grpprefix)
chk.setControlName(self._Test)
chk.setMapRenderer(self._MapRenderer)
# noinspection PyUnusedLocal
res = False
if imgpath:
res = chk.compareImages(self._Test, mismatch, str(imgpath))
Expand Down Expand Up @@ -317,7 +326,7 @@ def test_partials_labels_deactivate(self):
self.assertFalse(pal.isShowingPartialsLabels())



# noinspection PyPep8Naming,PyShadowingNames
def runSuite(module, tests):
"""This allows for a list of test names to be selectively run.
Also, ensures unittest verbose output comes at end, after debug output"""
Expand Down
6 changes: 5 additions & 1 deletion tests/src/python/test_qgspallabeling_canvas.py
Expand Up @@ -63,7 +63,11 @@ def checkTest(self, **kwargs):
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
suite = [
'TestCanvasPoint.test_text_size_map_unit'
'TestCanvasPoint.test_default_label',
'TestCanvasPoint.test_text_size_map_unit',
'TestCanvasPoint.test_text_color',
'TestCanvasPoint.test_partials_labels_enabled',
'TestCanvasPoint.test_partials_labels_disabled',
]
res = runSuite(sys.modules[__name__], suite)
sys.exit(not res.wasSuccessful())
14 changes: 11 additions & 3 deletions tests/src/python/test_qgspallabeling_server.py
Expand Up @@ -61,7 +61,7 @@ def setUpClass(cls):
MAPSERV.startup()
MAPSERV.web_dir_install(glob.glob(cls._PalDataDir + os.sep + '*.qml'))

# noinspection PyArgumentList
# noinspection PyArgumentList
cls._TestProj = QgsProject.instance()
cls._TestProjName = 'pal_test.qgs'
cls._TestProj.setFileName(
Expand Down Expand Up @@ -175,9 +175,17 @@ def setUpClass(cls):
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
suite = [
# 'TestServerVsCanvasPoint.test_text_size_map_unit',
'TestServerPoint.test_default_label',
'TestServerPoint.test_text_size_map_unit',
'TestServerPoint.test_text_color',
'TestServerPoint.test_partials_labels_enabled',
'TestServerPoint.test_partials_labels_disabled'
'TestServerPoint.test_partials_labels_disabled',

'TestServerVsCanvasPoint.test_default_label',
'TestServerVsCanvasPoint.test_text_size_map_unit',
'TestServerVsCanvasPoint.test_text_color',
'TestServerVsCanvasPoint.test_partials_labels_enabled',
'TestServerVsCanvasPoint.test_partials_labels_disabled',
]
res = runSuite(sys.modules[__name__], suite)
# if SPAWN:
Expand Down
6 changes: 4 additions & 2 deletions tests/src/python/test_qgspallabeling_tests.py
Expand Up @@ -22,13 +22,15 @@
from qgis.core import *


# noinspection PyPep8Naming
class TestPointBase(object):

def __init__(self):
"""Dummy assignments, intended to be overriden in subclasses"""
self.lyr = QgsPalLayerSettings()
""":type: QgsPalLayerSettings"""
self._TestFont = QApplication.font() # will become a standard test font
# noinspection PyArgumentList
self._TestFont = QFont() # will become a standard test font
self.params = dict()
self._Pal = None
""":type: QgsPalLabeling"""
Expand All @@ -47,7 +49,7 @@ def test_text_size_map_unit(self):
# Label text size in map units
self.lyr.fontSizeInMapUnits = True
font = QFont(self._TestFont)
font.setPointSizeF(500)
font.setPointSizeF(460)
self.lyr.textFont = font
self.checkTest()

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c4a60de

Please sign in to comment.