diff options
Diffstat (limited to 'tests/auto/corelib')
30 files changed, 110 insertions, 159 deletions
diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index d4b9c3f1f0..1253a32f97 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -1,13 +1,23 @@ /**************************************************************************** ** -** Copyright (C) 2011 Thiago Macieira <thiago@kde.org> +** Copyright (C) 2016 Thiago Macieira <thiago@kde.org> ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index f608a36214..ce227a6c8b 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -774,6 +774,17 @@ void tst_qmessagehandler::qMessagePattern_data() << true << (QList<QByteArray>() << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug")); + QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}" + << true << (QList<QByteArray>() + << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + + "/qDebug")); + + QTest::newRow("skipped-time-shown-time") + << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}" + << true << (QList<QByteArray>() + << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug")); + // %{time} should have a padding of 6 so if it takes less than 10 seconds to show // the first message, there should be 5 spaces QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList<QByteArray>() diff --git a/tests/auto/corelib/io/qdatastream/qdatastream.pro b/tests/auto/corelib/io/qdatastream/qdatastream.pro index 961e1933de..291b3eb611 100644 --- a/tests/auto/corelib/io/qdatastream/qdatastream.pro +++ b/tests/auto/corelib/io/qdatastream/qdatastream.pro @@ -5,7 +5,7 @@ SOURCES = tst_qdatastream.cpp TESTDATA += datastream.q42 -android: !android-no-sdk { +android { RESOURCES += \ testdata.qrc } diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index e8f5d1079a..e5739f7e0a 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -8,7 +8,7 @@ TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA -android:!android-no-sdk { +android { RESOURCES += android_testdata.qrc } diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 5780f2508c..3924716b55 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -221,13 +221,13 @@ private: Q_DECLARE_METATYPE(tst_QDir::UncHandling) tst_QDir::tst_QDir() -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) : m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) #elif !defined(BUILTIN_TESTDATA) : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) #endif { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QString resourceSourcePath = QStringLiteral(":/android_testdata/"); QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); while (it.hasNext()) { @@ -2115,7 +2115,7 @@ void tst_QDir::equalityOperator_data() QString pathinroot(QDir::rootPath() + QLatin1String("assets/..")); #elif defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); -#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#elif defined(Q_OS_ANDROID) QString pathinroot("/system/.."); #elif defined(Q_OS_HAIKU) QString pathinroot("/boot/.."); diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index 9bba9615ef..6450e9af7b 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -118,7 +118,7 @@ private: void tst_QDirIterator::initTestCase() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QString testdata_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); QString resourceSourcePath = QStringLiteral(":/"); QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index f10c746618..eea79406c3 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1180,7 +1180,7 @@ void tst_QFileInfo::fileTimes() QEXPECT_FAIL("", "WinRT does not allow timestamp handling change in the filesystem due to sandboxing", Continue); #elif defined(Q_OS_QNX) QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue); -#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#elif defined(Q_OS_ANDROID) if (fileInfo.lastRead() <= beforeRead) QEXPECT_FAIL("", "Android may use relatime or noatime on mounts", Continue); #endif @@ -1622,7 +1622,7 @@ void tst_QFileInfo::isWritable() void tst_QFileInfo::isExecutable() { QString appPath = QCoreApplication::applicationDirPath(); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) appPath += "/libtst_qfileinfo.so"; #else appPath += "/tst_qfileinfo"; diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 7060cf46ac..fe2a1a562d 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -87,7 +87,7 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX"); #endif // QT_NO_FILESYSTEMWATCHER -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); #endif } diff --git a/tests/auto/corelib/io/qiodevice/qiodevice.pro b/tests/auto/corelib/io/qiodevice/qiodevice.pro index 78f5b5e75d..945022a289 100644 --- a/tests/auto/corelib/io/qiodevice/qiodevice.pro +++ b/tests/auto/corelib/io/qiodevice/qiodevice.pro @@ -6,7 +6,7 @@ SOURCES = tst_qiodevice.cpp TESTDATA += tst_qiodevice.cpp MOC_DIR=tmp -android:!android-no-sdk: { +android { RESOURCES += \ android_testdata.qrc } diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 2a5d593d9a..5cb532f76b 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -66,7 +66,7 @@ private: void tst_QIODevice::initTestCase() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); #endif diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 6814302a1f..b7dc3e9ac0 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -70,7 +70,7 @@ public: void tst_QLockFile::initTestCase() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QSKIP("This test requires deploying and running external console applications"); #elif defined(QT_NO_PROCESS) QSKIP("This test requires QProcess support"); diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index a311173c0e..321420c2df 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -8,7 +8,7 @@ SOURCES += tst_qloggingregistry.cpp OTHER_FILES += qtlogging.ini TESTDATA += qtlogging.ini -android:!android-no-sdk: { +android { RESOURCES += \ android_testdata.qrc } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 1da9cf38a1..0bc1e77925 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -40,8 +40,6 @@ #include <QtNetwork/QHostInfo> #include <stdlib.h> -# include <private/qprocess_p.h> // only so we get QPROCESS_USE_SPAWN - typedef void (QProcess::*QProcessFinishedSignal1)(int); typedef void (QProcess::*QProcessFinishedSignal2)(int, QProcess::ExitStatus); typedef void (QProcess::*QProcessErrorSignal)(QProcess::ProcessError); @@ -317,9 +315,6 @@ void tst_QProcess::startDetached() { QVERIFY(QProcess::startDetached("testProcessNormal/testProcessNormal", QStringList() << "arg1" << "arg2")); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(QProcess::startDetached("nonexistingexe"), false); } @@ -685,9 +680,6 @@ void tst_QProcess::waitForFinished() QCOMPARE(output.count("\n"), 10*1024); process.start("blurdybloop"); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QVERIFY(!process.waitForFinished()); QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -878,6 +870,16 @@ void tst_QProcess::hardExit() proc.start("testProcessEcho/testProcessEcho"); QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + +#if defined(Q_OS_QNX) + // QNX may lose the kill if it's delivered while the forked process + // is doing the exec that morphs it into testProcessEcho. It's very + // unlikely that a normal application would do such a thing. Make + // sure the test doesn't accidentally try to do it. + proc.write("A"); + QVERIFY(proc.waitForReadyRead(5000)); +#endif + proc.kill(); QVERIFY(proc.waitForFinished(5000)); @@ -1431,11 +1433,6 @@ void tst_QProcess::createProcessArgumentsModifier() void tst_QProcess::exitCodeTest() { for (int i = 0; i < 255; ++i) { -#ifdef QPROCESS_USE_SPAWN - // POSIX reserves exit code 127 when using posix_spawn - if (i == 127) - continue; -#endif QProcess process; process.start("testExitCodes/testExitCodes " + QString::number(i)); QVERIFY(process.waitForFinished(5000)); @@ -1446,9 +1443,6 @@ void tst_QProcess::exitCodeTest() void tst_QProcess::failToStart() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); @@ -1519,9 +1513,6 @@ void tst_QProcess::failToStart() void tst_QProcess::failToStartWithWait() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1551,9 +1542,6 @@ void tst_QProcess::failToStartWithWait() void tst_QProcess::failToStartWithEventLoop() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1821,9 +1809,6 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); QCOMPARE(errorSpy2.count(), 1); @@ -2167,9 +2152,6 @@ void tst_QProcess::setNonExistentWorkingDirectory() // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either). process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath()); QVERIFY(!process.waitForFinished()); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(int(process.error()), int(QProcess::FailedToStart)); #ifdef Q_OS_UNIX diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index e8b82b4df7..a39de3c4d5 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -17,6 +17,6 @@ TESTDATA += \ testqrc/* GENERATED_TESTDATA = $${runtime_resource.target} -android:!android-no-sdk { +android { RESOURCES += android_testdata.qrc } diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 5c51e69add..561ab193c6 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -36,7 +36,7 @@ class tst_QResourceEngine: public QObject public: tst_QResourceEngine() -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) : m_runtimeResourceRcc(QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/runtime_resource.rcc")).absoluteFilePath()) #else : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) @@ -63,7 +63,7 @@ private: void tst_QResourceEngine::initTestCase() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QString sourcePath(QStringLiteral(":/android_testdata/")); QString dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); @@ -120,7 +120,7 @@ void tst_QResourceEngine::checkStructure_data() << QLatin1String("test") << QLatin1String("withoutslashes"); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) rootContents.insert(1, QLatin1String("android_testdata")); #endif diff --git a/tests/auto/corelib/io/qstandardpaths/BLACKLIST b/tests/auto/corelib/io/qstandardpaths/BLACKLIST deleted file mode 100644 index 8496a620b3..0000000000 --- a/tests/auto/corelib/io/qstandardpaths/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[testRuntimeDirectory] -rhel-7.1 diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 9380b7d73c..f0b9c05810 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -230,7 +230,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir() { #ifdef Q_OS_UNIX -# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +# if defined(Q_OS_ANDROID) const char nonWritableDir[] = "/data"; # else const char nonWritableDir[] = "/home"; diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro index 8f250e4568..a89e5c66ff 100644 --- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -5,6 +5,6 @@ SOURCES = tst_qtemporaryfile.cpp TESTDATA += tst_qtemporaryfile.cpp RESOURCES += qtemporaryfile.qrc -android:!android-no-sdk { +android { RESOURCES += android_testdata.qrc } diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 93a3bc895c..921136e79b 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -93,7 +93,7 @@ void tst_QTemporaryFile::initTestCase() QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QCoreApplication::setApplicationName("tst_qtemporaryfile"); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QString sourceDir(":/android_testdata/"); QDirIterator it(sourceDir, QDirIterator::Subdirectories); while (it.hasNext()) { @@ -290,7 +290,7 @@ void tst_QTemporaryFile::nonWritableCurrentDir() ChdirOnReturn cor(QDir::currentPath()); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QDir::setCurrent("/data"); #else QDir::setCurrent("/home"); @@ -459,7 +459,7 @@ void tst_QTemporaryFile::renameFdLeak() { #ifdef Q_OS_UNIX -# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +# if defined(Q_OS_ANDROID) ChdirOnReturn cor(QDir::currentPath()); QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); # endif @@ -668,7 +668,7 @@ void tst_QTemporaryFile::createNativeFile_data() QTest::addColumn<bool>("valid"); QTest::addColumn<QByteArray>("content"); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) const QString nativeFilePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/resources/test.txt"); #else const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index 838120bb68..914f9e2b9b 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -54,6 +54,7 @@ private slots: void qvariantCast(); void constPointer(); + void constQPointer(); }; void tst_QPointer::constructors() @@ -397,6 +398,21 @@ void tst_QPointer::constPointer() delete fp.data(); } +void tst_QPointer::constQPointer() +{ + // Check that const QPointers work. It's a bit weird to mark a pointer + // const if its value can change, but the shallow-const principle in C/C++ + // allows this, and people use it, so document it with a test. + // + // It's unlikely that this test will fail in and out of itself, but it + // presents the use-case to static and dynamic checkers that can raise + // a warning (hopefully) should this become an issue. + QObject *o = new QObject(this); + const QPointer<QObject> p = o; + delete o; + QVERIFY(!p); +} + QTEST_MAIN(tst_QPointer) #include "tst_qpointer.moc" diff --git a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro index 63189e5562..e673278920 100644 --- a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro +++ b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro @@ -4,6 +4,6 @@ QT = core testlib SOURCES = tst_qtranslator.cpp RESOURCES += qtranslator.qrc -android:!android-no-sdk: RESOURCES += android_testdata.qrc +android: RESOURCES += android_testdata.qrc else: TESTDATA += dependencies_la.qm hellotr_la.qm msgfmt_from_po.qm diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index 59ea484355..66971af7b4 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -64,7 +64,7 @@ tst_QTranslator::tst_QTranslator() void tst_QTranslator::initTestCase() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QString sourceDir(":/android_testdata/"); QDirIterator it(sourceDir, QDirIterator::Subdirectories); while (it.hasNext()) { diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 32c2154da6..7f6e26eecb 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -276,6 +276,8 @@ private slots: void compareSanity_data(); void compareSanity(); + void accessSequentialContainerKey(); + private: void dataStream_data(QDataStream::Version version); void loadQVariantFromDataStream(QDataStream::Version version); @@ -4763,5 +4765,30 @@ void tst_QVariant::compareSanity() } } +void tst_QVariant::accessSequentialContainerKey() +{ + QString nameResult; + + { + QMap<QString, QObject*> mapping; + QString name = QString::fromLatin1("Seven"); + mapping.insert(name, Q_NULLPTR); + + QVariant variant = QVariant::fromValue(mapping); + + QAssociativeIterable iterable = variant.value<QAssociativeIterable>(); + QAssociativeIterable::const_iterator iit = iterable.begin(); + const QAssociativeIterable::const_iterator end = iterable.end(); + for ( ; iit != end; ++iit) { + nameResult += iit.key().toString(); + } + } // Destroy mapping + // Regression test for QTBUG-52246 - no memory corruption/double deletion + // of the string key. + + QCOMPARE(nameResult, QStringLiteral("Seven")); +} + + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index fe465df395..5f5252aa96 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -174,9 +174,6 @@ private Q_SLOTS: void fetchAndSub_data() { addData(); } void fetchAndSub(); - void addSub_data() { addData(); } - void addSub(); - void fetchAndOr_data() { addData(); } void fetchAndOr(); @@ -656,96 +653,6 @@ void tst_QAtomicIntegerXX::fetchAndSub() } } -void tst_QAtomicIntegerXX::addSub() -{ - QFETCH(LargeInt, value); - QAtomicInteger<T> atomic(value); - - // note: this test has undefined behavior for signed max and min - T parcel1 = 42; - T parcel2 = T(0-parcel1); - T newValue1 = T(value) + parcel1; - T newValue2 = T(value) - parcel1; - - QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubAcquire(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddAcquire(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubAcquire(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddAcquire(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddRelease(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubRelease(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelease(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddRelease(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddRelease(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubRelease(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelease(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddRelease(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddOrdered(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubOrdered(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubOrdered(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddOrdered(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddOrdered(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubOrdered(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubOrdered(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddOrdered(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - // operator+= and operator-= - QCOMPARE(atomic += parcel1, newValue1); - QCOMPARE(atomic -= parcel1, T(value)); - QCOMPARE(atomic -= parcel1, newValue2); - QCOMPARE(atomic += parcel1, T(value)); - QCOMPARE(atomic += parcel2, newValue2); - QCOMPARE(atomic -= parcel2, T(value)); - QCOMPARE(atomic -= parcel2, newValue1); - QCOMPARE(atomic += parcel2, T(value)); -} - void tst_QAtomicIntegerXX::fetchAndOr() { QFETCH(LargeInt, value); diff --git a/tests/auto/corelib/tools/qbytearray/qbytearray.pro b/tests/auto/corelib/tools/qbytearray/qbytearray.pro index a4501611d6..f59cdf3524 100644 --- a/tests/auto/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/auto/corelib/tools/qbytearray/qbytearray.pro @@ -10,7 +10,7 @@ mac { LIBS += -framework Foundation } -android: !android-no-sdk { +android { RESOURCES += \ android_testdata.qrc } diff --git a/tests/auto/corelib/tools/qchar/qchar.pro b/tests/auto/corelib/tools/qchar/qchar.pro index 771e4290b8..012e591298 100644 --- a/tests/auto/corelib/tools/qchar/qchar.pro +++ b/tests/auto/corelib/tools/qchar/qchar.pro @@ -5,7 +5,7 @@ SOURCES = tst_qchar.cpp TESTDATA += data/NormalizationTest.txt -android: !android-no-sdk { +android { RESOURCES += \ testdata.qrc } diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp index f2f1038dc2..d09910fd5c 100644 --- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -165,7 +165,7 @@ void tst_QCollator::compare() QCollator collator(locale); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) if (collator.locale() != QLocale()) QSKIP("Posix implementation of collation only supports default locale"); #endif diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 319b04fa1a..a54ad3d9c9 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -512,7 +512,7 @@ void tst_QCommandLineParser::testVersionOption() #ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); #else -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QSKIP("Deploying executable applications to file system on Android not supported."); #endif @@ -578,7 +578,7 @@ void tst_QCommandLineParser::testHelpOption() #ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); #else -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) QSKIP("Deploying executable applications to file system on Android not supported."); #endif @@ -625,7 +625,7 @@ void tst_QCommandLineParser::testQuoteEscaping() { #ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); -#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#elif defined(Q_OS_ANDROID) QSKIP("Deploying executable applications to file system on Android not supported."); #else QCoreApplication app(empty_argc, empty_argv); diff --git a/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro b/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro index 15a57c692e..7fead5938b 100644 --- a/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro +++ b/tests/auto/corelib/tools/qcryptographichash/qcryptographichash.pro @@ -5,7 +5,7 @@ SOURCES = tst_qcryptographichash.cpp TESTDATA += data/* -android: !android-no-sdk { +android { RESOURCES += \ testdata.qrc } diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro b/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro index 9d26ec1fd5..8e0216b175 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro +++ b/tests/auto/corelib/tools/qtextboundaryfinder/qtextboundaryfinder.pro @@ -5,7 +5,7 @@ SOURCES = tst_qtextboundaryfinder.cpp TESTDATA += data -android: !android-no-sdk { +android { RESOURCES += \ testdata.qrc } |