Navigation Menu

Skip to content

Commit

Permalink
Unit tests for style proxy model smart group filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2018
1 parent 95d65ae commit 68c0d7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/symbology/qgsstylemodel.cpp
Expand Up @@ -479,8 +479,8 @@ void QgsStyleProxyModel::setSmartGroupId( int id )

if ( mSmartGroupId >= 0 )
{
mSmartGroupSymbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mTagId );
mSmartGroupSymbolNames.append( mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mTagId ) );
mSmartGroupSymbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mSmartGroupId );
mSmartGroupSymbolNames.append( mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mSmartGroupId ) );
}
else
{
Expand Down
23 changes: 22 additions & 1 deletion tests/src/python/test_qgsstylemodel.py
Expand Up @@ -692,7 +692,28 @@ def test_filter_proxy(self):
self.assertEqual(model.rowCount(), 8)

# smart group filter
# can't test in Python -- smart groups cannot be set here!
style.addSmartgroup('smart', 'AND', ['tag 3'], [], ['c'], [])
self.assertEqual(model.smartGroupId(), -1)
model.setSmartGroupId(1)
self.assertEqual(model.smartGroupId(), 1)
self.assertEqual(model.rowCount(), 1)
self.assertEqual(model.data(model.index(0, 0)), 'C')
style.addSmartgroup('smart', 'OR', ['tag 3'], [], ['c'], [])
model.setSmartGroupId(2)
self.assertEqual(model.rowCount(), 2)
self.assertEqual(model.data(model.index(0, 0)), 'C')
self.assertEqual(model.data(model.index(1, 0)), 'ramp c')
style.tagSymbol(QgsStyle.SymbolEntity, 'a', ['tag 3'])
self.assertEqual(model.rowCount(), 3)
self.assertEqual(model.data(model.index(0, 0)), 'a')
self.assertEqual(model.data(model.index(1, 0)), 'C')
self.assertEqual(model.data(model.index(2, 0)), 'ramp c')
style.renameColorRamp('ramp c', 'x')
self.assertEqual(model.rowCount(), 2)
self.assertEqual(model.data(model.index(0, 0)), 'a')
self.assertEqual(model.data(model.index(1, 0)), 'C')
model.setSmartGroupId(-1)
self.assertEqual(model.rowCount(), 8)


if __name__ == '__main__':
Expand Down

0 comments on commit 68c0d7f

Please sign in to comment.