67 changes: 20 additions & 47 deletions tests/src/python/test_qgscomposerhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,28 @@ def tearDown(self):
"""Run after each test."""
print "Tear down"

def controlImagePath(self, theImageName):
"""Helper to get the path to a control image."""
myPath = os.path.join(TEST_DATA_DIR,
"control_images",
"expected_composerhtml",
theImageName)
assert os.path.exists(myPath)
return myPath

def htmlUrl(self):
"""Helper to get the url of the html doc."""
myPath = os.path.join(TEST_DATA_DIR, "html_table.html")
myUrl = QUrl("file:///%1").arg(myPath)
myUrl = QUrl("file:///" + myPath)
return myUrl

@expectedFailure
def XtestTable(self):
def testTable(self):
"""Test we can render a html table in a single frame."""
composerHtml = QgsComposerHtml(self.mComposition, False)
htmlFrame = QgsComposerFrame(self.mComposition,
composerHtml, 0, 0, 100, 200)
htmlFrame.setFrameEnabled(True)
composerHtml.addFrame(htmlFrame)
composerHtml.setUrl(self.htmlUrl())
checker = QgsCompositionChecker()
myResult, myMessage = checker.testComposition(
"Composer html table",
self.mComposition,
self.controlImagePath("composerhtml_table.png"))

checker = QgsCompositionChecker('composerhtml_table', self.mComposition)
myTestResult, myMessage = checker.testComposition()

qDebug(myMessage)
assert myResult, myMessage
assert myTestResult, myMessage

@expectedFailure
def XtestTableMultiFrame(self):
def testTableMultiFrame(self):
"""Test we can render to multiframes."""
composerHtml = QgsComposerHtml(self.mComposition, False)
htmlFrame = QgsComposerFrame(self.mComposition, composerHtml,
Expand All @@ -87,38 +75,23 @@ def XtestTableMultiFrame(self):
composerHtml.setUrl(self.htmlUrl())
composerHtml.frame(0).setFrameEnabled(True)

myPage = 0
checker1 = QgsCompositionChecker()
myControlImage = self.controlImagePath(
"composerhtml_table_multiframe1.png")
print "Checking page 1"
myResult, myMessage = checker1.testComposition("Composer html table",
self.mComposition,
myControlImage,
myPage)
assert myResult, myMessage
myPage = 0
checker1 = QgsCompositionChecker('composerhtml_multiframe1', self.mComposition)
myTestResult, myMessage = checker1.testComposition( myPage )
assert myTestResult, myMessage

myPage = 1
checker2 = QgsCompositionChecker()
myControlImage = self.controlImagePath(
"composerhtml_table_multiframe2.png")
print "Checking page 2"
myResult, myMessage = checker2.testComposition("Composer html table",
self.mComposition,
myControlImage,
myPage)
assert myResult, myMessage
myPage = 1
checker2 = QgsCompositionChecker('composerhtml_multiframe2', self.mComposition)
myTestResult, myMessage = checker2.testComposition( myPage )
assert myTestResult, myMessage

myPage = 2
checker3 = QgsCompositionChecker()
myControlImage = self.controlImagePath(
"composerhtml_table_multiframe3.png")
myResult, myMessage = checker3.testComposition("Composer html table",
self.mComposition,
myControlImage,
myPage)
print "Checking page 3"
assert myResult, myMessage
myPage = 2
checker3 = QgsCompositionChecker('composerhtml_multiframe3', self.mComposition)
myTestResult, myMessage = checker3.testComposition( myPage )
assert myTestResult, myMessage

def testComposerHtmlAccessor(self):
"""Test that we can retrieve the ComposerHtml instance given an item.
Expand Down
72 changes: 20 additions & 52 deletions tests/src/python/test_qgscomposermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,8 @@ def testGrid(self):
QgsComposerMap.Bottom)
self.mComposerMap.setAnnotationFontColor(QColor(255,0,0,150))
self.mComposerMap.setGridBlendMode(QPainter.CompositionMode_Overlay)
checker = QgsCompositionChecker()
myPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_landsat_grid.png')
myTestResult, myMessage = checker.testComposition('Composer map grid',
self.mComposition, myPath)
checker = QgsCompositionChecker('composermap_grid', self.mComposition)
myTestResult, myMessage = checker.testComposition()
self.mComposerMap.setGridEnabled(False)
self.mComposerMap.setShowGridAnnotation(False)

Expand All @@ -119,15 +114,8 @@ def testOverviewMap(self):
793062.375, 3350923.125)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
checker = QgsCompositionChecker()
myPngPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_landsat_overview.png')
myTestResult, myMessage = checker.testComposition(
'Composer map overview',
self.mComposition,
myPngPath)
checker = QgsCompositionChecker('composermap_overview', self.mComposition)
myTestResult, myMessage = checker.testComposition()
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

Expand All @@ -144,15 +132,8 @@ def testOverviewMapBlend(self):
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewBlendMode(QPainter.CompositionMode_Multiply)
checker = QgsCompositionChecker()
myPngPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_landsat_overview_blend.png')
myTestResult, myMessage = checker.testComposition(
'Composer map overview blending',
self.mComposition,
myPngPath)
checker = QgsCompositionChecker('composermap_overview_blending', self.mComposition)
myTestResult, myMessage = checker.testComposition()
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

Expand All @@ -169,15 +150,8 @@ def testOverviewMapInvert(self):
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(True)
checker = QgsCompositionChecker()
myPngPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_landsat_overview_invert.png')
myTestResult, myMessage = checker.testComposition(
'Composer map overview inverted',
self.mComposition,
myPngPath)
checker = QgsCompositionChecker('composermap_overview_invert', self.mComposition)
myTestResult, myMessage = checker.testComposition()
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

Expand All @@ -195,15 +169,8 @@ def testOverviewMapCenter(self):
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)
checker = QgsCompositionChecker('composermap_overview_center', self.mComposition)
myTestResult, myMessage = checker.testComposition()
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

Expand Down Expand Up @@ -239,15 +206,16 @@ def testZebraStyle(self):
self.mComposerMap.setGridEnabled(True)
self.mComposerMap.setGridIntervalX(2000)
self.mComposerMap.setGridIntervalY(2000)
checker = QgsCompositionChecker()
myPngPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composermap',
'composermap_zebra_style.png')
testResult, myMessage = checker.testComposition('Composer map zebra',
self.mComposition,
myPngPath)
assert testResult == True, myMessage
self.mComposerMap.setGridFrameWidth( 10 )
self.mComposerMap.setGridFramePenSize( 1 )
self.mComposerMap.setGridPenWidth( 0.5 )
self.mComposerMap.setGridFramePenColor( QColor( 255, 100, 0, 200 ) )
self.mComposerMap.setGridFrameFillColor1( QColor( 50, 90, 50, 100 ) )
self.mComposerMap.setGridFrameFillColor2( QColor( 200, 220, 100, 60 ) )

checker = QgsCompositionChecker('composermap_zebrastyle', self.mComposition)
myTestResult, myMessage = checker.testComposition()
assert myTestResult == True, myMessage

def testWorldFileGeneration( self ):
myRectangle = QgsRectangle(781662.375, 3339523.125, 793062.375, 3345223.125)
Expand Down
36 changes: 8 additions & 28 deletions tests/src/python/test_qgscomposershapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ def testRectangle(self):

self.mComposerShape.setShapeType(QgsComposerShape.Rectangle)

checker = QgsCompositionChecker()
myPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composershapes',
'composershape_rectangle.png')
myTestResult, myMessage = checker.testComposition('Composer shapes rectangle',
self.mComposition, myPath)
checker = QgsCompositionChecker('composershapes_rectangle', self.mComposition)
myTestResult, myMessage = checker.testComposition()

assert myTestResult == True, myMessage

Expand All @@ -68,13 +63,8 @@ def testEllipse(self):

self.mComposerShape.setShapeType(QgsComposerShape.Ellipse)

checker = QgsCompositionChecker()
myPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composershapes',
'composershape_ellipse.png')
myTestResult, myMessage = checker.testComposition('Composer shapes ellipse',
self.mComposition, myPath)
checker = QgsCompositionChecker('composershapes_ellipse', self.mComposition)
myTestResult, myMessage = checker.testComposition()

assert myTestResult == True, myMessage

Expand All @@ -83,13 +73,8 @@ def testTriangle(self):

self.mComposerShape.setShapeType(QgsComposerShape.Triangle)

checker = QgsCompositionChecker()
myPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composershapes',
'composershape_triangle.png')
myTestResult, myMessage = checker.testComposition('Composer shapes triangle',
self.mComposition, myPath)
checker = QgsCompositionChecker('composershapes_triangle', self.mComposition)
myTestResult, myMessage = checker.testComposition()

assert myTestResult == True, myMessage

Expand All @@ -99,13 +84,8 @@ def testRoundedRectangle(self):
self.mComposerShape.setShapeType(QgsComposerShape.Rectangle)
self.mComposerShape.setCornerRadius(30)

checker = QgsCompositionChecker()
myPath = os.path.join(TEST_DATA_DIR,
'control_images',
'expected_composershapes',
'composershape_roundedrectangle.png')
myTestResult, myMessage = checker.testComposition('Composer shapes rounded rectangle',
self.mComposition, myPath)
checker = QgsCompositionChecker('composershapes_roundedrect', self.mComposition)
myTestResult, myMessage = checker.testComposition()

self.mComposerShape.setCornerRadius(0)
assert myTestResult == True, myMessage
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.