From 1607216cc6292ef9a4af68ce6d29dc79fffea92c Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Mon, 26 Oct 2009 16:55:20 -0300 Subject: QGAL: Add test for David Boddie bug The current simplification code does not handle sequences with anchors pointed to different directions could not be simplified together into a sequential anchor. A (10 / 20 / 50 ) B (20 / 20 / 20) Ex: o-----------------> <----------------o The reason we don't support it yet is shown in the example above. The resulting anchor would be either: Result_1 (-10 / 0 / 30) o------------------------------------> (or) Result_2 (-30 / 0 / 10) <------------------------------------o But the current implementation assumes no anchors can have negative sizes. Hopefully, the next commits will add support for it and then enable such simplification. :-) Signed-off-by: Eduardo M. Fleury --- .../tst_qgraphicsanchorlayout.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index facc1ef..5348e59 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -83,6 +83,7 @@ private slots: void floatConflict(); void infiniteMaxSizes(); void simplifiableUnfeasible(); + void simplificationVsOrder(); }; class RectWidget : public QGraphicsWidget @@ -1806,5 +1807,50 @@ void tst_QGraphicsAnchorLayout::simplifiableUnfeasible() QVERIFY(!usedSimplex(l, Qt::Horizontal)); } +/* + Test whether the anchor direction can prevent it from + being simplificated +*/ +void tst_QGraphicsAnchorLayout::simplificationVsOrder() +{ + QSizeF min(10, 10); + QSizeF pref(20, 10); + QSizeF max(50, 10); + + QGraphicsWidget *a = createItem(min, pref, max); + QGraphicsWidget *b = createItem(min, pref, max); + QGraphicsWidget *c = createItem(min, pref, max); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + // Bulk anchors + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + + // Problematic anchor, direction b->c + QGraphicsAnchor *anchor = l->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); + anchor->setSpacing(5); + + l->effectiveSizeHint(Qt::MinimumSize); + if (hasSimplification) { + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); + } + + // Problematic anchor, direction c->b + delete anchor; + anchor = l->addAnchor(c, Qt::AnchorRight, b, Qt::AnchorRight); + anchor->setSpacing(5); + + l->effectiveSizeHint(Qt::MinimumSize); + if (hasSimplification) { + QEXPECT_FAIL("", "Sequential anchors cannot handle children of opposite directions", Continue); + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); + } +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12