|
| 1 | +/*************************************************************************** |
| 2 | + testqgsvirtuallayerprovider.cpp |
| 3 | + ------------------------------------ |
| 4 | + Date : October 2023 |
| 5 | + Copyright : (C) 2023 by Sandro Santilli |
| 6 | + Email : strk at kbt dot net |
| 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 | + |
| 16 | +#include <limits> |
| 17 | + |
| 18 | +#include "qgstest.h" |
| 19 | +#include <QObject> |
| 20 | +#include <QString> |
| 21 | +#include <QStringList> |
| 22 | +#include <QApplication> |
| 23 | +#include <QFileInfo> |
| 24 | +#include <QDir> |
| 25 | +#include <fstream> |
| 26 | +#include <QVector> |
| 27 | +#include <QTest> |
| 28 | +#include <QStandardPaths> |
| 29 | +#include <QQueue> |
| 30 | + |
| 31 | +//qgis includes... |
| 32 | +#include "qgis.h" |
| 33 | +#include "qgsapplication.h" |
| 34 | +//#include "qgsproviderregistry.h" |
| 35 | +#include "qgsvirtuallayerprovider.h" |
| 36 | +//#include "qgsgeometry.h" |
| 37 | +//#include "qgsfeedback.h" |
| 38 | +//#include "qgsprovidermetadata.h" |
| 39 | + |
| 40 | +/** |
| 41 | + * \ingroup UnitTests |
| 42 | + * This is a unit test for the Virtual Layer provider |
| 43 | + */ |
| 44 | +class TestQgsVirtualLayerProvider : public QgsTest |
| 45 | +{ |
| 46 | + Q_OBJECT |
| 47 | + |
| 48 | + public: |
| 49 | + |
| 50 | + TestQgsVirtualLayerProvider() : QgsTest( QStringLiteral( "Virtual Layer Provider Tests" ) ) {} |
| 51 | + |
| 52 | + private slots: |
| 53 | + void initTestCase();// will be called before the first testfunction is executed. |
| 54 | + void cleanupTestCase();// will be called after the last testfunction was executed. |
| 55 | + void init() {}// will be called before each testfunction is executed. |
| 56 | + void cleanup() {}// will be called after every testfunction. |
| 57 | + |
| 58 | + void testConstructor(); |
| 59 | + |
| 60 | + private: |
| 61 | + QString mTestDataDir; |
| 62 | +}; |
| 63 | + |
| 64 | +//runs before all tests |
| 65 | +void TestQgsVirtualLayerProvider::initTestCase() |
| 66 | +{ |
| 67 | + // init QGIS's paths - true means that all path will be inited from prefix |
| 68 | + QgsApplication::init(); |
| 69 | + QgsApplication::initQgis(); |
| 70 | + |
| 71 | + mTestDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; //defined in CmakeLists.txt |
| 72 | +} |
| 73 | + |
| 74 | +//runs after all tests |
| 75 | +void TestQgsVirtualLayerProvider::cleanupTestCase() |
| 76 | +{ |
| 77 | + QgsApplication::exitQgis(); |
| 78 | +} |
| 79 | + |
| 80 | +void TestQgsVirtualLayerProvider::testConstructor() |
| 81 | +{ |
| 82 | + QgsDataProvider::ProviderOptions opts; |
| 83 | + QString uri; |
| 84 | + std::unique_ptr<QgsVectorDataProvider> prov( new QgsVirtualLayerProvider( uri, opts ) ); |
| 85 | + |
| 86 | + const QgsRectangle rectNull = QgsRectangle::createNull(); |
| 87 | + QCOMPARE( prov->sourceExtent(), rectNull ); |
| 88 | +} |
| 89 | + |
| 90 | +QGSTEST_MAIN( TestQgsVirtualLayerProvider ) |
| 91 | +#include "testqgsvirtuallayerprovider.moc" |
0 commit comments