Skip to content

Commit

Permalink
[layout expressions] add Y page offset expression - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang authored and nyalldawson committed Aug 21, 2020
1 parent 6ac8f61 commit 7b91f79
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/core/testqgslayoutlabel.cpp
Expand Up @@ -50,6 +50,7 @@ class TestQgsLayoutLabel : public QObject
void featureEvaluationUsingContext();
// test page expressions
void pageEvaluation();
void pageSizeEvaluation();
void marginMethods(); //tests getting/setting margins
void render();
void renderAsHtml();
Expand Down Expand Up @@ -235,6 +236,34 @@ void TestQgsLayoutLabel::pageEvaluation()
}
}

void TestQgsLayoutLabel::pageSizeEvaluation()
{
QgsLayout l( QgsProject::instance() );
l.initializeDefaults();

QgsLayoutItemLabel *label = new QgsLayoutItemLabel( &l );
label->setMargin( 1 );
label->setText( QStringLiteral( "[%array_to_string(@layout_pageoffsets)%]" ) );
l.addLayoutItem( label );

{
QString evaluated = label->currentText();
QString expected = QStringLiteral( "0" );
QCOMPARE( evaluated, expected );
}

// add a page and re-evaluate
QgsLayoutItemPage *page2 = new QgsLayoutItemPage( &l );
page2->setPageSize( "A4", QgsLayoutItemPage::Landscape );
l.pageCollection()->addPage( page2 );

{
QString evaluated = label->currentText();
QString expected = QStringLiteral( "0,220" );
QCOMPARE( evaluated, expected );
}
}

void TestQgsLayoutLabel::marginMethods()
{
QgsLayout l( QgsProject::instance() );
Expand Down

0 comments on commit 7b91f79

Please sign in to comment.