Skip to content
Permalink
Browse files

[layout expressions] add Y page offset expression - tests

  • Loading branch information
olivierdalang authored and nyalldawson committed Aug 21, 2020
1 parent 6ac8f61 commit 7b91f79cbb4a37f374aae58169bd4508bad871ca
Showing with 29 additions and 0 deletions.
  1. +29 −0 tests/src/core/testqgslayoutlabel.cpp
@@ -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();
@@ -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() );

0 comments on commit 7b91f79

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