@@ -34,17 +34,29 @@ class TestQgsComposerHtml: public QObject
34
34
void tableMultiFrame (); // tests multiframe capabilities of composer html
35
35
private:
36
36
QgsComposition* mComposition ;
37
+ QString mReport ;
37
38
};
38
39
39
40
void TestQgsComposerHtml::initTestCase ()
40
41
{
41
42
mComposition = new QgsComposition ( 0 );
42
43
mComposition ->setPaperSize ( 297 , 210 ); // A4 landscape
44
+
45
+ mReport = " <h1>Composer HTML Tests</h1>\n " ;
43
46
}
44
47
45
48
void TestQgsComposerHtml::cleanupTestCase ()
46
49
{
47
50
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
+ }
48
60
}
49
61
50
62
void TestQgsComposerHtml::init ()
@@ -64,9 +76,9 @@ void TestQgsComposerHtml::table()
64
76
htmlFrame->setFrameEnabled ( true );
65
77
htmlItem->addFrame ( htmlFrame );
66
78
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 );
70
82
mComposition ->removeMultiFrame ( htmlItem );
71
83
delete htmlItem;
72
84
QVERIFY ( result );
@@ -79,30 +91,18 @@ void TestQgsComposerHtml::tableMultiFrame()
79
91
htmlItem->addFrame ( htmlFrame );
80
92
htmlItem->setResizeMode ( QgsComposerMultiFrame::RepeatUntilFinished );
81
93
82
- bool result = true ;
83
94
// page1
84
95
htmlItem->setUrl ( QUrl ( QString ( " file:///%1" ).arg ( QString ( TEST_DATA_DIR ) + QDir::separator () + " html_table.html" ) ) );
85
96
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
+
92
100
// 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;
99
103
// 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;
106
106
107
107
mComposition ->removeMultiFrame ( htmlItem );
108
108
delete htmlItem;
0 commit comments