Fix problem with analyzer test

This commit is contained in:
Tim Sutton 2011-11-14 15:36:55 +02:00
parent 2b8487b942
commit d13fb2586b
3 changed files with 13 additions and 6 deletions

View File

@ -149,12 +149,14 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
{
if ( !layer )
{
QgsDebugMsg( "No layer passed to centroids" );
return false;
}
QgsVectorDataProvider* dp = layer->dataProvider();
if ( !dp )
{
QgsDebugMsg( "No data provider for layer passed to centroids" );
return false;
}

View File

@ -34,7 +34,10 @@ class CORE_EXPORT QgsApplication: public QApplication
virtual ~QgsApplication();
/** This method initialises paths etc for QGIS. Called by the ctor or call it manually
when your app does not extend the QApplication class. */
when your app does not extend the QApplication class.
@note you will probably want to call initQgis too to load the providers in
the above case.
*/
static void init( QString customConfigPath = QString() );
//! Watch for QFileOpenEvent.

View File

@ -51,28 +51,30 @@ void TestQgsVectorAnalyzer::initTestCase()
//
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
QgsApplication::init( INSTALL_PREFIX );
QgsApplication::initQgis( );
QgsApplication::showSettings();
// Instantiate the plugin directory so that providers are loaded
QgsProviderRegistry::instance(QgsApplication::pluginPath());
//create some objects that will be used in all tests...
//create a map layer that will be used in all tests...
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
QString myBaseFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
QString myEndName = "lines.shp";
myFileName = myFileName + QDir::separator() + myEndName;
QString myFileName = myBaseFileName + QDir::separator() + myEndName;
qDebug() << myFileName;
QFileInfo myLineInfo ( myFileName );
mpLineLayer = new QgsVectorLayer ( myLineInfo.filePath(),
myLineInfo.completeBaseName(), "ogr" );
myEndName = "polys.shp";
myFileName = myFileName + QDir::separator() + myEndName;
myFileName = myBaseFileName + QDir::separator() + myEndName;
QFileInfo myPolyInfo ( myFileName );
mpPolyLayer = new QgsVectorLayer ( myPolyInfo.filePath(),
myPolyInfo.completeBaseName(), "ogr" );
myEndName = "points.shp";
myFileName = myFileName + QDir::separator() + myEndName;
myFileName = myBaseFileName + QDir::separator() + myEndName;
QFileInfo myPointInfo ( myFileName );
mpPointLayer = new QgsVectorLayer ( myPointInfo.filePath(),
myPointInfo.completeBaseName(), "ogr" );