Skip to content

Commit

Permalink
Fix build and switch to QgsTest::imageCheck()
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 2, 2022
1 parent ec36709 commit ecb97c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
1 change: 1 addition & 0 deletions src/core/pointcloud/qgspointcloudrenderer.h
Expand Up @@ -24,6 +24,7 @@
#include "qgis_sip.h"
#include "qgsvector3d.h"
#include "qgspointcloudattribute.h"
#include "qgselevationmap.h"

class QgsPointCloudBlock;
class QgsLayerTreeLayer;
Expand Down
38 changes: 5 additions & 33 deletions tests/src/core/testqgselevationmap.cpp
Expand Up @@ -17,37 +17,20 @@ Email : wonder dot sk at gmail dot com
#include "qgsapplication.h"
#include "qgselevationmap.h"
#include "qgsrasterlayer.h"
#include "qgsrenderchecker.h"


static QString _fileNameForTest( const QString &testName )
class TestQgsElevationMap : public QgsTest
{
return QDir::tempPath() + '/' + testName + ".png";
}

static bool _verifyImage( const QString &testName, QString &report )
{
QgsRenderChecker checker;
checker.setControlPathPrefix( QStringLiteral( "elevation_map" ) );
checker.setControlName( "expected_" + testName );
checker.setRenderedImage( _fileNameForTest( testName ) );
checker.setSizeTolerance( 3, 3 );
const bool equal = checker.compareImages( testName, 500 );
report += checker.report();
return equal;
}
Q_OBJECT

public:
TestQgsElevationMap() : QgsTest( QStringLiteral( "Elevation Map Tests" ), QStringLiteral( "elevation_map" ) ) {}

class TestQgsElevationMap : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void testRasterDemEdl();

private:
QString mReport;
};


Expand All @@ -60,20 +43,10 @@ void TestQgsElevationMap::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();

mReport += QLatin1String( "<h1>Elevation Map Tests</h1>\n" );
}

void TestQgsElevationMap::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();
}

Expand All @@ -98,8 +71,7 @@ void TestQgsElevationMap::testRasterDemEdl()
std::unique_ptr<QgsElevationMap> elevationMap( QgsElevationMap::fromRasterBlock( block.get() ) );
elevationMap->applyEyeDomeLighting( img, 2, 100, 10000 );

img.save( _fileNameForTest( QStringLiteral( "dem_edl" ) ) );
QVERIFY( _verifyImage( "dem_edl", mReport ) );
QVERIFY( imageCheck( "dem_edl", "dem_edl", img ) );
}


Expand Down

0 comments on commit ecb97c4

Please sign in to comment.