Skip to content
Permalink
Browse files

Added unit test to replicate crash when a raster is removed from the …

…registry

git-svn-id: http://svn.osgeo.org/qgis/trunk@10206 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Feb 19, 2009
1 parent 3908cbe commit e8fcdfda377aa67111afb74832bef673f43d7b54
Showing with 26 additions and 0 deletions.
  1. +24 −0 tests/src/core/testqgsrasterlayer.cpp
  2. +2 −0 tests/src/core/testqgsrenderers.cpp
@@ -34,6 +34,7 @@
#include <qgsmaplayerregistry.h>
#include <qgsapplication.h>
#include <qgsmaprenderer.h>
#include <qgsmaplayerregistry.h>

//qgis unit test includes
#include <qgsrenderchecker.h>
@@ -57,6 +58,7 @@ class TestQgsRasterLayer: public QObject
void landsatBasic875Qml();
void checkDimensions();
void buildExternalOverviews();
void registry();
private:
bool render( QString theFileName );
bool setQml( QString theType );
@@ -204,6 +206,28 @@ void TestQgsRasterLayer::buildExternalOverviews()
//cleanup
delete mypLayer;
}


void TestQgsRasterLayer::registry()
{
QString myTempPath = QDir::tempPath() + QDir::separator();
QFile::remove( myTempPath + "landsat.tif.ovr" );
QFile::copy( mTestDataDir + "landsat.tif", myTempPath + "landsat.tif" );
QFileInfo myRasterFileInfo( myTempPath + "landsat.tif" );
QgsRasterLayer * mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName() );

QgsMapLayerRegistry::instance()->addMapLayer(mypLayer,false);
QgsMapLayerRegistry::instance()->removeMapLayer(mypLayer->getLayerID());
//cleanup
delete mypLayer;
}

//
// Helper methods
//


bool TestQgsRasterLayer::render( QString theTestType )
{
mReport += "<h2>" + theTestType + "</h2>\n";
@@ -51,6 +51,7 @@ class TestQgsRenderers: public QObject
void continuousSymbol();
void checkClassificationFieldMismatch();
private:
bool mTestHasError;
bool setQml( QString theType ); //uniquevalue / continuous / single /
bool imageCheck( QString theType ); //as above
QgsMapRenderer * mpMapRenderer;
@@ -64,6 +65,7 @@ class TestQgsRenderers: public QObject

void TestQgsRenderers::initTestCase()
{
mTestHasError = false;
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath();
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );

0 comments on commit e8fcdfd

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