Skip to content
Permalink
Browse files

Fix the composer label test unit

  • Loading branch information
Hugo Mercier
Hugo Mercier committed Sep 27, 2012
1 parent f57a5fe commit a8bc3c6c0a1adc73d965dc296adb294d4619ae2c
Showing with 17 additions and 0 deletions.
  1. +17 −0 tests/src/core/testqgscomposerlabel.cpp
@@ -38,6 +38,8 @@ private slots:
void evaluation();
// test expression evaluation when a feature is set
void feature_evaluation();
// test "$page" expressions
void page_evaluation();
private:
QgsComposition* mComposition;
QgsComposerLabel* mComposerLabel;
@@ -160,5 +162,20 @@ void TestQgsComposerLabel::feature_evaluation()
}
}

void TestQgsComposerLabel::page_evaluation()
{
mComposition->setNumPages( 2 );
{
mComposerLabel->setText( "[%$page||'/'||$numpages%]" );
QString evaluated = mComposerLabel->displayText();
QString expected = "1/2";
QCOMPARE( evaluated, expected );

// move to the second page and re-evaluate
mComposerLabel->setItemPosition( 0, 320 );
QCOMPARE( mComposerLabel->displayText(), QString("2/2") );
}
}

QTEST_MAIN( TestQgsComposerLabel )
#include "moc_testqgscomposerlabel.cxx"

0 comments on commit a8bc3c6

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