Skip to content
Permalink
Browse files

Add test for unique composermap ids

  • Loading branch information
mhugent committed Jul 19, 2012
1 parent b299e08 commit 937bffa2fa5490fbd4521b01ed9eeaf3d49246d4
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/src/core/testqgscomposermap.cpp
@@ -37,6 +37,7 @@ class TestQgsComposerMap: public QObject
void render(); //test if rendering of the composition with composr map is correct
void grid(); //test if grid and grid annotation works
void overviewMap(); //test if overview map frame works
void uniqueId(); //test if map id is adapted when doing copy paste

private:
QgsComposition* mComposition;
@@ -131,5 +132,32 @@ void TestQgsComposerMap::overviewMap()
QVERIFY( testResult );
}

void TestQgsComposerMap::uniqueId()
{
QDomDocument doc;
QDomElement documentElement = doc.createElement( "ComposerItemClipboard" );
mComposerMap->writeXML( documentElement, doc );
mComposition->addItemsFromXML( documentElement, doc, 0, false );

//test if both composer maps have different ids
const QgsComposerMap* newMap = 0;
QList<const QgsComposerMap*> mapList = mComposition->composerMapItems();
QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
for ( ; mapIt != mapList.constEnd(); ++mapIt )
{
if ( *mapIt != mComposerMap )
{
newMap = *mapIt;
break;
}
}
int oldId = mComposerMap->id();
int newId = newMap->id();

mComposition->removeComposerItem( const_cast<QgsComposerMap*>( newMap ) );

QVERIFY( oldId != newId );
}

QTEST_MAIN( TestQgsComposerMap )
#include "moc_testqgscomposermap.cxx"

0 comments on commit 937bffa

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