summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-10-19 14:10:31 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-10-26 22:17:39 (GMT)
commitf9dfd711d104bb438da6ea281012600a897ab30c (patch)
treece4a859383e10c211b164f760374cfdd705a737b /tests
parent3b025f72636041f7bfe1bf02b34e3b156a78844f (diff)
downloadQt-f9dfd711d104bb438da6ea281012600a897ab30c.zip
Qt-f9dfd711d104bb438da6ea281012600a897ab30c.tar.gz
Qt-f9dfd711d104bb438da6ea281012600a897ab30c.tar.bz2
QGAL: identify unfeasible setups even when graph is simplified
The calculate graphs now can return early due to unfeasible anchor setups found out during simplification. This allows finding out problems in parallel anchors, when one anchor has maximum size smaller than the minimum size of the other anchor. The order for simplification and refreshing size hints also has been swaped: - First, refresh size hints for all anchors in the graph. If the graph is simplified, the refreshSizeHints() call will reach the children anchors. - Then, if the simplificated graph is invalid, rebuild it. During this rebuild, refreshSizeHints_helper() will be called for all levels. So in both situations we can identify an unfeasible setup. Note that this test alone is not enough to classify the graph as feasible, depending on the graph, it will still need to go through the Simplex. A test case was added and the function that traverse the graph refreshing now is called refreshAllSizeHints(). The old name was not so clear since the function will not fill only the anchors that have items associated. Last but not least, the lastCalculationUsedSimplex variable is cleared when starting calculateGraphs(), since we now can leave the function earlier, without reaching calculateTrunk(), which is the function that sets it. 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')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 7b87969..facc1ef 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -82,6 +82,7 @@ private slots:
void expandingParallel();
void floatConflict();
void infiniteMaxSizes();
+ void simplifiableUnfeasible();
};
class RectWidget : public QGraphicsWidget
@@ -1755,5 +1756,55 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes()
QCOMPARE(d->geometry(), QRectF(QWIDGETSIZE_MAX - 50, 0, 50, 10));
}
+void tst_QGraphicsAnchorLayout::simplifiableUnfeasible()
+{
+ QGraphicsWidget *a = createItem(QSizeF(70.0, 100.0),
+ QSizeF(100.0, 100.0),
+ QSizeF(100.0, 100.0), "A");
+
+ QGraphicsWidget *b = createItem(QSizeF(110.0, 100.0),
+ QSizeF(150.0, 100.0),
+ QSizeF(190.0, 100.0), "B");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
+
+ l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
+ l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
+ l->addAnchor(b, Qt::AnchorBottom, l, Qt::AnchorBottom);
+
+ l->addAnchors(l, a, Qt::Horizontal);
+ l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
+ l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
+
+ QCOMPARE(l->count(), 2);
+
+ QGraphicsWidget p;
+ p.setLayout(l);
+
+ l->invalidate();
+ QVERIFY(layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+
+ // Now we make it valid again
+ b->setMinimumWidth(100);
+
+ l->invalidate();
+ QVERIFY(!layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+
+ // And make it invalid again
+ a->setPreferredWidth(70);
+ a->setMaximumWidth(70);
+
+ l->invalidate();
+ QVERIFY(layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"