From 22e7ee32913484e25ae7bc61083f6a28bfaecfe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 17 Aug 2009 10:40:03 +0200 Subject: Add autotest for setSpacing() --- .../tst_qgraphicsanchorlayout.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/auto/qgraphicsanchorlayout') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index d94cd82185..16a9af2a30 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -18,6 +18,8 @@ private slots: void fairDistributionOppositeDirections(); void proportionalPreferred(); void example(); + void setSpacing(); + }; class RectWidget : public QGraphicsWidget @@ -696,5 +698,45 @@ void tst_QGraphicsAnchorLayout::example() QCOMPARE(f->size(), g->size()); } +void tst_QGraphicsAnchorLayout::setSpacing() +{ + QSizeF min(10, 10); + QSizeF pref(20, 20); + QSizeF max(50, 50); + + QGraphicsWidget *a = createItem(min, pref, max); + QGraphicsWidget *b = createItem(min, pref, max); + QGraphicsWidget *c = createItem(min, pref, max); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->anchorCorner(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner); + l->anchorCorner(b, Qt::TopRightCorner, l, Qt::TopRightCorner); + l->anchor(a, QGraphicsAnchorLayout::Right, b, QGraphicsAnchorLayout::Left); + + l->anchorWidth(c); + + l->anchor(a, QGraphicsAnchorLayout::Bottom, c, QGraphicsAnchorLayout::Top); + l->anchor(c, QGraphicsAnchorLayout::Bottom, l, QGraphicsAnchorLayout::Bottom); + + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + + p->setLayout(l); + l->setSpacing(1); + + // don't let the style influence the test. + l->setContentsMargins(0, 0, 0, 0); + + QGraphicsScene scene; + scene.addItem(p); + QGraphicsView *view = new QGraphicsView(&scene); + view->show(); + p->show(); + + QApplication::processEvents(); + QCOMPARE(a->geometry(), QRectF(0, 0, 20, 20)); + QCOMPARE(b->geometry(), QRectF(21, 0, 20, 20)); + QCOMPARE(c->geometry(), QRectF(0, 21, 41, 20)); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v1.2.3