Skip to content

Commit

Permalink
Added unit test to replicate crash when a raster is removed from the …
Browse files Browse the repository at this point in the history
…registry

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

//qgis unit test includes
#include <qgsrenderchecker.h>
Expand All @@ -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 );
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsrenderers.cpp
Expand Up @@ -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;
Expand All @@ -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 );
Expand Down

0 comments on commit e8fcdfd

Please sign in to comment.