Skip to content
Permalink
Browse files

Update labeling canvas and server unit tests and output new control i…

…mages
  • Loading branch information
dakcarto committed Feb 21, 2014
1 parent b979774 commit c4a60de06c786a230a204338d7cf7677f1b3080e
@@ -61,6 +61,7 @@
PALREPORTS = {}


# noinspection PyPep8Naming,PyShadowingNames
class TestQgsPalLabeling(TestCase):

_TestDataDir = unitTestDataPath()
@@ -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

@@ -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()
@@ -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())
@@ -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))
@@ -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"""
@@ -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())
@@ -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(
@@ -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:
@@ -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"""
@@ -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()

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c4a60de

Please sign in to comment.
You can’t perform that action at this time.