Skip to content

Commit a1a92cd

Browse files
committed
[tests] Update composer html tests
1 parent f3d5e0b commit a1a92cd

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

tests/src/core/testqgscomposerhtml.cpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,29 @@ class TestQgsComposerHtml: public QObject
3434
void tableMultiFrame(); //tests multiframe capabilities of composer html
3535
private:
3636
QgsComposition* mComposition;
37+
QString mReport;
3738
};
3839

3940
void TestQgsComposerHtml::initTestCase()
4041
{
4142
mComposition = new QgsComposition( 0 );
4243
mComposition->setPaperSize( 297, 210 ); //A4 landscape
44+
45+
mReport = "<h1>Composer HTML Tests</h1>\n";
4346
}
4447

4548
void TestQgsComposerHtml::cleanupTestCase()
4649
{
4750
delete mComposition;
51+
52+
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
53+
QFile myFile( myReportFile );
54+
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
55+
{
56+
QTextStream myQTextStream( &myFile );
57+
myQTextStream << mReport;
58+
myFile.close();
59+
}
4860
}
4961

5062
void TestQgsComposerHtml::init()
@@ -64,9 +76,9 @@ void TestQgsComposerHtml::table()
6476
htmlFrame->setFrameEnabled( true );
6577
htmlItem->addFrame( htmlFrame );
6678
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
67-
QgsCompositionChecker checker( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
68-
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table.png" ) );
69-
bool result = checker.testComposition();
79+
80+
QgsCompositionChecker checker( "composerhtml_table", mComposition );
81+
bool result = checker.testComposition( mReport );
7082
mComposition->removeMultiFrame( htmlItem );
7183
delete htmlItem;
7284
QVERIFY( result );
@@ -79,30 +91,18 @@ void TestQgsComposerHtml::tableMultiFrame()
7991
htmlItem->addFrame( htmlFrame );
8092
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
8193

82-
bool result = true;
8394
//page1
8495
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
8596
htmlItem->frame( 0 )->setFrameEnabled( true );
86-
QgsCompositionChecker checker1( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
87-
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe1.png" ) );
88-
if ( !checker1.testComposition( 0 ) )
89-
{
90-
result = false;
91-
}
97+
QgsCompositionChecker checker1( "composerhtml_multiframe1", mComposition );
98+
bool result = checker1.testComposition( mReport );
99+
92100
//page2
93-
QgsCompositionChecker checker2( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
94-
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe2.png" ) );
95-
if ( !checker2.testComposition( 1 ) )
96-
{
97-
result = false;
98-
}
101+
QgsCompositionChecker checker2( "composerhtml_multiframe2", mComposition );
102+
result = checker2.testComposition( mReport, 1 ) && result;
99103
//page 3
100-
QgsCompositionChecker checker3( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
101-
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table_multiframe3.png" ) );
102-
if ( !checker3.testComposition( 2 ) )
103-
{
104-
result = false;
105-
}
104+
QgsCompositionChecker checker3( "composerhtml_multiframe3", mComposition );
105+
result = checker3.testComposition( mReport, 2 ) && result;
106106

107107
mComposition->removeMultiFrame( htmlItem );
108108
delete htmlItem;

0 commit comments

Comments
 (0)