Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Created test to replicate issue #7023
  • Loading branch information
timlinux committed Jan 22, 2013
1 parent 7010fbd commit 2fbe172
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/src/python/test_qgsrasterlayer.py
Expand Up @@ -151,6 +151,18 @@ def testTransparency(self):
myResultFlag = myChecker.runTest("raster_transparency_python");
assert myResultFlag, "Raster transparency rendering test failed"

def testIssue7023(self):
"""Check if converting a raster from 1.8 to 2 works."""
myPath = os.path.join(unitTestDataPath('raster'),
'raster-pallette-crash2.tif')
myFileInfo = QFileInfo(myPath)
myBaseName = myFileInfo.baseName()
myRasterLayer = QgsRasterLayer(myPath, myBaseName)
myMessage = 'Raster not loaded: %s' % myPath
assert myRasterLayer.isValid(), myMessage
# crash on next line
QgsMapLayerRegistry.addMapLayers([myRasterLayer])

def testShaderCrash(self):
"""Check if we assign a shader and then reassign it no crash occurs."""
myPath = os.path.join(unitTestDataPath('raster'),
Expand Down
44 changes: 44 additions & 0 deletions tests/testdata/raster/raster-pallette-crash2.qml
@@ -0,0 +1,44 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="1.8.0-Lisboa" minimumScale="0" maximumScale="1e+08" hasScaleBasedVisibilityFlag="0">
<transparencyLevelInt>255</transparencyLevelInt>
<rasterproperties>
<mDrawingStyle>PalettedColor</mDrawingStyle>
<mColorShadingAlgorithm>ColorRampShader</mColorShadingAlgorithm>
<mInvertColor boolean="false"/>
<mRedBandName>Not Set</mRedBandName>
<mGreenBandName>Not Set</mGreenBandName>
<mBlueBandName>Not Set</mBlueBandName>
<mGrayBandName>Band 1</mGrayBandName>
<mStandardDeviations>0</mStandardDeviations>
<mUserDefinedRGBMinimumMaximum boolean="false"/>
<mRGBMinimumMaximumEstimated boolean="true"/>
<mUserDefinedGrayMinimumMaximum boolean="false"/>
<mGrayMinimumMaximumEstimated boolean="true"/>
<mContrastEnhancementAlgorithm>NoEnhancement</mContrastEnhancementAlgorithm>
<contrastEnhancementMinMaxValues>
<minMaxEntry>
<min>-1.79769e+308</min>
<max>1.79769e+308</max>
</minMaxEntry>
</contrastEnhancementMinMaxValues>
<mNoDataValue mValidNoDataValue="true">nan</mNoDataValue>
<singleValuePixelList>
<pixelListEntry pixelValue="0.419576" percentTransparent="100"/>
<pixelListEntry pixelValue="94.209307" percentTransparent="30"/>
<pixelListEntry pixelValue="187.999039" percentTransparent="30"/>
<pixelListEntry pixelValue="281.788770" percentTransparent="30"/>
<pixelListEntry pixelValue="375.578502" percentTransparent="30"/>
</singleValuePixelList>
<threeValuePixelList>
<pixelListEntry red="nan" blue="nan" green="nan" percentTransparent="100"/>
</threeValuePixelList>
<customColorRamp>
<colorRampType>DISCRETE</colorRampType>
<colorRampEntry red="238" blue="238" value="0.419576" green="255" label="0.42 people/cell"/>
<colorRampEntry red="255" blue="127" value="94.209307" green="255" label=""/>
<colorRampEntry red="225" blue="0" value="187.999039" green="85" label="188.00 people/cell"/>
<colorRampEntry red="228" blue="27" value="281.788770" green="0" label=""/>
<colorRampEntry red="115" blue="0" value="375.578502" green="0" label="375.58 people/cell"/>
</customColorRamp>
</rasterproperties>
</qgis>
Binary file added tests/testdata/raster/raster-pallette-crash2.tif
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/testdata/raster/raster-pallette-crash2.tif.aux.xml
@@ -0,0 +1,5 @@
<PAMDataset>
<PAMRasterBand band="1">
<NoDataValue le_hex_equiv="000000000000F87F">nan</NoDataValue>
</PAMRasterBand>
</PAMDataset>

0 comments on commit 2fbe172

Please sign in to comment.