summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsanchorlayout
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-17 10:40:03 +0200
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-17 10:40:03 +0200
commit22e7ee32913484e25ae7bc61083f6a28bfaecfe9 (patch)
treee3ff00c4bb2b93f9bb49b3258e2cc63998768578 /tests/auto/qgraphicsanchorlayout
parent916a74ef9703da783894c4a49b4897ef57cc474c (diff)
Add autotest for setSpacing()
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp42
1 files changed, 42 insertions, 0 deletions
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"