Skip to content
Permalink
Browse files

[bugfix] Revert 2f2221a and update the tests

Fixes #19199 - regression: vector layer legend symbol / children (i.e. rules) aren't shown when in group
  • Loading branch information
elpaso committed Jun 17, 2018
1 parent cd782f2 commit 59fa2ce452d114636bab15dc0a68715d8971d018
Showing with 9 additions and 6 deletions.
  1. +9 −6 tests/src/core/testqgslayerdefinition.cpp
@@ -37,7 +37,7 @@ class TestQgsLayerDefinition: public QObject
void cleanup(); // will be called after every testfunction.

/**
* test that findLayers() skips invalid layers
* test that findLayers()
*/
void testFindLayers();

@@ -66,11 +66,13 @@ void TestQgsLayerDefinition::cleanupTestCase()

void TestQgsLayerDefinition::init()
{
mTempFile = new QTemporaryFile();
mTempFile = new QTemporaryFile( QStringLiteral( "qgis_XXXXXX.qlr" ) );
QVERIFY( mTempFile->open() );
mTempFile->close();
QString errorMessage;
const QString path = QString( TEST_DATA_DIR + QStringLiteral( "/bug_18981_broken.qlr" ) );
QgsProject::instance()->removeAllMapLayers();
QgsProject::instance()->layerTreeRoot()->removeAllChildren();
QgsLayerDefinition::loadLayerDefinition( path, QgsProject::instance(), QgsProject::instance()->layerTreeRoot(), errorMessage );
QVERIFY( errorMessage.isEmpty() );
}
@@ -83,8 +85,9 @@ void TestQgsLayerDefinition::cleanup()

void TestQgsLayerDefinition::testFindLayers()
{
QCOMPARE( QgsProject::instance()->layerTreeRoot()->findLayers().count(), 1 );
QCOMPARE( QgsProject::instance()->layerTreeRoot()->findLayers().at( 0 )->name(), QStringLiteral( "NewMemory" ) );
QCOMPARE( QgsProject::instance()->layerTreeRoot()->findLayers().count(), 2 );
QCOMPARE( QgsProject::instance()->layerTreeRoot()->findLayers().at( 0 )->name(), QStringLiteral( "DTK/D850" ) );
QCOMPARE( QgsProject::instance()->layerTreeRoot()->findLayers().at( 1 )->name(), QStringLiteral( "NewMemory" ) );
}

void TestQgsLayerDefinition::testExportDoesNotCrash()
@@ -93,9 +96,9 @@ void TestQgsLayerDefinition::testExportDoesNotCrash()
QVERIFY( QgsLayerDefinition::exportLayerDefinition( mTempFile->fileName(), QgsProject::instance()->layerTreeRoot()->children(), errorMessage ) );
QVERIFY( errorMessage.isEmpty() );
// Reload
const QString path = QString( TEST_DATA_DIR + QStringLiteral( "/bug_18981_broken.qlr" ) );
QgsProject::instance()->removeAllMapLayers();
QgsLayerDefinition::loadLayerDefinition( path, QgsProject::instance(), QgsProject::instance()->layerTreeRoot(), errorMessage );
QgsProject::instance()->layerTreeRoot()->removeAllChildren();
QgsLayerDefinition::loadLayerDefinition( mTempFile->fileName(), QgsProject::instance(), QgsProject::instance()->layerTreeRoot(), errorMessage );
testFindLayers();
}

0 comments on commit 59fa2ce

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