Skip to content

Commit

Permalink
Fixes for composer map grid test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 30, 2015
1 parent 6e6cb66 commit 5b97b7e
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/src/core/testqgscomposermapgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void TestQgsComposerMapGrid::init()
mComposerMap->grid()->setIntervalY( 2000 );
mComposerMap->grid()->setGridLineWidth( 0.5 );
mComposerMap->grid()->setGridLineColor( QColor( 0, 0, 0 ) );
mComposerMap->updateBoundingRect();
mComposition->addComposerMap( mComposerMap );
}

Expand All @@ -133,6 +134,7 @@ void TestQgsComposerMapGrid::grid()
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::Horizontal, QgsComposerMapGrid::Bottom );
mComposerMap->grid()->setAnnotationFontColor( QColor( 255, 0, 0, 150 ) );
mComposerMap->grid()->setBlendMode( QPainter::CompositionMode_Overlay );
mComposerMap->updateBoundingRect();
qWarning() << "grid annotation font: " << mComposerMap->grid()->annotationFont().toString() << " exactMatch:" << mComposerMap->grid()->annotationFont().exactMatch();
QgsCompositionChecker checker( "composermap_grid", mComposition );

Expand All @@ -155,6 +157,7 @@ void TestQgsComposerMapGrid::reprojected()
mComposerMap->grid()->setFrameStyle( QgsComposerMapGrid::ExteriorTicks );
mComposerMap->grid()->setFrameWidth( 10 );
mComposerMap->setFrameEnabled( false );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker( "composermap_gridreprojected", mComposition );

bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -174,6 +177,7 @@ void TestQgsComposerMapGrid::crossGrid()
mComposerMap->grid()->setAnnotationEnabled( false );
mComposerMap->grid()->setGridLineColor( QColor( 0, 255, 0 ) );
mComposerMap->grid()->setBlendMode( QPainter::CompositionMode_SourceOver );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker( "composermap_crossgrid", mComposition );

bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -190,6 +194,7 @@ void TestQgsComposerMapGrid::markerGrid()
mComposerMap->grid()->setStyle( QgsComposerMapGrid::Markers );
mComposerMap->grid()->setAnnotationEnabled( false );
mComposerMap->grid()->setBlendMode( QPainter::CompositionMode_SourceOver );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker( "composermap_markergrid", mComposition );

bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -210,6 +215,7 @@ void TestQgsComposerMapGrid::frameOnly()
mComposerMap->grid()->setFrameWidth( 2.0 );
mComposerMap->grid()->setFramePenSize( 0.5 );
mComposerMap->grid()->setBlendMode( QPainter::CompositionMode_SourceOver );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker( "composermap_gridframeonly", mComposition );

bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -233,6 +239,7 @@ void TestQgsComposerMapGrid::zebraStyle()
mComposerMap->grid()->setFrameFillColor1( QColor( 50, 90, 50, 100 ) );
mComposerMap->grid()->setFrameFillColor2( QColor( 200, 220, 100, 60 ) );
mComposerMap->grid()->setEnabled( true );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_zebrastyle", mComposition );

Expand All @@ -258,17 +265,20 @@ void TestQgsComposerMapGrid::zebraStyleSides()
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameRight, false );
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameTop, false );
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameBottom, false );
mComposerMap->updateBoundingRect();

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

mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameTop, true );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker2( "composermap_zebrastyle_lefttop", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
QVERIFY( testResult2 );

mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameRight, true );
mComposerMap->updateBoundingRect();
QgsCompositionChecker checker3( "composermap_zebrastyle_lefttopright", mComposition );
bool testResult3 = checker3.testComposition( mReport, 0, 0 );
QVERIFY( testResult3 );
Expand Down Expand Up @@ -298,6 +308,7 @@ void TestQgsComposerMapGrid::frameDivisions()
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameRight, true );
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameTop, true );
mComposerMap->grid()->setFrameSideFlag( QgsComposerMapGrid::FrameBottom, true );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_rotatedframe", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -307,6 +318,7 @@ void TestQgsComposerMapGrid::frameDivisions()
mComposerMap->grid()->setFrameDivisions( QgsComposerMapGrid::LongitudeOnly, QgsComposerMapGrid::Right );
mComposerMap->grid()->setFrameDivisions( QgsComposerMapGrid::LatitudeOnly, QgsComposerMapGrid::Top );
mComposerMap->grid()->setFrameDivisions( QgsComposerMapGrid::LongitudeOnly, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_framedivisions", mComposition );
testResult = checker2.testComposition( mReport, 0, 0 );
Expand Down Expand Up @@ -337,6 +349,7 @@ void TestQgsComposerMapGrid::annotationFilter()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_rotatedannotations", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -346,6 +359,7 @@ void TestQgsComposerMapGrid::annotationFilter()
mComposerMap->grid()->setAnnotationDisplay( QgsComposerMapGrid::LongitudeOnly, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationDisplay( QgsComposerMapGrid::LatitudeOnly, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationDisplay( QgsComposerMapGrid::LongitudeOnly, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_filteredannotations", mComposition );
testResult = checker2.testComposition( mReport, 0, 0 );
Expand All @@ -369,6 +383,7 @@ void TestQgsComposerMapGrid::interiorTicks()
mComposerMap->grid()->setFramePenColor( Qt::black );
mComposerMap->grid()->setEnabled( true );
mComposerMap->grid()->setStyle( QgsComposerMapGrid::FrameAnnotationsOnly );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_interiorticks", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -393,6 +408,7 @@ void TestQgsComposerMapGrid::interiorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_interiorticks_annotated", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -402,6 +418,7 @@ void TestQgsComposerMapGrid::interiorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_interiorticks_annotated2", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
Expand All @@ -421,6 +438,7 @@ void TestQgsComposerMapGrid::exteriorTicks()
mComposerMap->grid()->setFramePenColor( Qt::black );
mComposerMap->grid()->setEnabled( true );
mComposerMap->grid()->setStyle( QgsComposerMapGrid::FrameAnnotationsOnly );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_exteriorticks", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -445,6 +463,7 @@ void TestQgsComposerMapGrid::exteriorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_exteriorticks_annotated", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -454,6 +473,7 @@ void TestQgsComposerMapGrid::exteriorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_exteriorticks_annotated2", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
Expand All @@ -473,6 +493,7 @@ void TestQgsComposerMapGrid::interiorExteriorTicks()
mComposerMap->grid()->setFramePenColor( Qt::black );
mComposerMap->grid()->setEnabled( true );
mComposerMap->grid()->setStyle( QgsComposerMapGrid::FrameAnnotationsOnly );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_interiorexteriorticks", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -497,6 +518,7 @@ void TestQgsComposerMapGrid::interiorExteriorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_interiorexteriorticks_annotated", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -506,6 +528,7 @@ void TestQgsComposerMapGrid::interiorExteriorTicksAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_interiorexteriorticks_annotated2", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
Expand All @@ -525,6 +548,7 @@ void TestQgsComposerMapGrid::lineBorder()
mComposerMap->grid()->setFramePenColor( Qt::black );
mComposerMap->grid()->setEnabled( true );
mComposerMap->grid()->setStyle( QgsComposerMapGrid::FrameAnnotationsOnly );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_lineborder", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -549,6 +573,7 @@ void TestQgsComposerMapGrid::lineBorderAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_lineborder_annotated", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -558,6 +583,7 @@ void TestQgsComposerMapGrid::lineBorderAnnotated()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_lineborder_annotated2", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
Expand Down Expand Up @@ -625,6 +651,7 @@ void TestQgsComposerMapGrid::descendingAnnotations()
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::VerticalDescending, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::VerticalDescending, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::VerticalDescending, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker( "composermap_verticaldescending_inside", mComposition );
bool testResult = checker.testComposition( mReport, 0, 0 );
Expand All @@ -634,6 +661,7 @@ void TestQgsComposerMapGrid::descendingAnnotations()
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->updateBoundingRect();

QgsCompositionChecker checker2( "composermap_verticaldescending_outside", mComposition );
bool testResult2 = checker2.testComposition( mReport, 0, 0 );
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_qgscomposermapgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def testGrid(self):
self.mComposerMap.grid().setAnnotationDirection( QgsComposerMapGrid.Horizontal, QgsComposerMapGrid.Bottom )
self.mComposerMap.grid().setAnnotationFontColor( QColor( 255, 0, 0, 150 ) )
self.mComposerMap.grid().setBlendMode( QPainter.CompositionMode_Overlay )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_grid', self.mComposition)
myTestResult, myMessage = checker.testComposition()
Expand All @@ -94,6 +95,7 @@ def testCrossGrid(self):
self.mComposerMap.grid().setGridLineColor( QColor( 0, 255, 0 ) )
self.mComposerMap.grid().setGridLineWidth( 0.5 )
self.mComposerMap.grid().setBlendMode( QPainter.CompositionMode_SourceOver )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_crossgrid', self.mComposition)
myTestResult, myMessage = checker.testComposition()
Expand All @@ -114,6 +116,7 @@ def testMarkerGrid(self):
self.mComposerMap.grid().setIntervalY( 2000 )
self.mComposerMap.grid().setAnnotationEnabled( False )
self.mComposerMap.grid().setBlendMode( QPainter.CompositionMode_SourceOver )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_markergrid', self.mComposition)
myTestResult, myMessage = checker.testComposition()
Expand All @@ -135,6 +138,7 @@ def testFrameOnly(self):
self.mComposerMap.grid().setFrameStyle( QgsComposerMapGrid.Zebra )
self.mComposerMap.grid().setFramePenSize( 0.5 )
self.mComposerMap.grid().setBlendMode( QPainter.CompositionMode_SourceOver )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_gridframeonly', self.mComposition)
myTestResult, myMessage = checker.testComposition()
Expand Down Expand Up @@ -164,6 +168,7 @@ def testZebraStyle(self):
self.mComposerMap.grid().setFrameFillColor1( QColor( 50, 90, 50, 100 ) )
self.mComposerMap.grid().setFrameFillColor2( QColor( 200, 220, 100, 60 ) )
self.mComposerMap.grid().setEnabled( True )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_zebrastyle', self.mComposition)
myTestResult, myMessage = checker.testComposition( 0, 100 )
Expand Down Expand Up @@ -191,17 +196,20 @@ def testZebraStyleSides(self):
self.mComposerMap.grid().setFrameSideFlag( QgsComposerMapGrid.FrameRight, False )
self.mComposerMap.grid().setFrameSideFlag( QgsComposerMapGrid.FrameTop, False )
self.mComposerMap.grid().setFrameSideFlag( QgsComposerMapGrid.FrameBottom, False )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_zebrastyle_left', self.mComposition)
myTestResult, myMessage = checker.testComposition( 0, 100 )
assert myTestResult, myMessage

self.mComposerMap.grid().setFrameSideFlag( QgsComposerMapGrid.FrameTop, True )
self.mComposerMap.updateBoundingRect()
checker = QgsCompositionChecker('composermap_zebrastyle_lefttop', self.mComposition)
myTestResult, myMessage = checker.testComposition( 0, 100 )
assert myTestResult, myMessage

self.mComposerMap.grid().setFrameSideFlag( QgsComposerMapGrid.FrameRight, True )
self.mComposerMap.updateBoundingRect()
checker = QgsCompositionChecker('composermap_zebrastyle_lefttopright', self.mComposition)
myTestResult, myMessage = checker.testComposition( 0, 100 )
assert myTestResult, myMessage
Expand All @@ -223,6 +231,7 @@ def testInteriorTicks(self):
self.mComposerMap.grid().setFramePenColor( QColor( 0, 0, 0 ) )
self.mComposerMap.grid().setEnabled( True )
self.mComposerMap.grid().setStyle( QgsComposerMapGrid.FrameAnnotationsOnly )
self.mComposerMap.updateBoundingRect()

checker = QgsCompositionChecker('composermap_interiorticks', self.mComposition)
myTestResult, myMessage = checker.testComposition( 0, 100 )
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b97b7e

Please sign in to comment.