Skip to content
Permalink
Browse files

Fix python composermap test

  • Loading branch information
mhugent committed Oct 6, 2012
1 parent 9fb3111 commit f1c99553e37a65244092a0143c4c180a6f318bed
Showing with 31 additions and 32 deletions.
  1. +0 −2 tests/src/python/qgscompositionchecker.py
  2. +31 −30 tests/src/python/test_qgscomposermap.py
@@ -97,6 +97,4 @@ def compareImages( self, imgExpected, imgRendered, differenceImagePath ):

#allow pixel deviation of 1 percent
pixelCount = imageWidth * imageHeight;
print "MismatchCount: "+str(mismatchCount)
print "PixelCount: "+str(pixelCount)
return (float(mismatchCount) / float(pixelCount) ) < 0.01
@@ -49,9 +49,9 @@ def __init__(self, methodName):
rasterFileInfo.completeBaseName())
rasterRenderer = QgsMultiBandColorRenderer(
mRasterLayer.dataProvider(), 2, 3, 4)
#mRasterLayer.setRenderer( rasterRenderer )
pipe = mRasterLayer.pipe()
assert pipe.set(rasterRenderer), "Cannot set pipe renderer"
mRasterLayer.setRenderer( rasterRenderer )
#pipe = mRasterLayer.pipe()
#assert pipe.set(rasterRenderer), "Cannot set pipe renderer"
QgsMapLayerRegistry.instance().addMapLayer(mRasterLayer)

# create composition with composer map
@@ -101,7 +101,8 @@ def testGrid(self):
self.mComposerMap.setGridEnabled(False)
self.mComposerMap.setShowGridAnnotation(False)

assert testResult == True
print testResult
assert testResult[0] == True

def testOverviewMap(self):
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
@@ -124,31 +125,31 @@ def testOverviewMap(self):
self.mComposition,
myPngPath)
self.mComposition.removeComposerItem(overviewMap)
assert testResult == True


# def uniqueId(self, mComposerMap, mComposition):
# doc = QDomDocument()
# documentElement = doc.createElement( "ComposerItemClipboard" )
# mComposerMap.writeXML( documentElement, doc )
# mComposition.addItemsFromXML( documentElement, doc, 0, false )
#
# #test if both composer maps have different ids
# newMap = QgsComposerMap()
# mapList = mComposition.composerMapItems()
#
# for mapIt in mapList:
# if mapIt != mComposerMap:
# newMap = mapIt
# break
#
# oldId = mComposerMap.id()
# newId = newMap.id()
#
# mComposition.removeComposerItem( newMap );
# print "old: "+str(oldId)
# print "new "+str(newId)
# assert oldId != newId
assert testResult[0] == True


def uniqueId(self, mComposerMap, mComposition):
doc = QDomDocument()
documentElement = doc.createElement( "ComposerItemClipboard" )
mComposerMap.writeXML( documentElement, doc )
mComposition.addItemsFromXML( documentElement, doc, 0, false )

#test if both composer maps have different ids
newMap = QgsComposerMap()
mapList = mComposition.composerMapItems()

for mapIt in mapList:
if mapIt != mComposerMap:
newMap = mapIt
break

oldId = mComposerMap.id()
newId = newMap.id()

mComposition.removeComposerItem( newMap );
print "old: "+str(oldId)
print "new "+str(newId)
assert oldId != newId

def zebraStyle(self):
mComposerMap.setGridFrameStyle( QgsComposerMap.Zebra )
@@ -160,7 +161,7 @@ def zebraStyle(self):
testResult = checker.testComposition("Composer map zebra",
self.mComposition,
myPngPath)
assert testResult == True
assert testResult[0] == True

if __name__ == '__main__':
unittest.main()

0 comments on commit f1c9955

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