Skip to content

Commit cc985c2

Browse files
committedNov 20, 2016
use temporary memory db for style tests (avoids clash with default symbols)
1 parent 19368cf commit cc985c2

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed
 

‎tests/src/core/testqgsstyle.cpp

+5-19
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,9 @@ void TestStyle::initTestCase()
9393
QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) );
9494
QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST" ) );
9595

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();
10599

106100
// cpt-city ramp, small selection available in <testdir>/cpt-city
107101
QgsCptCityArchive::initArchives();
@@ -114,6 +108,7 @@ void TestStyle::cleanupTestCase()
114108
// don't save
115109
// mStyle->save();
116110
delete mStyle;
111+
117112
QgsCptCityArchive::clearArchives();
118113
QgsApplication::exitQgis();
119114

@@ -186,8 +181,7 @@ void TestStyle::testCreateColorRamps()
186181
void TestStyle::testLoadColorRamps()
187182
{
188183
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" )
191185
<< QStringLiteral( "test_cb1" ) << QStringLiteral( "test_cb2" );
192186

193187
// values for color tests
@@ -235,11 +229,6 @@ void TestStyle::testLoadColorRamps()
235229

236230
void TestStyle::testSaveLoad()
237231
{
238-
// save not needed anymore, because used update=true in addColorRamp()
239-
// mStyle->save();
240-
mStyle->clear();
241-
mStyle->load( QgsApplication::userStylePath() );
242-
243232
// basic test to see that ramp is present
244233
QStringList colorRamps = mStyle->colorRampNames();
245234
QgsDebugMsg( "loaded colorRamps: " + colorRamps.join( " " ) );
@@ -261,8 +250,6 @@ void TestStyle::testSaveLoad()
261250

262251
void TestStyle::testFavorites()
263252
{
264-
mStyle->clear();
265-
266253
// save initial number of favorites to compare against additions / substractions
267254
QStringList favorites;
268255
favorites = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity );
@@ -290,7 +277,6 @@ void TestStyle::testFavorites()
290277

291278
void TestStyle::testTags()
292279
{
293-
mStyle->clear();
294280
//add some tags
295281
int id = mStyle->addTag( QStringLiteral( "red" ) );
296282
QCOMPARE( id, mStyle->tagId( "red" ) );

0 commit comments

Comments
 (0)
Please sign in to comment.