Skip to content

Commit

Permalink
Another trial to fix mac tests on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 13, 2017
1 parent 40f683d commit 590526e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/core/symbology-ng/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3640,9 +3640,6 @@ QString QgsSymbolLayerUtils::svgSymbolPathToName( QString path, const QgsPathRes
if ( !QFileInfo::exists( path ) )
return path;

// keep original path for path resolver as its path does not have to be cannonical either
QString origPath = path;

path = QFileInfo( path ).canonicalFilePath();

QStringList svgPaths = QgsApplication::svgPaths();
Expand All @@ -3663,7 +3660,7 @@ QString QgsSymbolLayerUtils::svgSymbolPathToName( QString path, const QgsPathRes
if ( isInSvgPaths )
return path;

return pathResolver.writePath( origPath );
return pathResolver.writePath( path );
}


Expand Down
15 changes: 10 additions & 5 deletions tests/src/core/testqgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ void TestQgsProject::testPathResolver()
QCOMPARE( resolverAbs.writePath( "/home/qgis/file1.txt" ), QString( "/home/qgis/file1.txt" ) );
QCOMPARE( resolverAbs.readPath( "/home/qgis/file1.txt" ), QString( "/home/qgis/file1.txt" ) );
QCOMPARE( resolverAbs.readPath( "./file1.txt" ), QString( "./file1.txt" ) );

// TODO: test non-canonical paths - there are inconsistencies in the implementation
// e.g. base filename "/home/qgis/../test.qgs" resolving "/home/qgis/../file1.txt" back and forth
}

static void _useRendererWithSvgSymbol( QgsVectorLayer *layer, const QString &path )
Expand Down Expand Up @@ -186,10 +189,12 @@ void TestQgsProject::testPathResolverSvg()

QTemporaryDir dir;
QVERIFY( dir.isValid() );
// on mac the returned path was not canonical and the resolver failed to convert paths properly
QString dirPath = QFileInfo( dir.path() ).canonicalFilePath();

QString projectFilename = dir.path() + "/project.qgs";
QString ourSvgPath = dir.path() + "/valid.svg";
QString invalidSvgPath = dir.path() + "/invalid.svg";
QString projectFilename = dirPath + "/project.qgs";
QString ourSvgPath = dirPath + "/valid.svg";
QString invalidSvgPath = dirPath + "/invalid.svg";

QFile svgFile( ourSvgPath );
QVERIFY( svgFile.open( QIODevice::WriteOnly ) );
Expand All @@ -216,8 +221,8 @@ void TestQgsProject::testPathResolverSvg()
project.write( projectFilename );

// make sure the path resolver works with relative paths (enabled by default)
QCOMPARE( project.pathResolver().readPath( "./a.txt" ), dir.path() + "/a.txt" );
QCOMPARE( project.pathResolver().writePath( dir.path() + "/a.txt" ), QString( "./a.txt" ) );
QCOMPARE( project.pathResolver().readPath( "./a.txt" ), dirPath + "/a.txt" );
QCOMPARE( project.pathResolver().writePath( dirPath + "/a.txt" ), QString( "./a.txt" ) );

// check that the saved paths are relative

Expand Down

0 comments on commit 590526e

Please sign in to comment.