Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use standard test font for QgsComposerHtml test
  • Loading branch information
nyalldawson committed Oct 6, 2014
1 parent bed164e commit 2110611
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/src/core/testqgscomposerhtml.cpp
Expand Up @@ -15,10 +15,12 @@
* *
***************************************************************************/

#include "qgsapplication.h"
#include "qgscomposerhtml.h"
#include "qgscomposerframe.h"
#include "qgscomposition.h"
#include "qgscompositionchecker.h"
#include "qgsfontutils.h"
#include <QObject>
#include <QtTest>

Expand All @@ -41,14 +43,21 @@ class TestQgsComposerHtml: public QObject
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QString mReport;
QFont mTestFont;
};

void TestQgsComposerHtml::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();

mComposition = new QgsComposition( mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape

mReport = "<h1>Composer HTML Tests</h1>\n";

QgsFontUtils::loadStandardTestFonts( QStringList() << "Oblique" );
mTestFont = QgsFontUtils::getStandardTestFont( "Oblique " );
}

void TestQgsComposerHtml::cleanupTestCase()
Expand Down Expand Up @@ -82,7 +91,7 @@ void TestQgsComposerHtml::sourceMode()
htmlFrame->setFrameEnabled( true );
htmlItem->addFrame( htmlFrame );
htmlItem->setContentMode( QgsComposerHtml::ManualHtml );
htmlItem->setHtml( QString( "<p><i>Test manual <b>html</b></i></p>" ) );
htmlItem->setHtml( QString( "<p style=\"font-family: %1\"><i>Test manual <b>html</b></i></p>" ).arg( mTestFont.family() ) );
htmlItem->loadHtml();

QgsCompositionChecker checker( "composerhtml_manual", mComposition );
Expand All @@ -99,7 +108,7 @@ void TestQgsComposerHtml::userStylesheets()
htmlFrame->setFrameEnabled( true );
htmlItem->addFrame( htmlFrame );
htmlItem->setContentMode( QgsComposerHtml::ManualHtml );
htmlItem->setHtml( QString( "<p><i>Test user stylesheets <b>html</b></i></p>" ) );
htmlItem->setHtml( QString( "<p style=\"font-family: %1\"><i>Test user stylesheets <b>html</b></i></p>" ).arg( mTestFont.family() ) );

//set user stylesheet
htmlItem->setUserStylesheet( QString( "b { color: red; } i { color: green; }" ) );
Expand All @@ -121,7 +130,8 @@ void TestQgsComposerHtml::evalExpressions()
htmlItem->addFrame( htmlFrame );
htmlItem->setContentMode( QgsComposerHtml::ManualHtml );
htmlItem->setEvaluateExpressions( true );
htmlItem->setHtml( QString( "<p>Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ) );
htmlItem->setHtml( QString( "<p style=\"font-family: %1\">Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ).arg( mTestFont.family() ) );

htmlItem->loadHtml();

QgsCompositionChecker checker( "composerhtml_expressions_enabled", mComposition );
Expand All @@ -139,7 +149,7 @@ void TestQgsComposerHtml::evalExpressionsOff()
htmlItem->addFrame( htmlFrame );
htmlItem->setContentMode( QgsComposerHtml::ManualHtml );
htmlItem->setEvaluateExpressions( false );
htmlItem->setHtml( QString( "<p>Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ) );
htmlItem->setHtml( QString( "<p style=\"font-family: %1\">Test expressions = <i>[% 1 + 2 + 3%]</i></p>" ).arg( mTestFont.family() ) );
htmlItem->loadHtml();

QgsCompositionChecker checker( "composerhtml_expressions_disabled", mComposition );
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2110611

Please sign in to comment.