summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp13
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp39
-rw-r--r--tests/auto/corelib/itemmodels/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp27
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp7
-rw-r--r--tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp61
-rw-r--r--tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp12
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp2
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp4
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp6
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp1
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp25
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp94
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp9
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp95
-rw-r--r--tests/manual/highdpi/pixelgadget/CMakeLists.txt6
-rw-r--r--tests/manual/highdpi/screengadget/CMakeLists.txt6
19 files changed, 316 insertions, 96 deletions
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index d8da8ecc03b..c2c09a234c8 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -74,13 +74,13 @@ class TestAnimation : public QVariantAnimation
{
Q_OBJECT
public:
- virtual void updateCurrentValue(const QVariant &value) override { Q_UNUSED(value)};
+ virtual void updateCurrentValue(const QVariant &value) override { Q_UNUSED(value)}
virtual void updateState(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState) override
{
Q_UNUSED(oldState);
Q_UNUSED(newState);
- };
+ }
};
class TestAnimation2 : public QVariantAnimation
@@ -90,13 +90,13 @@ public:
TestAnimation2(QAbstractAnimation *animation) : QVariantAnimation(animation) {}
TestAnimation2(int duration, QAbstractAnimation *animation) : QVariantAnimation(animation), m_duration(duration) {}
- virtual void updateCurrentValue(const QVariant &value) override { Q_UNUSED(value)};
+ virtual void updateCurrentValue(const QVariant &value) override { Q_UNUSED(value)}
virtual void updateState(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState) override
{
Q_UNUSED(oldState);
Q_UNUSED(newState);
- };
+ }
virtual int duration() const override {
return m_duration;
@@ -463,8 +463,9 @@ void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim1->state(), QAnimationGroup::Running);
- QTest::qWait(80);
- QVERIFY(group.currentLoopTime() > 0);
+ QTest::qWaitFor([&]{
+ return group.currentLoopTime() > 0;
+ }, 200ms);
delete anim1;
QCOMPARE(group.animationCount(), 0);
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 458cdece514..dceb1e3bf66 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -55,6 +55,8 @@ class tst_QSaveFile : public QObject
public slots:
private slots:
+ void basics();
+ void stdfilesystem();
void transactionalWrite();
void retryTransactionalWrite();
void textStreamManualFlush();
@@ -91,6 +93,43 @@ static inline QByteArray msgCannotOpen(const QFileDevice &f)
return result.toLocal8Bit();
}
+void tst_QSaveFile::basics()
+{
+ QSaveFile f;
+ QCOMPARE(f.fileName(), QString());
+ f.setFileName("foobar");
+ QCOMPARE(f.fileName(), "foobar");
+ f.setFileName(QString());
+ QCOMPARE(f.fileName(), QString());
+
+ QString abspath = QDir::currentPath() + "/foobar";
+ QSaveFile f2(abspath);
+ QCOMPARE(f2.fileName(), abspath);
+ f2.setFileName(QString());
+ QCOMPARE(f2.fileName(), QString());
+}
+
+void tst_QSaveFile::stdfilesystem()
+{
+#if QT_CONFIG(cxx17_filesystem)
+ using namespace std::filesystem;
+ QSaveFile f;
+ f.setFileName(path("foobar"));
+ QCOMPARE(f.fileName(), "foobar");
+ QCOMPARE(f.filesystemFileName(), path("foobar"));
+ f.setFileName(path());
+ QCOMPARE(f.fileName(), QString());
+ QVERIFY(f.filesystemFileName().empty());
+
+ path abspath = QDir::current().filesystemAbsolutePath() / "foobar";
+ QSaveFile f2(abspath);
+ QCOMPARE(f2.filesystemFileName(), abspath);
+ f2.setFileName(path());
+ QCOMPARE(f2.fileName(), QString());
+ QVERIFY(f.filesystemFileName().empty());
+#endif
+}
+
void tst_QSaveFile::transactionalWrite()
{
QTemporaryDir dir;
diff --git a/tests/auto/corelib/itemmodels/CMakeLists.txt b/tests/auto/corelib/itemmodels/CMakeLists.txt
index 15c32b7a6f2..8304fa15bc6 100644
--- a/tests/auto/corelib/itemmodels/CMakeLists.txt
+++ b/tests/auto/corelib/itemmodels/CMakeLists.txt
@@ -2,8 +2,8 @@
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qstringlistmodel)
-add_subdirectory(qrangemodel)
if(TARGET Qt::Gui)
+ add_subdirectory(qrangemodel)
add_subdirectory(qabstractitemmodel)
if(QT_FEATURE_proxymodel)
add_subdirectory(qabstractproxymodel)
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index bef43091277..e713901101c 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -455,7 +455,6 @@ private:
};
const qlonglong intMax1 = (qlonglong)INT_MAX + 1;
-const qulonglong uintMax1 = (qulonglong)UINT_MAX + 1;
void tst_QVariant::constructor()
{
@@ -5737,22 +5736,24 @@ void tst_QVariant::sequentialIterableAppend()
void tst_QVariant::preferDirectConversionOverInterfaces()
{
using namespace QtMetaTypePrivate;
- bool calledCorrectConverter = false;
+ static bool calledCorrectConverter = false;
+ calledCorrectConverter = false;
+
QMetaType::registerConverter<MyType, QSequentialIterable>([](const MyType &) {
return QSequentialIterable {};
});
- QMetaType::registerConverter<MyType, QVariantList>([&calledCorrectConverter](const MyType &) {
+ QMetaType::registerConverter<MyType, QVariantList>([&](const MyType &) {
calledCorrectConverter = true;
return QVariantList {};
});
QMetaType::registerConverter<MyType, QAssociativeIterable>([](const MyType &) {
return QAssociativeIterable {};
});
- QMetaType::registerConverter<MyType, QVariantHash>([&calledCorrectConverter](const MyType &) {
+ QMetaType::registerConverter<MyType, QVariantHash>([&](const MyType &) {
calledCorrectConverter = true;
return QVariantHash {};
});
- QMetaType::registerConverter<MyType, QVariantMap>([&calledCorrectConverter](const MyType &) {
+ QMetaType::registerConverter<MyType, QVariantMap>([&](const MyType &) {
calledCorrectConverter = true;
return QVariantMap {};
});
@@ -5783,6 +5784,11 @@ struct MyTypeView
void tst_QVariant::mutableView()
{
+ static bool calledOnce = false;
+ if (calledOnce)
+ QSKIP("This test can only be run once per test execution because of QMetaType registration");
+ calledOnce = true;
+
bool calledView = false;
const bool success = QMetaType::registerMutableView<MyType, MyTypeView>([&](MyType &data) {
calledView = true;
@@ -5906,6 +5912,11 @@ void tst_QVariant::moveOperations()
class NoMetaObject : public QObject {};
void tst_QVariant::equalsWithoutMetaObject()
{
+ static bool calledOnce = false;
+ if (calledOnce)
+ QSKIP("This test can only be run once per test execution because of QMetaType registration");
+ calledOnce = true;
+
using T = NoMetaObject*;
QtPrivate::QMetaTypeInterface d = {
/*.revision=*/ 0,
@@ -6021,6 +6032,12 @@ void tst_QVariant::constructFromIncompatibleMetaType()
void tst_QVariant::constructFromQtLT65MetaType()
{
+ static bool calledOnce = false;
+ if (calledOnce)
+ QSKIP("This test can only be run once per test execution because of QMetaType registration");
+ calledOnce = true;
+
+
auto qsizeIface = QtPrivate::qMetaTypeInterfaceForType<QSize>();
QtPrivate::QMetaTypeInterface qsize64Iface = {
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index e0173412339..a6662878786 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -2484,6 +2484,10 @@ void tst_QByteArray::fromPercentEncoding()
QFETCH(QByteArray, decodedString);
QCOMPARE(encodedString.percentDecoded(), decodedString);
+ QCOMPARE(QByteArray::fromPercentEncoding(encodedString), decodedString);
+ QCOMPARE(QByteArray{encodedString}.percentDecoded(), decodedString); // rvalue, shared
+ encodedString.detach();
+ QCOMPARE(std::move(encodedString).percentDecoded(), decodedString); // rvalue, detached
}
void tst_QByteArray::toPercentEncoding_data()
@@ -2545,6 +2549,9 @@ void tst_QByteArray::pecentEncodingRoundTrip()
QByteArray encodedData = original.toPercentEncoding(excludeInEncoding, includeInEncoding);
QCOMPARE(encodedData, encoded);
QCOMPARE(encodedData.percentDecoded(), original);
+ QCOMPARE(QByteArray{encodedData}.percentDecoded(), original); // rvalue, shared
+ encodedData.detach();
+ QCOMPARE(std::move(encodedData).percentDecoded(), original); // rvalue, detached
}
struct StringComparisonData
diff --git a/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp b/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp
index 22bff24eec0..c0a67840c75 100644
--- a/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp
+++ b/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp
@@ -11,6 +11,8 @@ class tst_QStringIterator : public QObject
private slots:
void sweep_data();
void sweep();
+ void nextOrRawCodeUnitEquivalenceWithOldCode_data() { sweep_data(); }
+ void nextOrRawCodeUnitEquivalenceWithOldCode();
void position();
};
@@ -253,6 +255,65 @@ void tst_QStringIterator::sweep()
}
}
+void tst_QStringIterator::nextOrRawCodeUnitEquivalenceWithOldCode()
+{
+ QFETCH(const QString, string);
+ // QFETCH(bool, valid);
+
+ const auto s = string.data_ptr().data(); // avoids QChar
+
+ // this is the old code, used before we had nextOrRawCodeUnit():
+ const auto oldResult = [&] {
+ QList<char32_t> result;
+ result.reserve(string.size());
+
+ const auto len = string.size();
+ for (qsizetype i = 0; i < len; ++i) {
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_CLANG("-Wcharacter-conversion")
+ char32_t ucs4;
+ const char16_t c = s[i];
+ if (QChar::isHighSurrogate(c) && i + 1 < len && QChar::isLowSurrogate(s[i + 1]))
+ ucs4 = QChar::surrogateToUcs4(c, s[++i]);
+ else
+ ucs4 = c;
+ QT_WARNING_POP
+ result.push_back(ucs4);
+ }
+ return result;
+ }();
+
+ // now the same with nextOrRawCodeUnit():
+ const auto newResult = [&] {
+ QList<char32_t> result;
+ result.reserve(string.size());
+
+ QStringIterator it(string);
+ while (it.hasNext())
+ result.push_back(it.nextOrRawCodeUnit());
+
+ return result;
+ }();
+
+ // they should yield the equivalent series of code points:
+ QCOMPARE_EQ(newResult, oldResult);
+
+ // also check next/previousOrRawCodeUnit() consistency:
+ const auto fromBack = [&] {
+ QList<char32_t> result;
+ result.reserve(string.size());
+
+ QStringIterator it(string, string.size());
+ while (it.hasPrevious())
+ result.push_back(it.previousOrRawCodeUnit());
+
+ std::reverse(result.begin(), result.end());
+ return result;
+ }();
+
+ QCOMPARE_EQ(fromBack, newResult);
+}
+
void tst_QStringIterator::position()
{
static const QChar stringData[] =
diff --git a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
index abb7497928a..a6a0ef2f26d 100644
--- a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
+++ b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
@@ -12,6 +12,7 @@ class tst_QUnicodeTools : public QObject
{
Q_OBJECT
private slots:
+ void allSurrogatesHaveLineBreakClassSG();
void lineBreakClass();
void graphemeBreakClass_data();
void graphemeBreakClass();
@@ -21,6 +22,17 @@ private slots:
void sentenceBreakClass();
};
+void tst_QUnicodeTools::allSurrogatesHaveLineBreakClassSG()
+{
+ char32_t c;
+ auto printOnFail = qScopeGuard([&] { qDebug() << c; });
+ for (c = 0; c <= QChar::LastValidCodePoint; ++c) {
+ if (QChar::isSurrogate(c))
+ QCOMPARE_EQ(QUnicodeTables::lineBreakClass(c), QUnicodeTables::LineBreak_SG);
+ }
+ printOnFail.dismiss();
+}
+
void tst_QUnicodeTools::lineBreakClass()
{
QVERIFY(QUnicodeTables::lineBreakClass(0x0029) == QUnicodeTables::LineBreak_CP);
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index 6a72b5ddf38..66fbac97977 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -1947,7 +1947,7 @@ void tst_QTimeZone::roundtripDisplayNames()
if (!match)
match = QTimeZonePrivate::findLongNamePrefix(extended, locale);
if (!match)
- match = QTimeZonePrivate::findNarrowOffsetPrefix(extended, locale, QLocale::NarrowFormat);
+ match = QTimeZonePrivate::findNarrowOffsetPrefix(extended, locale);
if (!match)
match = QTimeZonePrivate::findLongUtcPrefix(extended);
auto report = qScopeGuard([=]() {
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 463f600e36d..cbe04ae39f7 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -650,14 +650,14 @@ QT_WARNING_POP
{
QList<int *> list;
QVERIFY(list.value(0) == 0);
- int i;
+ int i = 42;
list.append(&i);
QVERIFY(list.value(0) == &i);
}
{
QList<const int *> list;
QVERIFY(list.value(0) == 0);
- int i;
+ int i = 42;
list.append(&i);
QVERIFY(list.value(0) == &i);
}
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 51edf7a1ea7..b671c419b2b 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -17,6 +17,7 @@ class tst_QCommandLineParser : public QObject
public slots:
void initTestCase();
+ void cleanupTestCase();
private slots:
void parsingModes_data();
@@ -71,6 +72,11 @@ void tst_QCommandLineParser::initTestCase()
empty_argv[0] = const_cast<char*>(QTest::currentAppName());
}
+void tst_QCommandLineParser::cleanupTestCase()
+{
+ empty_argv[0] = nullptr;
+}
+
Q_DECLARE_METATYPE(QCommandLineParser::SingleDashWordOptionMode)
void tst_QCommandLineParser::parsingModes_data()
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index f7c5af53310..9129fb2e7ed 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -3244,7 +3244,6 @@ void tst_QWindow::enterLeaveOnWindowShowHide()
QSKIP("We can't move the cursor");
window.show();
- window.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&window));
++expectedEnter;
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index bf3efca35b2..2e92cdffada 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1357,6 +1357,11 @@ void tst_QAccessibility::scrollBarTest()
scrollBar->setMinimum(11);
scrollBar->setMaximum(111);
+ QAccessibleAttributesInterface *attributesIface = scrollBarInterface->attributesInterface();
+ QVERIFY(attributesIface);
+ QVERIFY(attributesIface->attributeKeys().contains(QAccessible::Attribute::Orientation));
+ QCOMPARE(attributesIface->attributeValue(QAccessible::Attribute::Orientation), Qt::Horizontal);
+
QAccessibleValueInterface *valueIface = scrollBarInterface->valueInterface();
QVERIFY(valueIface != 0);
QCOMPARE(valueIface->minimumValue().toInt(), scrollBar->minimum());
@@ -1899,6 +1904,20 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(textIface->textAtOffset(15, QAccessible::LineBoundary, &startOffset, &endOffset), QString("How are you today?"));
QCOMPARE(startOffset, 13);
QCOMPARE(endOffset, 31);
+
+ QCOMPARE(textIface->textAfterOffset(3, QAccessible::WordBoundary, &startOffset, &endOffset),
+ QString("world"));
+ QCOMPARE(
+ textIface->textBeforeOffset(8, QAccessible::WordBoundary, &startOffset, &endOffset),
+ QString("hello"));
+ // no more word before or after the last one
+ QCOMPARE(
+ textIface->textBeforeOffset(1, QAccessible::WordBoundary, &startOffset, &endOffset),
+ QString());
+ QCOMPARE(textIface->textAfterOffset(textIface->characterCount() - 1,
+ QAccessible::WordBoundary, &startOffset, &endOffset),
+ QString());
+
QCOMPARE(textIface->characterCount(), 48);
QFontMetrics fm(edit.document()->defaultFont());
QCOMPARE(textIface->characterRect(0).size(), QSize(fm.horizontalAdvance("h"), fm.height()));
@@ -2316,6 +2335,12 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(textIface->textAtOffset(5, QAccessible::LineBoundary,&start,&end), cite);
QCOMPARE(textIface->textAtOffset(5, QAccessible::NoBoundary,&start,&end), cite);
+ le3->setText("Hello");
+ QCOMPARE(textIface->textAtOffset(1, QAccessible::WordBoundary, &start, &end),
+ QString::fromLatin1("Hello"));
+ QCOMPARE(textIface->textBeforeOffset(1, QAccessible::WordBoundary, &start, &end), QString());
+ QCOMPARE(textIface->textAfterOffset(1, QAccessible::WordBoundary, &start, &end), QString());
+
QTestAccessibility::clearEvents();
}
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index c1b72d4d623..b4cfb0f4f79 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
@@ -364,7 +364,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
Window window;
window.show();
- window.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&window));
if (windowActivationReasonFail)
@@ -374,7 +373,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
Window window2;
window2.show();
- window2.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&window2));
if (windowActivationReasonFail)
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index a79d3454724..e8a3e8c046d 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -47,6 +47,7 @@ Q_GUI_EXPORT void qt_test_resetFetchedRoot();
QT_END_NAMESPACE
#endif
+[[maybe_unused]]
static QByteArray msgDoesNotExist(const QString &name)
{
return (QLatin1Char('"') + QDir::toNativeSeparators(name)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 48310996c46..878c5a8f39a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -1625,19 +1625,19 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust_data()
QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 0 << false;
// Anti-aliased.
- QTest::newRow("nil") << QRect() << 1 << true;
- QTest::newRow("0, 0, 300, 100") << QRect(0, 0, 300, 100) << 1 << true;
- QTest::newRow("0, 0, 100, 300") << QRect(0, 0, 100, 300) << 1 << true;
- QTest::newRow("200, 0, 100, 300") << QRect(200, 0, 100, 300) << 1 << true;
- QTest::newRow("0, 200, 300, 100") << QRect(0, 200, 300, 100) << 1 << true;
- QTest::newRow("0, 0, 300, 99") << QRect(0, 0, 300, 99) << 1 << true;
- QTest::newRow("0, 0, 99, 300") << QRect(0, 0, 99, 300) << 1 << true;
- QTest::newRow("201, 0, 99, 300") << QRect(201, 0, 99, 300) << 1 << true;
- QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 1 << true;
- QTest::newRow("0, 0, 300, 98") << QRect(0, 0, 300, 98) << 0 << false;
- QTest::newRow("0, 0, 98, 300") << QRect(0, 0, 98, 300) << 0 << false;
- QTest::newRow("202, 0, 98, 300") << QRect(202, 0, 98, 300) << 0 << false;
- QTest::newRow("0, 202, 300, 98") << QRect(0, 202, 300, 98) << 0 << false;
+ QTest::newRow("nil, antiAliased") << QRect() << 1 << true;
+ QTest::newRow("0, 0, 300, 100, antiAliased") << QRect(0, 0, 300, 100) << 1 << true;
+ QTest::newRow("0, 0, 100, 300, antiAliased") << QRect(0, 0, 100, 300) << 1 << true;
+ QTest::newRow("200, 0, 100, 300, antiAliased") << QRect(200, 0, 100, 300) << 1 << true;
+ QTest::newRow("0, 200, 300, 100, antiAliased") << QRect(0, 200, 300, 100) << 1 << true;
+ QTest::newRow("0, 0, 300, 99, antiAliased") << QRect(0, 0, 300, 99) << 1 << true;
+ QTest::newRow("0, 0, 99, 300, antiAliased") << QRect(0, 0, 99, 300) << 1 << true;
+ QTest::newRow("201, 0, 99, 300, antiAliased") << QRect(201, 0, 99, 300) << 1 << true;
+ QTest::newRow("0, 201, 300, 99, antiAliased") << QRect(0, 201, 300, 99) << 1 << true;
+ QTest::newRow("0, 0, 300, 98, antiAliased") << QRect(0, 0, 300, 98) << 0 << false;
+ QTest::newRow("0, 0, 98, 300, antiAliased") << QRect(0, 0, 98, 300) << 0 << false;
+ QTest::newRow("202, 0, 98, 300, antiAliased") << QRect(202, 0, 98, 300) << 0 << false;
+ QTest::newRow("0, 202, 300, 98, antiAliased") << QRect(0, 202, 300, 98) << 0 << false;
}
void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
@@ -1833,11 +1833,7 @@ void tst_QGraphicsView::itemAt2()
void tst_QGraphicsView::mapToScene()
{
- // Uncomment the commented-out code to see what's going on. It doesn't
- // affect the test; it just slows it down.
-
QGraphicsScene scene;
- scene.addPixmap(QPixmap("3D-Qt-1-2.png"));
QWidget topLevel;
QGraphicsView view(&topLevel);
@@ -1847,16 +1843,11 @@ void tst_QGraphicsView::mapToScene()
view.setFixedSize(viewSize);
topLevel.show();
- QApplication::processEvents();
- QVERIFY(view.isVisible());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCOMPARE(view.size(), viewSize);
// First once without setting the scene rect
-#ifdef Q_PROCESSOR_ARM
- const int step = 20;
-#else
const int step = 5;
-#endif
for (int x = 0; x < view.width(); x += step) {
for (int y = 0; y < view.height(); y += step) {
@@ -1920,20 +1911,21 @@ void tst_QGraphicsView::mapToSceneRect_data()
QTest::addColumn<QPolygonF>("scenePoly");
QTest::addColumn<qreal>("rotation");
- QTest::newRow("nil") << QRect() << QPolygonF() << qreal(0);
- QTest::newRow("0, 0, 1, 1") << QRect(0, 0, 1, 1) << QPolygonF(QRectF(0, 0, 1, 1)) << qreal(0);
- QTest::newRow("0, 0, 10, 10") << QRect(0, 0, 10, 10) << QPolygonF(QRectF(0, 0, 10, 10)) << qreal(0);
- QTest::newRow("nil") << QRect() << QPolygonF() << qreal(90);
- QPolygonF p;
- p << QPointF(0, 0) << QPointF(0, -1) << QPointF(1, -1) << QPointF(1, 0) << QPointF(0, 0);
- QTest::newRow("0, 0, 1, 1") << QRect(0, 0, 1, 1)
- << p
- << qreal(90);
- p.clear();
- p << QPointF(0, 0) << QPointF(0, -10) << QPointF(10, -10) << QPointF(10, 0) << QPointF(0, 0);
- QTest::newRow("0, 0, 10, 10") << QRect(0, 0, 10, 10)
- << p
- << qreal(90);
+ const auto translate90 = [&](const QPolygonF &poly) -> QPolygonF {
+ const QTransform mat = QTransform().rotate(-90); // the view is rotated
+ return mat.map(QPolygonF(poly));
+ };
+
+ constexpr QRect r1(0, 0, 1, 1);
+ constexpr QRect r2(0, 0, 10, 10);
+ const QPolygonF p1 = QPolygonF(QRectF(r1));
+ const QPolygonF p2 = QPolygonF(QRectF(r2));
+ QTest::newRow("nil, no rotation") << QRect() << QPolygonF() << qreal(0);
+ QTest::newRow("0, 0, 1, 1, no rotation") << r1 << p1 << qreal(0);
+ QTest::newRow("0, 0, 10, 10, no rotation") << r2 << p2 << qreal(0);
+ QTest::newRow("nil, 90 degree") << QRect() << QPolygonF() << qreal(90);
+ QTest::newRow("0, 0, 1, 1, 90 degree") << r1 << translate90(p1) << qreal(90);
+ QTest::newRow("0, 0, 10, 10, 90 degree") << r2 << translate90(p2) << qreal(90);
}
void tst_QGraphicsView::mapToSceneRect()
@@ -1954,6 +1946,7 @@ void tst_QGraphicsView::mapToSceneRect()
view.setTransformationAnchor(QGraphicsView::NoAnchor);
view.setResizeAnchor(QGraphicsView::NoAnchor);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.rotate(rotation);
@@ -1972,20 +1965,16 @@ void tst_QGraphicsView::mapToScenePoly()
view.translate(100, 100);
view.setFixedSize(117, 117);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QPoint center = view.viewport()->rect().center();
QRect rect(center + QPoint(10, 0), QSize(10, 10));
- QPolygon poly;
- poly << rect.topLeft();
- poly << rect.topRight();
- poly << rect.bottomRight();
- poly << rect.bottomLeft();
-
- QPolygonF poly2;
- poly2 << view.mapToScene(rect.topLeft());
- poly2 << view.mapToScene(rect.topRight());
- poly2 << view.mapToScene(rect.bottomRight());
- poly2 << view.mapToScene(rect.bottomLeft());
+ const QPolygon poly = { rect.topLeft(), rect.topRight(),
+ rect.bottomRight(), rect.bottomLeft() };
+ const QPolygonF poly2 = { view.mapToScene(rect.topLeft()),
+ view.mapToScene(rect.topRight()),
+ view.mapToScene(rect.bottomRight()),
+ view.mapToScene(rect.bottomLeft()) };
QCOMPARE(view.mapToScene(poly), poly2);
}
@@ -1998,6 +1987,7 @@ void tst_QGraphicsView::mapToScenePath()
view.translate(10, 10);
view.setFixedSize(300, 300);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QRect rect(QPoint(10, 0), QSize(10, 10));
QPainterPath path;
@@ -2019,6 +2009,7 @@ void tst_QGraphicsView::mapFromScenePoint()
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QPoint mapped = view.mapFromScene(0, 0);
QPoint center = view.viewport()->rect().center();
@@ -2038,6 +2029,7 @@ void tst_QGraphicsView::mapFromScenePoint()
view.ensurePolished();
view.resize(view.sizeHint());
toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
QCOMPARE(view.mapFromScene(0, 0), QPoint(0, 0));
QCOMPARE(view.mapFromScene(0.4, 0.4), QPoint(0, 0));
@@ -2799,15 +2791,15 @@ void tst_QGraphicsView::levelOfDetail_data()
QTest::newRow("1:4, 1:4") << QTransform().scale(0.25, 0.25) << qreal(0.25);
QTest::newRow("1:2, 1:4") << QTransform().scale(0.5, 0.25) << qreal(::sqrt(0.125));
- QTest::newRow("4:1, 1:2") << QTransform().scale(0.25, 0.5) << qreal(::sqrt(0.125));
+ QTest::newRow("1:4, 1:2") << QTransform().scale(0.25, 0.5) << qreal(::sqrt(0.125));
QTest::newRow("1:2, 1:2") << QTransform().scale(0.5, 0.5) << qreal(0.5);
QTest::newRow("1:1, 1:2") << QTransform().scale(1, 0.5) << qreal(::sqrt(0.5));
- QTest::newRow("2:1, 1:1") << QTransform().scale(0.5, 1) << qreal(::sqrt(0.5));
+ QTest::newRow("1:2, 1:1") << QTransform().scale(0.5, 1) << qreal(::sqrt(0.5));
QTest::newRow("1:1, 1:1") << QTransform().scale(1, 1) << qreal(1.0);
QTest::newRow("2:1, 1:1") << QTransform().scale(2, 1) << qreal(::sqrt(2.0));
- QTest::newRow("1:1, 2:1") << QTransform().scale(2, 1) << qreal(::sqrt(2.0));
+ QTest::newRow("1:1, 2:1") << QTransform().scale(1, 2) << qreal(::sqrt(2.0));
QTest::newRow("2:1, 2:1") << QTransform().scale(2, 2) << qreal(2.0);
QTest::newRow("2:1, 4:1") << QTransform().scale(2, 4) << qreal(::sqrt(8.0));
QTest::newRow("4:1, 2:1") << QTransform().scale(4, 2) << qreal(::sqrt(8.0));
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index b651668cabd..526081b2f19 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -2842,15 +2842,6 @@ const bool block_some_signals = true; // The test should also work with this set
const int rowcount = 500;
const int colcount = 10;
-static inline QString istr(int n, bool comma = true)
-{
- QString s;
- s.setNum(n);
- if (comma)
- s += ", ";
- return s;
-}
-
void tst_QHeaderView::setupTestData()
{
QTest::addColumn<bool>("updates_enabled");
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 8e46876934d..e3d172c60c0 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -187,6 +187,7 @@ private slots:
void mapFromAndTo();
void focusChainOnHide();
void focusChainOnReparent();
+ void focusChainOnReparentNoChange();
void focusAbstraction();
void defaultTabOrder();
void reverseTabOrder();
@@ -1983,6 +1984,82 @@ void tst_QWidget::focusChainOnReparent()
}
}
+//#define DEBUG_FOCUS_CHAIN
+static void dumpFocusChain(QWidget *start, bool bForward, const char *desc = nullptr)
+{
+#ifdef DEBUG_FOCUS_CHAIN
+ qDebug() << "Dump focus chain, start:" << start << "isForward:" << bForward << desc;
+ QWidget *cur = start;
+ do {
+ qDebug() << "-" << cur << cur->objectName();
+ auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur));
+ cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev;
+ } while (cur != start);
+#else
+ Q_UNUSED(start);
+ Q_UNUSED(bForward);
+ Q_UNUSED(desc);
+#endif
+}
+
+void tst_QWidget::focusChainOnReparentNoChange()
+{
+ QWidget window;
+
+ auto new_QWidget = [](QWidget *parent, const char *name) {
+ QWidget *w = new QWidget(parent);
+ w->setObjectName(name);
+ return w;
+ };
+ QWidget *child1 = new_QWidget(&window, "child1");
+ QWidget *child2 = new_QWidget(&window, "child2");
+ QWidget *child3 = new_QWidget(&window, "child3");
+ QWidget *child21 = new_QWidget(child2, "child21");
+ QWidget *child22 = new_QWidget(child2, "child22");
+ QWidget *child4 = new_QWidget(&window, "child4");
+
+ dumpFocusChain(&window, true);
+
+ QWidget *expectedOriginalChain[8] = {&window, child1, child2, child3, child21, child22, child4, &window};
+ QWidget *w = &window;
+ for (auto expectedOriginal : expectedOriginalChain) {
+ QCOMPARE(w, expectedOriginal);
+ w = w->nextInFocusChain();
+ }
+ for (int i = 7; i >= 0; --i) {
+ w = w->previousInFocusChain();
+ QCOMPARE(w, expectedOriginalChain[i]);
+ }
+
+ child2->setParent(child4);
+ child22->setParent(&window);
+ dumpFocusChain(&window, true);
+
+ /*
+ * child2 and child22 was reparented *within* the &window hierarchy
+ * Hierarchy is now:
+ *
+ * - window
+ * - child1
+ * - child3
+ * - child4
+ * - child2
+ * - child21
+ * - child22
+ *
+ * but focus chain remains the same (it depends on the order of widget construction)
+ */
+ QWidget *expectedNewChain[8] = {&window, child1, child2, child3, child21, child22, child4, &window};
+ w = &window;
+ for (auto expectedNew : expectedNewChain) {
+ QCOMPARE(w, expectedNew);
+ w = w->nextInFocusChain();
+ }
+ for (int i = 7; i >= 0; --i) {
+ w = w->previousInFocusChain();
+ QCOMPARE(w, expectedNewChain[i]);
+ }
+}
void tst_QWidget::focusChainOnHide()
{
@@ -2536,24 +2613,6 @@ void tst_QWidget::tabOrderWithProxyDisabled()
qPrintable(focusWidgetName()));
}
-//#define DEBUG_FOCUS_CHAIN
-static void dumpFocusChain(QWidget *start, bool bForward, const char *desc = nullptr)
-{
-#ifdef DEBUG_FOCUS_CHAIN
- qDebug() << "Dump focus chain, start:" << start << "isForward:" << bForward << desc;
- QWidget *cur = start;
- do {
- qDebug() << "-" << cur;
- auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur));
- cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev;
- } while (cur != start);
-#else
- Q_UNUSED(start);
- Q_UNUSED(bForward);
- Q_UNUSED(desc);
-#endif
-}
-
void tst_QWidget::tabOrderWithCompoundWidgets()
{
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
diff --git a/tests/manual/highdpi/pixelgadget/CMakeLists.txt b/tests/manual/highdpi/pixelgadget/CMakeLists.txt
index f808786b2a0..80f40fea352 100644
--- a/tests/manual/highdpi/pixelgadget/CMakeLists.txt
+++ b/tests/manual/highdpi/pixelgadget/CMakeLists.txt
@@ -5,6 +5,12 @@
## pixelgadget Binary:
#####################################################################
+if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(pixelgadget LANGUAGES C CXX)
+ find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_manual_test(pixelgadget
GUI
SOURCES
diff --git a/tests/manual/highdpi/screengadget/CMakeLists.txt b/tests/manual/highdpi/screengadget/CMakeLists.txt
index f4a7aad3067..038ff8fc851 100644
--- a/tests/manual/highdpi/screengadget/CMakeLists.txt
+++ b/tests/manual/highdpi/screengadget/CMakeLists.txt
@@ -5,6 +5,12 @@
## screengadget Binary:
#####################################################################
+if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(screengadget LANGUAGES C CXX)
+ find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_manual_test(screengadget
GUI
SOURCES