mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[composer] Add test for text table cell values
This commit is contained in:
parent
ebb31de525
commit
9f84e9fd98
@ -22,6 +22,7 @@
|
|||||||
#include "qgsmapsettings.h"
|
#include "qgsmapsettings.h"
|
||||||
#include "qgsvectorlayer.h"
|
#include "qgsvectorlayer.h"
|
||||||
#include "qgsvectordataprovider.h"
|
#include "qgsvectordataprovider.h"
|
||||||
|
#include "qgsfeature.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
@ -36,6 +37,7 @@ class TestQgsComposerTable: public QObject
|
|||||||
void cleanup();// will be called after every testfunction.
|
void cleanup();// will be called after every testfunction.
|
||||||
|
|
||||||
void textTableHeadings(); //test setting/retrieving text table headers
|
void textTableHeadings(); //test setting/retrieving text table headers
|
||||||
|
void textTableRows(); //test adding and retrieving text table rows
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
@ -102,5 +104,48 @@ void TestQgsComposerTable::textTableHeadings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsComposerTable::textTableRows()
|
||||||
|
{
|
||||||
|
//test adding and retrieving text table rows
|
||||||
|
|
||||||
|
//add some rows to the table
|
||||||
|
QList<QStringList> rows;
|
||||||
|
QStringList row;
|
||||||
|
row << "a1" << "b1" << "c1";
|
||||||
|
rows.append( row );
|
||||||
|
row.clear();
|
||||||
|
row << "a2" << "b2" << "c2";
|
||||||
|
rows.append( row );
|
||||||
|
row.clear();
|
||||||
|
row << "a3" << "b3" << "c3";
|
||||||
|
rows.append( row );
|
||||||
|
QList<QStringList>::const_iterator rowIt = rows.constBegin();
|
||||||
|
for ( ; rowIt != rows.constEnd(); ++rowIt )
|
||||||
|
{
|
||||||
|
mComposerTextTable->addRow( *rowIt );
|
||||||
|
}
|
||||||
|
|
||||||
|
//now retrieve rows and check
|
||||||
|
QList<QgsAttributeMap> evaluatedRows;
|
||||||
|
bool result = mComposerTextTable->getFeatureAttributes( evaluatedRows );
|
||||||
|
QCOMPARE( result, true );
|
||||||
|
|
||||||
|
QList<QgsAttributeMap>::const_iterator resultIt = evaluatedRows.constBegin();
|
||||||
|
int rowNumber = 0;
|
||||||
|
int colNumber = 0;
|
||||||
|
for ( ; resultIt != evaluatedRows.constEnd(); ++resultIt )
|
||||||
|
{
|
||||||
|
colNumber = 0;
|
||||||
|
QgsAttributeMap::const_iterator cellIt = ( *resultIt ).constBegin();
|
||||||
|
for ( ; cellIt != ( *resultIt ).constEnd(); ++cellIt )
|
||||||
|
{
|
||||||
|
QCOMPARE(( *cellIt ).toString(), rows.at( rowNumber ).at( colNumber ) );
|
||||||
|
colNumber++;
|
||||||
|
}
|
||||||
|
rowNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN( TestQgsComposerTable )
|
QTEST_MAIN( TestQgsComposerTable )
|
||||||
#include "moc_testqgscomposertable.cxx"
|
#include "moc_testqgscomposertable.cxx"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user