From ac8955794f9584076a0132677a28bdb347d1a475 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 6 Jul 2017 11:44:43 -0700 Subject: tst_qstyle: Don't fail on empty scroller subcontrols on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS hasn't had SC_ScrollBarAddLine and SC_ScrollBarAddLine since 10.7, when transient scrollbars first appeared. We also make the warning message a bit more informative. Change-Id: Idef4684162456d9bc274eea77908a6afe24fa0f5 Reviewed-by: Tor Arne Vestbø Reviewed-by: Friedemann Kleint --- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 8422fe2439..3607f1ba92 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -289,16 +289,22 @@ bool tst_QStyle::testAllFunctions(QStyle *style) bool tst_QStyle::testScrollBarSubControls() { + const auto *style = testWidget->style(); + const bool isMacStyle = style->objectName().toLower() == "macintosh"; QScrollBar scrollBar; setFrameless(&scrollBar); scrollBar.show(); const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar); - foreach (int subControl, QList() << 1 << 2 << 4 << 8) { - QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt, - QStyle::SubControl(subControl), &scrollBar); + foreach (int sc, QList() << 1 << 2 << 4 << 8) { + const auto subControl = static_cast(sc); + const QRect sr = style->subControlRect(QStyle::CC_ScrollBar, &opt, subControl, &scrollBar); if (sr.isNull()) { - qWarning("Null rect for subcontrol %d", subControl); - return false; + // macOS scrollbars no longer have these, so there's no reason to fail + if (!(isMacStyle && (subControl == QStyle::SC_ScrollBarAddLine || + subControl == QStyle::SC_ScrollBarSubLine))) { + qWarning() << "Unexpected null rect for subcontrol" << subControl; + return false; + } } } return true; -- cgit v1.2.3