Skip to content
Permalink
Browse files

Unit tests for style proxy model smart group filter

  • Loading branch information
nyalldawson committed Sep 12, 2018
1 parent 95d65ae commit 68c0d7f4e1aa11aff6f9e2f25c23bfc031ab9b5b
Showing with 24 additions and 3 deletions.
  1. +2 −2 src/core/symbology/qgsstylemodel.cpp
  2. +22 −1 tests/src/python/test_qgsstylemodel.py
@@ -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
{
@@ -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__':

0 comments on commit 68c0d7f

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