Skip to content
Permalink
Browse files

Add some tests

  • Loading branch information
nyalldawson committed Jun 9, 2020
1 parent 2b91bd0 commit 6237ba2ab194070862c969eb34c57dbadb26ef17
@@ -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.
@@ -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')
Binary file not shown.
Binary file not shown.

0 comments on commit 6237ba2

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