15
15
16
16
#include " qgstest.h"
17
17
18
+ #include " qgsauxiliarystorage.h"
18
19
#include " qgsproject.h"
19
20
#include " qgsprojectstorage.h"
20
21
#include " qgsprojectstorageregistry.h"
@@ -165,6 +166,16 @@ void TestQgsProjectStorage::testMemoryStorage()
165
166
prj1.setTitle ( " best project ever" );
166
167
prj1.addMapLayer ( layer1 );
167
168
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
+
168
179
bool writeOk = prj1.write ();
169
180
170
181
QVERIFY ( writeOk );
@@ -184,6 +195,12 @@ void TestQgsProjectStorage::testMemoryStorage()
184
195
QCOMPARE ( prj2.mapLayers ().count (), 1 );
185
196
QCOMPARE ( prj2.title (), QString ( " best project ever" ) );
186
197
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
+
187
204
// test access of non-existent project
188
205
189
206
QgsProject prj3;
0 commit comments