Skip to content
Permalink
Browse files

Test for multiframe html item

  • Loading branch information
mhugent committed Aug 7, 2012
1 parent 95e7832 commit 02d05d1930db5c84730c87ce30d067087bd1d41b
@@ -28,8 +28,9 @@ QgsComposerMultiFrame::QgsComposerMultiFrame(): mComposition( 0 ), mResizeMode(

QgsComposerMultiFrame::~QgsComposerMultiFrame()
{
setResizeMode( UseExistingFrames );
QList<QgsComposerFrame*>::iterator frameIt = mFrameItems.begin();
for ( ; frameIt != mFrameItems.begin(); ++frameIt )
for ( ; frameIt != mFrameItems.end(); ++frameIt )
{
mComposition->removeComposerItem( *frameIt );
delete( *frameIt );
@@ -41,7 +42,7 @@ void QgsComposerMultiFrame::setResizeMode( ResizeMode mode )
if ( mode != mResizeMode )
{
mResizeMode = mode;
recalculateFrameSizes( true );
recalculateFrameSizes( false );
emit changed();
}
}
@@ -49,9 +49,9 @@ bool QgsCompositionChecker::testComposition( int page )
outputImage.setDotsPerMeterY( 300 / 25.4 * 1000 );
outputImage.fill( 0 );
QPainter p( &outputImage );
QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
QRectF targetArea( 0, 0, 3507, 2480 );
mComposition->render( &p, targetArea, sourceArea );
//QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
//QRectF targetArea( 0, 0, 3507, 2480 );
mComposition->renderPage( &p, page );
p.end();
outputImage.save( "/tmp/composerhtml_table_control.png", "PNG" );
return false;
@@ -30,7 +30,7 @@ class TestQgsComposerHtml: public QObject
void init();// will be called before each testfunction is executed.
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
private:
QgsComposition* mComposition;
};
@@ -58,11 +58,46 @@ void TestQgsComposerHtml::cleanup()

void TestQgsComposerHtml::table()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, 0, 0, 100, 200 );
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, 0, 0, 100, 200, false );
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
QgsCompositionChecker checker( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table.png" ) );
QVERIFY( checker.testComposition() );
bool result = checker.testComposition();
mComposition->removeMultiFrame( htmlItem );
delete htmlItem;
QVERIFY( result );
}

void TestQgsComposerHtml::tableMultiFrame()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, 10, 10, 100, 50, false );
htmlItem->setResizeMode( QgsComposerMultiFrame::ExtendToNextPage );
bool result = true;
//page1
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
QgsCompositionChecker checker1( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe1.png" ) );
if ( !checker1.testComposition( 0 ) )
{
result = false;
}
//page2
QgsCompositionChecker checker2( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe2.png" ) );
if ( !checker2.testComposition( 1 ) )
{
result = false;
}
//page 3
QgsCompositionChecker checker3( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe3.png" ) );
if ( !checker3.testComposition( 2 ) )
{
result = false;
}

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


Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 02d05d1

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