Skip to content

Commit 0b32f2a

Browse files
committedApr 3, 2014
[tests] Fix composer tests. Rebuild images following MTR rendering changes. Switch tests to use standard test font.
1 parent 6d73593 commit 0b32f2a

File tree

79 files changed

+59
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+59
-47
lines changed
 

‎tests/src/core/testqgsatlascomposition.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsvectordataprovider.h"
2828
#include "qgssymbolv2.h"
2929
#include "qgssinglesymbolrendererv2.h"
30+
#include "qgsfontutils.h"
3031
#include <QObject>
3132
#include <QSignalSpy>
3233
#include <QtTest>
@@ -134,14 +135,16 @@ void TestQgsAtlasComposition::initTestCase()
134135
mLabel1 = new QgsComposerLabel( mComposition );
135136
mComposition->addComposerLabel( mLabel1 );
136137
mLabel1->setText( "[% \"NAME_1\" %] area" );
137-
//next to explicetly set width, since expression isn't yet evaulated against
138-
//an atlas feature and will be shorter then required
138+
mLabel1->setFont( QgsFontUtils::getStandardTestFont() );
139+
//need to explictly set width, since expression hasn't been evaluated against
140+
//an atlas feature yet and will be shorter than required
139141
mLabel1->setSceneRect( QRectF( 150, 5, 60, 15 ) );
140142

141143
// feature number label
142144
mLabel2 = new QgsComposerLabel( mComposition );
143145
mComposition->addComposerLabel( mLabel2 );
144146
mLabel2->setText( "# [%$feature || ' / ' || $numfeatures%]" );
147+
mLabel2->setFont( QgsFontUtils::getStandardTestFont() );
145148
mLabel2->setSceneRect( QRectF( 150, 200, 60, 15 ) );
146149

147150
qWarning() << "header label font: " << mLabel1->font().toString() << " exactMatch:" << mLabel1->font().exactMatch();
@@ -201,7 +204,7 @@ void TestQgsAtlasComposition::autoscale_render()
201204
mLabel1->adjustSizeToText();
202205

203206
QgsCompositionChecker checker( QString( "atlas_autoscale%1" ).arg((( int )fit ) + 1 ), mComposition );
204-
QVERIFY( checker.testComposition( mReport, 0, 10 ) );
207+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
205208
}
206209
mAtlas->endRender();
207210
mAtlasMap->setAtlasDriven( false );
@@ -223,7 +226,7 @@ void TestQgsAtlasComposition::autoscale_render_2_0_api()
223226
mLabel1->adjustSizeToText();
224227

225228
QgsCompositionChecker checker( QString( "atlas_autoscale_old_api%1" ).arg((( int )fit ) + 1 ), mComposition );
226-
QVERIFY( checker.testComposition( mReport, 0 ) );
229+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
227230
}
228231
mAtlas->endRender();
229232
mAtlas->setComposerMap( 0 );
@@ -245,7 +248,7 @@ void TestQgsAtlasComposition::fixedscale_render()
245248
mLabel1->adjustSizeToText();
246249

247250
QgsCompositionChecker checker( QString( "atlas_fixedscale%1" ).arg((( int )fit ) + 1 ), mComposition );
248-
QVERIFY( checker.testComposition( mReport, 0 ) );
251+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
249252
}
250253
mAtlas->endRender();
251254

@@ -266,7 +269,7 @@ void TestQgsAtlasComposition::fixedscale_render_2_0_api()
266269
mLabel1->adjustSizeToText();
267270

268271
QgsCompositionChecker checker( QString( "atlas_fixedscale_old_api%1" ).arg((( int )fit ) + 1 ), mComposition );
269-
QVERIFY( checker.testComposition( mReport, 0 ) );
272+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
270273
}
271274
mAtlas->endRender();
272275
mAtlas->setComposerMap( 0 );
@@ -290,7 +293,7 @@ void TestQgsAtlasComposition::two_map_autoscale_render()
290293
mLabel1->adjustSizeToText();
291294

292295
QgsCompositionChecker checker( QString( "atlas_two_maps%1" ).arg((( int )fit ) + 1 ), mComposition );
293-
QVERIFY( checker.testComposition( mReport, 0, 10 ) );
296+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
294297
}
295298
mAtlas->endRender();
296299
mAtlasMap->setAtlasDriven( false );
@@ -314,7 +317,7 @@ void TestQgsAtlasComposition::hiding_render()
314317
mLabel1->adjustSizeToText();
315318

316319
QgsCompositionChecker checker( QString( "atlas_hiding%1" ).arg((( int )fit ) + 1 ), mComposition );
317-
QVERIFY( checker.testComposition( mReport, 0 ) );
320+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
318321
}
319322
mAtlas->endRender();
320323
}
@@ -338,7 +341,7 @@ void TestQgsAtlasComposition::sorting_render()
338341
mLabel1->adjustSizeToText();
339342

340343
QgsCompositionChecker checker( QString( "atlas_sorting%1" ).arg((( int )fit ) + 1 ), mComposition );
341-
QVERIFY( checker.testComposition( mReport, 0 ) );
344+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
342345
}
343346
mAtlas->endRender();
344347
}
@@ -363,7 +366,7 @@ void TestQgsAtlasComposition::filtering_render()
363366
mLabel1->adjustSizeToText();
364367

365368
QgsCompositionChecker checker( QString( "atlas_filtering%1" ).arg((( int )fit ) + 1 ), mComposition );
366-
QVERIFY( checker.testComposition( mReport, 0 ) );
369+
QVERIFY( checker.testComposition( mReport, 0, 200 ) );
367370
}
368371
mAtlas->endRender();
369372
}
@@ -377,9 +380,9 @@ void TestQgsAtlasComposition::test_signals()
377380
mAtlas->setSortFeatures( false );
378381
mAtlas->setFilterFeatures( false );
379382

380-
QSignalSpy spyRenderBegun( mAtlas, SIGNAL(renderBegun()) );
381-
QSignalSpy spyRenderEnded( mAtlas, SIGNAL(renderEnded()) );
382-
QSignalSpy spyPreparedForAtlas( mAtlasMap, SIGNAL(preparedForAtlas()) );
383+
QSignalSpy spyRenderBegun( mAtlas, SIGNAL( renderBegun() ) );
384+
QSignalSpy spyRenderEnded( mAtlas, SIGNAL( renderEnded() ) );
385+
QSignalSpy spyPreparedForAtlas( mAtlasMap, SIGNAL( preparedForAtlas() ) );
383386
mAtlas->beginRender();
384387

385388
QVERIFY( spyRenderBegun.count() == 1 );

‎tests/src/core/testqgscomposermap.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "qgsmaprenderer.h"
2424
#include "qgsmultibandcolorrenderer.h"
2525
#include "qgsrasterlayer.h"
26+
#include "qgsfontutils.h"
2627
#include <QObject>
2728
#include <QtTest>
2829

@@ -107,7 +108,7 @@ void TestQgsComposerMap::render()
107108
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
108109
QgsCompositionChecker checker( "composermap_render", mComposition );
109110

110-
QVERIFY( checker.testComposition( mReport ) );
111+
QVERIFY( checker.testComposition( mReport, 0, 100 ) );
111112
}
112113

113114
void TestQgsComposerMap::grid()
@@ -116,12 +117,10 @@ void TestQgsComposerMap::grid()
116117
mComposerMap->setGridEnabled( true );
117118
mComposerMap->setGridIntervalX( 2000 );
118119
mComposerMap->setGridIntervalY( 2000 );
119-
// Anotation is disabled because fonts are different on each platform
120-
// TODO: ship a test font with QGIS and use it here
121-
//mComposerMap->setShowGridAnnotation( true );
120+
mComposerMap->setShowGridAnnotation( true );
122121
mComposerMap->setGridPenWidth( 0.5 );
123122
mComposerMap->setGridPenColor( QColor( 0, 255, 0 ) );
124-
#if 0
123+
mComposerMap->setGridAnnotationFont( QgsFontUtils::getStandardTestFont() );
125124
mComposerMap->setGridAnnotationPrecision( 0 );
126125
mComposerMap->setGridAnnotationPosition( QgsComposerMap::Disabled, QgsComposerMap::Left );
127126
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Right );
@@ -130,12 +129,11 @@ void TestQgsComposerMap::grid()
130129
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, QgsComposerMap::Right );
131130
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, QgsComposerMap::Bottom );
132131
mComposerMap->setAnnotationFontColor( QColor( 255, 0, 0, 150 ) );
133-
#endif
134132
mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay );
135133
qWarning() << "grid annotation font: " << mComposerMap->gridAnnotationFont().toString() << " exactMatch:" << mComposerMap->gridAnnotationFont().exactMatch();
136134
QgsCompositionChecker checker( "composermap_grid", mComposition );
137135

138-
bool testResult = checker.testComposition( mReport );
136+
bool testResult = checker.testComposition( mReport, 0, 100 );
139137
mComposerMap->setGridEnabled( false );
140138
mComposerMap->setShowGridAnnotation( false );
141139
QVERIFY( testResult );
@@ -151,7 +149,7 @@ void TestQgsComposerMap::overviewMap()
151149
overviewMap->setOverviewFrameMap( mComposerMap->id() );
152150
QgsCompositionChecker checker( "composermap_overview", mComposition );
153151

154-
bool testResult = checker.testComposition( mReport );
152+
bool testResult = checker.testComposition( mReport, 0, 100 );
155153
mComposition->removeComposerItem( overviewMap );
156154
QVERIFY( testResult );
157155
}
@@ -168,7 +166,7 @@ void TestQgsComposerMap::overviewMapBlending()
168166

169167
QgsCompositionChecker checker( "composermap_overview_blending", mComposition );
170168

171-
bool testResult = checker.testComposition( mReport );
169+
bool testResult = checker.testComposition( mReport, 0, 100 );
172170
mComposition->removeComposerItem( overviewMapBlend );
173171
QVERIFY( testResult );
174172
}
@@ -185,7 +183,7 @@ void TestQgsComposerMap::overviewMapInvert()
185183

186184
QgsCompositionChecker checker( "composermap_overview_invert", mComposition );
187185

188-
bool testResult = checker.testComposition( mReport );
186+
bool testResult = checker.testComposition( mReport, 0, 100 );
189187
mComposition->removeComposerItem( overviewMapInvert );
190188
QVERIFY( testResult );
191189
}
@@ -233,7 +231,7 @@ void TestQgsComposerMap::zebraStyle()
233231

234232
QgsCompositionChecker checker( "composermap_zebrastyle", mComposition );
235233

236-
bool testResult = checker.testComposition( mReport );
234+
bool testResult = checker.testComposition( mReport, 0, 100 );
237235
QVERIFY( testResult );
238236
}
239237

@@ -250,7 +248,7 @@ void TestQgsComposerMap::overviewMapCenter()
250248

251249
QgsCompositionChecker checker( "composermap_overview_center", mComposition );
252250

253-
bool testResult = checker.testComposition( mReport );
251+
bool testResult = checker.testComposition( mReport, 0, 100 );
254252
mComposition->removeComposerItem( overviewMapCenter );
255253
QVERIFY( testResult );
256254
}

0 commit comments

Comments
 (0)
Please sign in to comment.