|
| 1 | +/*************************************************************************** |
| 2 | + testqgsvectorfilewriter.cpp |
| 3 | + -------------------------------------- |
| 4 | + Date : Sun Sep 16 12:22:54 AKDT 2007 |
| 5 | + Copyright : (C) 2007 by Gary E. Sherman |
| 6 | + Email : sherman at mrcc dot com |
| 7 | + *************************************************************************** |
| 8 | + * * |
| 9 | + * This program is free software; you can redistribute it and/or modify * |
| 10 | + * it under the terms of the GNU General Public License as published by * |
| 11 | + * the Free Software Foundation; either version 2 of the License, or * |
| 12 | + * (at your option) any later version. * |
| 13 | + * * |
| 14 | + ***************************************************************************/ |
| 15 | +#include <QtTest> |
| 16 | +#include <QObject> |
| 17 | +#include <QString> |
| 18 | +#include <QStringList> |
| 19 | +#include <QObject> |
| 20 | +#include <iostream> |
| 21 | +#include <QApplication> |
| 22 | +#include <QFileInfo> |
| 23 | +#include <QDir> |
| 24 | + |
| 25 | +//qgis includes... |
| 26 | +#include <qgsrasterlayer.h> |
| 27 | +#include <qgsapplication.h> |
| 28 | + |
| 29 | +/** \ingroup UnitTests |
| 30 | + * This is a unit test for the QgsRasterLayer class. |
| 31 | + */ |
| 32 | +class TestQgsRasterLayer: public QObject |
| 33 | +{ |
| 34 | + Q_OBJECT; |
| 35 | + private slots: |
| 36 | + void initTestCase();// will be called before the first testfunction is executed. |
| 37 | + void cleanupTestCase(){};// will be called after the last testfunction was executed. |
| 38 | + void init(){};// will be called before each testfunction is executed. |
| 39 | + void cleanup(){};// will be called after every testfunction. |
| 40 | + |
| 41 | + void isValid(); |
| 42 | + |
| 43 | + private: |
| 44 | + QgsRasterLayer * mpLayer; |
| 45 | +}; |
| 46 | + |
| 47 | +void TestQgsRasterLayer::initTestCase() |
| 48 | +{ |
| 49 | + // init QGIS's paths - true means that all path will be inited from prefix |
| 50 | + QString qgisPath = QCoreApplication::applicationDirPath (); |
| 51 | + QgsApplication::setPrefixPath(qgisPath, TRUE); |
| 52 | +#ifdef Q_OS_LINUX |
| 53 | + QgsApplication::setPkgDataPath(qgisPath + "/../share/qgis"); |
| 54 | +#endif |
| 55 | + //create some objects that will be used in all tests... |
| 56 | + |
| 57 | + std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl; |
| 58 | + std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl; |
| 59 | + std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl; |
| 60 | + std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl; |
| 61 | + |
| 62 | + //create a raster layer that will be used in all tests... |
| 63 | + QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt |
| 64 | + myFileName = myFileName + QDir::separator() + "tenbytenraster.asc"; |
| 65 | + QFileInfo myRasterFileInfo ( myFileName ); |
| 66 | + mpLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(), |
| 67 | + myRasterFileInfo.completeBaseName() ); |
| 68 | +} |
| 69 | + |
| 70 | +void TestQgsRasterLayer::isValid() |
| 71 | +{ |
| 72 | + QVERIFY ( mpLayer->isValid() ); |
| 73 | +} |
| 74 | + |
| 75 | +QTEST_MAIN(TestQgsRasterLayer) |
| 76 | +#include "moc_testqgsrasterlayer.cxx" |
| 77 | + |
0 commit comments