33
33
#include " qgsmarkersymbollayer.h"
34
34
#include " qgsfillsymbol.h"
35
35
36
- // qgis test includes
37
- #include " qgsrenderchecker.h"
38
-
39
36
/* *
40
37
* \ingroup UnitTests
41
38
* This is a unit test for line fill symbol types.
@@ -45,7 +42,7 @@ class TestQgsCentroidFillSymbol : public QgsTest
45
42
Q_OBJECT
46
43
47
44
public:
48
- TestQgsCentroidFillSymbol () : QgsTest( QStringLiteral( " Centroid Fill Symbol Tests" ) ) {}
45
+ TestQgsCentroidFillSymbol () : QgsTest( QStringLiteral( " Centroid Fill Symbol Tests" ), QStringLiteral( " symbol_centroidfill " ) ) {}
49
46
50
47
private slots:
51
48
void initTestCase ();// will be called before the first testfunction is executed.
@@ -64,7 +61,6 @@ class TestQgsCentroidFillSymbol : public QgsTest
64
61
private:
65
62
bool mTestHasError = false ;
66
63
67
- bool imageCheck ( const QString &type );
68
64
QgsMapSettings mMapSettings ;
69
65
QgsVectorLayer *mpPolysLayer = nullptr ;
70
66
QgsCentroidFillSymbolLayer *mCentroidFill = nullptr ;
@@ -122,35 +118,45 @@ void TestQgsCentroidFillSymbol::cleanupTestCase()
122
118
123
119
void TestQgsCentroidFillSymbol::centroidFillSymbol ()
124
120
{
125
- QVERIFY ( imageCheck ( " symbol_centroidfill" ) );
121
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
122
+ mMapSettings .setOutputDpi ( 96 );
123
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill" , " symbol_centroidfill" , mMapSettings );
126
124
}
127
125
128
126
void TestQgsCentroidFillSymbol::centroidFillSymbolPointOnSurface ()
129
127
{
130
128
mCentroidFill ->setPointOnSurface ( true );
131
- QVERIFY ( imageCheck ( " symbol_centroidfill_point_on_surface" ) );
129
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
130
+ mMapSettings .setOutputDpi ( 96 );
131
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_point_on_surface" , " symbol_centroidfill_point_on_surface" , mMapSettings );
132
132
mCentroidFill ->setPointOnSurface ( false );
133
133
}
134
134
135
135
void TestQgsCentroidFillSymbol::centroidFillSymbolPartBiggest ()
136
136
{
137
137
mCentroidFill ->setPointOnAllParts ( false );
138
- QVERIFY ( imageCheck ( " symbol_centroidfill_part_biggest" ) );
138
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
139
+ mMapSettings .setOutputDpi ( 96 );
140
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_part_biggest" , " symbol_centroidfill_part_biggest" , mMapSettings );
139
141
mCentroidFill ->setPointOnAllParts ( true );
140
142
}
141
143
142
144
void TestQgsCentroidFillSymbol::centroidFillClipPoints ()
143
145
{
144
146
mCentroidFill ->setClipPoints ( true );
145
- QVERIFY ( imageCheck ( " symbol_centroidfill_clip_points" ) );
147
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
148
+ mMapSettings .setOutputDpi ( 96 );
149
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_clip_points" , " symbol_centroidfill_clip_points" , mMapSettings );
146
150
mCentroidFill ->setClipPoints ( false );
147
151
}
148
152
149
153
void TestQgsCentroidFillSymbol::centroidFillClipOnCurrentPartOnly ()
150
154
{
151
155
mCentroidFill ->setClipPoints ( true );
152
156
mCentroidFill ->setClipOnCurrentPartOnly ( true );
153
- QVERIFY ( imageCheck ( " symbol_centroidfill_clip_current_only" ) );
157
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
158
+ mMapSettings .setOutputDpi ( 96 );
159
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_clip_current_only" , " symbol_centroidfill_clip_current_only" , mMapSettings );
154
160
mCentroidFill ->setClipPoints ( false );
155
161
mCentroidFill ->setClipOnCurrentPartOnly ( false );
156
162
}
@@ -160,7 +166,9 @@ void TestQgsCentroidFillSymbol::centroidFillClipOnCurrentPartOnlyBiggest()
160
166
mCentroidFill ->setClipPoints ( true );
161
167
mCentroidFill ->setClipOnCurrentPartOnly ( true );
162
168
mCentroidFill ->setPointOnAllParts ( false );
163
- QVERIFY ( imageCheck ( " symbol_centroidfill_clip_current_biggest" ) );
169
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
170
+ mMapSettings .setOutputDpi ( 96 );
171
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_clip_current_biggest" , " symbol_centroidfill_clip_current_biggest" , mMapSettings );
164
172
mCentroidFill ->setClipPoints ( false );
165
173
mCentroidFill ->setClipOnCurrentPartOnly ( false );
166
174
mCentroidFill ->setPointOnAllParts ( true );
@@ -178,7 +186,9 @@ void TestQgsCentroidFillSymbol::centroidFillClipMultiplayerPoints()
178
186
mFillSymbol ->appendSymbolLayer ( mCentroidFill ->clone () );
179
187
mFillSymbol ->appendSymbolLayer ( simpleFill.clone () );
180
188
181
- QVERIFY ( imageCheck ( " symbol_centroidfill_clip_multilayer" ) );
189
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
190
+ mMapSettings .setOutputDpi ( 96 );
191
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_clip_multilayer" , " symbol_centroidfill_clip_multilayer" , mMapSettings );
182
192
183
193
mCentroidFill ->setClipPoints ( false );
184
194
mFillSymbol ->deleteSymbolLayer ( 0 );
@@ -199,7 +209,9 @@ void TestQgsCentroidFillSymbol::opacityWithDataDefinedColor()
199
209
mCentroidFill ->subSymbol ()->setOpacity ( 0.5 );
200
210
mFillSymbol ->setOpacity ( 0.5 );
201
211
202
- QVERIFY ( imageCheck ( " symbol_centroidfill_opacityddcolor" ) );
212
+ mMapSettings .setExtent ( mpPolysLayer->extent () );
213
+ mMapSettings .setOutputDpi ( 96 );
214
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_opacityddcolor" , " symbol_centroidfill_opacityddcolor" , mMapSettings );
203
215
}
204
216
205
217
void TestQgsCentroidFillSymbol::dataDefinedOpacity ()
@@ -214,27 +226,9 @@ void TestQgsCentroidFillSymbol::dataDefinedOpacity()
214
226
mFillSymbol ->setOpacity ( 1.0 );
215
227
mFillSymbol ->setDataDefinedProperty ( QgsSymbol::PropertyOpacity, QgsProperty::fromExpression ( QStringLiteral ( " if(\" Value\" >10, 25, 50)" ) ) );
216
228
217
- QVERIFY ( imageCheck ( " symbol_centroidfill_ddopacity" ) );
218
- }
219
-
220
- //
221
- // Private helper functions not called directly by CTest
222
- //
223
-
224
-
225
- bool TestQgsCentroidFillSymbol::imageCheck ( const QString &testType )
226
- {
227
- // use the QgsRenderChecker test utility class to
228
- // ensure the rendered output matches our control image
229
229
mMapSettings .setExtent ( mpPolysLayer->extent () );
230
230
mMapSettings .setOutputDpi ( 96 );
231
- QgsRenderChecker myChecker;
232
- myChecker.setControlPathPrefix ( QStringLiteral ( " symbol_centroidfill" ) );
233
- myChecker.setControlName ( " expected_" + testType );
234
- myChecker.setMapSettings ( mMapSettings );
235
- const bool myResultFlag = myChecker.runTest ( testType );
236
- mReport += myChecker.report ();
237
- return myResultFlag;
231
+ QGSVERIFYRENDERMAPSETTINGSCHECK ( " symbol_centroidfill_ddopacity" , " symbol_centroidfill_ddopacity" , mMapSettings );
238
232
}
239
233
240
234
QGSTEST_MAIN ( TestQgsCentroidFillSymbol )
0 commit comments