"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/src/core/testqgslabelingengine.cpp" between
QGIS-final-3_14_15.tar.gz and QGIS-final-3_14_16.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Latest release (3.14.x series).

testqgslabelingengine.cpp  (QGIS-final-3_14_15):testqgslabelingengine.cpp  (QGIS-final-3_14_16)
skipping to change at line 83 skipping to change at line 83
void curvedOverrun(); void curvedOverrun();
void parallelOverrun(); void parallelOverrun();
void testDataDefinedLabelAllParts(); void testDataDefinedLabelAllParts();
void testVerticalOrientation(); void testVerticalOrientation();
void testVerticalOrientationLetterLineSpacing(); void testVerticalOrientationLetterLineSpacing();
void testRotationBasedOrientationPoint(); void testRotationBasedOrientationPoint();
void testRotationBasedOrientationLine(); void testRotationBasedOrientationLine();
void testMapUnitLetterSpacing(); void testMapUnitLetterSpacing();
void testMapUnitWordSpacing(); void testMapUnitWordSpacing();
void testReferencedFields(); void testReferencedFields();
void testShowAllLabelsWhenALabelHasNoCandidates();
private: private:
QgsVectorLayer *vl = nullptr; QgsVectorLayer *vl = nullptr;
QString mReport; QString mReport;
void setDefaultLabelParams( QgsPalLayerSettings &settings ); void setDefaultLabelParams( QgsPalLayerSettings &settings );
QgsLabelingEngineSettings createLabelEngineSettings(); QgsLabelingEngineSettings createLabelEngineSettings();
bool imageCheck( const QString &testName, QImage &image, int mismatchCount ) ; bool imageCheck( const QString &testName, QImage &image, int mismatchCount ) ;
skipping to change at line 2690 skipping to change at line 2691
settings.isExpression = true; settings.isExpression = true;
QCOMPARE( settings.referencedFields( QgsRenderContext() ), QSet<QString>() << QStringLiteral( "hello" ) << QStringLiteral( "world" ) ); QCOMPARE( settings.referencedFields( QgsRenderContext() ), QSet<QString>() << QStringLiteral( "hello" ) << QStringLiteral( "world" ) );
settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Size, QgsPr operty::fromField( QStringLiteral( "my_dd_size" ) ) ); settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Size, QgsPr operty::fromField( QStringLiteral( "my_dd_size" ) ) );
QCOMPARE( settings.referencedFields( QgsRenderContext() ), QSet<QString>() << QStringLiteral( "hello" ) << QStringLiteral( "world" ) << QStringLiteral( "my_dd _size" ) ); QCOMPARE( settings.referencedFields( QgsRenderContext() ), QSet<QString>() << QStringLiteral( "hello" ) << QStringLiteral( "world" ) << QStringLiteral( "my_dd _size" ) );
} }
void TestQgsLabelingEngine::testShowAllLabelsWhenALabelHasNoCandidates()
{
// test that showing all labels when a label has no candidate placements doesn
't
// result in a crash
// refs https://github.com/qgis/QGIS/issues/38093
QgsPalLayerSettings settings;
setDefaultLabelParams( settings );
QgsTextFormat format = settings.format();
format.setSize( 20 );
format.setColor( QColor( 0, 0, 0 ) );
settings.setFormat( format );
settings.fieldName = QStringLiteral( "'xxxxxxxxxxxxxx'" );
settings.isExpression = true;
settings.placement = QgsPalLayerSettings::Line;
settings.placementFlags = QgsPalLayerSettings::OnLine;
settings.obstacleSettings().setFactor( 10 );
settings.overrunDistance = 50;
std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Lin
eString?crs=epsg:23700&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral
( "memory" ) ) );
vl2->setRenderer( new QgsNullSymbolRenderer() );
QgsFeature f;
f.setAttributes( QgsAttributes() << QVariant() );
f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (-2446233 -52
04828, -2342845 -5203825)" ) ) );
QVERIFY( vl2->dataProvider()->addFeature( f ) );
f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (-2439207 -51
98806, -2331302 -5197802)" ) ) );
QVERIFY( vl2->dataProvider()->addFeature( f ) );
vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: th
is should not be necessary!
vl2->setLabelsEnabled( true );
// make a fake render context
QSize size( 640, 480 );
QgsMapSettings mapSettings;
mapSettings.setLabelingEngineSettings( createLabelEngineSettings() );
mapSettings.setDestinationCrs( vl2->crs() );
mapSettings.setOutputSize( size );
mapSettings.setExtent( QgsRectangle( -3328044.9, -5963176., -1127782.7, -42768
44.3 ) );
mapSettings.setLayers( QList<QgsMapLayer *>() << vl2.get() );
mapSettings.setOutputDpi( 96 );
QgsLabelingEngineSettings engineSettings = mapSettings.labelingEngineSettings(
);
engineSettings.setFlag( QgsLabelingEngineSettings::DrawLabelRectOnly, true );
engineSettings.setFlag( QgsLabelingEngineSettings::UseAllLabels, true );
engineSettings.setFlag( QgsLabelingEngineSettings::DrawUnplacedLabels, true );
// engineSettings.setFlag( QgsLabelingEngineSettings::DrawCandidates, true );
mapSettings.setLabelingEngineSettings( engineSettings );
QgsMapRendererSequentialJob job( mapSettings );
job.start();
job.waitForFinished();
QImage img = job.renderedImage();
QVERIFY( imageCheck( QStringLiteral( "show_all_labels_when_no_candidates" ), i
mg, 20 ) );
}
QGSTEST_MAIN( TestQgsLabelingEngine ) QGSTEST_MAIN( TestQgsLabelingEngine )
#include "testqgslabelingengine.moc" #include "testqgslabelingengine.moc"
 End of changes. 2 change blocks. 
0 lines changed or deleted 72 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)