15
15
* *
16
16
***************************************************************************/
17
17
18
+ #include " qgsapplication.h"
18
19
#include " qgscomposerhtml.h"
19
20
#include " qgscomposerframe.h"
20
21
#include " qgscomposition.h"
21
22
#include " qgscompositionchecker.h"
23
+ #include " qgsfontutils.h"
22
24
#include < QObject>
23
25
#include < QtTest>
24
26
@@ -41,14 +43,21 @@ class TestQgsComposerHtml: public QObject
41
43
QgsComposition* mComposition ;
42
44
QgsMapSettings mMapSettings ;
43
45
QString mReport ;
46
+ QFont mTestFont ;
44
47
};
45
48
46
49
void TestQgsComposerHtml::initTestCase ()
47
50
{
51
+ QgsApplication::init ();
52
+ QgsApplication::initQgis ();
53
+
48
54
mComposition = new QgsComposition ( mMapSettings );
49
55
mComposition ->setPaperSize ( 297 , 210 ); // A4 landscape
50
56
51
57
mReport = " <h1>Composer HTML Tests</h1>\n " ;
58
+
59
+ QgsFontUtils::loadStandardTestFonts ( QStringList () << " Oblique" );
60
+ mTestFont = QgsFontUtils::getStandardTestFont ( " Oblique " );
52
61
}
53
62
54
63
void TestQgsComposerHtml::cleanupTestCase ()
@@ -82,7 +91,7 @@ void TestQgsComposerHtml::sourceMode()
82
91
htmlFrame->setFrameEnabled ( true );
83
92
htmlItem->addFrame ( htmlFrame );
84
93
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 () ) );
86
95
htmlItem->loadHtml ();
87
96
88
97
QgsCompositionChecker checker ( " composerhtml_manual" , mComposition );
@@ -99,7 +108,7 @@ void TestQgsComposerHtml::userStylesheets()
99
108
htmlFrame->setFrameEnabled ( true );
100
109
htmlItem->addFrame ( htmlFrame );
101
110
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 () ) );
103
112
104
113
// set user stylesheet
105
114
htmlItem->setUserStylesheet ( QString ( " b { color: red; } i { color: green; }" ) );
@@ -121,7 +130,8 @@ void TestQgsComposerHtml::evalExpressions()
121
130
htmlItem->addFrame ( htmlFrame );
122
131
htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
123
132
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
+
125
135
htmlItem->loadHtml ();
126
136
127
137
QgsCompositionChecker checker ( " composerhtml_expressions_enabled" , mComposition );
@@ -139,7 +149,7 @@ void TestQgsComposerHtml::evalExpressionsOff()
139
149
htmlItem->addFrame ( htmlFrame );
140
150
htmlItem->setContentMode ( QgsComposerHtml::ManualHtml );
141
151
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 () ) );
143
153
htmlItem->loadHtml ();
144
154
145
155
QgsCompositionChecker checker ( " composerhtml_expressions_disabled" , mComposition );
0 commit comments