Ejemplo n.º 1
0
 def Xtest_renderTable(self):
     """Test that html renders nicely. Commented out for now until we work
     out how to get webkit to do offscreen rendering nicely."""
     myFilename = 'test_floodimpact.tif'
     myLayer, myType = loadLayer(myFilename)
     CANVAS.refresh()
     del myType
     myMessage = 'Layer is not valid: %s' % myFilename
     assert myLayer.isValid(), myMessage
     myMap = ISMap(IFACE)
     myMap.setImpactLayer(myLayer)
     myPixmap = myMap.renderImpactTable()
     assert myPixmap is not None
     myExpectedWidth = 500
     myExpectedHeight = 300
     myMessage = 'Invalid width - got %s expected %s' % (
                                 myPixmap.width(),
                                 myExpectedWidth)
     assert myPixmap.width() == myExpectedWidth, myMessage
     myMessage = 'Invalid height - got %s expected %s' % (
                                 myPixmap.height(),
                                 myExpectedHeight)
     assert myPixmap.height() == myExpectedHeight
     myPath = os.path.join(getTempDir(), 'renderImpactTable.png')
     myPixmap.save(myPath, 'PNG')
     myExpectedHash = 'c9164d5c2bb85c6081905456ab827f3e'
     assertHashForFile(myExpectedHash, myPath)
Ejemplo n.º 2
0
 def addSymbolToLegend(self):
     """Test we can add a symbol to the legend."""
     myLayer, myType = loadLayer('test_floodimpact.tif')
     del myType
     myMap = ISMap(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.legend = None
     mySymbol = QgsSymbol()
     mySymbol.setColor(QtGui.QColor(12, 34, 56))
     myMap.addSymbolToLegend(mySymbol,
                             theMin=0,
                             theMax=2,
                             theCategory=None,
                             theLabel='Foo')
     myPath = os.path.join(getTempDir(), 'addSymbolToLegend.png')
     myMap.legend.save(myPath, 'PNG')
     myExpectedHash = '1234'
     assertHashForFile(myExpectedHash, myPath)