Skip to content
Permalink
Browse files

Try to fix some more intermittent composer tests

  • Loading branch information
nyalldawson committed Dec 1, 2014
1 parent 118a9f6 commit d815ac00617222300bcffca5678bc326e414b622
@@ -189,6 +189,7 @@ void TestQgsAtlasComposition::init()
void TestQgsAtlasComposition::cleanup()
{
delete mComposition;
mComposition = 0;
}

void TestQgsAtlasComposition::filename()
@@ -54,7 +54,6 @@ class TestQgsComposerRotation: public QObject
QgsComposition* mComposition;
QgsComposerShape* mComposerRect;
QgsComposerLabel* mComposerLabel;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsRasterLayer* mRasterLayer;
QString mReport;
@@ -92,9 +91,6 @@ void TestQgsComposerRotation::initTestCase()
mComposerLabel->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
mComposerLabel->setBackgroundEnabled( true );

mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );

mReport = "<h1>Composer Rotation Tests</h1>\n";
}

@@ -184,46 +180,34 @@ void TestQgsComposerRotation::oldLabelRotationApi()
void TestQgsComposerRotation::mapRotation()
{
//test map rotation
mComposition->addComposerMap( mComposerMap );
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setMapRotation( 90 );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setMapRotation( 90 );

QgsCompositionChecker checker( "composerrotation_maprotation", mComposition );
QVERIFY( checker.testComposition( mReport, 0, 0 ) );

mComposition->removeItem( mComposerMap );
mComposerMap->setMapRotation( 0 );
mComposition->removeItem( composerMap );
delete composerMap;
}

void TestQgsComposerRotation::mapItemRotation()
{
//test map item rotation
mComposition->addComposerMap( mComposerMap );
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setItemRotation( 90, true );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setItemRotation( 90, true );

QgsCompositionChecker checker( "composerrotation_mapitemrotation", mComposition );
QVERIFY( checker.testComposition( mReport ) );

mComposition->removeItem( mComposerMap );
mComposerMap->setItemRotation( 0, true );
}

#if 0
void TestQgsComposerRotation::oldMapRotationApi()
{
//test old style deprecated rotation api - remove test after 2.0 series
mComposition->addComposerMap( mComposerMap );
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setRotation( 90 );

QgsCompositionChecker checker( "composerrotation_maprotation_oldapi", mComposition );
QVERIFY( checker.testComposition( mReport ) );

mComposition->removeItem( mComposerMap );
mComposerMap->setRotation( 0 );
mComposition->removeItem( composerMap );
delete composerMap;
}
#endif

QTEST_MAIN( TestQgsComposerRotation )
#include "testqgscomposerrotation.moc"
@@ -61,10 +61,8 @@ class TestQgsComposerTableV2: public QObject

private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsVectorLayer* mVectorLayer2;
QgsComposerAttributeTableV2* mComposerAttributeTable;
QgsComposerFrame* mFrame1;
QgsComposerFrame* mFrame2;
@@ -85,12 +83,9 @@ void TestQgsComposerTableV2::initTestCase()
vectorFileInfo.completeBaseName(),
"ogr" );
QgsMapLayerRegistry::instance()->addMapLayer( mVectorLayer );
mVectorLayer2 = new QgsVectorLayer( vectorFileInfo.filePath(),
vectorFileInfo.completeBaseName(),
"ogr" );

//create composition with composer map
mMapSettings.setLayers( QStringList() << mVectorLayer->id() << mVectorLayer2->id() );
mMapSettings.setLayers( QStringList() << mVectorLayer->id() );
mMapSettings.setCrsTransformEnabled( false );
mComposition = new QgsComposition( mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 portrait
@@ -120,7 +115,6 @@ void TestQgsComposerTableV2::initTestCase()
void TestQgsComposerTableV2::cleanupTestCase()
{
delete mComposition;
delete mVectorLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
@@ -283,12 +277,11 @@ void TestQgsComposerTableV2::attributeTableVisibleOnly()
{
//test displaying only visible attributes

mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );
mComposition->addComposerMap( mComposerMap );
mComposerMap->setNewExtent( QgsRectangle( -131.767, 30.558, -110.743, 41.070 ) );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
composerMap->setFrameEnabled( true );
composerMap->setNewExtent( QgsRectangle( -131.767, 30.558, -110.743, 41.070 ) );

mComposerAttributeTable->setComposerMap( mComposerMap );
mComposerAttributeTable->setComposerMap( composerMap );
mComposerAttributeTable->setDisplayOnlyVisibleFeatures( true );

QList<QStringList> expectedRows;
@@ -307,7 +300,7 @@ void TestQgsComposerTableV2::attributeTableVisibleOnly()

mComposerAttributeTable->setDisplayOnlyVisibleFeatures( false );
mComposerAttributeTable->setComposerMap( 0 );
mComposition->removeItem( mComposerMap );
delete composerMap;
}

void TestQgsComposerTableV2::attributeTableRender()
@@ -411,7 +404,13 @@ void TestQgsComposerTableV2::attributeTableAtlasSource()
table->setSource( QgsComposerAttributeTableV2::AtlasFeature );

//setup atlas
mComposition->atlasComposition().setCoverageLayer( mVectorLayer2 );
QgsVectorLayer* vectorLayer;
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points.shp" );
vectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
vectorFileInfo.completeBaseName(),
"ogr" );
QgsMapLayerRegistry::instance()->addMapLayer( vectorLayer );
mComposition->atlasComposition().setCoverageLayer( vectorLayer );
mComposition->atlasComposition().setEnabled( true );
QVERIFY( mComposition->atlasComposition().beginRender() );

@@ -452,7 +451,7 @@ void TestQgsComposerTableV2::attributeTableAtlasSource()
mComposition->atlasComposition().endRender();

//try for a crash when removing current atlas layer
QgsMapLayerRegistry::instance()->removeMapLayer( mVectorLayer2->id() );
QgsMapLayerRegistry::instance()->removeMapLayer( vectorLayer->id() );
table->refreshAttributes();

mComposition->removeMultiFrame( table );

0 comments on commit d815ac0

Please sign in to comment.
You can’t perform that action at this time.