From 34e60228d4d449f6ec9177e3ef731089db0fcef9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 17 Dec 2012 11:47:12 +0100 Subject: Fix QStyle-test for Windows Aero / 8. Increase tolerance on Windows for the Aero style. Set small top level widgets frameless to avoid warnings about minimum size of decorated windows on Windows. Task-number: QTBUG-28611 Change-Id: Ia4aec0cf0763da9955577054cb8cf81337fac134 Reviewed-by: Oliver Wolff Reviewed-by: Jens Bache-Wiig --- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'tests/auto/widgets/styles/qstyle/tst_qstyle.cpp') diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 1363ee9ed2..9dee368768 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -85,6 +85,16 @@ static bool qt_wince_is_smartphone() { #include +// Make a widget frameless to prevent size constraints of title bars +// from interfering (Windows). +static inline void setFrameless(QWidget *w) +{ + Qt::WindowFlags flags = w->windowFlags(); + flags |= Qt::FramelessWindowHint; + flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + w->setWindowFlags(flags); +} + class tst_QStyle : public QObject { Q_OBJECT @@ -337,6 +347,7 @@ bool tst_QStyle::testScrollBarSubControls(QStyle* style) #endif QScrollBar scrollBar; + setFrameless(&scrollBar); scrollBar.show(); const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar); foreach (int subControl, QList() << 1 << 2 << 4 << 8) { @@ -660,6 +671,7 @@ void tst_QStyle::progressBarChangeStyle() void tst_QStyle::lineUpLayoutTest(QStyle *style) { QWidget widget; + setFrameless(&widget); QHBoxLayout layout; QFont font; font.setPointSize(9); //Plastique is lined up for odd numbers... @@ -677,10 +689,21 @@ void tst_QStyle::lineUpLayoutTest(QStyle *style) foreach (QWidget *w, qFindChildren(&widget)) w->setStyle(style); widget.show(); - QTest::qWait( 500 ); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - QVERIFY(qAbs(spinbox.height() - lineedit.height()) <= 1); - QVERIFY(qAbs(spinbox.height() - combo.height()) <= 1); +#ifdef Q_OS_WIN + const int limit = 2; // Aero style has larger margins +#else + const int limit = 1; +#endif + const int slDiff = qAbs(spinbox.height() - lineedit.height()); + const int scDiff = qAbs(spinbox.height() - combo.height()); + QVERIFY2(slDiff <= limit, + qPrintable(QString::fromLatin1("%1 exceeds %2 for %3") + .arg(slDiff).arg(limit).arg(style->objectName()))); + QVERIFY2(scDiff <= limit, + qPrintable(QString::fromLatin1("%1 exceeds %2 for %3") + .arg(scDiff).arg(limit).arg(style->objectName()))); } void tst_QStyle::defaultFont() @@ -690,6 +713,7 @@ void tst_QStyle::defaultFont() pointFont.setPixelSize(9); qApp->setFont(pointFont); QPushButton button; + setFrameless(&button); button.show(); qApp->processEvents(); qApp->setFont(defaultFont); @@ -716,6 +740,7 @@ void tst_QStyle::testDrawingShortcuts() { { QWidget w; + setFrameless(&w); QToolButton *tb = new QToolButton(&w); tb->setText("&abc"); DrawTextStyle *dts = new DrawTextStyle; @@ -730,6 +755,7 @@ void tst_QStyle::testDrawingShortcuts() } { QToolBar w; + setFrameless(&w); QToolButton *tb = new QToolButton(&w); tb->setText("&abc"); DrawTextStyle *dts = new DrawTextStyle; -- cgit v1.2.3