Skip to content

Commit

Permalink
Added unit test to verify zip layers can be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Apr 18, 2012
1 parent f77b993 commit 7bd9240
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/core/CMakeLists.txt
Expand Up @@ -93,4 +93,5 @@ ADD_QGIS_TEST(pointtest testqgspoint.cpp)
ADD_QGIS_TEST(searchstringtest testqgssearchstring.cpp)
ADD_QGIS_TEST(vectorlayertest testqgsvectorlayer.cpp)
ADD_QGIS_TEST(rulebasedrenderertest testqgsrulebasedrenderer.cpp)
ADD_QGIS_TEST(ziplayertest testziplayer.cpp)

64 changes: 64 additions & 0 deletions tests/src/core/testziplayer.cpp
@@ -0,0 +1,64 @@
/***************************************************************************
testziplayer.cpp
--------------------------------------
Date : Sun Sep 16 12:22:23 AKDT 2007
Copyright : (C) 2012 Tim Sutton
Email : tim@linfiniti.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest>
#include <QObject>
#include <QString>
#include <QObject>
#include <QApplication>
#include <QFileInfo>

//qgis includes...
#include <qgsvectorlayer.h>
#include <qgsapplication.h>
#include <qgsproviderregistry.h>

/** \ingroup UnitTests
* This is a unit test to verify that zip vector layers work
*/
class TestZipLayer: public QObject
{
Q_OBJECT;

private slots:

void testZipLayer()
{
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath();
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
// Instantiate the plugin directory so that providers are loaded
QgsProviderRegistry::instance( QgsApplication::pluginPath() );
//
//create a point layer that will be used in all tests...
//
QString myDataDir( TEST_DATA_DIR );
myDataDir += QDir::separator();
QString myPointsFileName = myDataDir + "points.zip";
QFileInfo myPointFileInfo( myPointsFileName );
QgsVectorLayer * mypPointsLayer;
mypPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), "ogr" );
QVERIFY( mypPointsLayer->isValid() );
delete mypPointsLayer;
}

};

QTEST_MAIN( TestZipLayer )
#include "moc_testziplayer.cxx"




0 comments on commit 7bd9240

Please sign in to comment.