summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-12-17 10:47:12 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 10:31:14 (GMT)
commit7801f57ef3d79e30836f3470d1f7cbecf7a082ba (patch)
treed38d0c73df667b12eea202fe4382a082b8dcdc38
parent180bf94c241728dd6d6f100437914d3cb11cbc30 (diff)
downloadQt-7801f57ef3d79e30836f3470d1f7cbecf7a082ba.zip
Qt-7801f57ef3d79e30836f3470d1f7cbecf7a082ba.tar.gz
Qt-7801f57ef3d79e30836f3470d1f7cbecf7a082ba.tar.bz2
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> (cherry picked from qtbase/34e60228d4d449f6ec9177e3ef731089db0fcef9)
-rw-r--r--tests/auto/qstyle/tst_qstyle.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index c26eacb..d61898b 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -115,6 +115,16 @@ static bool qt_wince_is_smartphone() {
//TESTED_CLASS=
//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp gui/styles/qs60style.cpp
+// 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
@@ -383,6 +393,7 @@ void 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) {
@@ -767,6 +778,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...
@@ -784,10 +796,21 @@ void tst_QStyle::lineUpLayoutTest(QStyle *style)
foreach (QWidget *w, qFindChildren<QWidget *>(&widget))
w->setStyle(style);
widget.show();
- QTest::qWait( 500 );
+ QVERIFY(QTest::qWaitForWindowShown(&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()
@@ -797,6 +820,7 @@ void tst_QStyle::defaultFont()
pointFont.setPixelSize(9);
qApp->setFont(pointFont);
QPushButton button;
+ setFrameless(&button);
button.show();
qApp->processEvents();
qApp->setFont(defaultFont);
@@ -822,6 +846,7 @@ void tst_QStyle::testDrawingShortcuts()
{
{
QWidget w;
+ setFrameless(&w);
QToolButton *tb = new QToolButton(&w);
tb->setText("&abc");
DrawTextStyle *dts = new DrawTextStyle;
@@ -836,6 +861,7 @@ void tst_QStyle::testDrawingShortcuts()
}
{
QToolBar w;
+ setFrameless(&w);
QToolButton *tb = new QToolButton(&w);
tb->setText("&abc");
DrawTextStyle *dts = new DrawTextStyle;