[tests] Update composer html tests
@ -34,17 +34,29 @@ class TestQgsComposerHtml: public QObject
|
|||||||
void tableMultiFrame(); //tests multiframe capabilities of composer html
|
void tableMultiFrame(); //tests multiframe capabilities of composer html
|
||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
|
QString mReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestQgsComposerHtml::initTestCase()
|
void TestQgsComposerHtml::initTestCase()
|
||||||
{
|
{
|
||||||
mComposition = new QgsComposition( 0 );
|
mComposition = new QgsComposition( 0 );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
|
mReport = "<h1>Composer HTML Tests</h1>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsComposerHtml::cleanupTestCase()
|
void TestQgsComposerHtml::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
|
|
||||||
|
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
|
||||||
|
QFile myFile( myReportFile );
|
||||||
|
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
|
||||||
|
{
|
||||||
|
QTextStream myQTextStream( &myFile );
|
||||||
|
myQTextStream << mReport;
|
||||||
|
myFile.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsComposerHtml::init()
|
void TestQgsComposerHtml::init()
|
||||||
@ -64,9 +76,9 @@ void TestQgsComposerHtml::table()
|
|||||||
htmlFrame->setFrameEnabled( true );
|
htmlFrame->setFrameEnabled( true );
|
||||||
htmlItem->addFrame( htmlFrame );
|
htmlItem->addFrame( htmlFrame );
|
||||||
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
|
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" ) );
|
QgsCompositionChecker checker( "composerhtml_table", mComposition );
|
||||||
bool result = checker.testComposition();
|
bool result = checker.testComposition( mReport );
|
||||||
mComposition->removeMultiFrame( htmlItem );
|
mComposition->removeMultiFrame( htmlItem );
|
||||||
delete htmlItem;
|
delete htmlItem;
|
||||||
QVERIFY( result );
|
QVERIFY( result );
|
||||||
@ -79,30 +91,18 @@ void TestQgsComposerHtml::tableMultiFrame()
|
|||||||
htmlItem->addFrame( htmlFrame );
|
htmlItem->addFrame( htmlFrame );
|
||||||
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
|
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
|
||||||
|
|
||||||
bool result = true;
|
|
||||||
//page1
|
//page1
|
||||||
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
|
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
|
||||||
htmlItem->frame( 0 )->setFrameEnabled( true );
|
htmlItem->frame( 0 )->setFrameEnabled( true );
|
||||||
QgsCompositionChecker checker1( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
|
QgsCompositionChecker checker1( "composerhtml_multiframe1", mComposition );
|
||||||
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe1.png" ) );
|
bool result = checker1.testComposition( mReport );
|
||||||
if ( !checker1.testComposition( 0 ) )
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
//page2
|
//page2
|
||||||
QgsCompositionChecker checker2( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
|
QgsCompositionChecker checker2( "composerhtml_multiframe2", mComposition );
|
||||||
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe2.png" ) );
|
result = checker2.testComposition( mReport, 1 ) && result;
|
||||||
if ( !checker2.testComposition( 1 ) )
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
//page 3
|
//page 3
|
||||||
QgsCompositionChecker checker3( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
|
QgsCompositionChecker checker3( "composerhtml_multiframe3", mComposition );
|
||||||
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe3.png" ) );
|
result = checker3.testComposition( mReport, 2 ) && result;
|
||||||
if ( !checker3.testComposition( 2 ) )
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mComposition->removeMultiFrame( htmlItem );
|
mComposition->removeMultiFrame( htmlItem );
|
||||||
delete htmlItem;
|
delete htmlItem;
|
||||||
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |