From 7a2547164d207119468abbfa4c0eb594948bb608 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 May 2014 17:16:38 +0200 Subject: [PATCH] Fix tst_QStyleSheetStyle::toolTip(). Use the correct palette and enforce Fusion style to prevent the Vista style from clobbering the tooltip palette in polish(). Task-number: QTBUG-38183 Change-Id: Id19d548f818d801c4914a343e08207195c343888 Reviewed-by: Oliver Wolff --- .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 86e3c51d5a..14d59d3630 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1351,10 +1351,26 @@ void tst_QStyleSheetStyle::emptyStyleSheet() QCOMPARE(img1,img2); } +class ApplicationStyleSetter +{ +public: + explicit inline ApplicationStyleSetter(QStyle *s) : m_oldStyleName(QApplication::style()->objectName()) + { QApplication::setStyle(s); } + inline ~ApplicationStyleSetter() + { QApplication::setStyle(QStyleFactory::create(m_oldStyleName)); } + +private: + const QString m_oldStyleName; +}; + void tst_QStyleSheetStyle::toolTip() { qApp->setStyleSheet(QString()); QWidget w; + // Use "Fusion" to prevent the Vista style from clobbering the tooltip palette in polish(). + QStyle *fusionStyle = QStyleFactory::create(QLatin1String("Fusion")); + QVERIFY(fusionStyle); + ApplicationStyleSetter as(fusionStyle); QHBoxLayout layout(&w); w.setLayout(&layout); @@ -1387,7 +1403,7 @@ void tst_QStyleSheetStyle::toolTip() qApp->setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QColor normalToolTip = qApp->palette().toolTipBase().color(); + const QColor normalToolTip = QToolTip::palette().color(QPalette::Inactive, QPalette::ToolTipBase); QList widgets; QList colors;