Skip to content

Commit

Permalink
Add unit tests for qgsproject
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Nov 19, 2019
1 parent 35c2a9a commit 0770ca9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/src/core/testqgsproject.cpp
Expand Up @@ -46,6 +46,7 @@ class TestQgsProject : public QObject
void testLocalUrlFiles();
void testReadFlags();
void testSetGetCrs();
void testEmbeddedLayerGroupFromQgz();
};

void TestQgsProject::init()
Expand Down Expand Up @@ -466,6 +467,24 @@ void TestQgsProject::testReadFlags()
QCOMPARE( p3.layoutManager()->layouts().count(), 0 );
}

void TestQgsProject::testEmbeddedLayerGroupFromQgz()
{
QString path = QString( TEST_DATA_DIR ) + QStringLiteral( "/embedded_groups/project1.qgz" );
QList<QDomNode> brokenNodes;

QgsProject p0;
p0.read(path);
QgsMapLayer* points = p0.mapLayersByName("points")[0];
QgsMapLayer* polys = p0.mapLayersByName("polys")[0];

QgsProject p1;
p1.createEmbeddedLayer(points->id(), p0.fileName(), brokenNodes);
p1.createEmbeddedGroup("group1", p0.fileName(), QStringList());

QCOMPARE(p1.layerIsEmbedded(points->id()), path);
QCOMPARE(p1.layerIsEmbedded(polys->id()), path);
}

void TestQgsProject::testSetGetCrs()
{
QgsProject p;
Expand Down
Binary file added tests/testdata/embedded_groups/project1.qgz
Binary file not shown.

0 comments on commit 0770ca9

Please sign in to comment.