diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-12-17 11:47:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-18 10:53:57 +0100 |
commit | 34e60228d4d449f6ec9177e3ef731089db0fcef9 (patch) | |
tree | 3ce8ab49db097b0346a8d6f55f8ac64eb5acebdd /tests | |
parent | 5a2fc03ef40d9b2a8384abffe3f1cb9d943b9acc (diff) | |
download | qtbase-34e60228d4d449f6ec9177e3ef731089db0fcef9.tar.gz |
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 <oliver.wolff@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
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 <qwidget.h> +// 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<int>() << 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<QWidget *>(&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; |