@@ -93,15 +93,9 @@ void TestStyle::initTestCase()
93
93
QCoreApplication::setOrganizationDomain ( QStringLiteral ( " qgis.org" ) );
94
94
QCoreApplication::setApplicationName ( QStringLiteral ( " QGIS-TEST" ) );
95
95
96
- // initialize with a clean style
97
- QFile styleFile ( QgsApplication::userStylePath () );
98
- if ( styleFile.exists () )
99
- {
100
- styleFile.remove ();
101
- QgsDebugMsg ( " removed user style file " + styleFile.fileName () );
102
- }
103
- mStyle = QgsStyle::defaultStyle ();
104
- // mStyle->clear();
96
+ // initize a temporary memory-based style for tests to avoid clashing with shipped symbols
97
+ mStyle = new QgsStyle ();
98
+ mStyle ->createMemoryDB ();
105
99
106
100
// cpt-city ramp, small selection available in <testdir>/cpt-city
107
101
QgsCptCityArchive::initArchives ();
@@ -114,6 +108,7 @@ void TestStyle::cleanupTestCase()
114
108
// don't save
115
109
// mStyle->save();
116
110
delete mStyle ;
111
+
117
112
QgsCptCityArchive::clearArchives ();
118
113
QgsApplication::exitQgis ();
119
114
@@ -186,8 +181,7 @@ void TestStyle::testCreateColorRamps()
186
181
void TestStyle::testLoadColorRamps ()
187
182
{
188
183
QStringList colorRamps = mStyle ->colorRampNames ();
189
- QStringList colorRampsTest = QStringList () << QStringLiteral ( " BrBG" ) << QStringLiteral ( " Spectral" )
190
- << QStringLiteral ( " test_gradient" ) << QStringLiteral ( " test_random" )
184
+ QStringList colorRampsTest = QStringList () << QStringLiteral ( " test_gradient" ) << QStringLiteral ( " test_random" )
191
185
<< QStringLiteral ( " test_cb1" ) << QStringLiteral ( " test_cb2" );
192
186
193
187
// values for color tests
@@ -235,11 +229,6 @@ void TestStyle::testLoadColorRamps()
235
229
236
230
void TestStyle::testSaveLoad ()
237
231
{
238
- // save not needed anymore, because used update=true in addColorRamp()
239
- // mStyle->save();
240
- mStyle ->clear ();
241
- mStyle ->load ( QgsApplication::userStylePath () );
242
-
243
232
// basic test to see that ramp is present
244
233
QStringList colorRamps = mStyle ->colorRampNames ();
245
234
QgsDebugMsg ( " loaded colorRamps: " + colorRamps.join ( " " ) );
@@ -261,8 +250,6 @@ void TestStyle::testSaveLoad()
261
250
262
251
void TestStyle::testFavorites ()
263
252
{
264
- mStyle ->clear ();
265
-
266
253
// save initial number of favorites to compare against additions / substractions
267
254
QStringList favorites;
268
255
favorites = mStyle ->symbolsOfFavorite ( QgsStyle::SymbolEntity );
@@ -290,7 +277,6 @@ void TestStyle::testFavorites()
290
277
291
278
void TestStyle::testTags ()
292
279
{
293
- mStyle ->clear ();
294
280
// add some tags
295
281
int id = mStyle ->addTag ( QStringLiteral ( " red" ) );
296
282
QCOMPARE ( id, mStyle ->tagId ( " red" ) );
0 commit comments