Skip to content
Permalink
Browse files

Add SIP and Python unit test for overview autocentering.

Work funded by Tuscany Region - SITA. Contract "Support to the use
of GFOSS (Geographic Free and Open Source Software) Desktop tools"
(CIG Z3B06FA6D7).
  • Loading branch information
Hugo Mercier
Hugo Mercier committed Jun 17, 2013
1 parent 9d20a69 commit f0f72ca8a9141dddc4524618fee194e362d0d7d3
Showing with 32 additions and 1 deletion.
  1. +6 −1 python/core/composer/qgscomposermap.sip
  2. +26 −0 tests/src/python/test_qgscomposermap.py
@@ -300,7 +300,12 @@ class QgsComposerMap : QgsComposerItem
/**Sets flag if overview frame should be inverted
@note this function was added in version 1.9*/
void setOverviewInverted( bool inverted );
bool overviewInverted() const;
bool overviewInverted() const;

/** Returns true if the extent is forced to center on the overview when the overview is outside the extent */
bool overviewCentered() const;
/** Set the overview's centering mode */
void setOverviewCentered( bool centered );

/**Sets mId to a number not yet used in the composition. mId is kept if it is not in use.
Usually, this function is called before adding the composer map to the composition*/
@@ -181,6 +181,32 @@ def testOverviewMapInvert(self):
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

def testOverviewMapCenter(self):
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375+5000, 3341423.125,
789262.375+5000, 3343323.125)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(False)
overviewMap.setOverviewCentered(True)
checker = QgsCompositionChecker()
myPngPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_landsat_overview_center.png')
myTestResult, myMessage = checker.testComposition(
'Composer map overview centered',
self.mComposition,
myPngPath)
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

# Fails because addItemsFromXML has been commented out in sip
@expectedFailure
def testuniqueId(self):

0 comments on commit f0f72ca

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