Navigation Menu

Skip to content

Commit

Permalink
Fix test build
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent 8ae9143 commit 0d7ccea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -44,6 +44,7 @@
#include "qgsprintlayout.h"
#include "qgslayoutmanager.h"
#include "qgslayoutitemlabel.h"
#include "qgscoordinatetransformcontext.h"

class DummyAlgorithm : public QgsProcessingAlgorithm
{
Expand Down Expand Up @@ -1032,41 +1033,41 @@ void TestQgsProcessing::mapLayers()
QString vector = testDataDir + "points.shp";

// test loadMapLayerFromString with raster
QgsMapLayer *l = QgsProcessingUtils::loadMapLayerFromString( raster );
QgsMapLayer *l = QgsProcessingUtils::loadMapLayerFromString( raster, QgsCoordinateTransformContext() );
QVERIFY( l->isValid() );
QCOMPARE( l->type(), QgsMapLayerType::RasterLayer );
QCOMPARE( l->name(), QStringLiteral( "landsat" ) );

delete l;

//test with vector
l = QgsProcessingUtils::loadMapLayerFromString( vector );
l = QgsProcessingUtils::loadMapLayerFromString( vector, QgsCoordinateTransformContext() );
QVERIFY( l->isValid() );
QCOMPARE( l->type(), QgsMapLayerType::VectorLayer );
QCOMPARE( l->name(), QStringLiteral( "points" ) );
delete l;

l = QgsProcessingUtils::loadMapLayerFromString( QString() );
l = QgsProcessingUtils::loadMapLayerFromString( QString(), QgsCoordinateTransformContext() );
QVERIFY( !l );
l = QgsProcessingUtils::loadMapLayerFromString( QStringLiteral( "so much room for activities!" ) );
l = QgsProcessingUtils::loadMapLayerFromString( QStringLiteral( "so much room for activities!" ), QgsCoordinateTransformContext() );
QVERIFY( !l );
l = QgsProcessingUtils::loadMapLayerFromString( testDataDir + "multipoint.shp" );
l = QgsProcessingUtils::loadMapLayerFromString( testDataDir + "multipoint.shp", QgsCoordinateTransformContext() );
QVERIFY( l->isValid() );
QCOMPARE( l->type(), QgsMapLayerType::VectorLayer );
QCOMPARE( l->name(), QStringLiteral( "multipoint" ) );
delete l;

// Test layers from a string with parameters
QString osmFilePath = testDataDir + "openstreetmap/testdata.xml";
std::unique_ptr< QgsVectorLayer > osm( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath ) ) );
std::unique_ptr< QgsVectorLayer > osm( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath, QgsCoordinateTransformContext() ) ) );
QVERIFY( osm->isValid() );
QCOMPARE( osm->geometryType(), QgsWkbTypes::PointGeometry );

osm.reset( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath + "|layerid=3" ) ) );
osm.reset( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath + "|layerid=3", QgsCoordinateTransformContext() ) ) );
QVERIFY( osm->isValid() );
QCOMPARE( osm->geometryType(), QgsWkbTypes::PolygonGeometry );

osm.reset( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath + "|layerid=3|subset=\"building\" is not null" ) ) );
osm.reset( qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::loadMapLayerFromString( osmFilePath + "|layerid=3|subset=\"building\" is not null", QgsCoordinateTransformContext() ) ) );
QVERIFY( osm->isValid() );
QCOMPARE( osm->geometryType(), QgsWkbTypes::PolygonGeometry );
QCOMPARE( osm->subsetString(), QStringLiteral( "\"building\" is not null" ) );
Expand Down

0 comments on commit 0d7ccea

Please sign in to comment.