summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-10 13:00:44 -0300
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-12 18:35:26 -0300
commit0f5a0ec164b3a5bc1f2a48ae56688a984b990bbd (patch)
tree0da27b50e3e3011cfac9f945a95fd6cc656a49f1 /tests
parente7689dbab0e9a491d0ac6ead5b9412bf6ff86be0 (diff)
QGAL (Test): Add test to ensure persistency of user-defined spacing
Currently the user-defined spacing is saved inside "AnchorData->prefSize". However this value may be modified if spacing is negative or if the anchor's policy is "QSizePolicy::Ignored". Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index c7ed309a2b..2ad024fe5e 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -85,6 +85,7 @@ private slots:
void simplificationVsOrder();
void parallelSimplificationOfCenter();
void simplificationVsRedundance();
+ void spacingPersistency();
};
class RectWidget : public QGraphicsWidget
@@ -1866,5 +1867,30 @@ void tst_QGraphicsAnchorLayout::simplificationVsRedundance()
QCOMPARE(usedSimplex(l, Qt::Vertical), false);
}
+/*
+ Avoid regression where the saved prefSize would be lost. This was
+ solved by saving the original spacing in the QGraphicsAnchorPrivate class
+*/
+void tst_QGraphicsAnchorLayout::spacingPersistency()
+{
+ QGraphicsWidget w;
+ QGraphicsWidget *a = createItem();
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w);
+
+ l->addAnchors(l, a, Qt::Horizontal);
+ QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+
+ anchor->setSpacing(-30);
+ QCOMPARE(anchor->spacing(), -30.0);
+
+ anchor->setSpacing(30);
+ QCOMPARE(anchor->spacing(), 30.0);
+
+ anchor->setSizePolicy(QSizePolicy::Ignored);
+ w.effectiveSizeHint(Qt::PreferredSize);
+
+ QCOMPARE(anchor->spacing(), 30.0);
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"