diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-11-06 02:49:43 (GMT) |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-11-06 18:18:13 (GMT) |
commit | 5f46db57f3baed15bfca2b4725e400808eabb7e5 (patch) | |
tree | d8eac09f90527da45a72717b36eab6e6f9dd91b6 /tests/auto | |
parent | 9d89f0bd155b9eccc89eac6ff30b572795062baa (diff) | |
download | Qt-5f46db57f3baed15bfca2b4725e400808eabb7e5.zip Qt-5f46db57f3baed15bfca2b4725e400808eabb7e5.tar.gz Qt-5f46db57f3baed15bfca2b4725e400808eabb7e5.tar.bz2 |
QGAL (Test): redundant anchors shouldn't harm simplification
Adds a simple test to check whether redundant anchors avoid
simplification to happen. In this case, the use of addCornerAnchors
generate redundant anchors.
Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 8b52674..c7ed309 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -84,6 +84,7 @@ private slots: void simplifiableUnfeasible(); void simplificationVsOrder(); void parallelSimplificationOfCenter(); + void simplificationVsRedundance(); }; class RectWidget : public QGraphicsWidget @@ -1827,5 +1828,43 @@ void tst_QGraphicsAnchorLayout::parallelSimplificationOfCenter() QCOMPARE(b->geometry(), QRectF(20, 0, 20, 10)); } +/* + Test whether redundance of anchors (in this case by using addCornerAnchors), will + prevent simplification to take place when it should. +*/ +void tst_QGraphicsAnchorLayout::simplificationVsRedundance() +{ + QSizeF min(10, 10); + QSizeF pref(20, 10); + QSizeF max(50, 30); + + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(min, pref, max, "C"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner); + l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner); + + l->addCornerAnchors(b, Qt::TopLeftCorner, a, Qt::TopRightCorner); + l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner); + + l->addCornerAnchors(c, Qt::TopLeftCorner, b, Qt::BottomLeftCorner); + l->addCornerAnchors(c, Qt::BottomLeftCorner, a, Qt::BottomRightCorner); + l->addCornerAnchors(c, Qt::TopRightCorner, b, Qt::BottomRightCorner); + l->addCornerAnchors(c, Qt::BottomRightCorner, l, Qt::BottomRightCorner); + + l->effectiveSizeHint(Qt::MinimumSize); + + QCOMPARE(layoutHasConflict(l), false); + + if (!hasSimplification) + QEXPECT_FAIL("", "Test depends on simplification.", Abort); + + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" |