Skip to content

Commit 624e446

Browse files
committed
Add unit test
1 parent 58b3e20 commit 624e446

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/src/python/test_qgsrulebasedrenderer.py

+23
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ def testWillRenderFeature(self):
125125
renderer.stopRender(ctx)
126126
assert rendered == True
127127

128+
def testFeatureCount(self):
129+
vl = self.mapsettings.layers()[0]
130+
ft = vl.getFeature(2) # 'id' = 3 => ELSE
131+
renderer = vl.renderer()
132+
133+
ctx = QgsRenderContext.fromMapSettings(self.mapsettings)
134+
ctx.expressionContext().setFeature(ft)
135+
136+
counter = vl.countSymbolFeatures()
137+
counter.waitForFinished()
138+
139+
renderer.startRender(ctx, vl.fields())
140+
141+
elseRule = None
142+
for rule in renderer.rootRule().children():
143+
if rule.filterExpression() == 'ELSE':
144+
elseRule = rule
145+
146+
assert elseRule != None
147+
148+
cnt = counter.featureCount(elseRule.ruleKey())
149+
assert cnt == 1
150+
128151
def testRefineWithCategories(self):
129152
# Test refining rule with categories (refs #10815)
130153

0 commit comments

Comments
 (0)