summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-07-01 12:17:16 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-07-11 01:34:19 +0200
commit8c18a245b0245de20c064cd53d03498088bd57df (patch)
treebf1b90e02c35062aac0c85200d3f4bce465bb4bb /tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
parentc4301be7d5f94852e1b17f2c2989d5ca807855d4 (diff)
QAbstractScrollArea: Don't include size of invisible scrollbars
Amend 3e59a88e8968c6cdac788926bec34c259146b6a8, which incorrectly used isHidden() to test whether the scrollbar is visible or not. QWidget::isHidden() is only true for child widgets that are explicitly hidden (or created for visible parents, which the scrollbars are not). Since the scrollbars are children of a container that is hidden and shown, isHidden always returns false. Instead, use QWidget::isVisibleTo, passing the scroll area, as that tells us if the scrollbar's visibility is relevant for the layout of the scroll area. Add a test case for QAbstractScrollArea, verifying that the scrollbar's size is correctly taken into account when calculating the size hint. This change revealed an instability in the tests introduced in the earlier commit: the layout process is asynchronous, requiring event processing to update the visibility of the scrollbars. Add a call to processEvents before storing the reference size hint. Also, explicitly set a style that doesn't use transient scrollbars as otherwise we cannot control when the scrollbars are shown. The chagne also revealed an inaccuracy in the QListView test, which only passed because the width of the vertical scrollbar was included. We cannot use font metrics results to compare expected width, as the item delegate's text rendering uses text layouts. Task-number: QTBUG-69120 Fixes: QTBUG-109326 Fixes: QTBUG-113552 Pick-to: 6.6 6.5 Change-Id: I1f06f9e88046a77722291ac17c56090f8dff7cf3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index cb6a05c135..2b908d4d4f 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -2564,8 +2564,9 @@ void tst_QListView::taskQTBUG_58749_adjustToContent()
// use the long text and make sure the width is adjusted.
model.setData(model.index(0, 0), longText);
QApplication::processEvents();
- QVERIFY(w.width() > longTextWidth);
- QVERIFY(view->width() >= longTextWidth);
+ const QRect itemRect = view->visualRect(model.index(0, 0));
+ QVERIFY(w.width() > itemRect.width());
+ QCOMPARE_GE(view->width(), itemRect.width());
}
void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()