Skip to content
Permalink
Browse files

Fix test build

  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent 8ae9143 commit 0d7cceab0c9adad6811a7aee10495f4cb9c1b7cd
Showing with 9 additions and 8 deletions.
  1. +9 −8 tests/src/analysis/testqgsprocessing.cpp
@@ -44,6 +44,7 @@
#include "qgsprintlayout.h"
#include "qgslayoutmanager.h"
#include "qgslayoutitemlabel.h"
#include "qgscoordinatetransformcontext.h"

class DummyAlgorithm : public QgsProcessingAlgorithm
{
@@ -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" ) );

0 comments on commit 0d7ccea

Please sign in to comment.
You can’t perform that action at this time.