Skip to content
Permalink
Browse files

Another trial to fix mac tests on travis

  • Loading branch information
wonder-sk committed May 13, 2017
1 parent 40f683d commit 590526ee32761e49b9e32f12f739c510e26ba039
Showing with 11 additions and 9 deletions.
  1. +1 −4 src/core/symbology-ng/qgssymbollayerutils.cpp
  2. +10 −5 tests/src/core/testqgsproject.cpp
@@ -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();
@@ -3663,7 +3660,7 @@ QString QgsSymbolLayerUtils::svgSymbolPathToName( QString path, const QgsPathRes
if ( isInSvgPaths )
return path;

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


@@ -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 )
@@ -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 ) );
@@ -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

0 comments on commit 590526e

Please sign in to comment.