diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-09-09 11:23:31 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-09-17 12:38:41 (GMT) |
commit | d267c0946b65e0c93cb97ebb3dea1035ff390280 (patch) | |
tree | d76735d4bdf283b6c7861da46dd47cdb919bbdb1 /tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | |
parent | 37b9577f00bfba78915dfd659499efbf04acce4e (diff) | |
download | Qt-d267c0946b65e0c93cb97ebb3dea1035ff390280.zip Qt-d267c0946b65e0c93cb97ebb3dea1035ff390280.tar.gz Qt-d267c0946b65e0c93cb97ebb3dea1035ff390280.tar.bz2 |
Implement hasConflicts().
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp')
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 5bb3746..f982973 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -65,6 +65,7 @@ private slots: void setSpacing(); void hardComplexS60(); void delete_anchor(); + void conflicts(); }; class RectWidget : public QGraphicsWidget @@ -100,7 +101,7 @@ static void setAnchor(QGraphicsAnchorLayout *l, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, - qreal spacing) + qreal spacing = 0) { QGraphicsAnchor *anchor = l->addAnchor(firstItem, firstEdge, secondItem, secondEdge); anchor->setSpacing(spacing); @@ -1102,5 +1103,46 @@ void tst_QGraphicsAnchorLayout::delete_anchor() } +void tst_QGraphicsAnchorLayout::conflicts() +{ + QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a"); + QGraphicsWidget *b = createItem(QSizeF(10,10), QSizeF(20,10), QSizeF(30,10), "b"); + QGraphicsWidget *c = createItem(QSizeF(10,10), QSizeF(20,10), QSizeF(30,10), "c"); + + QGraphicsAnchorLayout *l; + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + + l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // with the following setup, 'a' cannot be larger than 30 we will first have a Simplex conflict + + // horizontal + setAnchor(l, l, Qt::AnchorLeft, b, Qt::AnchorLeft); + setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft); + setAnchor(l, c, Qt::AnchorRight, l, Qt::AnchorRight); + setAnchor(l, b, Qt::AnchorHorizontalCenter, a, Qt::AnchorLeft); + setAnchor(l, a, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter); + + // vertical + setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop); + setAnchor(l, a, Qt::AnchorBottom, b, Qt::AnchorTop); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorTop); + setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom); + setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom); + + p->setLayout(l); + + QCOMPARE(l->hasConflicts(), true); + + a->setMinimumSize(QSizeF(29,10)); + QCOMPARE(l->hasConflicts(), false); + + // It will currently fail if we uncomment this: + //QEXPECT_FAIL("", "The constraints are just within their bounds in order to be feasible", Continue); + //a->setMinimumSize(QSizeF(30,10)); + //QCOMPARE(l->hasConflicts(), false); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" |