summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/cmake/CMakeLists.txt7
-rw-r--r--tests/auto/cmake/test_add_big_resource/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp4
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp8
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp54
-rw-r--r--tests/auto/corelib/tools/qregexp/tst_qregexp.cpp7
-rw-r--r--tests/auto/shared/highdpi.h109
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp5
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp11
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp68
11 files changed, 223 insertions, 54 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 51d0d2879e..5b10a74d3f 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -146,7 +146,12 @@ endif()
expect_pass(test_interface_link_libraries)
expect_pass(test_moc_macro_target)
-expect_pass(test_add_big_resource)
+
+if (NOT CMAKE_VERSION VERSION_LESS 3.9)
+ # The modification of TARGET_OBJECTS needs the following change in cmake
+ # https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f
+ expect_pass(test_add_big_resource)
+endif()
if (NOT CMAKE_VERSION VERSION_LESS 3.8)
# With earlier CMake versions, this test would simply run moc multiple times and lead to:
diff --git a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
index f928b11278..45ed2c79d5 100644
--- a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(test_add_big_resource)
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index aa6f0935e8..b73a297245 100644
--- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -172,9 +172,9 @@ void tst_qfloat16::qNan()
QVERIFY(qIsInf(-inf));
QVERIFY(qIsInf(2.f*inf));
QVERIFY(qIsInf(inf*2.f));
- // QTBUG-75812: QEMU's over-optimized arm64 flakily fails 1/inf == 0 :-(
+ // QTBUG-75812: QEMU/arm64 compiler over-optimizes, so flakily fails 1/inf == 0 :-(
if (qfloat16(9.785e-4f) == qfloat16(9.794e-4f))
- QCOMPARE(qfloat16(1.f/inf), qfloat16(0.f));
+ QCOMPARE(qfloat16(1.f) / inf, qfloat16(0.f));
#ifdef Q_CC_INTEL
QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue);
#endif
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index c9f1e3d9f6..11b1fdaeeb 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -205,15 +205,23 @@ void tst_QFileSelector::urlConvenience_data()
QString test("/test");// '/' is here so dir string can also be selector string
QString custom1("custom1");
+ QString testWithQueryAndFragment("/test?query#Fragment");
QTest::newRow("qrc") << QUrl("qrc:///extras/test") << (QStringList() << custom1)
<< QUrl(QString("qrc:///extras/") + QLatin1Char(selectorIndicator) + custom1 + test);
+ QTest::newRow("qrc with query and fragment") << QUrl(QString::fromLatin1("qrc:///extras%1").arg(testWithQueryAndFragment)) << (QStringList() << custom1)
+ << QUrl(QString("qrc:///extras/") + QLatin1Char(selectorIndicator) + custom1 + testWithQueryAndFragment);
QString fileBasePath = QFINDTESTDATA("extras/test");
QString fileSelectedPath = QFINDTESTDATA(QString("extras/") + QLatin1Char(selectorIndicator)
+ custom1 + QString("/test"));
QTest::newRow("file") << QUrl::fromLocalFile(fileBasePath) << (QStringList() << custom1)
<< QUrl::fromLocalFile(fileSelectedPath);
+ // do not strip off the query and fragment
+ QString strUrlWithFragment = QString("file://") + testWithQueryAndFragment;
+ QTest::newRow("file with query and fragment") << QUrl(strUrlWithFragment) << (QStringList()) << QUrl(strUrlWithFragment);
+ strUrlWithFragment = QString("file:") + testWithQueryAndFragment;
+ QTest::newRow("file with query and fragment too") << QUrl(strUrlWithFragment) << (QStringList()) << QUrl(strUrlWithFragment);
// http://qt-project.org/images/qtdn/sprites-combined-latest.png is chosen as a representative real world URL
// But note that this test is checking that http urls are NOT selected so it shouldn't be checked
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index d204727bbd..3ad1794176 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -183,6 +183,7 @@ private slots:
void floatingPointPrecision();
+ void compatibility_Qt5();
void compatibility_Qt3();
void compatibility_Qt2();
@@ -269,17 +270,17 @@ static int NColorRoles[] = {
QPalette::HighlightedText + 1, // Qt_4_0, Qt_4_1
QPalette::HighlightedText + 1, // Qt_4_2
QPalette::AlternateBase + 1, // Qt_4_3
- QPalette::PlaceholderText + 1, // Qt_4_4
- QPalette::PlaceholderText + 1, // Qt_4_5
- QPalette::PlaceholderText + 1, // Qt_4_6
- QPalette::PlaceholderText + 1, // Qt_5_0
- QPalette::PlaceholderText + 1, // Qt_5_1
- QPalette::PlaceholderText + 1, // Qt_5_2
- QPalette::PlaceholderText + 1, // Qt_5_3
- QPalette::PlaceholderText + 1, // Qt_5_4
- QPalette::PlaceholderText + 1, // Qt_5_5
- QPalette::PlaceholderText + 1, // Qt_5_6
- 0 // add the correct value for Qt_5_7 here later
+ QPalette::ToolTipText + 1, // Qt_4_4
+ QPalette::ToolTipText + 1, // Qt_4_5
+ QPalette::ToolTipText + 1, // Qt_4_6, Qt_4_7, Qt_4_8, Qt_4_9
+ QPalette::ToolTipText + 1, // Qt_5_0
+ QPalette::ToolTipText + 1, // Qt_5_1
+ QPalette::ToolTipText + 1, // Qt_5_2, Qt_5_3
+ QPalette::ToolTipText + 1, // Qt_5_4, Qt_5_5
+ QPalette::ToolTipText + 1, // Qt_5_6, Qt_5_7, Qt_5_8, Qt_5_9, Qt_5_10, Qt_5_11
+ QPalette::PlaceholderText + 1, // Qt_5_12
+ QPalette::PlaceholderText + 1, // Qt_5_13
+ 0 // add the correct value for Qt_5_14 here later
};
// Testing get/set functions
@@ -3243,6 +3244,37 @@ void tst_QDataStream::streamRealDataTypes()
}
}
+void tst_QDataStream::compatibility_Qt5()
+{
+ QLinearGradient gradient(QPointF(0,0), QPointF(1,1));
+ gradient.setColorAt(0, Qt::red);
+ gradient.setColorAt(1, Qt::blue);
+
+ QBrush brush(gradient);
+ QPalette palette;
+ palette.setBrush(QPalette::Button, brush);
+ palette.setColor(QPalette::Light, Qt::green);
+
+ QByteArray stream;
+ {
+ QDataStream out(&stream, QIODevice::WriteOnly);
+ out.setVersion(QDataStream::Qt_5_7);
+ out << palette;
+ out << brush;
+ }
+ QBrush in_brush;
+ QPalette in_palette;
+ {
+ QDataStream in(stream);
+ in.setVersion(QDataStream::Qt_5_7);
+ in >> in_palette;
+ in >> in_brush;
+ }
+ QCOMPARE(in_brush.style(), Qt::LinearGradientPattern);
+ QCOMPARE(in_palette.brush(QPalette::Button).style(), Qt::LinearGradientPattern);
+ QCOMPARE(in_palette.color(QPalette::Light), QColor(Qt::green));
+}
+
void tst_QDataStream::compatibility_Qt3()
{
QByteArray ba("hello");
diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
index a98d37d733..a8111af6c1 100644
--- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
+++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
@@ -834,6 +834,13 @@ void tst_QRegExp::testEscapingWildcard_data(){
QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true;
QTest::newRow("a '\\' at the end") << "\\\\Qt;\\" << "\\\\Qt;\\" << true;
+
+ QTest::newRow("[]\\] matches ]") << "[]\\]" << "]" << true;
+ QTest::newRow("[]\\] matches \\") << "[]\\]" << "\\" << true;
+ QTest::newRow("[]\\] does not match [") << "[]\\]" << "[" << false;
+ QTest::newRow("[]\\]a matches ]a") << "[]\\]a" << "]a" << true;
+ QTest::newRow("[]\\]a matches \\a") << "[]\\]a" << "\\a" << true;
+ QTest::newRow("[]\\]a does not match [a") << "[]\\]a" << "[a" << false;
}
void tst_QRegExp::testEscapingWildcard(){
diff --git a/tests/auto/shared/highdpi.h b/tests/auto/shared/highdpi.h
new file mode 100644
index 0000000000..f0c34bea25
--- /dev/null
+++ b/tests/auto/shared/highdpi.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HIGHDPI_H
+#define HIGHDPI_H
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qsize.h>
+
+// Helpers for comparing geometries a that may go through scaling in the
+// platform plugin with fuzz (pass rounded-down device pixel ratios or
+// scaling factors). Error message for use with QVERIFY2() are also provided.
+
+class HighDpi
+{
+public:
+ HighDpi() = delete;
+ HighDpi(const HighDpi &) = delete;
+ HighDpi &operator=(const HighDpi &) = delete;
+ HighDpi(HighDpi &&) = delete;
+ HighDpi &operator=(HighDpi &&) = delete;
+ ~HighDpi() = delete;
+
+ static int manhattanDelta(const QPoint &p1, const QPoint p2)
+ {
+ return (p1 - p2).manhattanLength();
+ }
+
+ static bool fuzzyCompare(const QPoint &p1, const QPoint p2, int fuzz)
+ {
+ return manhattanDelta(p1, p2) <= fuzz;
+ }
+
+ static QByteArray msgPointMismatch(const QPoint &p1, const QPoint p2)
+ {
+ return QByteArray::number(p1.x()) + ',' + QByteArray::number(p1.y())
+ + " != " + QByteArray::number(p2.x()) + ',' + QByteArray::number(p2.y())
+ + ", manhattanLength=" + QByteArray::number(manhattanDelta(p1, p2));
+ }
+
+ // Compare a size that may go through scaling in the platform plugin with fuzz.
+
+ static inline int manhattanDelta(const QSize &s1, const QSize &s2)
+ {
+ return qAbs(s1.width() - s2.width()) + qAbs(s1.height() - s2.height());
+ }
+
+ static inline bool fuzzyCompare(const QSize &s1, const QSize &s2, int fuzz)
+ {
+ return manhattanDelta(s1, s2) <= fuzz;
+ }
+
+ static QByteArray msgSizeMismatch(const QSize &s1, const QSize &s2)
+ {
+ return QByteArray::number(s1.width()) + 'x' + QByteArray::number(s1.height())
+ + " != " + QByteArray::number(s2.width()) + 'x' + QByteArray::number(s2.height())
+ + ", manhattanLength=" + QByteArray::number(manhattanDelta(s1, s2));
+ }
+
+ // Compare a geometry that may go through scaling in the platform plugin with fuzz.
+
+ static inline bool fuzzyCompare(const QRect &r1, const QRect &r2, int fuzz)
+ {
+ return manhattanDelta(r1.topLeft(), r2.topLeft()) <= fuzz
+ && manhattanDelta(r1.size(), r2.size()) <= fuzz;
+ }
+
+ static QByteArray msgRectMismatch(const QRect &r1, const QRect &r2)
+ {
+ return formatRect(r1) + " != " + formatRect(r2);
+ }
+
+private:
+ static QByteArray formatRect(const QRect &r)
+ {
+ return QByteArray::number(r.width()) + 'x' + QByteArray::number(r.height())
+ + (r.left() < 0 ? '-' : '+') + QByteArray::number(r.left())
+ + (r.top() < 0 ? '-' : '+') + QByteArray::number(r.top());
+ }
+};
+
+#endif // HIGHDPI_H
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index afe49368ae..c840dabc1a 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include "../../../shared/highdpi.h"
#include <QtTest/QtTest>
@@ -388,8 +389,10 @@ void tst_QDialog::toolDialogPosition()
dialog.move(QPoint(100,100));
const QPoint beforeShowPosition = dialog.pos();
dialog.show();
+ const int fuzz = int(dialog.devicePixelRatioF());
const QPoint afterShowPosition = dialog.pos();
- QCOMPARE(afterShowPosition, beforeShowPosition);
+ QVERIFY2(HighDpi::fuzzyCompare(afterShowPosition, beforeShowPosition, fuzz),
+ HighDpi::msgPointMismatch(afterShowPosition, beforeShowPosition).constData());
}
class Dialog : public QDialog
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index a5b8646d40..63f6e67a3e 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -2551,7 +2551,7 @@ void tst_QWizard::task183550_stretchFactor()
page2->enableVerticalExpansion();
wizard.next();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2));
- QVERIFY(page2->treeWidgetHeight() > page2->treeWidgetSizeHintHeight());
+ QVERIFY(page2->treeWidgetHeight() >= page2->treeWidgetSizeHintHeight());
wizard.back();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page1));
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 7fd1822295..dc246c0ebf 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include "../../../shared/highdpi.h"
#include <QtTest/QtTest>
@@ -51,6 +52,8 @@
#include <QPlainTextEdit>
#include <QDialog>
+#include <qscreen.h>
+
#include <QtWidgets/private/qabstractitemdelegate_p.h>
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
@@ -223,8 +226,8 @@ private slots:
void dateTextForRole_data();
void dateTextForRole();
-#ifdef QT_BUILD_INTERNAL
private:
+#ifdef QT_BUILD_INTERNAL
struct RoleDelegate : public QItemDelegate
{
QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale)
@@ -234,6 +237,8 @@ private:
}
};
#endif
+
+ const int m_fuzz = int(QGuiApplication::primaryScreen()->devicePixelRatio());
};
@@ -286,8 +291,8 @@ void tst_QItemDelegate::textRectangle()
QFont font;
TestItemDelegate delegate;
QRect result = delegate.textRectangle(0, rect, font, text);
-
- QCOMPARE(result, expected);
+ QVERIFY2(HighDpi::fuzzyCompare(result, expected, m_fuzz),
+ HighDpi::msgRectMismatch(result, expected).constData());
}
void tst_QItemDelegate::sizeHint_data()
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 11c3336748..063a2b5b9d 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include "../../../shared/highdpi.h"
#include <qboxlayout.h>
#include <qapplication.h>
@@ -140,19 +141,6 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
return s.toLocal8Bit();
}
-// Compare a window position that may go through scaling in the platform plugin with fuzz.
-static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
-{
- return (p1 - p2).manhattanLength() <= fuzz;
-}
-
-static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
-{
- QString result;
- QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
- return result;
-}
-
class tst_QWidget : public QObject
{
Q_OBJECT
@@ -418,6 +406,7 @@ private:
QPoint m_safeCursorPos;
const bool m_windowsAnimationsEnabled;
QTouchDevice *m_touchScreen;
+ const int m_fuzz;
};
bool tst_QWidget::ensureScreenSize(int width, int height)
@@ -576,6 +565,7 @@ tst_QWidget::tst_QWidget()
, m_safeCursorPos(0, 0)
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
, m_touchScreen(QTest::createTouchDevice())
+ , m_fuzz(int(QGuiApplication::primaryScreen()->devicePixelRatio()))
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
setWindowsAnimationsEnabled(false);
@@ -2049,10 +2039,9 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
- const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle()));
QVERIFY(!(widget1.windowState() & Qt::WindowMaximized));
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowMinimized);
@@ -2073,8 +2062,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)));
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -2095,8 +2084,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(Qt::WindowNoState);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowNoState);
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -2129,8 +2118,8 @@ void tst_QWidget::windowState()
QVERIFY(!(widget1.windowState() & stateMask));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QTRY_COMPARE(widget1.size(), size);
}
@@ -2323,7 +2312,7 @@ void tst_QWidget::resizeEvent()
{
QWidget wParent;
wParent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- wParent.resize(200, 200);
+ wParent.resize(m_testWidgetSize);
ResizeWidget wChild(&wParent);
wParent.show();
QVERIFY(QTest::qWaitForWindowExposed(&wParent));
@@ -2341,7 +2330,7 @@ void tst_QWidget::resizeEvent()
{
ResizeWidget wTopLevel;
wTopLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- wTopLevel.resize(200, 200);
+ wTopLevel.resize(m_testWidgetSize);
wTopLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel));
if (m_platform == QStringLiteral("winrt"))
@@ -2379,17 +2368,20 @@ void tst_QWidget::showMinimized()
#ifdef Q_OS_WINRT
QEXPECT_FAIL("", "Winrt does not support move and resize", Abort);
#endif
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.showNormal();
QVERIFY(!plain.isMinimized());
QVERIFY(plain.isVisible());
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.showMinimized();
QVERIFY(plain.isMinimized());
QVERIFY(plain.isVisible());
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.hide();
QVERIFY(plain.isMinimized());
@@ -2781,7 +2773,9 @@ void tst_QWidget::setGeometry()
tlw.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
QWidget child(&tlw);
- QRect tr(100,100,200,200);
+ const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
+ const QSize initialSize = 2 * m_testWidgetSize;
+ QRect tr(topLeft + QPoint(100,100), initialSize);
QRect cr(50,50,50,50);
tlw.setGeometry(tr);
child.setGeometry(cr);
@@ -2792,8 +2786,7 @@ void tst_QWidget::setGeometry()
QCOMPARE(child.geometry(), cr);
tlw.setParent(nullptr, Qt::Window|Qt::FramelessWindowHint);
- tr = QRect(0,0,100,100);
- tr.moveTopLeft(QGuiApplication::primaryScreen()->availableGeometry().topLeft());
+ tr = QRect(topLeft, initialSize / 2);
tlw.setGeometry(tr);
QCOMPARE(tlw.geometry(), tr);
tlw.showNormal();
@@ -3265,7 +3258,8 @@ void tst_QWidget::saveRestoreGeometry()
if (m_platform == QStringLiteral("winrt"))
QEXPECT_FAIL("", "WinRT does not support move/resize", Abort);
- QTRY_COMPARE(widget.pos(), position);
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
savedGeometry = widget.saveGeometry();
}
@@ -3293,10 +3287,12 @@ void tst_QWidget::saveRestoreGeometry()
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
- QTRY_COMPARE(widget.pos(), position);
+ QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
widget.show();
- QCOMPARE(widget.pos(), position);
+ QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
}
@@ -3410,6 +3406,9 @@ void tst_QWidget::restoreVersion1Geometry()
QFETCH(QSize, expectedSize);
QFETCH(QRect, expectedNormalGeometry);
+ if (m_platform == QLatin1String("windows") && QGuiApplication::primaryScreen()->geometry().width() > 2000)
+ QSKIP("Skipping due to minimum decorated window size on Windows");
+
// WindowActive is uninteresting for this test
const Qt::WindowStates WindowStateMask = Qt::WindowFullScreen | Qt::WindowMaximized | Qt::WindowMinimized;
@@ -4990,7 +4989,8 @@ void tst_QWidget::windowMoveResize()
widget.showNormal();
QTest::qWait(10);
- QTRY_COMPARE(widget.pos(), rect.topLeft());
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), rect.topLeft(), m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), rect.topLeft())));
// Windows: Minimum size of decorated windows.
const bool expectResizeFail = (!windowFlags && (rect.width() < 160 || rect.height() < 40))
&& m_platform == QStringLiteral("windows");