Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add some tests
  • Loading branch information
nyalldawson committed Jun 9, 2020
1 parent 2b91bd0 commit 6237ba2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/src/python/test_qgspallabeling_placement.py
Expand Up @@ -144,6 +144,19 @@ def test_point_placement_around_obstacle_large_symbol(self):
self.removeMapLayer(self.layer)
self.layer = None

def test_line_with_no_candidate_show_all(self):
# A line too short to have any candidates, yet we need to show all labels for the layer
self.layer = TestQgsPalLabeling.loadFeatureLayer('line_short')
self._TestMapSettings = self.cloneMapSettings(self._MapSettings)
self.layer.setLabelsEnabled(True)
self.lyr.displayAll = True
f = self.lyr.format()
f.setSize(60)
self.lyr.setFormat(f)
self.checkTest()
self.removeMapLayer(self.layer)
self.layer = None

def test_polygon_placement_with_hole(self):
# Horizontal label placement for polygon with hole
# Note for this test, the mask is used to check only pixels outside of the polygon.
Expand Down Expand Up @@ -249,6 +262,29 @@ def test_point_offset_below_left_placement(self):
self.removeMapLayer(self.layer)
self.layer = None

def test_obstacle_collision_but_showing_all(self):
# Test the when a collision occurs and the Show All labels setting is active, Show All wins
self.layer = TestQgsPalLabeling.loadFeatureLayer('point')

obstacleLayer = TestQgsPalLabeling.loadFeatureLayer('line')
obstacle_label_settings = QgsPalLayerSettings()
obstacle_label_settings.obstacle = True
obstacle_label_settings.drawLabels = False
obstacle_label_settings.obstacleFactor = 8
obstacleLayer.setLabeling(QgsVectorLayerSimpleLabeling(obstacle_label_settings))
obstacleLayer.setLabelsEnabled(True)

self._TestMapSettings = self.cloneMapSettings(self._MapSettings)
self.lyr.placement = QgsPalLayerSettings.OverPoint
self.lyr.quadOffset = QgsPalLayerSettings.QuadrantAboveLeft
self.lyr.priority = 4
self.lyr.displayAll = True
self.checkTest()

self.removeMapLayer(obstacleLayer)
self.removeMapLayer(self.layer)
self.layer = None

def test_point_point_obstacle_obstacle_factor_greater_equal(self):
# Test point label but obstacle exists with a greater than obstacle factor vs label priority => NO LABEL
self.layer = TestQgsPalLabeling.loadFeatureLayer('point')
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.

0 comments on commit 6237ba2

Please sign in to comment.