Skip to content

Commit

Permalink
Add unit test for world file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier authored and mhugent committed Sep 8, 2013
1 parent 387c88d commit 50f86c8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/src/core/testqgscomposermap.cpp
Expand Up @@ -42,6 +42,7 @@ class TestQgsComposerMap: public QObject
void uniqueId(); //test if map id is adapted when doing copy paste
void zebraStyle(); //test zebra map border style
void overviewMapCenter(); //test if centering of overview map frame works
void worldFileGeneration(); // test world file generation

private:
QgsComposition* mComposition;
Expand Down Expand Up @@ -84,7 +85,6 @@ void TestQgsComposerMap::cleanupTestCase()

void TestQgsComposerMap::init()
{

}

void TestQgsComposerMap::cleanup()
Expand Down Expand Up @@ -235,5 +235,25 @@ void TestQgsComposerMap::overviewMapCenter()
mComposition->removeComposerItem( overviewMapCenter );
QVERIFY( testResult );
}

void TestQgsComposerMap::worldFileGeneration()
{
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setRotation( 30.0 );

mComposition->setGenerateWorldFile( true );
mComposition->setWorldFileMap( mComposerMap );

double params[6];
mComposition->computeWorldFileParameters( params );

QVERIFY( fabs(params[0] - 4.18048) < 0.001 );
QVERIFY( fabs(params[1] - 2.41331) < 0.001 );
QVERIFY( fabs(params[2] - 779444) < 1 );
QVERIFY( fabs(params[3] - 2.4136) < 0.001 );
QVERIFY( fabs(params[4] + 4.17997) < 0.001 );
QVERIFY( fabs(params[5] - 3.34241e+06) < 1e+03 );
}

QTEST_MAIN( TestQgsComposerMap )
#include "moc_testqgscomposermap.cxx"

0 comments on commit 50f86c8

Please sign in to comment.