mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Add a unit test
This commit is contained in:
parent
1bfed13484
commit
272097b83a
@ -50,6 +50,8 @@ class TestItem : public QgsLayoutItem
|
||||
int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; }
|
||||
QString stringType() const override { return QStringLiteral( "TestItemType" ); }
|
||||
|
||||
bool forceResize = false;
|
||||
|
||||
protected:
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * = nullptr ) override
|
||||
{
|
||||
@ -61,6 +63,14 @@ class TestItem : public QgsLayoutItem
|
||||
painter->drawRect( rect() );
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override
|
||||
{
|
||||
if ( !forceResize )
|
||||
return targetSize;
|
||||
|
||||
return QSizeF( 17, 27 );
|
||||
}
|
||||
};
|
||||
|
||||
//item with minimum size
|
||||
@ -753,6 +763,12 @@ void TestQgsLayoutItem::resize()
|
||||
QCOMPARE( spySizeChanged.count(), 13 );
|
||||
|
||||
l.setUnits( QgsUnitTypes::LayoutMillimeters );
|
||||
|
||||
// try override item size in item
|
||||
item->forceResize = true;
|
||||
item->attemptResize( QgsLayoutSize( 10.0, 15.0, QgsUnitTypes::LayoutMillimeters ) );
|
||||
QCOMPARE( item->rect().width(), 17.0 );
|
||||
QCOMPARE( item->rect().height(), 27.0 );
|
||||
}
|
||||
|
||||
void TestQgsLayoutItem::referencePoint()
|
||||
|
Loading…
x
Reference in New Issue
Block a user