diff options
Diffstat (limited to 'tests/auto')
11 files changed, 224 insertions, 8 deletions
diff --git a/tests/auto/corelib/io/qioring/tst_qioring.cpp b/tests/auto/corelib/io/qioring/tst_qioring.cpp index 75d4fe68c55..5d5662cd9b4 100644 --- a/tests/auto/corelib/io/qioring/tst_qioring.cpp +++ b/tests/auto/corelib/io/qioring/tst_qioring.cpp @@ -20,6 +20,7 @@ class tst_QIORing : public QObject Q_OBJECT private slots: + void initTestCase(); void construct(); void sharedInstance(); void open(); @@ -33,6 +34,12 @@ private: static qintptr openHelper(QIORing *ring, const QString &path, QIODevice::OpenMode flags); }; +void tst_QIORing::initTestCase() +{ + if (QIORing::sharedInstance() == nullptr) + QSKIP("QIORing wasn't able to initialize on this platform. Test will be skipped."); +} + void tst_QIORing::closeFile(qintptr fd) { #ifdef Q_OS_WIN diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index d25a6d60cca..cae462c526b 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -381,8 +381,17 @@ void tst_QEventDispatcher::postEventFromThread() QAtomicInt hadToQuit = false; QAtomicInt done = false; + int threadCount = 500; + const int timeout = (1000 +#if defined(QT_GUI_LIB) + // Aggressively posting events may on some platforms rate limit us to + // the display's refresh rate, so give us enough time if that happens. + + ((1000.0 / qGuiApp->primaryScreen()->refreshRate()) * threadCount) +#endif + ); + threadPool->start([&]{ - int loop = 1000 / 10; // give it a second + int loop = timeout / 10; while (!done && --loop) QThread::sleep(std::chrono::milliseconds{10}); if (done) @@ -399,8 +408,7 @@ void tst_QEventDispatcher::postEventFromThread() } } receiver; - int count = 500; - while (!hadToQuit && --count) { + while (!hadToQuit && --threadCount) { threadPool->start([&receiver]{ QCoreApplication::postEvent(&receiver, new QEvent(QEvent::User)); }); diff --git a/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST index a8f73d73f4d..e69de29bb2d 100644 --- a/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST +++ b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST @@ -1,2 +0,0 @@ -[postEventFromThread] -macos-26 developer-build # QTBUG-142185 diff --git a/tests/auto/tools/rcc/data/deduplication/deduplication.expected b/tests/auto/tools/rcc/data/deduplication/deduplication.expected new file mode 100644 index 00000000000..bd873437b46 --- /dev/null +++ b/tests/auto/tools/rcc/data/deduplication/deduplication.expected @@ -0,0 +1,157 @@ +/**************************************************************************** +** Resource object code +** +IGNORE:** Created by: The Resource Compiler for Qt version 6.9.0 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#ifdef _MSC_VER +// disable informational message "function ... selected for automatic inline expansion" +#pragma warning (disable: 4711) +#endif + +static const unsigned char qt_resource_data[] = { + // b.txt + 0x0,0x0,0x0,0xb, + 0x62, + 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65, + // c_with_a_content.txt + 0x0,0x0,0x0,0xb, + 0x61, + 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65, + // b.txt + 0x0,0x0,0x0,0xb, + 0x62, + 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65, + +}; + +static const unsigned char qt_resource_name[] = { + // files + 0x0,0x5, + 0x0,0x6d,0x2,0xc3, + 0x0,0x66, + 0x0,0x69,0x0,0x6c,0x0,0x65,0x0,0x73, + // b.txt + 0x0,0x5, + 0x0,0x65,0x5b,0xf4, + 0x0,0x62, + 0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // c_with_a_content.txt + 0x0,0x14, + 0x1,0x61,0x1d,0x34, + 0x0,0x63, + 0x0,0x5f,0x0,0x77,0x0,0x69,0x0,0x74,0x0,0x68,0x0,0x5f,0x0,0x61,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6e,0x0,0x74,0x0,0x65,0x0,0x6e,0x0,0x74,0x0,0x2e, + 0x0,0x74,0x0,0x78,0x0,0x74, + // a.txt + 0x0,0x5, + 0x0,0x64,0x5b,0xf4, + 0x0,0x61, + 0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // alias_of_b_compress9.txt + 0x0,0x18, + 0xb,0x26,0xf,0xb4, + 0x0,0x61, + 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6d,0x0,0x70,0x0,0x72,0x0,0x65, + 0x0,0x73,0x0,0x73,0x0,0x39,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // alias_of_b.txt + 0x0,0xe, + 0x1,0xa4,0x6d,0x34, + 0x0,0x61, + 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // alias_of_b_compress9_dupe.txt + 0x0,0x1d, + 0x9,0x4,0x7a,0x14, + 0x0,0x61, + 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6d,0x0,0x70,0x0,0x72,0x0,0x65, + 0x0,0x73,0x0,0x73,0x0,0x39,0x0,0x5f,0x0,0x64,0x0,0x75,0x0,0x70,0x0,0x65,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + +}; + +static const unsigned char qt_resource_struct[] = { + // : + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, + // :/files + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x2, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, + // :/files/a.txt + 0x0,0x0,0x0,0x4e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xf, +TIMESTAMP:files/a.txt + // :/files/b.txt + 0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:files/b.txt + // :/files/c_with_a_content.txt + 0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xf, +TIMESTAMP:files/c_with_a_content.txt + // :/files/alias_of_b.txt + 0x0,0x0,0x0,0x94,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:files/b.txt + // :/files/alias_of_b_compress9_dupe.txt + 0x0,0x0,0x0,0xb6,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1e, +TIMESTAMP:files/b.txt + // :/files/alias_of_b_compress9.txt + 0x0,0x0,0x0,0x5e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1e, +TIMESTAMP:files/b.txt + +}; + +#ifdef QT_NAMESPACE +# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name +# define QT_RCC_MANGLE_NAMESPACE0(x) x +# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b +# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) +# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ + QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) +#else +# define QT_RCC_PREPEND_NAMESPACE(name) name +# define QT_RCC_MANGLE_NAMESPACE(name) name +#endif + +#if defined(QT_INLINE_NAMESPACE) +inline namespace QT_NAMESPACE { +#elif defined(QT_NAMESPACE) +namespace QT_NAMESPACE { +#endif + +bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); +bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +#ifdef QT_NAMESPACE +} +#endif + +int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); +int QT_RCC_MANGLE_NAMESPACE(qInitResources)() +{ + int version = 3; + QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) + (version, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() +{ + int version = 3; + QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) + (version, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace { + struct initializer { + initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); } + ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); } + } dummy; +} + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/tests/auto/tools/rcc/data/deduplication/deduplication.qrc b/tests/auto/tools/rcc/data/deduplication/deduplication.qrc new file mode 100644 index 00000000000..fd8a776503e --- /dev/null +++ b/tests/auto/tools/rcc/data/deduplication/deduplication.qrc @@ -0,0 +1,10 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>files/a.txt</file> + <file>files/b.txt</file> + <file alias="files/alias_of_b.txt">files/b.txt</file> + <file>files/c_with_a_content.txt</file> + <file alias="files/alias_of_b_compress9.txt" compress="9">files/b.txt</file> + <file alias="files/alias_of_b_compress9_dupe.txt" compress="9">files/b.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/data/deduplication/files/a.txt b/tests/auto/tools/rcc/data/deduplication/files/a.txt new file mode 100644 index 00000000000..abd91bd4652 --- /dev/null +++ b/tests/auto/tools/rcc/data/deduplication/files/a.txt @@ -0,0 +1 @@ +a test file
\ No newline at end of file diff --git a/tests/auto/tools/rcc/data/deduplication/files/b.txt b/tests/auto/tools/rcc/data/deduplication/files/b.txt new file mode 100644 index 00000000000..01e4d76fc57 --- /dev/null +++ b/tests/auto/tools/rcc/data/deduplication/files/b.txt @@ -0,0 +1 @@ +b test file
\ No newline at end of file diff --git a/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt b/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt new file mode 100644 index 00000000000..abd91bd4652 --- /dev/null +++ b/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt @@ -0,0 +1 @@ +a test file
\ No newline at end of file diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index f5edfbcaa51..ba7e5841185 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -152,6 +152,11 @@ void tst_rcc::rcc_data() QTest::newRow("legal") << m_dataPath + QLatin1StringView("/legal") << "legal.qrc" << "rcc_legal.cpp"; + + if (sizeof(size_t) == 8) { + const QString deduplicationPath = m_dataPath + QLatin1String("/deduplication"); + QTest::newRow("deduplication") << deduplicationPath << "deduplication.qrc" << "deduplication.expected"; + } } static QStringList readLinesFromFile(const QString &fileName, diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 560c725fd3f..2c14a408804 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -449,12 +449,12 @@ void tst_QWizard::setPixmap() int newWidth = 1240; wizard.resize(newWidth, 720); QCOMPARE(wizard.width(), oldWidth); - wizard.setBannerSizePolicy(QWizard::BannerSizePolicy::Stretch); + wizard.setBannerStretchPolicy(QWizard::BannerStretchPolicy::Stretch); wizard.resize(newWidth, 720); QCOMPARE(wizard.width(), newWidth); - wizard.setBannerSizePolicy(QWizard::BannerSizePolicy::NoStretch); + wizard.setBannerStretchPolicy(QWizard::BannerStretchPolicy::NoStretch); QCOMPARE(wizard.width(), oldWidth); - wizard.setBannerSizePolicy(QWizard::BannerSizePolicy::Stretch); + wizard.setBannerStretchPolicy(QWizard::BannerStretchPolicy::Stretch); wizard.resize(newWidth, 720); QCOMPARE(wizard.width(), newWidth); } diff --git a/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp index 8fcf9c49fe6..88e67b34a2d 100644 --- a/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp +++ b/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp @@ -18,6 +18,9 @@ public: private slots: void getSetCheck(); + + void displayEdgeCases_data(); + void displayEdgeCases(); }; tst_QLCDNumber::tst_QLCDNumber() @@ -42,5 +45,30 @@ void tst_QLCDNumber::getSetCheck() QCOMPARE(99, obj1.digitCount()); // Range<0, 99> } +// Test case for undefined behavior when displaying INT_MIN +void tst_QLCDNumber::displayEdgeCases_data() +{ + QTest::addColumn<int>("number"); + QTest::addColumn<QString>("expected"); + + // INT_MIN previously caused UB due to -INT_MIN overflow in int2string(). + QTest::newRow("INT_MIN") << INT_MIN << QString::number(INT_MIN); + QTest::newRow("INT_MAX") << INT_MAX << QString::number(INT_MAX); + QTest::newRow("Zero") << 0 << QStringLiteral("0"); +} + +void tst_QLCDNumber::displayEdgeCases() +{ + QFETCH(int, number); + QFETCH(QString, expected); + + QLCDNumber lcd; + lcd.setDigitCount(12); + lcd.display(number); + + QString result = QString::number(lcd.intValue()); + QCOMPARE(result, expected); +} + QTEST_MAIN(tst_QLCDNumber) #include "tst_qlcdnumber.moc" |
