Skip to content
Permalink
Browse files

[composer] Add tests for grids on specific sides (sponsored by

NIWA, New Zealand)
  • Loading branch information
nyalldawson committed Sep 3, 2014
1 parent 48e1411 commit 854418598587128868870494a48346106e36c08e
@@ -1861,8 +1861,8 @@ void QgsComposerMapWidget::loadGridEntries()
}

//load all composer grids into list widget
QList< const QgsComposerMapGrid* > grids = mComposerMap->mapGrids();
QList< const QgsComposerMapGrid* >::const_iterator gridIt = grids.constBegin();
QList< QgsComposerMapGrid* > grids = mComposerMap->mapGrids();
QList< QgsComposerMapGrid* >::const_iterator gridIt = grids.constBegin();
for ( ; gridIt != grids.constEnd(); ++gridIt )
{
QListWidgetItem* item = addGridListItem(( *gridIt )->id(), ( *gridIt )->name() );
@@ -2090,9 +2090,9 @@ QgsComposerMapGrid* QgsComposerMap::mapGrid( const QString& id ) const
return 0;
}

QList< const QgsComposerMapGrid* > QgsComposerMap::mapGrids() const
QList<QgsComposerMapGrid *> QgsComposerMap::mapGrids() const
{
QList< const QgsComposerMapGrid* > list;
QList< QgsComposerMapGrid* > list;
QList< QgsComposerMapGrid* >::const_iterator it = mGrids.begin();
for ( ; it != mGrids.end(); ++it )
{
@@ -565,7 +565,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void moveGridDown( const QString& name );
const QgsComposerMapGrid* constMapGrid( const QString& id ) const;
QgsComposerMapGrid* mapGrid( const QString& id ) const;
QList< const QgsComposerMapGrid* > mapGrids() const;
QList< QgsComposerMapGrid* > mapGrids() const;

int gridCount() const { return mGrids.size(); }

@@ -19,6 +19,7 @@
#include "qgscomposition.h"
#include "qgscompositionchecker.h"
#include "qgscomposermap.h"
#include "qgscomposermapgrid.h"
#include "qgsmaplayerregistry.h"
#include "qgsmaprenderer.h"
#include "qgsfontutils.h"
@@ -38,6 +39,7 @@ class TestQgsComposerMapGrid: public QObject
void markerGrid(); //test if grid "marker" mode works
void frameOnly(); //test if grid "frame/annotation" mode works
void zebraStyle(); //test zebra map border style
void zebraStyleSides(); //test zebra border on certain sides

private:
QgsComposition* mComposition;
@@ -196,5 +198,43 @@ void TestQgsComposerMapGrid::zebraStyle()
QVERIFY( testResult );
}

void TestQgsComposerMapGrid::zebraStyleSides()
{
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setGridPenColor( QColor( 0, 0, 0 ) );
mComposerMap->setAnnotationFontColor( QColor( 0, 0, 0, 0 ) );
mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver );

mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra );
mComposerMap->setGridFrameWidth( 10 );
mComposerMap->setGridFramePenSize( 1 );
mComposerMap->setGridFramePenColor( Qt::black );
mComposerMap->setGridFrameFillColor1( Qt::black );
mComposerMap->setGridFrameFillColor2( Qt::white );
mComposerMap->setGridEnabled( true );

mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameLeft, true );
mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameRight, false );
mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameTop, false );
mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameBottom, false );

QgsCompositionChecker checker( "composermap_zebrastyle_left", mComposition );
bool testResult = checker.testComposition( mReport, 0, 100 );
QVERIFY( testResult );

mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameTop, true );
QgsCompositionChecker checker2( "composermap_zebrastyle_lefttop", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 100 );
QVERIFY( testResult2 );

mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameRight, true );
QgsCompositionChecker checker3( "composermap_zebrastyle_lefttopright", mComposition );
bool testResult3 = checker3.testComposition( mReport, 0, 100 );
QVERIFY( testResult3 );

mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameBottom, true );
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
}

QTEST_MAIN( TestQgsComposerMapGrid )
#include "moc_testqgscomposermapgrid.cxx"
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8544185

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