summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-12-17 13:41:43 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2011-01-19 08:30:21 (GMT)
commit101ecddd24e194761cde0d84a421657c1206c506 (patch)
tree97630668a2f467d482a5728e26dae4da9f0ff93d /tests
parent923f7c6b07b27cf51de31dc9c2456010bd8434d5 (diff)
downloadQt-101ecddd24e194761cde0d84a421657c1206c506.zip
Qt-101ecddd24e194761cde0d84a421657c1206c506.tar.gz
Qt-101ecddd24e194761cde0d84a421657c1206c506.tar.bz2
Fix a bug that got revealed by 604c51f1fc5c79b7fad12cda911b06b9e6e5005f
The bug has been around for a while, but change 604c51f1fc5c7 made it emerge. The problem was that stretches were combined by always *maxing* them. The values of 'stretch' can be interpreted as this: -1: (the default) it means that the items should be stretched with the stretch factor dervived from the size hints. (In practice this means that they are distributed fairly). 0: Means that the item should not be stretched >0: Means that the item should be stretch with that number as a factor. This meant that combining one item with a fixed size(0) and another item with a default stretch (-1) the combined row stretch would end up being fixed. This also fixes how stretches are combined for spanning items too. Task-number: QTBUG-13551 Reviewed-by: John Tapsell (cherry picked from commit 7fbf1829e11504eca6a55f1e5dbddf2f658b5302)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index a024f65..62ba1b4 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -106,6 +106,7 @@ private slots:
void testAlignmentInLargerLayout();
void testOffByOneInLargerLayout();
void testDefaultAlignment();
+ void combineSizePolicies();
// Task specific tests
void task218400_insertStretchCrash();
@@ -1583,6 +1584,31 @@ void tst_QGraphicsLinearLayout::testDefaultAlignment()
QCOMPARE(w2->geometry(), QRectF(0,50,100,100));
}
+void tst_QGraphicsLinearLayout::combineSizePolicies()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+
+ QGraphicsWidget *w1 = new QGraphicsWidget;
+ w1->setMaximumSize(200,200);
+ w1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ layout->addItem(w1);
+
+ QGraphicsWidget *w2 = new QGraphicsWidget;
+ w2->setPreferredSize(50,50);
+ w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ layout->addItem(w2);
+ QCOMPARE(layout->maximumHeight(), qreal(200));
+
+ // now remove the fixed vertical size policy, and set instead the maximum height to 50
+ // this should in effect give the same maximumHeight
+ w2->setMaximumHeight(50);
+ w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+ QCOMPARE(layout->maximumHeight(), qreal(200));
+}
+
QTEST_MAIN(tst_QGraphicsLinearLayout)
#include "tst_qgraphicslinearlayout.moc"