Skip to content

Commit

Permalink
Test for multiframe html item
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Aug 7, 2012
1 parent 95e7832 commit 02d05d1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -41,7 +42,7 @@ void QgsComposerMultiFrame::setResizeMode( ResizeMode mode )
if ( mode != mResizeMode )
{
mResizeMode = mode;
recalculateFrameSizes( true );
recalculateFrameSizes( false );
emit changed();
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/qgscompositionchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 38 additions & 3 deletions tests/src/core/testqgscomposerhtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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 );
}


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 02d05d1

Please sign in to comment.