Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic vector tiles utils test class, inc. zoom level test
- Loading branch information
1 parent
372ae04
commit 601e2ca
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*************************************************************************** | ||
testqgsvectortileutils.cpp | ||
-------------------------------------- | ||
Date : November 2021 | ||
Copyright : (C) 2021 by Mathieu Pellerin | ||
Email : nirvn dot asia at gmail dot 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 "qgstest.h" | ||
#include <QObject> | ||
#include <QString> | ||
|
||
//qgis includes... | ||
#include "qgsapplication.h" | ||
#include "qgsvectortileutils.h" | ||
|
||
/** | ||
* \ingroup UnitTests | ||
* This is a unit test for the vector tile utils class | ||
*/ | ||
class TestQgsVectorTileUtils : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
TestQgsVectorTileUtils() = default; | ||
|
||
private: | ||
QString mReport; | ||
|
||
private slots: | ||
void initTestCase();// will be called before the first testfunction is executed. | ||
void cleanupTestCase();// will be called after the last testfunction was executed. | ||
void init() {} // will be called before each testfunction is executed. | ||
void cleanup() {} // will be called after every testfunction. | ||
|
||
void test_scaleToZoomLevel(); | ||
}; | ||
|
||
|
||
void TestQgsVectorTileUtils::initTestCase() | ||
{ | ||
// init QGIS's paths - true means that all path will be inited from prefix | ||
QgsApplication::init(); | ||
QgsApplication::initQgis(); | ||
QgsApplication::showSettings(); | ||
mReport += QLatin1String( "<h1>Vector Tile Utils Tests</h1>\n" ); | ||
} | ||
|
||
void TestQgsVectorTileUtils::cleanupTestCase() | ||
{ | ||
const QString myReportFile = QDir::tempPath() + "/qgistest.html"; | ||
QFile myFile( myReportFile ); | ||
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) | ||
{ | ||
QTextStream myQTextStream( &myFile ); | ||
myQTextStream << mReport; | ||
myFile.close(); | ||
} | ||
|
||
QgsApplication::exitQgis(); | ||
} | ||
|
||
void TestQgsVectorTileUtils::test_scaleToZoomLevel() | ||
{ | ||
// test zoom level logic | ||
int zoomLevel = QgsVectorTileUtils::scaleToZoomLevel( 288896, 0, 20 ); | ||
QCOMPARE( zoomLevel, 10 ); | ||
} | ||
|
||
|
||
QGSTEST_MAIN( TestQgsVectorTileUtils ) | ||
#include "testqgsvectortileutils.moc" |