Skip to content
Permalink
Browse files

Add tests for composer html multi frames using smart breaks

  • Loading branch information
nyalldawson committed May 6, 2014
1 parent 68de427 commit 1af7581bf0faf20f14ce1de6c9e8d3858b0e605d
@@ -32,6 +32,7 @@ class TestQgsComposerHtml: public QObject
void cleanup();// will be called after every testfunction.
void table(); //test if rendering of the composition with composr map is correct
void tableMultiFrame(); //tests multiframe capabilities of composer html
void htmlMultiFrameSmarkBreak(); //tests smart page breaks in html multi frame
private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
@@ -111,6 +112,32 @@ void TestQgsComposerHtml::tableMultiFrame()
QVERIFY( result );
}

void TestQgsComposerHtml::htmlMultiFrameSmarkBreak()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, false );
QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 10, 10, 100, 50 );
htmlItem->addFrame( htmlFrame );
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
htmlItem->setUseSmartBreaks( true );

//page1
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
htmlItem->frame( 0 )->setFrameEnabled( true );
QgsCompositionChecker checker1( "composerhtml_smartbreaks1", mComposition );
bool result = checker1.testComposition( mReport );

//page2
QgsCompositionChecker checker2( "composerhtml_smartbreaks2", mComposition );
result = checker2.testComposition( mReport, 1 ) && result;
//page 3
QgsCompositionChecker checker3( "composerhtml_smartbreaks3", mComposition );
result = checker3.testComposition( mReport, 2 ) && result;

mComposition->removeMultiFrame( htmlItem );
delete htmlItem;
QVERIFY( result );
}


QTEST_MAIN( TestQgsComposerHtml )
#include "moc_testqgscomposerhtml.cxx"
@@ -103,6 +103,40 @@ def testTableMultiFrame(self):

assert myTestResult, myMessage

def testHtmlSmartBreaks(self):
"""Test rendering to multiframes with smart breaks."""
composerHtml = QgsComposerHtml(self.mComposition, False)
htmlFrame = QgsComposerFrame(self.mComposition, composerHtml,
10, 10, 100, 50)
composerHtml.addFrame(htmlFrame)
composerHtml.setResizeMode(
QgsComposerMultiFrame.RepeatUntilFinished)
composerHtml.setUseSmartBreaks( True )
composerHtml.setUrl(self.htmlUrl())
composerHtml.frame(0).setFrameEnabled(True)

print "Checking page 1"
myPage = 0
checker1 = QgsCompositionChecker('composerhtml_smartbreaks1', self.mComposition)
myTestResult, myMessage = checker1.testComposition( myPage )
assert myTestResult, myMessage

print "Checking page 2"
myPage = 1
checker2 = QgsCompositionChecker('composerhtml_smartbreaks2', self.mComposition)
myTestResult, myMessage = checker2.testComposition( myPage )
assert myTestResult, myMessage

print "Checking page 3"
myPage = 2
checker3 = QgsCompositionChecker('composerhtml_smartbreaks3', self.mComposition)
myTestResult, myMessage = checker3.testComposition( myPage )

self.mComposition.removeMultiFrame( composerHtml )
composerHtml = None

assert myTestResult, myMessage

def testComposerHtmlAccessor(self):
"""Test that we can retrieve the ComposerHtml instance given an item.
"""
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 1af7581

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