From 7bd9240efdfd049d900030a6ba63783cf0bf28a7 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Wed, 18 Apr 2012 23:02:23 +0200 Subject: [PATCH] Added unit test to verify zip layers can be opened --- tests/src/core/CMakeLists.txt | 1 + tests/src/core/testziplayer.cpp | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/src/core/testziplayer.cpp diff --git a/tests/src/core/CMakeLists.txt b/tests/src/core/CMakeLists.txt index 88f6c944862d..c43ec0e8a359 100644 --- a/tests/src/core/CMakeLists.txt +++ b/tests/src/core/CMakeLists.txt @@ -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) diff --git a/tests/src/core/testziplayer.cpp b/tests/src/core/testziplayer.cpp new file mode 100644 index 000000000000..0f014ce9c567 --- /dev/null +++ b/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 +#include +#include +#include +#include +#include + +//qgis includes... +#include +#include +#include + +/** \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" + + + +