|
22 | 22 | #include "qgsmaprenderer.h"
|
23 | 23 | #include "qgsvectorlayer.h"
|
24 | 24 | #include "qgsvectordataprovider.h"
|
| 25 | +#include "qgsmultirenderchecker.h" |
| 26 | +#include "qgsfontutils.h" |
25 | 27 |
|
26 | 28 | #include <QObject>
|
27 | 29 | #include <QtTest/QtTest>
|
@@ -50,14 +52,16 @@ class TestQgsComposerLabel : public QObject
|
50 | 52 | void feature_evaluation();
|
51 | 53 | // test page expressions
|
52 | 54 | void page_evaluation();
|
53 |
| - |
54 | 55 | void marginMethods(); //tests getting/setting margins
|
| 56 | + void render(); |
| 57 | + void renderAsHtml(); |
55 | 58 |
|
56 | 59 | private:
|
57 | 60 | QgsComposition* mComposition;
|
58 | 61 | QgsComposerLabel* mComposerLabel;
|
59 | 62 | QgsMapSettings *mMapSettings;
|
60 | 63 | QgsVectorLayer* mVectorLayer;
|
| 64 | + QString mReport; |
61 | 65 | };
|
62 | 66 |
|
63 | 67 | void TestQgsComposerLabel::initTestCase()
|
@@ -89,6 +93,15 @@ void TestQgsComposerLabel::initTestCase()
|
89 | 93 |
|
90 | 94 | void TestQgsComposerLabel::cleanupTestCase()
|
91 | 95 | {
|
| 96 | + QString myReportFile = QDir::tempPath() + "/qgistest.html"; |
| 97 | + QFile myFile( myReportFile ); |
| 98 | + if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) |
| 99 | + { |
| 100 | + QTextStream myQTextStream( &myFile ); |
| 101 | + myQTextStream << mReport; |
| 102 | + myFile.close(); |
| 103 | + } |
| 104 | + |
92 | 105 | delete mComposition;
|
93 | 106 | delete mMapSettings;
|
94 | 107 |
|
@@ -225,5 +238,32 @@ void TestQgsComposerLabel::marginMethods()
|
225 | 238 | QCOMPARE( label3.marginY(), 12.0 );
|
226 | 239 | }
|
227 | 240 |
|
| 241 | +void TestQgsComposerLabel::render() |
| 242 | +{ |
| 243 | + mComposerLabel->setText( "test label" ); |
| 244 | + mComposerLabel->setFont( QgsFontUtils::getStandardTestFont( "Bold", 48 ) ); |
| 245 | + mComposerLabel->setPos( 70, 70 ); |
| 246 | + mComposerLabel->adjustSizeToText(); |
| 247 | + |
| 248 | + QgsCompositionChecker checker( "composerlabel_render", mComposition ); |
| 249 | + checker.setControlPathPrefix( "composer_label" ); |
| 250 | + QVERIFY( checker.testComposition( mReport, 0, 0 ) ); |
| 251 | +} |
| 252 | + |
| 253 | +void TestQgsComposerLabel::renderAsHtml() |
| 254 | +{ |
| 255 | + mComposerLabel->setFontColor( QColor( 200, 40, 60 ) ); |
| 256 | + mComposerLabel->setText( "test <i>html</i>" ); |
| 257 | + mComposerLabel->setFont( QgsFontUtils::getStandardTestFont( "Bold", 48 ) ); |
| 258 | + mComposerLabel->setPos( 70, 70 ); |
| 259 | + mComposerLabel->adjustSizeToText(); |
| 260 | + mComposerLabel->setHtmlState( 1 ); |
| 261 | + mComposerLabel->update(); |
| 262 | + |
| 263 | + QgsCompositionChecker checker( "composerlabel_renderhtml", mComposition ); |
| 264 | + checker.setControlPathPrefix( "composer_label" ); |
| 265 | + QVERIFY( checker.testComposition( mReport, 0, 0 ) ); |
| 266 | +} |
| 267 | + |
228 | 268 | QTEST_MAIN( TestQgsComposerLabel )
|
229 | 269 | #include "testqgscomposerlabel.moc"
|
0 commit comments