Skip to content
Permalink
Browse files

Added unit-tests for ShowingPartialsLabels

  • Loading branch information
yellow-sky committed Sep 20, 2013
1 parent cf5d35b commit 83c8478f8f9ab7d4ef55a84828ff833a8b113d7b
@@ -106,13 +106,18 @@ def setUpClass(cls):
cls._MapRenderer.setDestinationCrs(cls._CRS)
# use platform's native logical output dpi for QgsMapRenderer on launch

cls._Pal = QgsPalLabeling()
cls._MapRenderer.setLabelingEngine(cls._Pal)
cls._PalEngine = cls._MapRenderer.labelingEngine()
cls.setDefaultEngineSettings()
msg = ('\nCould not initialize PAL labeling engine, '
'SKIPPING TEST SUITE')
assert cls._PalEngine, msg

@classmethod
def setDefaultEngineSettings(cls):
"""Restore default settings for pal labelling"""
cls._Pal = QgsPalLabeling()
cls._MapRenderer.setLabelingEngine(cls._Pal)
cls._PalEngine = cls._MapRenderer.labelingEngine()

@classmethod
def tearDownClass(cls):
"""Run after all tests"""
@@ -46,6 +46,7 @@ def setUpClass(cls):
def setUp(self):
"""Run before each test."""
self.configTest('pal_canvas', 'sp')
TestQgsPalLabeling.setDefaultEngineSettings()
self.lyr = self.defaultSettings()

def tearDown(self):
@@ -151,6 +151,7 @@ def setUpClass(cls):
def setUp(self):
"""Run before each test."""
self.configTest('pal_server', 'sp')
TestQgsPalLabeling.setDefaultEngineSettings()
self.lyr = self.defaultSettings()
self.params = self.defaultWmsParams('point')
self._TestImage = ''
@@ -52,6 +52,32 @@ def test_text_color(self):
self.lyr.textColor = Qt.blue
self.checkTest()

def test_partials_labels_def_setting_value(self):
# by default: enabled
self.assertTrue(self._PalEngine.isShowingPartialsLabels())

def test_partials_labels_enabled(self):
# Set Big font size
font = QFont(self._TestFont)
font.setPointSizeF(90)
self.lyr.textFont = font
# Enable partials labels
self._PalEngine.setShowingPartialsLabels(True)
self.assertTrue(self._PalEngine.isShowingPartialsLabels())
# Check
self.checkTest()

def test_partials_labels_disabled(self):
# Set Big font size
font = QFont(self._TestFont)
font.setPointSizeF(90)
self.lyr.textFont = font
# Disable partials labels
self._PalEngine.setShowingPartialsLabels(False)
self.assertFalse(self._PalEngine.isShowingPartialsLabels())
# Check
self.checkTest()


if __name__ == '__main__':
pass
Binary file not shown.
Binary file not shown.

0 comments on commit 83c8478

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