Skip to content

Commit

Permalink
fix PyQgsSymbolLayerV2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jul 18, 2013
1 parent 090048f commit 8fc14f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 76 deletions.
128 changes: 53 additions & 75 deletions tests/src/python/test_qgssymbollayerv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

import os

from PyQt4.QtCore import (QString,
QChar,
pyqtWrapperType,
QFile,
QIODevice,
QDir,
Qt)
import qgis
from PyQt4.QtCore import *
from PyQt4.QtXml import QDomDocument

from qgis.core import (QgsCentroidFillSymbolLayerV2,
Expand Down Expand Up @@ -228,13 +223,11 @@ def testBinding(self):
def testQgsSimpleFillSymbolLayerV2(self):
'''Create a new style from a .sld file and match test.
'''
mTestName = QString ('QgsSimpleFillSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsSimpleFillSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -251,7 +244,7 @@ def testQgsSimpleFillSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ffaa7f')
mExpectedValue = u'#ffaa7f'
mValue = mSymbolLayer.borderColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -270,13 +263,11 @@ def testQgsCentroidFillSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString('QgsCentroidFillSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsCentroidFillSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -288,17 +279,17 @@ def testQgsCentroidFillSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'regular_star')
mExpectedValue = u'regular_star'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#55aaff')
mExpectedValue = u'#55aaff'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#00ff00')
mExpectedValue = u'#00ff00'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -307,13 +298,11 @@ def testQgsLinePatternFillSymbolLayer(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsLinePatternFillSymbolLayer')
mFilePath = QDir.toNativeSeparators(
QString ('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsLinePatternFillSymbolLayer'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -325,7 +314,7 @@ def testQgsLinePatternFillSymbolLayer(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ff55ff')
mExpectedValue = u'#ff55ff'
mValue = mSymbolLayer.color().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -352,13 +341,11 @@ def testQgsPointPatternFillSymbolLayer(self):
'''
# at the moment there is an empty createFromSld implementation
# that return nulls
mTestName = QString('QgsPointPatternFillSymbolLayer')
mFilePath = QDir.toNativeSeparators(
QString ('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsPointPatternFillSymbolLayer'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -370,17 +357,17 @@ def testQgsPointPatternFillSymbolLayer(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'triangle')
mExpectedValue = u'triangle'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ffaa00')
mExpectedValue = u'#ffaa00'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ff007f')
mExpectedValue = u'#ff007f'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -399,13 +386,11 @@ def testQgsSVGFillSymbolLayer(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsSVGFillSymbolLayer')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsSVGFillSymbolLayer'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -418,7 +403,7 @@ def testQgsSVGFillSymbolLayer(self):
assert mExpectedValue == mValue, mMessage

mExpectedValue = 'accommodation_camping.svg'
mValue = os.path.basename (str (mSymbolLayer.svgFilePath()))
mValue = os.path.basename(mSymbolLayer.svgFilePath())
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

Expand All @@ -431,13 +416,11 @@ def testQgsMarkerLineSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsMarkerLineSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsMarkerLineSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -454,17 +437,17 @@ def testQgsMarkerLineSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString (u'circle')
mExpectedValue = u'circle'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#000000')
mExpectedValue = u'#000000'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ff0000')
mExpectedValue = u'#ff0000'
mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -473,13 +456,11 @@ def testQgsSimpleLineSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsSimpleLineSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsSimpleLineSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -491,7 +472,7 @@ def testQgsSimpleLineSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#aa007f')
mExpectedValue = u'#aa007f'
mValue = mSymbolLayer.color().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand Down Expand Up @@ -525,13 +506,11 @@ def testQgsEllipseSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsEllipseSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsEllipseSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -543,17 +522,17 @@ def testQgsEllipseSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'circle')
mExpectedValue = u'circle'
mValue = mSymbolLayer.symbolName()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#ffff7f')
mExpectedValue = u'#ffff7f'
mValue = mSymbolLayer.fillColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'#aaaaff')
mExpectedValue = u'#aaaaff'
mValue = mSymbolLayer.outlineColor().name()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -572,13 +551,11 @@ def testQgsFontMarkerSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsFontMarkerSymbolLayerV2')
mFilePath = QDir.toNativeSeparators(
QString('%1/symbol_layer/%2.sld').arg(
unitTestDataPath(), mTestName))
mTestName = 'QgsFontMarkerSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -590,12 +567,12 @@ def testQgsFontMarkerSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'Arial')
mExpectedValue = u'Arial'
mValue = mSymbolLayer.fontFamily()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QChar(0x4d)
mExpectedValue = u"M"
mValue = mSymbolLayer.character()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage
Expand All @@ -614,11 +591,11 @@ def testQgsSvgMarkerSymbolLayerV2(self):
'''
Create a new style from a .sld file and match test
'''
mTestName = QString ('QgsSvgMarkerSymbolLayerV2')
mFilePath = QDir.toNativeSeparators (QString ('%1/symbol_layer/%2.sld').arg (unitTestDataPath(), mTestName))
mTestName = 'QgsSvgMarkerSymbolLayerV2'
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName))

mDoc = QDomDocument(mTestName)
mFile = QFile (mFilePath)
mFile = QFile(mFilePath)
mFile.open(QIODevice.ReadOnly)
mDoc.setContent(mFile,True)
mFile.close()
Expand All @@ -629,8 +606,9 @@ def testQgsSvgMarkerSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

mExpectedValue = QString(u'skull.svg')
mValue = os.path.basename (str(mSymbolLayer.path()))
mExpectedValue = u'skull.svg'
mValue = os.path.basename(mSymbolLayer.path())
print "VALUE", mSymbolLayer.path()
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue)
assert mExpectedValue == mValue, mMessage

Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/symbol_layer/QgsSvgMarkerSymbolLayerV2.sld
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<se:PointSymbolizer>
<se:Graphic>
<se:ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="file:gpsicons/skull.svg"/>
<OnlineResource xlink:type="simple" xlink:href="file:///gpsicons/skull.svg"/>
<Format>image/svg+xml</Format>
</se:ExternalGraphic>
<se:Size>12</se:Size>
Expand Down

0 comments on commit 8fc14f8

Please sign in to comment.