[QGIS Commit] r10206 - trunk/qgis/tests/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 19 18:52:59 EST 2009


Author: timlinux
Date: 2009-02-19 18:52:59 -0500 (Thu, 19 Feb 2009)
New Revision: 10206

Modified:
   trunk/qgis/tests/src/core/testqgsrasterlayer.cpp
   trunk/qgis/tests/src/core/testqgsrenderers.cpp
Log:
Added unit test to replicate crash when a raster is removed from the registry

Modified: trunk/qgis/tests/src/core/testqgsrasterlayer.cpp
===================================================================
--- trunk/qgis/tests/src/core/testqgsrasterlayer.cpp	2009-02-19 12:23:24 UTC (rev 10205)
+++ trunk/qgis/tests/src/core/testqgsrasterlayer.cpp	2009-02-19 23:52:59 UTC (rev 10206)
@@ -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 @@
     void landsatBasic875Qml();
     void checkDimensions();
     void buildExternalOverviews();
+    void registry();
   private:
     bool render( QString theFileName );
     bool setQml( QString theType );
@@ -204,6 +206,28 @@
   //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";

Modified: trunk/qgis/tests/src/core/testqgsrenderers.cpp
===================================================================
--- trunk/qgis/tests/src/core/testqgsrenderers.cpp	2009-02-19 12:23:24 UTC (rev 10205)
+++ trunk/qgis/tests/src/core/testqgsrenderers.cpp	2009-02-19 23:52:59 UTC (rev 10206)
@@ -51,6 +51,7 @@
     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 @@
 
 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 );



More information about the QGIS-commit mailing list