1515 * *
1616 ***************************************************************************/
1717
18+ #include " qgsapplication.h"
1819#include " qgscomposerhtml.h"
1920#include " qgscomposerframe.h"
2021#include " qgscomposition.h"
2122#include " qgscompositionchecker.h"
23+ #include " qgsfontutils.h"
2224#include < QObject>
2325#include < QtTest>
2426
@@ -41,14 +43,21 @@ class TestQgsComposerHtml: public QObject
4143 QgsComposition* mComposition ;
4244 QgsMapSettings mMapSettings ;
4345 QString mReport ;
46+ QFont mTestFont ;
4447};
4548
4649void TestQgsComposerHtml::initTestCase ()
4750{
51+ QgsApplication::init ();
52+ QgsApplication::initQgis ();
53+
4854 mComposition = new QgsComposition ( mMapSettings );
4955 mComposition ->setPaperSize ( 297 , 210 ); // A4 landscape
5056
5157 mReport = " <h1>Composer HTML Tests</h1>\n " ;
58+
59+ QgsFontUtils::loadStandardTestFonts ( QStringList () << " Oblique" );
60+ mTestFont = QgsFontUtils::getStandardTestFont ( " Oblique " );
5261}
5362
5463void TestQgsComposerHtml::cleanupTestCase ()
@@ -82,7 +91,7 @@ void TestQgsComposerHtml::sourceMode()
8291 htmlFrame->setFrameEnabled ( true );
8392 htmlItem->addFrame ( htmlFrame );
8493 htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
85- htmlItem->setHtml ( QString ( " <p><i>Test manual <b>html</b></i></p>" ) );
94+ htmlItem->setHtml ( QString ( " <p style= \" font-family: %1 \" ><i>Test manual <b>html</b></i></p>" ). arg ( mTestFont . family () ) );
8695 htmlItem->loadHtml ();
8796
8897 QgsCompositionChecker checker ( " composerhtml_manual" , mComposition );
@@ -99,7 +108,7 @@ void TestQgsComposerHtml::userStylesheets()
99108 htmlFrame->setFrameEnabled ( true );
100109 htmlItem->addFrame ( htmlFrame );
101110 htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
102- htmlItem->setHtml ( QString ( " <p><i>Test user stylesheets <b>html</b></i></p>" ) );
111+ htmlItem->setHtml ( QString ( " <p style= \" font-family: %1 \" ><i>Test user stylesheets <b>html</b></i></p>" ). arg ( mTestFont . family () ) );
103112
104113 // set user stylesheet
105114 htmlItem->setUserStylesheet ( QString ( " b { color: red; } i { color: green; }" ) );
@@ -121,7 +130,8 @@ void TestQgsComposerHtml::evalExpressions()
121130 htmlItem->addFrame ( htmlFrame );
122131 htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
123132 htmlItem->setEvaluateExpressions ( true );
124- htmlItem->setHtml ( QString ( " <p>Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ) );
133+ htmlItem->setHtml ( QString ( " <p style=\" font-family: %1\" >Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ).arg ( mTestFont .family () ) );
134+
125135 htmlItem->loadHtml ();
126136
127137 QgsCompositionChecker checker ( " composerhtml_expressions_enabled" , mComposition );
@@ -139,7 +149,7 @@ void TestQgsComposerHtml::evalExpressionsOff()
139149 htmlItem->addFrame ( htmlFrame );
140150 htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
141151 htmlItem->setEvaluateExpressions ( false );
142- htmlItem->setHtml ( QString ( " <p>Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ) );
152+ htmlItem->setHtml ( QString ( " <p style= \" font-family: %1 \" >Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ). arg ( mTestFont . family () ) );
143153 htmlItem->loadHtml ();
144154
145155 QgsCompositionChecker checker ( " composerhtml_expressions_disabled" , mComposition );
0 commit comments