Skip to content

Commit 17a8c45

Browse files
committed
Add a test to check that extra content in project ZIP is saved/loaded
1 parent 2aabad9 commit 17a8c45

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/src/core/testqgsprojectstorage.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "qgstest.h"
1717

18+
#include "qgsauxiliarystorage.h"
1819
#include "qgsproject.h"
1920
#include "qgsprojectstorage.h"
2021
#include "qgsprojectstorageregistry.h"
@@ -165,6 +166,16 @@ void TestQgsProjectStorage::testMemoryStorage()
165166
prj1.setTitle( "best project ever" );
166167
prj1.addMapLayer( layer1 );
167168
prj1.setFileName( "memory:project1" );
169+
170+
// let's use the aux storage as well - so that the project will include aux database as well
171+
int fldCnt0 = layer1->fields().count();
172+
QgsAuxiliaryLayer *layerAux = prj1.auxiliaryStorage()->createAuxiliaryLayer( layer1->fields().at( 0 ), layer1 );
173+
layer1->setAuxiliaryLayer( layerAux );
174+
layerAux->addAttribute( QgsField( "fld_aux", QVariant::Int ) );
175+
layerAux->commitChanges();
176+
QCOMPARE( fldCnt0, 6 );
177+
QCOMPARE( layer1->fields().count(), 7 );
178+
168179
bool writeOk = prj1.write();
169180

170181
QVERIFY( writeOk );
@@ -184,6 +195,12 @@ void TestQgsProjectStorage::testMemoryStorage()
184195
QCOMPARE( prj2.mapLayers().count(), 1 );
185196
QCOMPARE( prj2.title(), QString( "best project ever" ) );
186197

198+
// let's check that our stuff from auxiliary database got stored written and read
199+
QgsVectorLayer *prj2layer1 = qobject_cast<QgsVectorLayer *>( prj2.mapLayers().constBegin().value() );
200+
QVERIFY( prj2layer1 );
201+
QCOMPARE( prj2layer1->fields().count(), 7 );
202+
QCOMPARE( prj2layer1->fields().at( 6 ).name(), QString( "auxiliary_storage_fld_aux" ) );
203+
187204
// test access of non-existent project
188205

189206
QgsProject prj3;

0 commit comments

Comments
 (0)