Skip to content

Commit

Permalink
Add unit test for atlas signals
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Mar 18, 2014
1 parent 9eb8ef4 commit 7805bc0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/core/testqgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "qgssymbolv2.h"
#include "qgssinglesymbolrendererv2.h"
#include <QObject>
#include <QSignalSpy>
#include <QtTest>

class TestQgsAtlasComposition: public QObject
Expand Down Expand Up @@ -57,6 +58,8 @@ class TestQgsAtlasComposition: public QObject
void sorting_render();
// test rendering with feature filtering
void filtering_render();
// test render signals
void test_signals();
private:
QgsComposition* mComposition;
QgsComposerLabel* mLabel1;
Expand Down Expand Up @@ -365,5 +368,31 @@ void TestQgsAtlasComposition::filtering_render()
mAtlas->endRender();
}

void TestQgsAtlasComposition::test_signals()
{
mAtlasMap->setNewExtent( QgsRectangle( 209838.166, 6528781.020, 610491.166, 6920530.620 ) );
mAtlasMap->setAtlasDriven( true );
mAtlasMap->setAtlasFixedScale( true );
mAtlas->setHideCoverage( false );
mAtlas->setSortFeatures( false );
mAtlas->setFilterFeatures( false );

QSignalSpy spyRenderBegun( mAtlas, SIGNAL(renderBegun()) );
QSignalSpy spyRenderEnded( mAtlas, SIGNAL(renderEnded()) );
QSignalSpy spyPreparedForAtlas( mAtlasMap, SIGNAL(preparedForAtlas()) );
mAtlas->beginRender();

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

for ( int fit = 0; fit < 2; ++fit )
{
mAtlas->prepareForFeature( fit );
mLabel1->adjustSizeToText();
}
QVERIFY( spyPreparedForAtlas.count() == 2 );
mAtlas->endRender();
QVERIFY( spyRenderEnded.count() == 1 );
}

QTEST_MAIN( TestQgsAtlasComposition )
#include "moc_testqgsatlascomposition.cxx"

0 comments on commit 7805bc0

Please sign in to comment.