Showing with 65 additions and 0 deletions.
  1. +1 −0 tests/src/core/CMakeLists.txt
  2. +64 −0 tests/src/core/testziplayer.cpp
1 change: 1 addition & 0 deletions tests/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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"