Skip to content

Commit 6ce7645

Browse files
committedOct 25, 2023
Update test to newer methods
1 parent 184dd70 commit 6ce7645

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed
 

‎tests/src/core/testqgsvectortilelayer.cpp

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
//qgis includes...
2121
#include "qgsapplication.h"
2222
#include "qgsproject.h"
23-
#include "qgsrenderchecker.h"
2423
#include "qgstiles.h"
2524
#include "qgsvectortilebasicrenderer.h"
2625
#include "qgsvectortilelayer.h"
@@ -47,15 +46,13 @@ class TestQgsVectorTileLayer : public QgsTest
4746
Q_OBJECT
4847

4948
public:
50-
TestQgsVectorTileLayer() : QgsTest( QStringLiteral( "Vector Tile Layer Tests" ) ) {}
49+
TestQgsVectorTileLayer() : QgsTest( QStringLiteral( "Vector Tile Layer Tests" ), QStringLiteral( "vector_tile" ) ) {}
5150

5251
private:
5352
QString mDataDir;
5453
QgsVectorTileLayer *mLayer = nullptr;
5554
QgsMapSettings *mMapSettings = nullptr;
5655

57-
bool imageCheck( const QString &testType, QgsVectorTileLayer *layer, QgsRectangle extent );
58-
5956
private slots:
6057
void initTestCase();// will be called before the first testfunction is executed.
6158
void cleanupTestCase();// will be called after the last testfunction was executed.
@@ -103,6 +100,7 @@ void TestQgsVectorTileLayer::initTestCase()
103100

104101
mMapSettings = new QgsMapSettings();
105102
mMapSettings->setLayers( QList<QgsMapLayer *>() << mLayer );
103+
mMapSettings->setOutputDpi( 96 );
106104

107105
// let's have some standard style config for the layer
108106
QColor polygonFillColor = Qt::blue;
@@ -142,25 +140,12 @@ void TestQgsVectorTileLayer::test_basic()
142140
QCOMPARE( mLayer->properties(), Qgis::MapLayerProperties( Qgis::MapLayerProperty::IsBasemapLayer ) );
143141
}
144142

145-
146-
bool TestQgsVectorTileLayer::imageCheck( const QString &testType, QgsVectorTileLayer *layer, QgsRectangle extent )
147-
{
148-
mMapSettings->setExtent( extent );
149-
mMapSettings->setDestinationCrs( layer->crs() );
150-
mMapSettings->setOutputDpi( 96 );
151-
QgsRenderChecker myChecker;
152-
myChecker.setControlPathPrefix( QStringLiteral( "vector_tile" ) );
153-
myChecker.setControlName( "expected_" + testType );
154-
myChecker.setMapSettings( *mMapSettings );
155-
myChecker.setColorTolerance( 15 );
156-
const bool myResultFlag = myChecker.runTest( testType, 0 );
157-
mReport += myChecker.report();
158-
return myResultFlag;
159-
}
160-
161143
void TestQgsVectorTileLayer::test_render()
162144
{
163-
QVERIFY( imageCheck( "render_test_basic", mLayer, mLayer->extent() ) );
145+
mMapSettings->setExtent( mLayer->extent() );
146+
mMapSettings->setDestinationCrs( mLayer->crs() );
147+
QVERIFY( renderMapSettingsCheck( QStringLiteral( "render_test_basic" ),
148+
QStringLiteral( "render_test_basic" ), *mMapSettings, 0, 15 ) );
164149
}
165150

166151
void TestQgsVectorTileLayer::test_render_withClip()
@@ -171,7 +156,11 @@ void TestQgsVectorTileLayer::test_render_withClip()
171156
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipToIntersection );
172157
mMapSettings->addClippingRegion( region );
173158
mMapSettings->addClippingRegion( region2 );
174-
const bool res = imageCheck( "render_painterclip", mLayer, mLayer->extent() );
159+
160+
mMapSettings->setExtent( mLayer->extent() );
161+
mMapSettings->setDestinationCrs( mLayer->crs() );
162+
const bool res = renderMapSettingsCheck( QStringLiteral( "render_painterclip" ),
163+
QStringLiteral( "render_painterclip" ), *mMapSettings, 0, 15 );
175164
mMapSettings->setClippingRegions( QList< QgsMapClippingRegion >() );
176165
QVERIFY( res );
177166
}
@@ -213,11 +202,16 @@ void TestQgsVectorTileLayer::test_labeling()
213202
Qt::transparent, 0,
214203
Qt::transparent, Qt::transparent, 0 ) );
215204
mLayer->setRenderer( rend ); // takes ownership
216-
bool res1 = imageCheck( "render_test_labeling", mLayer, mLayer->extent() );
205+
206+
mMapSettings->setExtent( mLayer->extent() );
207+
mMapSettings->setDestinationCrs( mLayer->crs() );
208+
const bool res1 = renderMapSettingsCheck( QStringLiteral( "render_test_labeling" ),
209+
QStringLiteral( "render_test_labeling" ), *mMapSettings, 0, 15 );
217210

218211
// disable label rendering
219212
mLayer->setLabelsEnabled( false );
220-
bool res2 = imageCheck( "render_test_labeling_disabled", mLayer, mLayer->extent() );
213+
const bool res2 = renderMapSettingsCheck( QStringLiteral( "render_test_labeling_disabled" ),
214+
QStringLiteral( "render_test_labeling_disabled" ), *mMapSettings, 0, 15 );
221215

222216
mLayer->setRenderer( oldRenderer );
223217

@@ -556,7 +550,10 @@ void TestQgsVectorTileLayer::test_polygonWithLineStyle()
556550
rend->setStyles( QList<QgsVectorTileBasicRendererStyle>() << bgst << st );
557551
layer->setRenderer( rend ); // takes ownership
558552

559-
QVERIFY( imageCheck( "render_test_polygon_with_line_style", layer.get(), layer->extent() ) );
553+
mMapSettings->setExtent( layer->extent() );
554+
mMapSettings->setDestinationCrs( layer->crs() );
555+
QVERIFY( renderMapSettingsCheck( QStringLiteral( "render_test_polygon_with_line_style" ),
556+
QStringLiteral( "render_test_polygon_with_line_style" ), *mMapSettings, 0, 15 ) );
560557
}
561558

562559
void TestQgsVectorTileLayer::test_polygonWithMarker()
@@ -592,7 +589,10 @@ void TestQgsVectorTileLayer::test_polygonWithMarker()
592589
rend->setStyles( QList<QgsVectorTileBasicRendererStyle>() << bgst << st );
593590
layer->setRenderer( rend ); // takes ownership
594591

595-
QVERIFY( imageCheck( "render_test_polygon_with_marker", layer.get(), layer->extent() ) );
592+
mMapSettings->setExtent( layer->extent() );
593+
mMapSettings->setDestinationCrs( layer->crs() );
594+
QVERIFY( renderMapSettingsCheck( QStringLiteral( "render_test_polygon_with_marker" ),
595+
QStringLiteral( "render_test_polygon_with_marker" ), *mMapSettings, 0, 15 ) );
596596
}
597597

598598
void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom()
@@ -631,7 +631,10 @@ void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom()
631631
rend->setStyles( QList<QgsVectorTileBasicRendererStyle>() << bgst << st );
632632
layer->setRenderer( rend ); // takes ownership
633633

634-
QVERIFY( imageCheck( "render_test_style_min_zoom", layer.get(), QgsRectangle( -1180017, 4261973, 155871, 5474783 ) ) );
634+
mMapSettings->setExtent( QgsRectangle( -1180017, 4261973, 155871, 5474783 ) );
635+
mMapSettings->setDestinationCrs( layer->crs() );
636+
QVERIFY( renderMapSettingsCheck( QStringLiteral( "render_test_style_min_zoom" ),
637+
QStringLiteral( "render_test_style_min_zoom" ), *mMapSettings, 0, 15 ) );
635638
}
636639

637640

0 commit comments

Comments
 (0)
Please sign in to comment.