Skip to content

Commit

Permalink
Fix the composer label test unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Sep 27, 2012
1 parent f57a5fe commit a8bc3c6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/src/core/testqgscomposerlabel.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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.