diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-11-11 06:13:35 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-11-11 09:32:15 (GMT) |
commit | fb0765f5285b8518b3336a6aa36de1adc37bc1fc (patch) | |
tree | 11c9e3b6dbf49b6d33dc9fe47a6ba5f6780891ba /tests/auto/qgraphicsgridlayout | |
parent | 0870d766b9e302081ba31a9c8f6dfa3a1e8c1e52 (diff) | |
download | Qt-fb0765f5285b8518b3336a6aa36de1adc37bc1fc.zip Qt-fb0765f5285b8518b3336a6aa36de1adc37bc1fc.tar.gz Qt-fb0765f5285b8518b3336a6aa36de1adc37bc1fc.tar.bz2 |
Fix a behaviour change of sizeHint() introduced by 6d4d265e7e67dde58
Commit 6d4d265e7e67dde58e45d7d89f4974d0bd8b70e4 added a behaviour change
in the cases if there was an item with height-for-width and sizeHint()
was called with no constraint. The commit tried to return the height
needed for the preferred width, but it still did not satisfy the
constraints, since the width used as the constraint could be less than
the preferred width. This also meant that the sizeHint(Qt::MinimumSize)
could actually be larger than the smallest possible size.
The behaviour should be that it should return the smallest width
possible regardless of height. For instance, for a label it could return
the size of the longest word (to avoid hyphenation issues).
The same logic applies for the height: It should return the smallest
height possible regardless of width. For instance, for a label it could
then return the height of the font.
I also had to fix some stuff in the heightForWidthWithSpanning()
autotest since it wrongly expected the maximum size to be
QWIDGETSIZE_MAX in several of the cases. However, that is the current
behaviour (and it is a bug), but it is unrelated to the problem with
spans so I simply fix the test and mark them with QEXPECT_FAIL.
Reviewed-by: John Tapsell
Diffstat (limited to 'tests/auto/qgraphicsgridlayout')
-rw-r--r-- | tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 174e4aa..ff49b27 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -2556,8 +2556,9 @@ void tst_QGraphicsGridLayout::heightForWidth() w11->setSizePolicy(sp); layout->addItem(w11, 1, 1); - QSizeF prefSize = layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)); - QCOMPARE(prefSize, QSizeF(10+200, 10+100)); + QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(2, 2)); + QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(210, 110)); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30100, 30100)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 20001)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20010)); @@ -2610,21 +2611,25 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() w->setSizePolicy(sp); layout->addItem(w, 0,0,2,2); - QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 100)); + QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 1)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30000, 30000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 10000)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, QWIDGETSIZE_MAX)); + QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); } QTEST_MAIN(tst_QGraphicsGridLayout) |