Skip to content
Permalink
Browse files

Add composer html test

  • Loading branch information
mhugent committed Aug 7, 2012
1 parent 8719ef9 commit 95e7832148a19af26bad75d45cfaccaa1377ec05
@@ -97,3 +97,4 @@ ADD_QGIS_TEST(rulebasedrenderertest testqgsrulebasedrenderer.cpp)
ADD_QGIS_TEST(ziplayertest testziplayer.cpp)
ADD_QGIS_TEST(dataitemtest testqgsdataitem.cpp)
ADD_QGIS_TEST(composermaptest testqgscomposermap.cpp)
ADD_QGIS_TEST(composerhtmltest testqgscomposerhtml.cpp )
@@ -53,7 +53,7 @@ bool QgsCompositionChecker::testComposition( int page )
QRectF targetArea( 0, 0, 3507, 2480 );
mComposition->render( &p, targetArea, sourceArea );
p.end();
outputImage.save( "/tmp/composermap_control.png", "PNG" );
outputImage.save( "/tmp/composerhtml_table_control.png", "PNG" );
return false;
#endif //0

@@ -0,0 +1,70 @@
/***************************************************************************
testqgscomposerhtml.cpp
-----------------------
begin : August 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco at sourcepole dot ch
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

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

class TestQgsComposerHtml: public QObject
{
Q_OBJECT;
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void table(); //test if rendering of the composition with composr map is correct

private:
QgsComposition* mComposition;
};

void TestQgsComposerHtml::initTestCase()
{
mComposition = new QgsComposition( 0 );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
}

void TestQgsComposerHtml::cleanupTestCase()
{
delete mComposition;
}

void TestQgsComposerHtml::init()
{

}

void TestQgsComposerHtml::cleanup()
{

}

void TestQgsComposerHtml::table()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, 0, 0, 100, 200 );
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
QgsCompositionChecker checker( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerhtml" + QDir::separator() + "composerhtml_table.png" ) );
QVERIFY( checker.testComposition() );
}


QTEST_MAIN( TestQgsComposerHtml )
#include "moc_testqgscomposerhtml.cxx"
Binary file not shown.
@@ -0,0 +1,10 @@
<table border="1" style="font-size:12pt; ">
<tbody>
<tr><td>1 Foo data</td><td>Bar data</td></tr>
<tr><td>2 Foo data</td><td>Bar data</td></tr>
<tr><td>3 Foo data</td><td>Bar data</td></tr>
<tr><td>4 Foo data</td><td>Bar data</td></tr>
<tr><td>5 Foo data</td><td>Bar data</td></tr>
</tbody>
</table>
<table>

0 comments on commit 95e7832

Please sign in to comment.
You can’t perform that action at this time.