summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp140
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp44
-rw-r--r--tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp14
-rw-r--r--tests/auto/corelib/kernel/qtranslator/hellotr_la.qmbin230 -> 237 bytes
-rw-r--r--tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp15
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp24
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp24
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp162
-rw-r--r--tests/auto/corelib/text/qcollator/tst_qcollator.cpp14
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp37
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp160
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp23
-rw-r--r--tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp25
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp4
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp23
-rw-r--r--tests/auto/corelib/time/qtime/tst_qtime.cpp6
-rw-r--r--tests/auto/corelib/tools/qscopeguard/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/tools/qscopeguard/qscopeguard.pro3
-rw-r--r--tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp119
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp17
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp12
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/links.md25
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp1
-rw-r--r--tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp2
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp6
-rw-r--r--tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp8
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp20
-rw-r--r--tests/auto/testlib/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/badxml/tst_badxml.cpp3
-rw-r--r--tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp10
-rw-r--r--tests/auto/testlib/selftests/benchlibcounting/tst_benchlibcounting.cpp11
-rw-r--r--tests/auto/testlib/selftests/benchlibeventcounter/tst_benchlibeventcounter.cpp5
-rw-r--r--tests/auto/testlib/selftests/benchliboptions/tst_benchliboptions.cpp23
-rw-r--r--tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp10
-rw-r--r--tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp2
-rw-r--r--tests/auto/testlib/selftests/commandlinedata/tst_commandlinedata.cpp12
-rw-r--r--tests/auto/testlib/selftests/counting/tst_counting.cpp12
-rw-r--r--tests/auto/testlib/selftests/deleteLater/deleteLater.pro2
-rw-r--r--tests/auto/testlib/selftests/deleteLater_noApp/deleteLater_noApp.pro2
-rw-r--r--tests/auto/testlib/selftests/expected_assert.junitxml (renamed from tests/auto/testlib/selftests/expected_assert.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.junitxml (renamed from tests/auto/testlib/selftests/expected_badxml.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibcallgrind.junitxml (renamed from tests/auto/testlib/selftests/expected_benchlibcallgrind.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibcounting.junitxml (renamed from tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibeventcounter.junitxml (renamed from tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchliboptions.junitxml (renamed from tests/auto/testlib/selftests/expected_benchliboptions.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibtickcounter.junitxml (renamed from tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibwalltime.junitxml (renamed from tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_blacklisted.junitxml (renamed from tests/auto/testlib/selftests/expected_blacklisted.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.junitxml (renamed from tests/auto/testlib/selftests/expected_cmptest.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_commandlinedata.junitxml (renamed from tests/auto/testlib/selftests/expected_commandlinedata.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_counting.junitxml (renamed from tests/auto/testlib/selftests/expected_counting.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_datatable.junitxml (renamed from tests/auto/testlib/selftests/expected_datatable.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.junitxml (renamed from tests/auto/testlib/selftests/expected_datetime.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_differentexec.junitxml (renamed from tests/auto/testlib/selftests/expected_differentexec.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_exceptionthrow.junitxml (renamed from tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_expectfail.junitxml (renamed from tests/auto/testlib/selftests/expected_expectfail.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_failcleanup.junitxml (renamed from tests/auto/testlib/selftests/expected_failcleanup.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_faildatatype.junitxml (renamed from tests/auto/testlib/selftests/expected_faildatatype.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_failfetchtype.junitxml (renamed from tests/auto/testlib/selftests/expected_failfetchtype.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_failinit.junitxml (renamed from tests/auto/testlib/selftests/expected_failinit.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_failinitdata.junitxml (renamed from tests/auto/testlib/selftests/expected_failinitdata.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_fetchbogus.junitxml (renamed from tests/auto/testlib/selftests/expected_fetchbogus.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_findtestdata.junitxml (renamed from tests/auto/testlib/selftests/expected_findtestdata.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_float.junitxml (renamed from tests/auto/testlib/selftests/expected_float.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_globaldata.junitxml (renamed from tests/auto/testlib/selftests/expected_globaldata.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_keyboard.junitxml (renamed from tests/auto/testlib/selftests/expected_keyboard.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_longstring.junitxml (renamed from tests/auto/testlib/selftests/expected_longstring.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_maxwarnings.junitxml (renamed from tests/auto/testlib/selftests/expected_maxwarnings.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_multiexec.junitxml (renamed from tests/auto/testlib/selftests/expected_multiexec.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml (renamed from tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_qexecstringlist.junitxml (renamed from tests/auto/testlib/selftests/expected_qexecstringlist.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_signaldumper.junitxml (renamed from tests/auto/testlib/selftests/expected_signaldumper.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_silent.junitxml (renamed from tests/auto/testlib/selftests/expected_silent.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_singleskip.junitxml (renamed from tests/auto/testlib/selftests/expected_singleskip.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_skip.junitxml (renamed from tests/auto/testlib/selftests/expected_skip.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_skipcleanup.junitxml (renamed from tests/auto/testlib/selftests/expected_skipcleanup.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_skipinit.junitxml (renamed from tests/auto/testlib/selftests/expected_skipinit.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_skipinitdata.junitxml (renamed from tests/auto/testlib/selftests/expected_skipinitdata.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_sleep.junitxml (renamed from tests/auto/testlib/selftests/expected_sleep.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_strcmp.junitxml (renamed from tests/auto/testlib/selftests/expected_strcmp.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_subtest.junitxml (renamed from tests/auto/testlib/selftests/expected_subtest.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_testlib.junitxml (renamed from tests/auto/testlib/selftests/expected_testlib.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_tuplediagnostics.junitxml (renamed from tests/auto/testlib/selftests/expected_tuplediagnostics.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_verbose1.junitxml (renamed from tests/auto/testlib/selftests/expected_verbose1.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_verbose2.junitxml (renamed from tests/auto/testlib/selftests/expected_verbose2.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.junitxml (renamed from tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.junitxml (renamed from tests/auto/testlib/selftests/expected_warnings.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_watchdog.junitxml (renamed from tests/auto/testlib/selftests/expected_watchdog.xunitxml)0
-rw-r--r--tests/auto/testlib/selftests/expected_xunit.junitxml (renamed from tests/auto/testlib/selftests/expected_xunit.xunitxml)0
-rwxr-xr-xtests/auto/testlib/selftests/generate_expected_output.py23
-rw-r--r--tests/auto/testlib/selftests/mouse/tst_mouse.cpp67
-rw-r--r--tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp10
-rw-r--r--tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp10
-rw-r--r--tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp11
-rw-r--r--tests/auto/testlib/selftests/silent/tst_silent.cpp13
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp103
-rw-r--r--tests/auto/testlib/selftests/verbose1/verbose1.pro2
-rw-r--r--tests/auto/testlib/selftests/verbose2/verbose2.pro2
-rw-r--r--tests/auto/tools/uic/baseline/config.ui.py10
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp28
-rw-r--r--tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp7
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp70
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp51
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp37
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp63
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp28
108 files changed, 1311 insertions, 252 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 16a30af892..350bff0652 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -279,6 +279,9 @@ private slots:
void reuseQFile();
+ void moveToTrash_data();
+ void moveToTrash();
+
private:
#ifdef BUILTIN_TESTDATA
QSharedPointer<QTemporaryDir> m_dataDir;
@@ -3672,5 +3675,142 @@ void tst_QFile::reuseQFile()
}
}
+void tst_QFile::moveToTrash_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("create");
+ QTest::addColumn<bool>("result");
+
+ // success cases
+ {
+ QTemporaryFile temp;
+ QVERIFY(temp.open());
+ QTest::newRow("temporary file") << temp.fileName() << true << true;
+ }
+ {
+ QTemporaryDir tempDir;
+ tempDir.setAutoRemove(false);
+ QTest::newRow("temporary dir")
+ << tempDir.path() + QLatin1Char('/')
+ << true << true;
+ }
+ {
+ QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/XXXXXX"));
+ homeDir.setAutoRemove(false);
+ QTemporaryFile homeFile(homeDir.path()
+ + QLatin1String("/tst_qfile-XXXXXX"));
+ homeFile.open();
+ QTest::newRow("home file")
+ << homeFile.fileName()
+ << true << true;
+
+ QTest::newRow("home dir")
+ << homeDir.path() + QLatin1Char('/')
+ << true << true;
+ }
+ QTest::newRow("relative") << QStringLiteral("tst_qfile_moveToTrash.tmp") << true << true;
+
+ // failure cases
+ QTest::newRow("root") << QDir::rootPath() << false << false;
+ QTest::newRow("no-such-file") << QString::fromLatin1("no/such/file") << false << false;
+}
+
+void tst_QFile::moveToTrash()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, create);
+ QFETCH(bool, result);
+
+ /* This test makes assumptions about the file system layout
+ which might be wrong - moveToTrash may fail if the file lives
+ on a file system that is different from the home file system, and
+ has no .Trash directory.
+ */
+ const bool mayFail = QStorageInfo(source) != QStorageInfo(QDir::home());
+
+#if defined(Q_OS_WINRT)
+ QSKIP("WinRT does not have a trash", SkipAll);
+#endif
+
+ auto ensureFile = [](const QString &source, bool create) {
+ if (QFileInfo::exists(source) || !create)
+ return;
+ if (source.endsWith(QLatin1Char('/'))) {
+ QDir::root().mkdir(source);
+ QFile file(source + QLatin1String("test"));
+ if (!file.open(QIODevice::WriteOnly))
+ QSKIP("Couldn't create directory with file");
+ } else {
+ QFile sourceFile(source);
+ QVERIFY2(sourceFile.open(QFile::WriteOnly | QFile::Text), qPrintable(sourceFile.errorString()));
+ sourceFile.close();
+ }
+ };
+ auto cleanupFile = [source, create]() {
+ if (!QFileInfo::exists(source) || !create)
+ return;
+ if (source.endsWith(QLatin1Char('/'))) {
+ QDir(source).removeRecursively();
+ } else {
+ QFile sourceFile(source);
+ sourceFile.remove();
+ }
+ };
+ // non-static version
+ {
+ ensureFile(source, create);
+ QFile sourceFile(source);
+ const bool success = sourceFile.moveToTrash();
+
+ // tolerate moveToTrash failing
+ if (result && !success && mayFail)
+ result = false;
+
+ if (result) {
+ // if any of the test fails, we still want to remove the file
+ auto onFailure = qScopeGuard(cleanupFile);
+ QVERIFY2(success, qPrintable(sourceFile.errorString()));
+ QCOMPARE(sourceFile.error(), QFile::NoError);
+ QVERIFY(source != sourceFile.fileName());
+ if (!sourceFile.fileName().isEmpty()) {
+ QVERIFY2(sourceFile.exists(), qPrintable(sourceFile.fileName()));
+ // remove file/dir in trash as well, don't fill disk
+ if (source.endsWith(QLatin1Char('/')))
+ QDir(sourceFile.fileName()).removeRecursively();
+ else
+ sourceFile.remove();
+ }
+ } else {
+ QVERIFY(!success);
+ QVERIFY(!sourceFile.errorString().isEmpty());
+ QCOMPARE(source, sourceFile.fileName());
+ }
+ }
+
+ // don't retry
+ if (mayFail)
+ return;
+
+ // static version
+ {
+ ensureFile(source, create);
+ QString pathInTrash;
+ const bool success = QFile::moveToTrash(source, &pathInTrash);
+ QCOMPARE(success, result);
+ if (result) {
+ auto onFailure = qScopeGuard(cleanupFile);
+ QVERIFY(source != pathInTrash);
+ if (!pathInTrash.isEmpty()) {
+ // remove file/dir in trash as well, don't fill disk
+ QVERIFY2(QFile::exists(pathInTrash), qPrintable(pathInTrash));
+ if (source.endsWith(QLatin1Char('/')))
+ QDir(pathInTrash).removeRecursively();
+ else
+ QFile::remove(pathInTrash);
+ }
+ }
+ }
+}
+
QTEST_MAIN(tst_QFile)
#include "tst_qfile.moc"
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 365508024b..85a2dae3b6 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -45,8 +45,10 @@ class tst_QEventDispatcher : public QObject
Q_OBJECT
QAbstractEventDispatcher *eventDispatcher;
- int receivedEventType;
- int timerIdFromEvent;
+
+ int receivedEventType = -1;
+ int timerIdFromEvent = -1;
+ bool doubleTimer = false;
protected:
bool event(QEvent *e);
@@ -54,9 +56,7 @@ protected:
public:
inline tst_QEventDispatcher()
: QObject(),
- eventDispatcher(QAbstractEventDispatcher::instance(thread())),
- receivedEventType(-1),
- timerIdFromEvent(-1)
+ eventDispatcher(QAbstractEventDispatcher::instance(thread()))
{ }
private slots:
@@ -75,6 +75,9 @@ bool tst_QEventDispatcher::event(QEvent *e)
switch (receivedEventType = e->type()) {
case QEvent::Timer:
{
+ // sometimes, two timers fire during a single QTRY_xxx wait loop
+ if (timerIdFromEvent != -1)
+ doubleTimer = true;
timerIdFromEvent = static_cast<QTimerEvent *>(e)->timerId();
return true;
}
@@ -206,10 +209,31 @@ void tst_QEventDispatcher::registerTimer()
QVERIFY(timers.foundCoarse());
QVERIFY(timers.foundVeryCoarse());
+#ifdef Q_OS_DARWIN
+ /*
+ We frequently experience flaky failures on macOS. Assumption is that this is
+ due to undeterministic VM scheduling, making us process events for significantly
+ longer than expected and resulting in timers firing in undefined order.
+ To detect this condition, we use a QElapsedTimer, and skip the test.
+ */
+ QElapsedTimer elapsedTimer;
+ elapsedTimer.start();
+#endif
+
// process events, waiting for the next event... this should only fire the precise timer
receivedEventType = -1;
timerIdFromEvent = -1;
+ doubleTimer = false;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2);
+
+#ifdef Q_OS_DARWIN
+ if (doubleTimer)
+ QSKIP("Double timer during a single timeout - aborting test as flaky on macOS");
+ if (timerIdFromEvent != timers.preciseTimerId()
+ && elapsedTimer.elapsed() > PreciseTimerInterval * 3)
+ QSKIP("Ignore flaky test behavior due to VM scheduling on macOS");
+#endif
+
QCOMPARE(timerIdFromEvent, timers.preciseTimerId());
// now unregister it and make sure it's gone
timers.unregister(timers.preciseTimerId());
@@ -223,7 +247,17 @@ void tst_QEventDispatcher::registerTimer()
// do the same again for the coarse timer
receivedEventType = -1;
timerIdFromEvent = -1;
+ doubleTimer = false;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2);
+
+#ifdef Q_OS_DARWIN
+ if (doubleTimer)
+ QSKIP("Double timer during a single timeout - aborting test as flaky on macOS");
+ if (timerIdFromEvent != timers.coarseTimerId()
+ && elapsedTimer.elapsed() > CoarseTimerInterval * 3)
+ QSKIP("Ignore flaky test behavior due to VM scheduling on macOS");
+#endif
+
QCOMPARE(timerIdFromEvent, timers.coarseTimerId());
// now unregister it and make sure it's gone
timers.unregister(timers.coarseTimerId());
diff --git a/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp b/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp
index c03e3e8e9f..78b0b5dc55 100644
--- a/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp
+++ b/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp
@@ -41,8 +41,8 @@ class QtTestObject : public QObject
{
Q_OBJECT
public slots:
- void myslot(int id);
- void myslot(const QString &str);
+ void myIntSlot(int id);
+ void myStringSlot(const QString &str);
signals:
void mysignal(int);
@@ -54,12 +54,12 @@ public:
QString str;
};
-void QtTestObject::myslot(int id)
+void QtTestObject::myIntSlot(int id)
{
this->id = id;
}
-void QtTestObject::myslot(const QString &str)
+void QtTestObject::myStringSlot(const QString &str)
{
this->str = str;
}
@@ -71,7 +71,7 @@ void QtTestObject::emit_mysignal(int value)
void tst_QSignalMapper::mapped()
{
- QSignalMapper mapper(0);
+ QSignalMapper mapper;
QtTestObject target;
QtTestObject src1;
@@ -88,8 +88,8 @@ void tst_QSignalMapper::mapped()
mapper.setMapping(&src2, "two");
mapper.setMapping(&src3, "three");
- connect(&mapper, SIGNAL(mapped(int)), &target, SLOT(myslot(int)));
- connect(&mapper, SIGNAL(mapped(QString)), &target, SLOT(myslot(QString)));
+ connect(&mapper, &QSignalMapper::mappedInt, &target, &QtTestObject::myIntSlot);
+ connect(&mapper, &QSignalMapper::mappedString, &target, &QtTestObject::myStringSlot);
src1.emit_mysignal(20);
QCOMPARE(target.id, 1);
diff --git a/tests/auto/corelib/kernel/qtranslator/hellotr_la.qm b/tests/auto/corelib/kernel/qtranslator/hellotr_la.qm
index cc42afe05c..25c0aad583 100644
--- a/tests/auto/corelib/kernel/qtranslator/hellotr_la.qm
+++ b/tests/auto/corelib/kernel/qtranslator/hellotr_la.qm
Binary files differ
diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
index b3efa97dbd..9fde7da816 100644
--- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
@@ -110,9 +110,10 @@ void tst_QTranslator::load_data()
QTest::addColumn<QString>("filepath");
QTest::addColumn<bool>("isEmpty");
QTest::addColumn<QString>("translation");
+ QTest::addColumn<QString>("language");
- QTest::newRow("hellotr_la") << "hellotr_la.qm" << false << "Hallo Welt!";
- QTest::newRow("hellotr_empty") << "hellotr_empty.qm" << true << "";
+ QTest::newRow("hellotr_la") << "hellotr_la.qm" << false << "Hallo Welt!" << "de";
+ QTest::newRow("hellotr_empty") << "hellotr_empty.qm" << true << "" << "";
}
void tst_QTranslator::load()
@@ -120,12 +121,15 @@ void tst_QTranslator::load()
QFETCH(QString, filepath);
QFETCH(bool, isEmpty);
QFETCH(QString, translation);
+ QFETCH(QString, language);
{
QTranslator tor;
QVERIFY(tor.load(QFileInfo(filepath).baseName()));
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
+ QCOMPARE(tor.filePath(), filepath);
+ QCOMPARE(tor.language(), language);
}
{
@@ -136,13 +140,18 @@ void tst_QTranslator::load()
QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
+ QCOMPARE(tor.filePath(), "");
+ QCOMPARE(tor.language(), language);
}
{
QTranslator tor;
- QVERIFY(tor.load(QString(":/tst_qtranslator/%1").arg(filepath)));
+ QString path = QString(":/tst_qtranslator/%1").arg(filepath);
+ QVERIFY(tor.load(path));
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
+ QCOMPARE(tor.filePath(), path);
+ QCOMPARE(tor.language(), language);
}
}
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 91733bea90..b8baa1cde1 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 shouldDeleteVariantDataWorksForAssociative();
void fromStdVariant();
void qt4UuidDataStream();
+ void sequentialIterableEndianessSanityCheck();
+ void sequentialIterableAppend();
void preferDirectConversionOverInterfaces();
@@ -4698,6 +4700,28 @@ void tst_QVariant::qt4UuidDataStream()
QCOMPARE(result.value<QUuid>(), source);
}
+void tst_QVariant::sequentialIterableEndianessSanityCheck()
+{
+ namespace QMTP = QtMetaTypePrivate;
+ uint oldIteratorCaps = QMTP::ForwardCapability | QMTP::BiDirectionalCapability | QMTP::RandomAccessCapability;
+ QMTP::QSequentialIterableImpl seqImpl {};
+ QCOMPARE(seqImpl.revision(), 1u);
+ memcpy(&seqImpl._iteratorCapabilities, &oldIteratorCaps, sizeof(oldIteratorCaps));
+ QCOMPARE(seqImpl.revision(), 0u);
+}
+
+void tst_QVariant::sequentialIterableAppend()
+{
+ QVector<int> container {1, 2};
+ auto variant = QVariant::fromValue(container);
+ QVERIFY(variant.canConvert<QtMetaTypePrivate::QSequentialIterableImpl>());
+ auto asIterable = variant.value<QtMetaTypePrivate::QSequentialIterableImpl>();
+ const int i = 3, j = 4;
+ asIterable.append(&i);
+ asIterable.append(&j);
+ QCOMPARE(variant.value<QVector<int>>(), QVector<int> ({1, 2, 3, 4}));
+}
+
void tst_QVariant::preferDirectConversionOverInterfaces()
{
using namespace QtMetaTypePrivate;
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index d1a77173c3..2f812a9952 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -1276,18 +1276,18 @@ void tst_QDataStream::readQCursor(QDataStream *s)
QVERIFY(d5.shape() == test.shape()); //## lacks operator==
QCOMPARE(d5.hotSpot(), test.hotSpot());
- QVERIFY((d5.bitmap() != 0 && test.bitmap() != 0) || (d5.bitmap() == 0 && test.bitmap() == 0));
- if (d5.bitmap() != 0) {
- QPixmap actual = *(d5.bitmap());
- QPixmap expected = *(test.bitmap());
- QCOMPARE(actual, expected);
- }
- QVERIFY((d5.mask() != 0 && test.mask() != 0) || (d5.mask() == 0 && test.mask() == 0));
- if (d5.mask() != 0) {
- QPixmap actual = *(d5.mask());
- QPixmap expected = *(test.mask());
- QCOMPARE(actual, expected);
- }
+
+ // Comparing non-null QBitmaps will fail. Upcast them first to pass.
+ QCOMPARE(d5.bitmap(Qt::ReturnByValue).isNull(), test.bitmap(Qt::ReturnByValue).isNull());
+ QCOMPARE(
+ static_cast<QPixmap>(d5.bitmap(Qt::ReturnByValue)),
+ static_cast<QPixmap>(test.bitmap(Qt::ReturnByValue))
+ );
+ QCOMPARE(d5.mask(Qt::ReturnByValue).isNull(), test.mask(Qt::ReturnByValue).isNull());
+ QCOMPARE(
+ static_cast<QPixmap>(d5.mask(Qt::ReturnByValue)),
+ static_cast<QPixmap>(test.mask(Qt::ReturnByValue))
+ );
}
#endif
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index 4b13ac45cc..b1f6090585 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -253,6 +253,10 @@ private slots:
void qtbug_46703();
void postEventFromBeginSelectTransitions();
void dontProcessSlotsWhenMachineIsNotRunning();
+
+ void cancelDelayedEventWithChrono();
+ void postDelayedEventWithChronoAndStop();
+ void postDelayedEventWithChronoFromThread();
};
class TestState : public QState
@@ -6702,5 +6706,163 @@ void tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning()
QTRY_VERIFY(emitter.thread.isFinished());
}
+void tst_QStateMachine::cancelDelayedEventWithChrono()
+{
+#if __has_include(<chrono>)
+ QStateMachine machine;
+ QTest::ignoreMessage(QtWarningMsg,
+ "QStateMachine::cancelDelayedEvent: the machine is not running");
+ QVERIFY(!machine.cancelDelayedEvent(-1));
+
+ QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
+ QFinalState *s2 = new QFinalState(&machine);
+ s1->addTransition(new StringTransition("a", s2));
+ machine.setInitialState(s1);
+
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(startedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+ int id1 = machine.postDelayedEvent(new StringEvent("c"), std::chrono::seconds{50});
+ QVERIFY(id1 != -1);
+ int id2 = machine.postDelayedEvent(new StringEvent("b"), std::chrono::seconds{25});
+ QVERIFY(id2 != -1);
+ QVERIFY(id2 != id1);
+ int id3 = machine.postDelayedEvent(new StringEvent("a"), std::chrono::milliseconds{100});
+ QVERIFY(id3 != -1);
+ QVERIFY(id3 != id2);
+ QVERIFY(machine.cancelDelayedEvent(id1));
+ QVERIFY(!machine.cancelDelayedEvent(id1));
+ QVERIFY(machine.cancelDelayedEvent(id2));
+ QVERIFY(!machine.cancelDelayedEvent(id2));
+
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QVERIFY(finishedSpy.isValid());
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+#endif
+}
+
+void tst_QStateMachine::postDelayedEventWithChronoAndStop()
+{
+#if __has_include(<chrono>)
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
+ QFinalState *s2 = new QFinalState(&machine);
+ s1->addTransition(new StringTransition("a", s2));
+ machine.setInitialState(s1);
+
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QVERIFY(startedSpy.isValid());
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ int id1 = machine.postDelayedEvent(new StringEvent("a"), std::chrono::milliseconds{0});
+ QVERIFY(id1 != -1);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QVERIFY(stoppedSpy.isValid());
+ machine.stop();
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ int id2 = machine.postDelayedEvent(new StringEvent("a"), std::chrono::seconds{1});
+ QVERIFY(id2 != -1);
+ machine.stop();
+ QTRY_COMPARE(stoppedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 3);
+ TEST_RUNNING_CHANGED(true);
+ QTestEventLoop::instance().enterLoop(2);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+ TEST_ACTIVE_CHANGED(s1, 5);
+ QVERIFY(machine.isRunning());
+#endif
+}
+
+class DelayedEventWithChronoPosterThread : public QThread
+{
+ Q_OBJECT
+public:
+ DelayedEventWithChronoPosterThread(QStateMachine *machine, QObject *parent = 0)
+ : QThread(parent), firstEventWasCancelled(false), m_machine(machine)
+ {
+ moveToThread(this);
+ QObject::connect(m_machine, SIGNAL(started()), this, SLOT(postEvent()));
+ }
+
+ mutable bool firstEventWasCancelled;
+
+private Q_SLOTS:
+ void postEvent()
+ {
+#if __has_include(<chrono>)
+ int id = m_machine->postDelayedEvent(new QEvent(QEvent::User), std::chrono::seconds{1});
+ firstEventWasCancelled = m_machine->cancelDelayedEvent(id);
+
+ m_machine->postDelayedEvent(new QEvent(QEvent::User), std::chrono::milliseconds{1});
+
+ quit();
+#endif
+ }
+
+private:
+ QStateMachine *m_machine;
+};
+
+void tst_QStateMachine::postDelayedEventWithChronoFromThread()
+{
+#if __has_include(<chrono>)
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
+ QFinalState *f = new QFinalState(&machine);
+ s1->addTransition(new EventTransition(QEvent::User, f));
+ machine.setInitialState(s1);
+
+ DelayedEventWithChronoPosterThread poster(&machine);
+ poster.start();
+
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QVERIFY(finishedSpy.isValid());
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s1, 2);
+ QVERIFY(poster.firstEventWasCancelled);
+#endif
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/corelib/text/qcollator/tst_qcollator.cpp b/tests/auto/corelib/text/qcollator/tst_qcollator.cpp
index 2ae9c6e159..6806aa09b5 100644
--- a/tests/auto/corelib/text/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/text/qcollator/tst_qcollator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -105,6 +105,8 @@ void tst_QCollator::compare_data()
QTest::newRow("english6") << QString("en_US") << QString("test 9") << QString("test_19") << -1 << -1 << true << true << -1;
QTest::newRow("english7") << QString("en_US") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("english8") << QString("en_US") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
+ QTest::newRow("en-empty-word") << QString("en_US") << QString() << QString("non-empty") << -1 << -1 << false << true << -1;
+ QTest::newRow("en-empty-number") << QString("en_US") << QString() << QString("42") << -1 << -1 << true << true << -1;
/*
In Swedish, a with ring above (E5) comes before a with
@@ -119,6 +121,8 @@ void tst_QCollator::compare_data()
QTest::newRow("swedish6") << QString("sv_SE") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("swedish7") << QString("sv_SE") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("swedish8") << QString("sv_SE") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
+ QTest::newRow("sv-empty-word") << QString("sv_SE") << QString() << QString("mett") << -1 << -1 << false << true << -1;
+ QTest::newRow("sv-empty-number") << QString("sv_SE") << QString() << QString("42") << -1 << -1 << true << true << -1;
/*
@@ -133,6 +137,8 @@ void tst_QCollator::compare_data()
QTest::newRow("norwegian6") << QString("no_NO") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("norwegian7") << QString("no_NO") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("norwegian8") << QString("no_NO") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
+ QTest::newRow("nb-empty-word") << QString("nb_NO") << QString() << QString("mett") << -1 << -1 << false << true << -1;
+ QTest::newRow("nb-empty-number") << QString("nb_NO") << QString() << QString("42") << -1 << -1 << true << true << -1;
/*
In German, z comes *after* a with diaresis (E4),
@@ -151,6 +157,8 @@ void tst_QCollator::compare_data()
QTest::newRow("german11") << QString("de_DE") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("german12") << QString("de_DE") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("german13") << QString("de_DE") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
+ QTest::newRow("de-empty-word") << QString("de_DE") << QString() << QString("satt") << -1 << -1 << false << true << -1;
+ QTest::newRow("de-empty-number") << QString("de_DE") << QString() << QString("42") << -1 << -1 << true << true << -1;
/*
French sorting of e and e with acute accent
@@ -163,11 +171,15 @@ void tst_QCollator::compare_data()
QTest::newRow("french6") << QString("fr_FR") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("french7") << QString("fr_FR") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("french8") << QString("fr_FR") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
+ QTest::newRow("fr-empty-word") << QString("fr_FR") << QString() << QString("plein") << -1 << -1 << false << true << -1;
+ QTest::newRow("fr-empty-number") << QString("fr_FR") << QString() << QString("42") << -1 << -1 << true << true << -1;
// C locale: case sensitive [A-Z] < [a-z] but case insensitive [Aa] < [Bb] <...< [Zz]
const QString C = QStringLiteral("C");
QTest::newRow("C:ABBA:AaaA") << C << QStringLiteral("ABBA") << QStringLiteral("AaaA") << -1 << 1 << false << false << 1;
QTest::newRow("C:AZa:aAZ") << C << QStringLiteral("AZa") << QStringLiteral("aAZ") << -1 << 1 << false << false << 1;
+ QTest::newRow("C-empty-word") << QString(C) << QString() << QString("non-empty") << -1 << -1 << false << true << -1;
+ QTest::newRow("C-empty-number") << QString(C) << QString() << QString("42") << -1 << -1 << true << true << -1;
}
void tst_QCollator::compare()
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index f19b66be37..e4144a376e 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -1887,14 +1887,16 @@ void tst_QLocale::toDateTime()
// Format number string according to system locale settings.
// Expected in format is US "1,234.56".
-QString systemLocaleFormatNumber(const QString &numberString)
+QString systemLocaleFormatNumber(QString &&numberString)
{
QLocale locale = QLocale::system();
- QString numberStringCopy = numberString;
- return numberStringCopy.replace(QChar(','), QChar('G'))
- .replace(QChar('.'), QChar('D'))
- .replace(QChar('G'), locale.groupSeparator())
- .replace(QChar('D'), locale.decimalPoint());
+ QString numberStringMunged =
+ numberString.replace(QChar(','), QChar('G')).replace(QChar('.'), QChar('D'));
+ if (locale.numberOptions() & QLocale::OmitGroupSeparator)
+ numberStringMunged.remove(QLatin1Char('G'));
+ else
+ numberStringMunged.replace(QChar('G'), locale.groupSeparator());
+ return numberStringMunged.replace(QChar('D'), locale.decimalPoint());
}
void tst_QLocale::macDefaultLocale()
@@ -1917,12 +1919,14 @@ void tst_QLocale::macDefaultLocale()
// independently of the locale. Verify that they have one of the
// allowed values and are not the same.
QVERIFY(locale.decimalPoint() == QChar('.') || locale.decimalPoint() == QChar(','));
- QVERIFY(locale.groupSeparator() == QChar(',')
- || locale.groupSeparator() == QChar('.')
- || locale.groupSeparator() == QChar('\xA0') // no-breaking space
- || locale.groupSeparator() == QChar('\'')
- || locale.groupSeparator() == QChar());
- QVERIFY(locale.decimalPoint() != locale.groupSeparator());
+ if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) {
+ QVERIFY(locale.groupSeparator() == QChar(',')
+ || locale.groupSeparator() == QChar('.')
+ || locale.groupSeparator() == QChar('\xA0') // no-breaking space
+ || locale.groupSeparator() == QChar('\'')
+ || locale.groupSeparator() == QChar());
+ QVERIFY(locale.decimalPoint() != locale.groupSeparator());
+ }
// make sure we are using the system to parse them
QCOMPARE(locale.toString(1234.56), systemLocaleFormatNumber(QString("1,234.56")));
@@ -2056,6 +2060,8 @@ void tst_QLocale::windowsDefaultLocale()
setWinLocaleInfo(LOCALE_SLONGDATE, longDateFormat);
const QString shortTimeFormat = QStringLiteral("h^m^s");
setWinLocaleInfo(LOCALE_SSHORTTIME, shortTimeFormat);
+ const QString longTimeFormat = QStringLiteral("HH%mm%ss");
+ setWinLocaleInfo(LOCALE_STIMEFORMAT, longTimeFormat);
QSystemLocale dummy; // to provoke a refresh of the system locale
QLocale locale = QLocale::system();
@@ -2069,7 +2075,7 @@ void tst_QLocale::windowsDefaultLocale()
QCOMPARE(locale.dateTimeFormat(QLocale::ShortFormat),
shortDateFormat + QLatin1Char(' ') + shortTimeFormat);
const QString expectedLongDateTimeFormat
- = longDateFormat + QLatin1Char(' ') + QStringLiteral("h:mm:ss AP");
+ = longDateFormat + QLatin1Char(' ') + longTimeFormat;
QCOMPARE(locale.dateTimeFormat(QLocale::LongFormat), expectedLongDateTimeFormat);
// make sure we are using the system to parse them
@@ -2083,7 +2089,7 @@ void tst_QLocale::windowsDefaultLocale()
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime);
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat),
locale.toString(QTime(1,2,3), QLocale::ShortFormat));
- const QString expectedFormattedLongTime = QStringLiteral("1:02:03 AM");
+ const QString expectedFormattedLongTime = QStringLiteral("01%02%03");
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime);
QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat),
QStringLiteral("1*12*1974 ") + expectedFormattedShortTime);
@@ -2091,7 +2097,6 @@ void tst_QLocale::windowsDefaultLocale()
locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat));
QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::LongFormat),
QStringLiteral("1@12@1974 ") + expectedFormattedLongTime);
- QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime);
}
#endif // Q_OS_WIN but !Q_OS_WINRT
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index 24382a2b61..bcf4e73108 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
** Copyright (C) 2019 Mail.ru Group.
** Contact: https://www.qt.io/licensing/
**
@@ -80,6 +80,13 @@ MAKE_ALL(const char*, QChar)
#undef MAKE_RELOP
// END FIXME
+static Q_DECL_CONSTEXPR int sign(int i) noexcept
+{
+ return i < 0 ? -1 :
+ i > 0 ? +1 :
+ /*else*/ 0 ;
+}
+
// Return a plain ASCII row name consisting of maximum 16 chars and the
// size for data
static QByteArray rowName(const QByteArray &data)
@@ -162,6 +169,12 @@ private Q_SLOTS:
void compare_QStringView_QStringView() { compare_impl<QStringView, QStringView>(); }
void compare_QStringView_QLatin1String_data() { compare_data(); }
void compare_QStringView_QLatin1String() { compare_impl<QStringView, QLatin1String>(); }
+#ifdef NOT_YET_IMPLMENTED
+ void compare_QStringView_QByteArray_data() { compare_data(); }
+ void compare_QStringView_QByteArray() { compare_impl<QStringView, QByteArray>(); }
+ void compare_QStringView_const_char_star_data() { compare_data(); }
+ void compare_QStringView_const_char_star() { compare_impl<QStringView, const char *>(); }
+#endif
void compare_QLatin1String_QChar_data() { compare_data(false); }
void compare_QLatin1String_QChar() { compare_impl<QLatin1String, QChar>(); }
@@ -205,6 +218,111 @@ private Q_SLOTS:
//void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
private:
+ void member_compare_data(bool hasConceptOfNullAndEmpty=true) { compare_data(hasConceptOfNullAndEmpty); }
+ template <typename LHS, typename RHS>
+ void member_compare_impl() const;
+
+private Q_SLOTS:
+ // test all combinations of {QChar, QStringRef, QString, QStringView, QLatin1String, QByteArray, const char*}
+#ifdef NOT_YET_IMPLEMENTED // probably never will be - what's the point of QChar::compare(QStringView)?
+ void member_compare_QChar_QChar_data() { member_compare_data(false); }
+ void member_compare_QChar_QChar() { member_compare_impl<QChar, QChar>(); }
+ void member_compare_QChar_QStringRef_data() { member_compare_data(false); }
+ void member_compare_QChar_QStringRef() { member_compare_impl<QChar, QStringRef>(); }
+ void member_compare_QChar_QString_data() { member_compare_data(false); }
+ void member_compare_QChar_QString() { member_compare_impl<QChar, QString>(); }
+ void member_compare_QChar_QStringView_data() { member_compare_data(false); }
+ void member_compare_QChar_QStringView() { member_compare_impl<QChar, QStringView>(); }
+ void member_compare_QChar_QLatin1String_data() { member_compare_data(false); }
+ void member_compare_QChar_QLatin1String() { member_compare_impl<QChar, QLatin1String>(); }
+ void member_compare_QChar_QByteArray_data() { member_compare_data(false); }
+ void member_compare_QChar_QByteArray() { member_compare_impl<QChar, QByteArray>(); }
+ void member_compare_QChar_const_char_star_data() { member_compare_data(false); }
+ void member_compare_QChar_const_char_star() { member_compare_impl<QChar, const char *>(); }
+#endif
+
+ void member_compare_QStringRef_QChar_data() { member_compare_data(false); }
+ void member_compare_QStringRef_QChar() { member_compare_impl<QStringRef, QChar>(); }
+ void member_compare_QStringRef_QStringRef_data() { member_compare_data(); }
+ void member_compare_QStringRef_QStringRef() { member_compare_impl<QStringRef, QStringRef>(); }
+ void member_compare_QStringRef_QString_data() { member_compare_data(); }
+ void member_compare_QStringRef_QString() { member_compare_impl<QStringRef, QString>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QStringRef_QStringView_data() { member_compare_data(); }
+ void member_compare_QStringRef_QStringView() { member_compare_impl<QStringRef, QStringView>(); }
+#endif
+ void member_compare_QStringRef_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QStringRef_QLatin1String() { member_compare_impl<QStringRef, QLatin1String>(); }
+ void member_compare_QStringRef_QByteArray_data() { member_compare_data(); }
+ void member_compare_QStringRef_QByteArray() { member_compare_impl<QStringRef, QByteArray>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QStringRef_const_char_star_data() { member_compare_data(); }
+ void member_compare_QStringRef_const_char_star() { member_compare_impl<QStringRef, const char *>(); }
+#endif
+
+ void member_compare_QString_QChar_data() { member_compare_data(false); }
+ void member_compare_QString_QChar() { member_compare_impl<QString, QChar>(); }
+ void member_compare_QString_QStringRef_data() { member_compare_data(); }
+ void member_compare_QString_QStringRef() { member_compare_impl<QString, QStringRef>(); }
+ void member_compare_QString_QString_data() { member_compare_data(); }
+ void member_compare_QString_QString() { member_compare_impl<QString, QString>(); }
+ void member_compare_QString_QStringView_data() { member_compare_data(); }
+ void member_compare_QString_QStringView() { member_compare_impl<QString, QStringView>(); }
+ void member_compare_QString_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QString_QLatin1String() { member_compare_impl<QString, QLatin1String>(); }
+ void member_compare_QString_QByteArray_data() { member_compare_data(); }
+ void member_compare_QString_QByteArray() { member_compare_impl<QString, QByteArray>(); }
+ void member_compare_QString_const_char_star_data() { member_compare_data(); }
+ void member_compare_QString_const_char_star() { member_compare_impl<QString, const char *>(); }
+
+#ifdef NOT_YET_IMPLEMENTED // QChar doesn't implicitly convert to QStringView
+ void member_compare_QStringView_QChar_data() { member_compare_data(false); }
+ void member_compare_QStringView_QChar() { member_compare_impl<QStringView, QChar>(); }
+#endif
+ void member_compare_QStringView_QStringRef_data() { member_compare_data(); }
+ void member_compare_QStringView_QStringRef() { member_compare_impl<QStringView, QStringRef>(); }
+ void member_compare_QStringView_QString_data() { member_compare_data(); }
+ void member_compare_QStringView_QString() { member_compare_impl<QStringView, QString>(); }
+ void member_compare_QStringView_QStringView_data() { member_compare_data(); }
+ void member_compare_QStringView_QStringView() { member_compare_impl<QStringView, QStringView>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QStringView_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QStringView_QLatin1String() { member_compare_impl<QStringView, QLatin1String>(); }
+ void member_compare_QStringView_QByteArray_data() { member_compare_data(); }
+ void member_compare_QStringView_QByteArray() { member_compare_impl<QStringView, QByteArray>(); }
+ void member_compare_QStringView_const_char_star_data() { member_compare_data(); }
+ void member_compare_QStringView_const_char_star() { member_compare_impl<QStringView, const char *>(); }
+
+ void member_compare_QLatin1String_QChar_data() { member_compare_data(false); }
+ void member_compare_QLatin1String_QChar() { member_compare_impl<QLatin1String, QChar>(); }
+ void member_compare_QLatin1String_QStringRef_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QStringRef() { member_compare_impl<QLatin1String, QStringRef>(); }
+ void member_compare_QLatin1String_QString_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QString() { member_compare_impl<QLatin1String, QString>(); }
+ void member_compare_QLatin1String_QStringView_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QStringView() { member_compare_impl<QLatin1String, QStringView>(); }
+ void member_compare_QLatin1String_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QLatin1String() { member_compare_impl<QLatin1String, QLatin1String>(); }
+ void member_compare_QLatin1String_QByteArray_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QByteArray() { member_compare_impl<QLatin1String, QByteArray>(); }
+ void member_compare_QLatin1String_const_char_star_data() { member_compare_data(); }
+ void member_compare_QLatin1String_const_char_star() { member_compare_impl<QLatin1String, const char *>(); }
+
+ void member_compare_QByteArray_QChar_data() { member_compare_data(false); }
+ void member_compare_QByteArray_QChar() { member_compare_impl<QByteArray, QChar>(); }
+ void member_compare_QByteArray_QStringRef_data() { member_compare_data(); }
+ void member_compare_QByteArray_QStringRef() { member_compare_impl<QByteArray, QStringRef>(); }
+ void member_compare_QByteArray_QString_data() { member_compare_data(); }
+ void member_compare_QByteArray_QString() { member_compare_impl<QByteArray, QString>(); }
+ void member_compare_QByteArray_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QByteArray_QLatin1String() { member_compare_impl<QByteArray, QLatin1String>(); }
+#endif
+ void member_compare_QByteArray_QByteArray_data() { member_compare_data(); }
+ void member_compare_QByteArray_QByteArray() { member_compare_impl<QByteArray, QByteArray>(); }
+ void member_compare_QByteArray_const_char_star_data() { member_compare_data(); }
+ void member_compare_QByteArray_const_char_star() { member_compare_impl<QByteArray, const char *>(); }
+
+private:
void startsWith_data(bool rhsIsQChar = false);
template <typename Haystack, typename Needle> void startsWith_impl() const;
@@ -601,7 +719,7 @@ void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty)
QTest::newRow(qUtf8Printable(QLatin1String("'" lhs "' <> '" rhs "': "))) \
<< QStringRef(&pinned[0]) << QLatin1String(lhs) \
<< QStringRef(&pinned[1]) << QLatin1String(rhs) \
- << qstrcmp(lhs, rhs) << qstricmp(lhs, rhs); \
+ << sign(qstrcmp(lhs, rhs)) << sign(qstricmp(lhs, rhs)); \
} while (false)
ROW("", "0");
ROW("0", "");
@@ -691,6 +809,44 @@ void tst_QStringApiSymmetry::compare_impl() const
#undef CHECK
}
+template <typename LHS, typename RHS>
+void tst_QStringApiSymmetry::member_compare_impl() const
+{
+ QFETCH(QStringRef, lhsUnicode);
+ QFETCH(QLatin1String, lhsLatin1);
+ QFETCH(QStringRef, rhsUnicode);
+ QFETCH(QLatin1String, rhsLatin1);
+ QFETCH(const int, caseSensitiveCompareResult);
+ QFETCH(const int, caseInsensitiveCompareResult);
+
+ const auto lhsU8 = lhsUnicode.toUtf8();
+ const auto rhsU8 = rhsUnicode.toUtf8();
+
+ const auto lhs = make<LHS>(lhsUnicode, lhsLatin1, lhsU8);
+ const auto rhs = make<RHS>(rhsUnicode, rhsLatin1, rhsU8);
+
+#define QVERIFY_NOEXCEPT(expr) do { \
+ if (has_nothrow_compare<LHS, RHS>::value) {} else \
+ QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \
+ QVERIFY(noexcept(expr)); } while (0)
+
+ if (std::is_same<LHS, QByteArray>::value || // needs to simply be marked as noexcept
+ ((std::is_same<LHS, QString>::value || std::is_same<LHS, QStringRef>::value)
+ && std::is_same<RHS, QChar>::value)) // implict QChar -> QString conversion kills noexcept
+ QEXPECT_FAIL("", "known issues, will be fixed before 5.14 release", Continue);
+ QVERIFY_NOEXCEPT(lhs.compare(rhs, Qt::CaseSensitive));
+
+ QCOMPARE(sign(lhs.compare(rhs)), caseSensitiveCompareResult);
+ QCOMPARE(sign(lhs.compare(rhs, Qt::CaseSensitive)), caseSensitiveCompareResult);
+ if (is_utf8_encoded<LHS>::value && is_utf8_encoded<RHS>::value &&
+ caseSensitiveCompareResult != caseInsensitiveCompareResult &&
+ (!QtPrivate::isAscii(lhsUnicode) || !QtPrivate::isAscii(rhsUnicode)))
+ {
+ QEXPECT_FAIL("", "Qt is missing a case-insensitive UTF-8/UTF-8 comparator", Continue);
+ }
+ QCOMPARE(sign(lhs.compare(rhs, Qt::CaseInsensitive)), caseInsensitiveCompareResult);
+}
+
static QString empty = QLatin1String("");
static QString null;
// the tests below rely on the fact that these objects' names match their contents:
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 60e8d8cba2..49ce918caf 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -64,6 +64,7 @@ public:
private slots:
void runFunction();
+ void runFunction2();
void createThreadRunFunction();
void runMultiple();
void waitcomplete();
@@ -160,17 +161,27 @@ void tst_QThreadPool::runFunction()
{
QThreadPool manager;
testFunctionCount = 0;
- manager.start(createTask(noSleepTestFunction));
+ manager.start(noSleepTestFunction);
}
QCOMPARE(testFunctionCount, 1);
}
+void tst_QThreadPool::runFunction2()
+{
+ int localCount = 0;
+ {
+ QThreadPool manager;
+ manager.start([&]() { ++localCount; });
+ }
+ QCOMPARE(localCount, 1);
+}
+
void tst_QThreadPool::createThreadRunFunction()
{
{
QThreadPool manager;
testFunctionCount = 0;
- manager.start(createTask(noSleepTestFunction));
+ manager.start(noSleepTestFunction);
}
QCOMPARE(testFunctionCount, 1);
@@ -184,7 +195,7 @@ void tst_QThreadPool::runMultiple()
QThreadPool manager;
testFunctionCount = 0;
for (int i = 0; i < runs; ++i) {
- manager.start(createTask(sleepTestFunctionMutex));
+ manager.start(sleepTestFunctionMutex);
}
}
QCOMPARE(testFunctionCount, runs);
@@ -193,7 +204,7 @@ void tst_QThreadPool::runMultiple()
QThreadPool manager;
testFunctionCount = 0;
for (int i = 0; i < runs; ++i) {
- manager.start(createTask(noSleepTestFunctionMutex));
+ manager.start(noSleepTestFunctionMutex);
}
}
QCOMPARE(testFunctionCount, runs);
@@ -201,7 +212,7 @@ void tst_QThreadPool::runMultiple()
{
QThreadPool manager;
for (int i = 0; i < 500; ++i)
- manager.start(createTask(emptyFunct));
+ manager.start(emptyFunct);
}
}
@@ -211,7 +222,7 @@ void tst_QThreadPool::waitcomplete()
const int runs = 500;
for (int i = 0; i < 500; ++i) {
QThreadPool pool;
- pool.start(createTask(noSleepTestFunction));
+ pool.start(noSleepTestFunction);
}
QCOMPARE(testFunctionCount, runs);
}
diff --git a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
index 9b41014394..5da69e76a5 100644
--- a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
+++ b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -40,6 +40,8 @@ private:
private slots:
void basic_data();
void basic();
+ void unspecified_data() { basic_data(); }
+ void unspecified();
void nameCase();
void specific_data();
void specific();
@@ -145,6 +147,27 @@ void tst_QCalendar::basic()
NORMALYEAR(cal, year);
}
+void tst_QCalendar::unspecified()
+{
+ QFETCH(QCalendar::System, system);
+ QCalendar cal(system);
+
+ const QDate today = QDate::currentDate();
+ const int thisYear = today.year();
+ QCOMPARE(cal.monthsInYear(QCalendar::Unspecified), cal.maximumMonthsInYear());
+ for (int month = cal.maximumMonthsInYear(); month > 0; month--) {
+ const int days = cal.daysInMonth(month);
+ int count = 0;
+ // 19 years = one Metonic cycle (used by some lunar calendars)
+ for (int i = 19; i > 0; --i) {
+ if (cal.daysInMonth(month, thisYear - i) == days)
+ count++;
+ }
+ // Require a majority of the years tested:
+ QVERIFY2(count > 9, "Default daysInMonth() should be for a normal year");
+ }
+}
+
void tst_QCalendar::nameCase()
{
QVERIFY(QCalendar::availableCalendars().contains(QStringLiteral("Gregorian")));
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index 567209dcf6..274bf4f6f0 100644
--- a/tests/auto/corelib/time/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -1352,6 +1352,7 @@ void tst_QDate::toStringDateFormat()
QFETCH(Qt::DateFormat, format);
QFETCH(QString, expectedStr);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat));
@@ -1361,6 +1362,7 @@ void tst_QDate::toStringDateFormat()
QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat));
QCOMPARE(date.toString(Qt::DefaultLocaleLongDate), QLocale().toString(date, QLocale::LongFormat));
+#endif // ### Qt 6: remove
QCOMPARE(date.toString(format), expectedStr);
}
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 6aae91f62f..26ad91271d 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -127,8 +127,10 @@ private slots:
#ifdef Q_OS_WIN
void fromString_LOCALE_ILDATE();
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void fromStringToStringLocale_data();
void fromStringToStringLocale();
+#endif // ### Qt 6: remove
void offsetFromUtc();
void setOffsetFromUtc();
@@ -295,9 +297,9 @@ void tst_QDateTime::initTestCase()
void tst_QDateTime::init()
{
-#if defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
-#endif
+#endif // ### Qt 6: remove
}
QString tst_QDateTime::str( int y, int month, int d, int h, int min, int s )
@@ -834,8 +836,10 @@ void tst_QDateTime::toString_isoDate()
QFETCH(Qt::DateFormat, format);
QFETCH(QString, expected);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QLocale oldLocale;
QLocale::setDefault(QLocale("en_US"));
+#endif // ### Qt 6: remove
QString result = datetime.toString(format);
QCOMPARE(result, expected);
@@ -854,7 +858,9 @@ void tst_QDateTime::toString_isoDate()
QCOMPARE(resultDatetime, QDateTime());
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QLocale::setDefault(oldLocale);
+#endif // ### Qt 6: remove
}
void tst_QDateTime::toString_isoDate_extra()
@@ -1763,7 +1769,7 @@ void tst_QDateTime::daylightSavingsTimeChange()
// because some functions did not reset the flag when moving in or out of DST.
// WARNING: This only tests anything if there's a Daylight Savings Time change
- // in the current locale between inDST and outDST.
+ // in the current time-zone between inDST and outDST.
// This is true for Central European Time and may be elsewhere.
QFETCH(QDate, inDST);
@@ -2612,6 +2618,9 @@ void tst_QDateTime::fromString_LOCALE_ILDATE()
}
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
+
void tst_QDateTime::fromStringToStringLocale_data()
{
QTest::addColumn<QLocale>("locale");
@@ -2643,6 +2652,8 @@ void tst_QDateTime::fromStringToStringLocale()
#undef ROUNDTRIP
QLocale::setDefault(def);
}
+QT_WARNING_POP
+#endif // ### Qt 6: remove
void tst_QDateTime::offsetFromUtc()
{
@@ -2941,19 +2952,19 @@ void tst_QDateTime::fewDigitsInYear() const
void tst_QDateTime::printNegativeYear() const
{
{
- QDateTime date(QDate(-20, 10, 11));
+ QDateTime date(QDate(-20, 10, 11).startOfDay());
QVERIFY(date.isValid());
QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0020"));
}
{
- QDateTime date(QDate(-3, 10, 11));
+ QDateTime date(QDate(-3, 10, 11).startOfDay());
QVERIFY(date.isValid());
QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0003"));
}
{
- QDateTime date(QDate(-400, 10, 11));
+ QDateTime date(QDate(-400, 10, 11).startOfDay());
QVERIFY(date.isValid());
QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0400"));
}
diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp
index f85e0ea74e..027232f6d5 100644
--- a/tests/auto/corelib/time/qtime/tst_qtime.cpp
+++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -77,7 +77,9 @@ private slots:
void toStringDateFormat();
void toStringFormat_data();
void toStringFormat();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void toStringLocale();
+#endif // ### Qt 6: remove
void msecsSinceStartOfDay_data();
void msecsSinceStartOfDay();
@@ -770,6 +772,7 @@ void tst_QTime::toStringFormat()
QCOMPARE( t.toString( format ), str );
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void tst_QTime::toStringLocale()
{
QTime time(18, 30);
@@ -791,6 +794,7 @@ void tst_QTime::toStringLocale()
QCOMPARE(time.toString(Qt::DefaultLocaleLongDate),
QLocale().toString(time, QLocale::LongFormat));
}
+#endif // ### Qt 6: remove
void tst_QTime::msecsSinceStartOfDay_data()
{
diff --git a/tests/auto/corelib/tools/qscopeguard/CMakeLists.txt b/tests/auto/corelib/tools/qscopeguard/CMakeLists.txt
index 243efdd0b2..11b425448b 100644
--- a/tests/auto/corelib/tools/qscopeguard/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qscopeguard/CMakeLists.txt
@@ -8,3 +8,6 @@ add_qt_test(tst_qscopeguard
SOURCES
tst_qscopeguard.cpp
)
+
+## Scopes:
+#####################################################################
diff --git a/tests/auto/corelib/tools/qscopeguard/qscopeguard.pro b/tests/auto/corelib/tools/qscopeguard/qscopeguard.pro
index 070d4b077c..e3645befcf 100644
--- a/tests/auto/corelib/tools/qscopeguard/qscopeguard.pro
+++ b/tests/auto/corelib/tools/qscopeguard/qscopeguard.pro
@@ -2,3 +2,6 @@ CONFIG += testcase
TARGET = tst_qscopeguard
QT = core testlib
SOURCES = tst_qscopeguard.cpp
+
+# Force C++17 if available
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
diff --git a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
index 01181ce20e..4bb4113845 100644
--- a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
+++ b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sérgio Martins <sergio.martins@kdab.com>
+** 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.
@@ -30,24 +31,130 @@
#include <QtCore/QScopeGuard>
/*!
- \class tst_QScopedGuard
+ \class tst_QScopeGuard
\internal
\since 5.11
- \brief Tests class QScopedCleanup and function qScopeGuard
+ \brief Tests class QScopeGuard and function qScopeGuard
*/
-class tst_QScopedGuard : public QObject
+class tst_QScopeGuard : public QObject
{
Q_OBJECT
private Q_SLOTS:
+ void construction();
+ void constructionFromLvalue();
+ void constructionFromRvalue();
void leavingScope();
void exceptions();
};
+void func()
+{
+}
+
+int intFunc()
+{
+ return 0;
+}
+
+Q_REQUIRED_RESULT int noDiscardFunc()
+{
+ return 0;
+}
+
+struct Callable
+{
+ Callable() { }
+ Callable(const Callable &other)
+ {
+ Q_UNUSED(other);
+ ++copied;
+ }
+ Callable(Callable &&other)
+ {
+ Q_UNUSED(other);
+ ++moved;
+ }
+ void operator()() { }
+
+ static int copied;
+ static int moved;
+ static void resetCounts()
+ {
+ copied = 0;
+ moved = 0;
+ }
+};
+
+int Callable::copied = 0;
+int Callable::moved = 0;
+
static int s_globalState = 0;
-void tst_QScopedGuard::leavingScope()
+void tst_QScopeGuard::construction()
+{
+#ifdef __cpp_deduction_guides
+ QScopeGuard fromLambda([] { });
+ QScopeGuard fromFunction(func);
+ QScopeGuard fromFunctionPointer(&func);
+ QScopeGuard fromNonVoidFunction(intFunc);
+ QScopeGuard fromNoDiscardFunction(noDiscardFunc);
+#ifndef __apple_build_version__
+ QScopeGuard fromStdFunction{std::function(func)};
+ std::function stdFunction(func);
+ QScopeGuard fromNamedStdFunction(stdFunction);
+#endif
+#else
+ QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
+void tst_QScopeGuard::constructionFromLvalue()
+{
+#ifdef __cpp_deduction_guides
+ Callable::resetCounts();
+ {
+ Callable callable;
+ QScopeGuard guard(callable);
+ }
+ QCOMPARE(Callable::copied, 1);
+ QCOMPARE(Callable::moved, 0);
+ Callable::resetCounts();
+ {
+ Callable callable;
+ auto guard = qScopeGuard(callable);
+ }
+ QCOMPARE(Callable::copied, 1);
+ QCOMPARE(Callable::moved, 0);
+#else
+ QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
+void tst_QScopeGuard::constructionFromRvalue()
+{
+#ifdef __cpp_deduction_guides
+ Callable::resetCounts();
+ {
+ Callable callable;
+ QScopeGuard guard(std::move(callable));
+ }
+ QCOMPARE(Callable::copied, 0);
+ QCOMPARE(Callable::moved, 1);
+ Callable::resetCounts();
+ {
+ Callable callable;
+ auto guard = qScopeGuard(std::move(callable));
+ }
+ QCOMPARE(Callable::copied, 0);
+ QCOMPARE(Callable::moved, 1);
+#else
+ QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
+void tst_QScopeGuard::leavingScope()
{
auto cleanup = qScopeGuard([] { s_globalState++; QCOMPARE(s_globalState, 3); });
QCOMPARE(s_globalState, 0);
@@ -61,7 +168,7 @@ void tst_QScopedGuard::leavingScope()
s_globalState++;
}
-void tst_QScopedGuard::exceptions()
+void tst_QScopeGuard::exceptions()
{
s_globalState = 0;
bool caught = false;
@@ -81,5 +188,5 @@ void tst_QScopedGuard::exceptions()
}
-QTEST_MAIN(tst_QScopedGuard)
+QTEST_MAIN(tst_QScopeGuard)
#include "tst_qscopeguard.moc"
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
index 8e6ca486d5..758aeb42b9 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
+++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
@@ -42,6 +42,19 @@ class TstWidget;
class TstDialog;
QT_FORWARD_DECLARE_CLASS(QPushButton)
+class TestButton : public QPushButton
+{
+public:
+ TestButton(const QString &title, QWidget *parent = nullptr)
+ : QPushButton(title, parent)
+ {}
+protected:
+ bool hitButton(const QPoint &pos) const override
+ {
+ return rect().contains(pos);
+ }
+};
+
class tst_qmouseevent_modal : public QObject
{
Q_OBJECT
@@ -63,7 +76,7 @@ public:
public slots:
void buttonPressed();
public:
- QPushButton *pb;
+ TestButton *pb;
TstDialog *d;
};
@@ -135,7 +148,7 @@ void tst_qmouseevent_modal::mousePressRelease()
TstWidget::TstWidget()
{
- pb = new QPushButton( "Press me", this );
+ pb = new TestButton( "Press me", this );
pb->setObjectName("testbutton");
QSize s = pb->sizeHint();
pb->setGeometry( 5, 5, s.width(), s.height() );
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 945a4772f3..99fb3d3e72 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -413,6 +413,7 @@ void tst_QColorSpace::primaries2()
void tst_QColorSpace::invalidPrimaries()
{
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QColorSpace attempted constructed from invalid primaries"));
QColorSpace custom(QPointF(), QPointF(), QPointF(), QPointF(), QColorSpace::TransferFunction::Linear);
QVERIFY(!custom.isValid());
}
@@ -444,8 +445,15 @@ void tst_QColorSpace::changeTransferFunction()
QColorSpace undefined;
QCOMPARE(undefined.withTransferFunction(QColorSpace::TransferFunction::Linear), undefined);
- undefined.setTransferFunction(QColorSpace::TransferFunction::SRgb);
- QCOMPARE(undefined, QColorSpace());
+
+ QColorSpace partial;
+ partial.setTransferFunction(QColorSpace::TransferFunction::SRgb);
+ QCOMPARE(partial.transferFunction(), QColorSpace::TransferFunction::SRgb);
+ QVERIFY(!partial.isValid());
+
+ partial.setPrimaries(QColorSpace::Primaries::SRgb);
+ QVERIFY(partial.isValid());
+ QCOMPARE(partial, QColorSpace(QColorSpace::SRgb));
}
void tst_QColorSpace::changePrimaries()
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/links.md b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md
new file mode 100644
index 0000000000..33cdb2b3ab
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md
@@ -0,0 +1,25 @@
+A series of links.
+
+[link](/uri)
+
+[link]()
+
+[link](/uri "title")
+
+[link](/uri "àbcdè")
+
+[link](/uri "title title \" title title")
+
+[link](/url "title \"&quot;")
+
+[link](/url "title
+title
+title title
+\"title\" title \"
+title")
+
+* [link](/url "title")
+* [link](/url)
+* [link](/url "title
+title title")
+* nonlink
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index d15e856a20..31592c7f0f 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -368,6 +368,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data()
QTest::newRow("example") << "example.md";
QTest::newRow("list items after headings") << "headingsAndLists.md";
QTest::newRow("word wrap") << "wordWrap.md";
+ QTest::newRow("links") << "links.md";
}
void tst_QTextMarkdownWriter::rewriteDocument()
diff --git a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
index 120b1c4b66..752655ee94 100644
--- a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
+++ b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
@@ -58,7 +58,7 @@ tst_QNetworkAccessManager::tst_QNetworkAccessManager()
void tst_QNetworkAccessManager::networkAccessible()
{
-#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section
QNetworkAccessManager manager;
qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility");
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index b8f69cb393..83fe83fe3d 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -1316,9 +1316,9 @@ tst_QNetworkReply::tst_QNetworkReply()
"+socksauth", true);
} else {
#endif // !QT_NO_NETWORKPROXY
- printf("==================================================================\n");
- printf("Proxy could not be looked up. No proxy will be used while testing!\n");
- printf("==================================================================\n");
+ fprintf(stderr, "==================================================================\n");
+ fprintf(stderr, "Proxy could not be looked up. No proxy will be used while testing!\n");
+ fprintf(stderr, "==================================================================\n");
#ifndef QT_NO_NETWORKPROXY
}
#endif // !QT_NO_NETWORKPROXY
diff --git a/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp b/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp
index 6355fea6ab..272e837ac5 100644
--- a/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp
+++ b/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp
@@ -65,8 +65,8 @@ bool runServer(int numberOfConnections)
return false;
}
printf("server: data written\n");
- if (socket->socketError() != QLocalSocket::UnknownSocketError) {
- fprintf(stderr, "server: socket error %d\n", socket->socketError());
+ if (socket->error() != QLocalSocket::UnknownSocketError) {
+ fprintf(stderr, "server: socket error %d\n", socket->error());
return false;
}
}
@@ -83,8 +83,8 @@ bool runClient()
socket.connectToServer(serverName, QLocalSocket::ReadWrite);
if (socket.waitForConnected())
break;
- if (socket.socketError() == QLocalSocket::ServerNotFoundError
- || socket.socketError() == QLocalSocket::ConnectionRefusedError) {
+ if (socket.error() == QLocalSocket::ServerNotFoundError
+ || socket.error() == QLocalSocket::ConnectionRefusedError) {
if (connectTimer.elapsed() > 5000) {
fprintf(stderr, "client: server not found or connection refused. Giving up.\n");
return false;
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 0c1536bd59..baf841d237 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -174,7 +174,7 @@ public:
this, SLOT(slotConnected()));
connect(this, SIGNAL(disconnected()),
this, SLOT(slotDisconnected()));
- connect(this, SIGNAL(error(QLocalSocket::LocalSocketError)),
+ connect(this, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)),
this, SLOT(slotError(QLocalSocket::LocalSocketError)));
connect(this, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)),
this, SLOT(slotStateChanged(QLocalSocket::LocalSocketState)));
@@ -192,10 +192,10 @@ private slots:
{
QCOMPARE(state(), QLocalSocket::UnconnectedState);
}
- void slotError(QLocalSocket::LocalSocketError newError)
+ void slotErrorOccurred(QLocalSocket::LocalSocketError newError)
{
QVERIFY(errorString() != QLatin1String("Unknown error"));
- QCOMPARE(socketError(), newError);
+ QCOMPARE(error(), newError);
}
void slotStateChanged(QLocalSocket::LocalSocketState newState)
{
@@ -244,7 +244,7 @@ void tst_QLocalSocket::socket_basic()
LocalSocket socket;
QSignalSpy spyConnected(&socket, SIGNAL(connected()));
QSignalSpy spyDisconnected(&socket, SIGNAL(disconnected()));
- QSignalSpy spyError(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
+ QSignalSpy spyError(&socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
QSignalSpy spyStateChanged(&socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
@@ -256,7 +256,7 @@ void tst_QLocalSocket::socket_basic()
QCOMPARE(socket.canReadLine(), false);
socket.close();
socket.disconnectFromServer();
- QCOMPARE(QLocalSocket::UnknownSocketError, socket.socketError());
+ QCOMPARE(QLocalSocket::UnknownSocketError, socket.error());
QVERIFY(!socket.errorString().isEmpty());
QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), false);
@@ -359,7 +359,7 @@ void tst_QLocalSocket::listenAndConnect()
QSignalSpy spyConnected(socket, SIGNAL(connected()));
QSignalSpy spyDisconnected(socket, SIGNAL(disconnected()));
- QSignalSpy spyError(socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
+ QSignalSpy spyError(socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
QSignalSpy spyStateChanged(socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
QSignalSpy spyReadyRead(socket, SIGNAL(readyRead()));
@@ -375,13 +375,13 @@ void tst_QLocalSocket::listenAndConnect()
QVERIFY(socket->waitForConnected());
QVERIFY(socket->isValid());
QCOMPARE(socket->errorString(), QString("Unknown error"));
- QCOMPARE(socket->socketError(), QLocalSocket::UnknownSocketError);
+ QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::ConnectedState);
//QVERIFY(socket->socketDescriptor() != -1);
QCOMPARE(spyError.count(), 0);
} else {
QVERIFY(!socket->errorString().isEmpty());
- QVERIFY(socket->socketError() != QLocalSocket::UnknownSocketError);
+ QVERIFY(socket->error() != QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::UnconnectedState);
//QCOMPARE(socket->socketDescriptor(), -1);
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]),
@@ -525,7 +525,7 @@ void tst_QLocalSocket::sendData()
LocalSocket socket;
QSignalSpy spyConnected(&socket, SIGNAL(connected()));
QSignalSpy spyDisconnected(&socket, SIGNAL(disconnected()));
- QSignalSpy spyError(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
+ QSignalSpy spyError(&socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
QSignalSpy spyStateChanged(&socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
@@ -1104,7 +1104,7 @@ void tst_QLocalSocket::recycleClientSocket()
QVERIFY(server.listen(serverName));
QLocalSocket client;
QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead()));
- QSignalSpy clientErrorSpy(&client, SIGNAL(error(QLocalSocket::LocalSocketError)));
+ QSignalSpy clientErrorSpy(&client, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
for (int i = 0; i < lines.count(); ++i) {
client.abort();
clientReadyReadSpy.clear();
diff --git a/tests/auto/testlib/CMakeLists.txt b/tests/auto/testlib/CMakeLists.txt
index fe80927327..fd342e82a4 100644
--- a/tests/auto/testlib/CMakeLists.txt
+++ b/tests/auto/testlib/CMakeLists.txt
@@ -2,7 +2,7 @@
# add_subdirectory(outformat) # special case missing project
add_subdirectory(qsignalspy)
-add_subdirectory(selftests)
+# add_subdirectory(selftests) # special case disable because the conversion is broken and hard to fix atm
if(TARGET Qt::Widgets)
add_subdirectory(qabstractitemmodeltester)
endif()
diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
index 164dc7eaa9..d82765311b 100644
--- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
+++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
@@ -194,6 +194,9 @@ int main(int argc, char** argv)
args << argv[i];
}
}
+
+ args << "-eventcounter";
+
/*
We just want testlib to output a benchmark result, we don't actually care about the value,
so just do one iteration to save time.
diff --git a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
index fe83ee6608..f2176612ad 100644
--- a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
+++ b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
@@ -79,6 +79,14 @@ void tst_BenchlibCallgrind::twoHundredMillionInstructions()
#endif
}
-QTEST_MAIN(tst_BenchlibCallgrind)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-callgrind");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_BenchlibCallgrind)
+}
#include "tst_benchlibcallgrind.moc"
diff --git a/tests/auto/testlib/selftests/benchlibcounting/tst_benchlibcounting.cpp b/tests/auto/testlib/selftests/benchlibcounting/tst_benchlibcounting.cpp
index 58df127f3a..56b6d92f67 100644
--- a/tests/auto/testlib/selftests/benchlibcounting/tst_benchlibcounting.cpp
+++ b/tests/auto/testlib/selftests/benchlibcounting/tst_benchlibcounting.cpp
@@ -59,5 +59,14 @@ void tst_BenchlibCounting::failingBenchmark()
};
}
-QTEST_MAIN(tst_BenchlibCounting)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-eventcounter");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_BenchlibCounting)
+}
+
#include "tst_benchlibcounting.moc"
diff --git a/tests/auto/testlib/selftests/benchlibeventcounter/tst_benchlibeventcounter.cpp b/tests/auto/testlib/selftests/benchlibeventcounter/tst_benchlibeventcounter.cpp
index e8015acb95..e3f4720a5e 100644
--- a/tests/auto/testlib/selftests/benchlibeventcounter/tst_benchlibeventcounter.cpp
+++ b/tests/auto/testlib/selftests/benchlibeventcounter/tst_benchlibeventcounter.cpp
@@ -94,6 +94,11 @@ void tst_BenchlibEventCounter::events_data()
int main(int argc, char** argv)
{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-eventcounter");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
TestEventDispatcher dispatcher;
QCoreApplication app(argc, argv);
tst_BenchlibEventCounter test;
diff --git a/tests/auto/testlib/selftests/benchliboptions/tst_benchliboptions.cpp b/tests/auto/testlib/selftests/benchliboptions/tst_benchliboptions.cpp
index c1acf5a6e8..b89ca28ff2 100644
--- a/tests/auto/testlib/selftests/benchliboptions/tst_benchliboptions.cpp
+++ b/tests/auto/testlib/selftests/benchliboptions/tst_benchliboptions.cpp
@@ -83,6 +83,9 @@ void tst_BenchlibOptions::threeEvents()
int main(int argc, char** argv)
{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-eventcounter");
+
int ret = 0;
TestEventDispatcher dispatcher;
@@ -91,29 +94,27 @@ int main(int argc, char** argv)
/* Run with no special arguments. */
{
tst_BenchlibOptions test;
- ret += QTest::qExec(&test, argc, argv);
+ ret += QTest::qExec(&test, args.size(), const_cast<char**>(&args[0]));
}
/* Run with an exact number of iterations. */
{
- QVector<char const*> args;
- for (int i = 0; i < argc; ++i) args << argv[i];
- args << "-iterations";
- args << "15";
+ auto extraArgs = args;
+ extraArgs.push_back("-iterations");
+ extraArgs.push_back("15");
tst_BenchlibFifteenIterations test;
- ret += QTest::qExec(&test, args.count(), const_cast<char**>(args.data()));
+ ret += QTest::qExec(&test, extraArgs.size(), const_cast<char**>(&extraArgs[0]));
}
/*
Run until getting a value of at least 100.
*/
{
- QVector<char const*> args;
- for (int i = 0; i < argc; ++i) args << argv[i];
- args << "-minimumvalue";
- args << "100";
+ auto extraArgs = args;
+ extraArgs.push_back("-minimumvalue");
+ extraArgs.push_back("100");
tst_BenchlibOneHundredMinimum test;
- ret += QTest::qExec(&test, args.count(), const_cast<char**>(args.data()));
+ ret += QTest::qExec(&test, extraArgs.size(), const_cast<char**>(&extraArgs[0]));
}
return ret;
diff --git a/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp b/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
index b37f63f20a..2cb7dfd77f 100644
--- a/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
+++ b/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
@@ -62,6 +62,14 @@ void tst_BenchlibTickCounter::threeBillionTicks()
#endif
}
-QTEST_MAIN(tst_BenchlibTickCounter)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-tickcounter");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_BenchlibTickCounter)
+}
#include "tst_benchlibtickcounter.moc"
diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
index 49c08982ad..cb3ac4fc2d 100644
--- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
+++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
@@ -80,7 +80,7 @@ void tst_Blacklisted::xpass()
#include <setjmp.h>
static jmp_buf state;
-static void abort_handler(int signal)
+static void abort_handler(int)
{
longjmp(state, 1);
}
diff --git a/tests/auto/testlib/selftests/commandlinedata/tst_commandlinedata.cpp b/tests/auto/testlib/selftests/commandlinedata/tst_commandlinedata.cpp
index 8cb1192ea2..a916fd7f1e 100644
--- a/tests/auto/testlib/selftests/commandlinedata/tst_commandlinedata.cpp
+++ b/tests/auto/testlib/selftests/commandlinedata/tst_commandlinedata.cpp
@@ -63,6 +63,16 @@ void tst_DataTable::fiveTablePasses_data() const
QTest::newRow("fiveTablePasses_data5") << true;
}
-QTEST_MAIN(tst_DataTable)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("fiveTablePasses");
+ args.push_back("fiveTablePasses:fiveTablePasses_data1");
+ args.push_back("-v2");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_DataTable)
+}
#include "tst_commandlinedata.moc"
diff --git a/tests/auto/testlib/selftests/counting/tst_counting.cpp b/tests/auto/testlib/selftests/counting/tst_counting.cpp
index da5595b04f..56933c78b7 100644
--- a/tests/auto/testlib/selftests/counting/tst_counting.cpp
+++ b/tests/auto/testlib/selftests/counting/tst_counting.cpp
@@ -287,5 +287,15 @@ void tst_Counting::testSkipInCleanup()
qDebug() << "This test function should execute and then QSKIP in cleanup()";
}
-QTEST_MAIN(tst_Counting)
+int main(int argc, char *argv[])
+{
+#ifdef TESTLIB_VERBOSITY_ARG
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back(QT_STRINGIFY(TESTLIB_VERBOSITY_ARG));
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+#endif
+
+ QTEST_MAIN_IMPL(tst_Counting)
+}
#include "tst_counting.moc"
diff --git a/tests/auto/testlib/selftests/deleteLater/deleteLater.pro b/tests/auto/testlib/selftests/deleteLater/deleteLater.pro
index 9a10096461..1b057eccde 100644
--- a/tests/auto/testlib/selftests/deleteLater/deleteLater.pro
+++ b/tests/auto/testlib/selftests/deleteLater/deleteLater.pro
@@ -4,6 +4,6 @@ QT = core testlib
CONFIG -= app_bundle
CONFIG -= debug_and_release_target
-TARGET = tst_deleteLater
+TARGET = deleteLater
include($$QT_SOURCE_TREE/src/testlib/selfcover.pri)
diff --git a/tests/auto/testlib/selftests/deleteLater_noApp/deleteLater_noApp.pro b/tests/auto/testlib/selftests/deleteLater_noApp/deleteLater_noApp.pro
index 6f2b253c14..90440109e7 100644
--- a/tests/auto/testlib/selftests/deleteLater_noApp/deleteLater_noApp.pro
+++ b/tests/auto/testlib/selftests/deleteLater_noApp/deleteLater_noApp.pro
@@ -4,6 +4,6 @@ QT = core testlib
CONFIG -= app_bundle
CONFIG -= debug_and_release_target
-TARGET = tst_deleteLater_noApp
+TARGET = deleteLater_noApp
include($$QT_SOURCE_TREE/src/testlib/selfcover.pri)
diff --git a/tests/auto/testlib/selftests/expected_assert.xunitxml b/tests/auto/testlib/selftests/expected_assert.junitxml
index ca12a45e20..ca12a45e20 100644
--- a/tests/auto/testlib/selftests/expected_assert.xunitxml
+++ b/tests/auto/testlib/selftests/expected_assert.junitxml
diff --git a/tests/auto/testlib/selftests/expected_badxml.xunitxml b/tests/auto/testlib/selftests/expected_badxml.junitxml
index 49048fdad6..49048fdad6 100644
--- a/tests/auto/testlib/selftests/expected_badxml.xunitxml
+++ b/tests/auto/testlib/selftests/expected_badxml.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchlibcallgrind.xunitxml b/tests/auto/testlib/selftests/expected_benchlibcallgrind.junitxml
index 95d90e6ee7..95d90e6ee7 100644
--- a/tests/auto/testlib/selftests/expected_benchlibcallgrind.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibcallgrind.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml b/tests/auto/testlib/selftests/expected_benchlibcounting.junitxml
index 05d1da9874..05d1da9874 100644
--- a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibcounting.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.junitxml
index ce0a81110d..ce0a81110d 100644
--- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchliboptions.xunitxml b/tests/auto/testlib/selftests/expected_benchliboptions.junitxml
index 370d1c7c5c..370d1c7c5c 100644
--- a/tests/auto/testlib/selftests/expected_benchliboptions.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchliboptions.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.junitxml
index 779d3bdcbc..779d3bdcbc 100644
--- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.junitxml
diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml b/tests/auto/testlib/selftests/expected_benchlibwalltime.junitxml
index 6a0510c4c9..6a0510c4c9 100644
--- a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.junitxml
diff --git a/tests/auto/testlib/selftests/expected_blacklisted.xunitxml b/tests/auto/testlib/selftests/expected_blacklisted.junitxml
index 6e192687fb..6e192687fb 100644
--- a/tests/auto/testlib/selftests/expected_blacklisted.xunitxml
+++ b/tests/auto/testlib/selftests/expected_blacklisted.junitxml
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.junitxml
index 397db4c3e4..397db4c3e4 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.junitxml
diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml b/tests/auto/testlib/selftests/expected_commandlinedata.junitxml
index 5072a7e6f4..5072a7e6f4 100644
--- a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_commandlinedata.junitxml
diff --git a/tests/auto/testlib/selftests/expected_counting.xunitxml b/tests/auto/testlib/selftests/expected_counting.junitxml
index cb3a7815af..cb3a7815af 100644
--- a/tests/auto/testlib/selftests/expected_counting.xunitxml
+++ b/tests/auto/testlib/selftests/expected_counting.junitxml
diff --git a/tests/auto/testlib/selftests/expected_datatable.xunitxml b/tests/auto/testlib/selftests/expected_datatable.junitxml
index 89fc7ee819..89fc7ee819 100644
--- a/tests/auto/testlib/selftests/expected_datatable.xunitxml
+++ b/tests/auto/testlib/selftests/expected_datatable.junitxml
diff --git a/tests/auto/testlib/selftests/expected_datetime.xunitxml b/tests/auto/testlib/selftests/expected_datetime.junitxml
index 6fc95719f3..6fc95719f3 100644
--- a/tests/auto/testlib/selftests/expected_datetime.xunitxml
+++ b/tests/auto/testlib/selftests/expected_datetime.junitxml
diff --git a/tests/auto/testlib/selftests/expected_differentexec.xunitxml b/tests/auto/testlib/selftests/expected_differentexec.junitxml
index 30ee50bc08..30ee50bc08 100644
--- a/tests/auto/testlib/selftests/expected_differentexec.xunitxml
+++ b/tests/auto/testlib/selftests/expected_differentexec.junitxml
diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml b/tests/auto/testlib/selftests/expected_exceptionthrow.junitxml
index 7d10bf6f04..7d10bf6f04 100644
--- a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml
+++ b/tests/auto/testlib/selftests/expected_exceptionthrow.junitxml
diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.junitxml
index 47483d71bf..47483d71bf 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml
+++ b/tests/auto/testlib/selftests/expected_expectfail.junitxml
diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml b/tests/auto/testlib/selftests/expected_failcleanup.junitxml
index 813e284ee0..813e284ee0 100644
--- a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failcleanup.junitxml
diff --git a/tests/auto/testlib/selftests/expected_faildatatype.xunitxml b/tests/auto/testlib/selftests/expected_faildatatype.junitxml
index fcc0db3892..fcc0db3892 100644
--- a/tests/auto/testlib/selftests/expected_faildatatype.xunitxml
+++ b/tests/auto/testlib/selftests/expected_faildatatype.junitxml
diff --git a/tests/auto/testlib/selftests/expected_failfetchtype.xunitxml b/tests/auto/testlib/selftests/expected_failfetchtype.junitxml
index a54a37a913..a54a37a913 100644
--- a/tests/auto/testlib/selftests/expected_failfetchtype.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failfetchtype.junitxml
diff --git a/tests/auto/testlib/selftests/expected_failinit.xunitxml b/tests/auto/testlib/selftests/expected_failinit.junitxml
index 3715725ea5..3715725ea5 100644
--- a/tests/auto/testlib/selftests/expected_failinit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failinit.junitxml
diff --git a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml b/tests/auto/testlib/selftests/expected_failinitdata.junitxml
index d245bc0dff..d245bc0dff 100644
--- a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failinitdata.junitxml
diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml b/tests/auto/testlib/selftests/expected_fetchbogus.junitxml
index 77ccbd896a..77ccbd896a 100644
--- a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml
+++ b/tests/auto/testlib/selftests/expected_fetchbogus.junitxml
diff --git a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml b/tests/auto/testlib/selftests/expected_findtestdata.junitxml
index c1138da6cb..c1138da6cb 100644
--- a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_findtestdata.junitxml
diff --git a/tests/auto/testlib/selftests/expected_float.xunitxml b/tests/auto/testlib/selftests/expected_float.junitxml
index 602f9252a4..602f9252a4 100644
--- a/tests/auto/testlib/selftests/expected_float.xunitxml
+++ b/tests/auto/testlib/selftests/expected_float.junitxml
diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.junitxml
index de184c2fdd..de184c2fdd 100644
--- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_globaldata.junitxml
diff --git a/tests/auto/testlib/selftests/expected_keyboard.xunitxml b/tests/auto/testlib/selftests/expected_keyboard.junitxml
index 93b5f7bfff..93b5f7bfff 100644
--- a/tests/auto/testlib/selftests/expected_keyboard.xunitxml
+++ b/tests/auto/testlib/selftests/expected_keyboard.junitxml
diff --git a/tests/auto/testlib/selftests/expected_longstring.xunitxml b/tests/auto/testlib/selftests/expected_longstring.junitxml
index 269c06fe08..269c06fe08 100644
--- a/tests/auto/testlib/selftests/expected_longstring.xunitxml
+++ b/tests/auto/testlib/selftests/expected_longstring.junitxml
diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml b/tests/auto/testlib/selftests/expected_maxwarnings.junitxml
index 329fae5f1d..329fae5f1d 100644
--- a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_maxwarnings.junitxml
diff --git a/tests/auto/testlib/selftests/expected_multiexec.xunitxml b/tests/auto/testlib/selftests/expected_multiexec.junitxml
index 8ab914842b..8ab914842b 100644
--- a/tests/auto/testlib/selftests/expected_multiexec.xunitxml
+++ b/tests/auto/testlib/selftests/expected_multiexec.junitxml
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml b/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml
index cf2a30b84a..cf2a30b84a 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml
diff --git a/tests/auto/testlib/selftests/expected_qexecstringlist.xunitxml b/tests/auto/testlib/selftests/expected_qexecstringlist.junitxml
index b352b8e6b9..b352b8e6b9 100644
--- a/tests/auto/testlib/selftests/expected_qexecstringlist.xunitxml
+++ b/tests/auto/testlib/selftests/expected_qexecstringlist.junitxml
diff --git a/tests/auto/testlib/selftests/expected_signaldumper.xunitxml b/tests/auto/testlib/selftests/expected_signaldumper.junitxml
index 6609f518a2..6609f518a2 100644
--- a/tests/auto/testlib/selftests/expected_signaldumper.xunitxml
+++ b/tests/auto/testlib/selftests/expected_signaldumper.junitxml
diff --git a/tests/auto/testlib/selftests/expected_silent.xunitxml b/tests/auto/testlib/selftests/expected_silent.junitxml
index ea229d1dc7..ea229d1dc7 100644
--- a/tests/auto/testlib/selftests/expected_silent.xunitxml
+++ b/tests/auto/testlib/selftests/expected_silent.junitxml
diff --git a/tests/auto/testlib/selftests/expected_singleskip.xunitxml b/tests/auto/testlib/selftests/expected_singleskip.junitxml
index 2b2da2f504..2b2da2f504 100644
--- a/tests/auto/testlib/selftests/expected_singleskip.xunitxml
+++ b/tests/auto/testlib/selftests/expected_singleskip.junitxml
diff --git a/tests/auto/testlib/selftests/expected_skip.xunitxml b/tests/auto/testlib/selftests/expected_skip.junitxml
index 63e582f96a..63e582f96a 100644
--- a/tests/auto/testlib/selftests/expected_skip.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skip.junitxml
diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml b/tests/auto/testlib/selftests/expected_skipcleanup.junitxml
index 9934584ec5..9934584ec5 100644
--- a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipcleanup.junitxml
diff --git a/tests/auto/testlib/selftests/expected_skipinit.xunitxml b/tests/auto/testlib/selftests/expected_skipinit.junitxml
index bab08c375c..bab08c375c 100644
--- a/tests/auto/testlib/selftests/expected_skipinit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipinit.junitxml
diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml b/tests/auto/testlib/selftests/expected_skipinitdata.junitxml
index e61d50b06b..e61d50b06b 100644
--- a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipinitdata.junitxml
diff --git a/tests/auto/testlib/selftests/expected_sleep.xunitxml b/tests/auto/testlib/selftests/expected_sleep.junitxml
index e4ed66bcb8..e4ed66bcb8 100644
--- a/tests/auto/testlib/selftests/expected_sleep.xunitxml
+++ b/tests/auto/testlib/selftests/expected_sleep.junitxml
diff --git a/tests/auto/testlib/selftests/expected_strcmp.xunitxml b/tests/auto/testlib/selftests/expected_strcmp.junitxml
index 66dce857c9..66dce857c9 100644
--- a/tests/auto/testlib/selftests/expected_strcmp.xunitxml
+++ b/tests/auto/testlib/selftests/expected_strcmp.junitxml
diff --git a/tests/auto/testlib/selftests/expected_subtest.xunitxml b/tests/auto/testlib/selftests/expected_subtest.junitxml
index b49c006940..b49c006940 100644
--- a/tests/auto/testlib/selftests/expected_subtest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_subtest.junitxml
diff --git a/tests/auto/testlib/selftests/expected_testlib.xunitxml b/tests/auto/testlib/selftests/expected_testlib.junitxml
index c9c67c7c9a..c9c67c7c9a 100644
--- a/tests/auto/testlib/selftests/expected_testlib.xunitxml
+++ b/tests/auto/testlib/selftests/expected_testlib.junitxml
diff --git a/tests/auto/testlib/selftests/expected_tuplediagnostics.xunitxml b/tests/auto/testlib/selftests/expected_tuplediagnostics.junitxml
index 0a276a17f5..0a276a17f5 100644
--- a/tests/auto/testlib/selftests/expected_tuplediagnostics.xunitxml
+++ b/tests/auto/testlib/selftests/expected_tuplediagnostics.junitxml
diff --git a/tests/auto/testlib/selftests/expected_verbose1.xunitxml b/tests/auto/testlib/selftests/expected_verbose1.junitxml
index cb3a7815af..cb3a7815af 100644
--- a/tests/auto/testlib/selftests/expected_verbose1.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verbose1.junitxml
diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.junitxml
index 6764a5564f..6764a5564f 100644
--- a/tests/auto/testlib/selftests/expected_verbose2.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verbose2.junitxml
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.junitxml
index 003a31a1cc..003a31a1cc 100644
--- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.junitxml
diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.junitxml
index 5cca215f12..5cca215f12 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_warnings.junitxml
diff --git a/tests/auto/testlib/selftests/expected_watchdog.xunitxml b/tests/auto/testlib/selftests/expected_watchdog.junitxml
index 7e16ab2c34..7e16ab2c34 100644
--- a/tests/auto/testlib/selftests/expected_watchdog.xunitxml
+++ b/tests/auto/testlib/selftests/expected_watchdog.junitxml
diff --git a/tests/auto/testlib/selftests/expected_xunit.xunitxml b/tests/auto/testlib/selftests/expected_xunit.junitxml
index 395b6efdd9..395b6efdd9 100644
--- a/tests/auto/testlib/selftests/expected_xunit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_xunit.junitxml
diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py
index 48ecbf0289..96fab44408 100755
--- a/tests/auto/testlib/selftests/generate_expected_output.py
+++ b/tests/auto/testlib/selftests/generate_expected_output.py
@@ -86,7 +86,7 @@ class Cleaner (object):
# Build details:
(r'(Config: Using QtTest library).*', r'\1'), # txt
(r'( *<QtBuild)>[^<]+</QtBuild>', r'\1/>'), # xml, lightxml
- (r'(<property value=")[^"]+(" name="QtBuild"/>)', r'\1\2'), # xunitxml
+ (r'(<property value=")[^"]+(" name="QtBuild"/>)', r'\1\2'), # junitxml
# Line numbers in source files:
(r'(ASSERT: ".*" in file .*, line) \d+', r'\1 0'), # lightxml
(r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt
@@ -295,23 +295,7 @@ def testEnv(testname,
return data
def generateTestData(testname, clean,
- formats = ('xml', 'txt', 'xunitxml', 'lightxml', 'teamcity', 'tap'),
- # Make sure this matches tst_Selftests::runSubTest_data():
- extraArgs = {
- "commandlinedata": "fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2",
- "benchlibcallgrind": "-callgrind",
- "benchlibeventcounter": "-eventcounter",
- "benchliboptions": "-eventcounter",
- "benchlibtickcounter": "-tickcounter",
- "badxml": "-eventcounter",
- "benchlibcounting": "-eventcounter",
- "printdatatags": "-datatags",
- "printdatatagswithglobaltags": "-datatags",
- "signaldumper": "-vs",
- "silent": "-silent",
- "verbose1": "-v1",
- "verbose2": "-v2",
- }):
+ formats = ('xml', 'txt', 'junitxml', 'lightxml', 'teamcity', 'tap')):
"""Run one test and save its cleaned results.
Required arguments are the name of the test directory (the binary
@@ -330,9 +314,6 @@ def generateTestData(testname, clean,
print(" running", testname)
for format in formats:
cmd = [path, '-' + format]
- if testname in extraArgs:
- cmd += extraArgs[testname].split()
-
data = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env,
universal_newlines=True).communicate()[0]
with open('expected_' + testname + '.' + format, 'w') as out:
diff --git a/tests/auto/testlib/selftests/mouse/tst_mouse.cpp b/tests/auto/testlib/selftests/mouse/tst_mouse.cpp
index d097027e7e..43dda31daf 100644
--- a/tests/auto/testlib/selftests/mouse/tst_mouse.cpp
+++ b/tests/auto/testlib/selftests/mouse/tst_mouse.cpp
@@ -42,6 +42,8 @@ class tst_Mouse : public QObject
Q_OBJECT
private slots:
+ void timestampBetweenTestFunction_data();
+ void timestampBetweenTestFunction();
void stateHandlingPart1_data();
void stateHandlingPart1();
void stateHandlingPart2();
@@ -55,20 +57,83 @@ public:
Qt::MouseButtons stateInMouseMove = Qt::NoButton;
int moveCount = 0;
int pressCount = 0;
+ int doubleClickCount = 0;
+ ulong lastTimeStamp = 0;
protected:
- void mousePressEvent(QMouseEvent *)
+ void mousePressEvent(QMouseEvent *e)
{
pressCount++;
+ processEvent(e);
}
void mouseMoveEvent(QMouseEvent *e)
{
moveCount++;
stateInMouseMove = e->buttons();
+ processEvent(e);
}
+
+ void mouseReleaseEvent(QMouseEvent *e)
+ {
+ processEvent(e);
+ }
+
+ void mouseDoubleClickEvent(QMouseEvent *e)
+ {
+ doubleClickCount++;
+ processEvent(e);
+ }
+
+ void processEvent(QMouseEvent *e)
+ {
+ lastTimeStamp = e->timestamp();
+ }
+
};
+static ulong lastTimeStampInPreviousTestFunction = 0;
+
+void tst_Mouse::timestampBetweenTestFunction_data()
+{
+ QTest::addColumn<bool>("hoverLast");
+ QTest::addColumn<bool>("pressAndRelease");
+ QTest::newRow("press, release") << true << false;
+ QTest::newRow("press, release, hover") << true << true;
+ QTest::newRow("hover") << false << true;
+ QTest::newRow("hover #2") << false << true;
+ QTest::newRow("press, release #2") << true << false;
+ QTest::newRow("press, release, hover #2") << true << true;
+}
+
+void tst_Mouse::timestampBetweenTestFunction()
+{
+ QFETCH(bool, hoverLast);
+ QFETCH(bool, pressAndRelease);
+
+ MouseWindow w;
+ w.show();
+ w.setGeometry(100, 100, 200, 200);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ QPoint point(10, 10);
+ QCOMPARE(w.pressCount, 0);
+ if (pressAndRelease) {
+ QTest::mousePress(&w, Qt::LeftButton, { }, point);
+ QVERIFY(w.lastTimeStamp - lastTimeStampInPreviousTestFunction > 500); // Should be at least 500 ms timestamp between each test case
+ QCOMPARE(w.pressCount, 1);
+ QTest::mouseRelease(&w, Qt::LeftButton, { }, point);
+ }
+ QCOMPARE(w.doubleClickCount, 0);
+ if (hoverLast) {
+ static int xMove = 0;
+ xMove += 5; // Just make sure we generate different hover coordinates
+ point.rx() += xMove;
+ QTest::mouseMove(&w, point); // a hover move. This doesn't generate a timestamp delay of 500 ms
+ }
+ lastTimeStampInPreviousTestFunction = w.lastTimeStamp;
+}
+
void tst_Mouse::stateHandlingPart1_data()
{
QTest::addColumn<bool>("dummy");
diff --git a/tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp b/tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp
index 5c9f5c5898..60a295c0f7 100644
--- a/tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp
+++ b/tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp
@@ -72,6 +72,14 @@ void tst_PrintDataTags::c() const
{
}
-QTEST_MAIN(tst_PrintDataTags)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-datatags");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_PrintDataTags)
+}
#include "tst_printdatatags.moc"
diff --git a/tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp b/tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
index b68daae538..6fea34467a 100644
--- a/tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
+++ b/tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
@@ -88,6 +88,14 @@ void tst_PrintDataTagsWithGlobalTags::c() const
{
}
-QTEST_MAIN(tst_PrintDataTagsWithGlobalTags)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-datatags");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_PrintDataTagsWithGlobalTags)
+}
#include "tst_printdatatagswithglobaltags.moc"
diff --git a/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp
index 08592e222d..c60260f109 100644
--- a/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp
+++ b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp
@@ -424,5 +424,14 @@ void tst_Signaldumper::deletingSender()
emit signalSlotOwner->signalWithoutParameters();
}
-QTEST_MAIN(tst_Signaldumper)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-vs");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_Signaldumper)
+}
+
#include "tst_signaldumper.moc"
diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp
index cf3c35dec4..7d64efffa2 100644
--- a/tests/auto/testlib/selftests/silent/tst_silent.cpp
+++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp
@@ -77,7 +77,7 @@ void tst_Silent::xpass()
#include <setjmp.h>
static jmp_buf state;
-static void abort_handler(int signal)
+static void abort_handler(int)
{
longjmp(state, 1);
}
@@ -102,5 +102,14 @@ void tst_Silent::messages()
qFatal("This is a fatal error message that should still appear in silent test output");
}
-QTEST_MAIN(tst_Silent)
+int main(int argc, char *argv[])
+{
+ std::vector<const char*> args(argv, argv + argc);
+ args.push_back("-silent");
+ argc = args.size();
+ argv = const_cast<char**>(&args[0]);
+
+ QTEST_MAIN_IMPL(tst_Silent)
+}
+
#include "tst_silent.moc"
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 331ae48135..be64752ceb 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -76,8 +76,6 @@ private:
QList<LoggerSet> allLoggerSets() const;
QTemporaryDir tempDir;
- QRegularExpression durationRegExp;
- QRegularExpression teamcityLocRegExp;
};
struct BenchmarkResult
@@ -280,13 +278,17 @@ QList<LoggerSet> tst_Selftests::allLoggerSets() const
QStringList() << "xml",
QStringList() << "-xml" << "-o" << logName("xml")
)
- << LoggerSet("old stdout xunitxml",
- QStringList() << "stdout xunitxml",
- QStringList() << "-xunitxml"
+ << LoggerSet("old stdout junitxml",
+ QStringList() << "stdout junitxml",
+ QStringList() << "-junitxml"
)
- << LoggerSet("old xunitxml",
- QStringList() << "xunitxml",
- QStringList() << "-xunitxml" << "-o" << logName("xunitxml")
+ << LoggerSet("old junitxml",
+ QStringList() << "junitxml",
+ QStringList() << "-junitxml" << "-o" << logName("junitxml")
+ )
+ << LoggerSet("old xunitxml compatibility",
+ QStringList() << "junitxml",
+ QStringList() << "-xunitxml" << "-o" << logName("junitxml")
)
<< LoggerSet("old stdout lightxml",
QStringList() << "stdout lightxml",
@@ -335,13 +337,17 @@ QList<LoggerSet> tst_Selftests::allLoggerSets() const
QStringList() << "xml",
QStringList() << "-o" << logName("xml")+",xml"
)
- << LoggerSet("new stdout xunitxml",
- QStringList() << "stdout xunitxml",
+ << LoggerSet("new stdout junitxml",
+ QStringList() << "stdout junitxml",
+ QStringList() << "-o" << "-,junitxml"
+ )
+ << LoggerSet("new stdout xunitxml compatibility",
+ QStringList() << "stdout junitxml",
QStringList() << "-o" << "-,xunitxml"
)
- << LoggerSet("new xunitxml",
- QStringList() << "xunitxml",
- QStringList() << "-o" << logName("xunitxml")+",xunitxml"
+ << LoggerSet("new junitxml",
+ QStringList() << "junitxml",
+ QStringList() << "-o" << logName("junitxml")+",junitxml"
)
<< LoggerSet("new stdout lightxml",
QStringList() << "stdout lightxml",
@@ -384,24 +390,24 @@ QList<LoggerSet> tst_Selftests::allLoggerSets() const
QStringList() << "-o" << logName("xml")+",xml"
<< "-o" << "-,txt"
)
- << LoggerSet("txt + xunitxml",
- QStringList() << "txt" << "xunitxml",
+ << LoggerSet("txt + junitxml",
+ QStringList() << "txt" << "junitxml",
QStringList() << "-o" << logName("txt")+",txt"
- << "-o" << logName("xunitxml")+",xunitxml"
+ << "-o" << logName("junitxml")+",junitxml"
)
- << LoggerSet("lightxml + stdout xunitxml",
- QStringList() << "lightxml" << "stdout xunitxml",
+ << LoggerSet("lightxml + stdout junitxml",
+ QStringList() << "lightxml" << "stdout junitxml",
QStringList() << "-o" << logName("lightxml")+",lightxml"
- << "-o" << "-,xunitxml"
+ << "-o" << "-,junitxml"
)
// All loggers at the same time (except csv)
<< LoggerSet("all loggers",
- QStringList() << "txt" << "xml" << "lightxml" << "stdout txt" << "xunitxml" << "tap",
+ QStringList() << "txt" << "xml" << "lightxml" << "stdout txt" << "junitxml" << "tap",
QStringList() << "-o" << logName("txt")+",txt"
<< "-o" << logName("xml")+",xml"
<< "-o" << logName("lightxml")+",lightxml"
<< "-o" << "-,txt"
- << "-o" << logName("xunitxml")+",xunitxml"
+ << "-o" << logName("junitxml")+",junitxml"
<< "-o" << logName("teamcity")+",teamcity"
<< "-o" << logName("tap")+",tap"
)
@@ -410,8 +416,6 @@ QList<LoggerSet> tst_Selftests::allLoggerSets() const
tst_Selftests::tst_Selftests()
: tempDir(QDir::tempPath() + "/tst_selftests.XXXXXX")
- , durationRegExp("<Duration msecs=\"[\\d\\.]+\"/>")
- , teamcityLocRegExp("\\|\\[Loc: .*\\(\\d*\\)\\|\\]")
{}
void tst_Selftests::initTestCase()
@@ -524,49 +528,6 @@ void tst_Selftests::runSubTest_data()
QStringList loggers = loggerSet.loggers;
foreach (QString const& subtest, tests) {
- QStringList arguments = loggerSet.arguments;
- // Keep in sync with generateTestData()'s extraArgs in generate_expected_output.py:
- if (subtest == "commandlinedata") {
- arguments << QString("fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2").split(' ');
- }
- else if (subtest == "benchlibcallgrind") {
- arguments << "-callgrind";
- }
- else if (subtest == "benchlibeventcounter") {
- arguments << "-eventcounter";
- }
- else if (subtest == "benchliboptions") {
- arguments << "-eventcounter";
- }
- else if (subtest == "benchlibtickcounter") {
- arguments << "-tickcounter";
- }
- else if (subtest == "badxml") {
- arguments << "-eventcounter";
- }
- else if (subtest == "benchlibcounting") {
- arguments << "-eventcounter";
- }
- else if (subtest == "printdatatags") {
- arguments << "-datatags";
- }
- else if (subtest == "printdatatagswithglobaltags") {
- arguments << "-datatags";
- }
- else if (subtest == "signaldumper") {
- arguments << "-vs";
- }
- else if (subtest == "silent") {
- arguments << "-silent";
- }
- else if (subtest == "verbose1") {
- arguments << "-v1";
- }
- else if (subtest == "verbose2") {
- arguments << "-v2";
- }
-
-
// These tests don't work right unless logging plain text to
// standard output, either because they execute multiple test
// objects or because they internally supply arguments to
@@ -630,7 +591,7 @@ void tst_Selftests::runSubTest_data()
QTest::newRow(qPrintable(QString("%1 %2").arg(subtest).arg(loggerSet.name)))
<< subtest
<< loggers
- << arguments
+ << loggerSet.arguments
<< crashes
;
}
@@ -686,7 +647,7 @@ static inline QByteArray msgProcessError(const QString &binary, const QStringLis
void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes)
{
#if defined(__GNUC__) && defined(__i386) && defined(Q_OS_LINUX)
- if (arguments.contains("-callgrind")) {
+ if (subdir == "benchlibcallgrind") {
QProcess checkProcess;
QStringList args;
args << QLatin1String("--version");
@@ -839,8 +800,8 @@ bool tst_Selftests::compareOutput(const QString &logger, const QString &subdir,
{
if (actual.size() != expected.size()) {
- *errorMessage = QString::fromLatin1("Mismatch in line count: %1 != %2.")
- .arg(actual.size()).arg(expected.size());
+ *errorMessage = QString::fromLatin1("Mismatch in line count. Expected %1 but got %2.")
+ .arg(expected.size()).arg(actual.size());
return false;
}
@@ -873,6 +834,7 @@ bool tst_Selftests::compareOutput(const QString &logger, const QString &subdir,
// Special handling for ignoring _FILE_ and _LINE_ if logger is teamcity
if (logger.endsWith(QLatin1String("teamcity"))) {
+ static QRegularExpression teamcityLocRegExp("\\|\\[Loc: .*\\(\\d*\\)\\|\\]");
actualLine.replace(teamcityLocRegExp, teamCityLocation());
expectedLine.replace(teamcityLocRegExp, teamCityLocation());
}
@@ -943,6 +905,7 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir,
if (actualLine.startsWith(QLatin1String(" <Duration msecs="))
|| actualLine.startsWith(QLatin1String("<Duration msecs="))) {
+ static QRegularExpression durationRegExp("<Duration msecs=\"[\\d\\.]+\"/>");
QRegularExpressionMatch match = durationRegExp.match(actualLine);
if (match.hasMatch())
return true;
diff --git a/tests/auto/testlib/selftests/verbose1/verbose1.pro b/tests/auto/testlib/selftests/verbose1/verbose1.pro
index 1f16d70d66..f50ce83ea6 100644
--- a/tests/auto/testlib/selftests/verbose1/verbose1.pro
+++ b/tests/auto/testlib/selftests/verbose1/verbose1.pro
@@ -4,6 +4,8 @@
SOURCES += ../counting/tst_counting.cpp
QT = core testlib
+DEFINES += TESTLIB_VERBOSITY_ARG="-v1"
+
mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
diff --git a/tests/auto/testlib/selftests/verbose2/verbose2.pro b/tests/auto/testlib/selftests/verbose2/verbose2.pro
index bf54904488..d4765f01b5 100644
--- a/tests/auto/testlib/selftests/verbose2/verbose2.pro
+++ b/tests/auto/testlib/selftests/verbose2/verbose2.pro
@@ -4,6 +4,8 @@
SOURCES += ../counting/tst_counting.cpp
QT = core testlib
+DEFINES += TESTLIB_VERBOSITY_ARG="-v2"
+
mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
diff --git a/tests/auto/tools/uic/baseline/config.ui.py b/tests/auto/tools/uic/baseline/config.ui.py
index 5fd558bb01..b3b6e09373 100644
--- a/tests/auto/tools/uic/baseline/config.ui.py
+++ b/tests/auto/tools/uic/baseline/config.ui.py
@@ -36,11 +36,11 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
-from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
- QRect, QSize, QUrl, Qt)
+from PySide2.QtCore import (QCoreApplication, QDate, QDateTime, QMetaObject,
+ QObject, QPoint, QRect, QSize, QTime, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
- QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
- QRadialGradient)
+ QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter,
+ QPixmap, QRadialGradient)
from PySide2.QtWidgets import *
from gammaview import GammaView
@@ -48,7 +48,7 @@ from gammaview import GammaView
class Ui_Config(object):
def setupUi(self, Config):
- if Config.objectName():
+ if not Config.objectName():
Config.setObjectName(u"Config")
Config.resize(600, 650)
Config.setSizeGripEnabled(True)
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 4e31c3e57c..63bf103725 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1014,30 +1014,38 @@ void tst_QFileSystemModel::drives()
void tst_QFileSystemModel::dirsBeforeFiles()
{
- QDir dir(flatDirTestPath);
+ auto diagnosticMsg = [](int row, const QFileInfo &left, const QFileInfo &right) -> QByteArray {
+ QString message;
+ QDebug(&message).noquote() << "Unexpected sort order at #" << row << ':' << left << right;
+ return message.toLocal8Bit();
+ };
+ QTemporaryDir testDir(flatDirTestPath);
+ QVERIFY2(testDir.isValid(), qPrintable(testDir.errorString()));
+ QDir dir(testDir.path());
const int itemCount = 3;
for (int i = 0; i < itemCount; ++i) {
QLatin1Char c('a' + char(i));
QVERIFY(dir.mkdir(c + QLatin1String("-dir")));
- QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
+ QFile file(dir.filePath(c + QLatin1String("-file")));
QVERIFY(file.open(QIODevice::ReadWrite));
file.close();
}
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = model->setRootPath(flatDirTestPath);
+ QModelIndex root = model->setRootPath(dir.absolutePath());
// Wait for model to be notified by the file system watcher
QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
-
- // Ensure that no file occurs before any directory:
- for (int i = 1; i < model->rowCount(root); ++i) {
+ // sort explicitly - dirs before files (except on macOS), and then by name
+ model->sort(0);
+ // Ensure that no file occurs before any directory (see QFileSystemModelSorter):
+ for (int i = 1, count = model->rowCount(root); i < count; ++i) {
+ const QFileInfo previous = model->fileInfo(model->index(i - 1, 0, root));
+ const QFileInfo current = model->fileInfo(model->index(i, 0, root));
#ifndef Q_OS_MAC
- QVERIFY(!(model->fileInfo(model->index(i - 1, 0, root)).isFile()
- && model->fileInfo(model->index(i, 0, root)).isDir()));
+ QVERIFY2(!(previous.isFile() && current.isDir()), diagnosticMsg(i, previous, current).constData());
#else
- QVERIFY(model->fileInfo(model->index(i - 1, 0, root)).fileName() <
- model->fileInfo(model->index(i, 0, root)).fileName());
+ QVERIFY2(previous.fileName() < current.fileName(), diagnosticMsg(i, previous, current).constData());
#endif
}
}
diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
index 259de49c67..877784041b 100644
--- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
@@ -326,7 +326,7 @@ void tst_QInputDialog::getDouble()
// rounded off to 10.03)
const double value = static_cast<int>(min + (max - min) / 2);
const double result =
- QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok);
+ QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok, Qt::WindowFlags(), 1);
QVERIFY(ok);
QCOMPARE(result, value);
delete parent;
@@ -395,7 +395,8 @@ void tst_QInputDialog::taskQTBUG_54693_crashWhenParentIsDeletedWhileDialogIsOpen
const double initial = 7;
QAutoPointer<SelfDestructParent> dialog(new SelfDestructParent);
bool ok = true;
- const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok);
+ const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok,
+ Qt::WindowFlags(), 1);
QVERIFY(!dialog);
QVERIFY(!ok);
QCOMPARE(result, initial);
@@ -411,7 +412,7 @@ void tst_QInputDialog::task255502getDouble()
bool ok = false;
const double value = 0.001;
const double result =
- QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok);
+ QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok, Qt::WindowFlags(), 1);
QVERIFY(ok);
QCOMPARE(result, value);
delete parent;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
index e760042def..31dbb38a5d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
@@ -1,3 +1,4 @@
# QTBUG-74760
[sorting]
opensuse-42.3
+osx
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index a437b05479..8c2d89e34b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -89,6 +89,7 @@ private slots:
void focusNextPrevChild();
void focusOutEvent_data();
void focusOutEvent();
+ void focusProxy_QTBUG_51856();
void hoverEnterLeaveEvent_data();
void hoverEnterLeaveEvent();
void hoverMoveEvent_data();
@@ -864,6 +865,75 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
}
}
+void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
+{
+ // QSpinBox has an internal QLineEdit; this QLineEdit has the spinbox
+ // as its focus proxy.
+ struct FocusedSpinBox : QSpinBox
+ {
+ int focusCount = 0;
+
+ bool event(QEvent *event) override
+ {
+ switch (event->type()) {
+ case QEvent::FocusIn:
+ ++focusCount;
+ break;
+ case QEvent::FocusOut:
+ --focusCount;
+ break;
+ default:
+ break;
+ }
+ return QSpinBox::event(event);
+ }
+ };
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
+ scene.addItem(proxy);
+ view.show();
+ view.raise();
+ view.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ FocusedSpinBox *spinBox = new FocusedSpinBox;
+
+ proxy->setWidget(spinBox);
+ proxy->show();
+ proxy->setFocus();
+ QVERIFY(proxy->hasFocus());
+ QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue);
+ QVERIFY(spinBox->hasFocus());
+ QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue);
+ QCOMPARE(spinBox->focusCount, 1);
+
+ enum { Count = 10 };
+
+ for (int i = 0; i < Count; ++i) {
+ for (int clickCount = 0; clickCount < Count; ++clickCount) {
+ auto proxyCenter = proxy->boundingRect().center();
+ auto proxyCenterInScene = proxy->mapToScene(proxyCenter);
+ auto proxyCenterInView = view.mapFromScene(proxyCenterInScene);
+
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, proxyCenterInView);
+ QTRY_COMPARE(spinBox->focusCount, 1);
+ }
+
+ QLineEdit *edit = new QLineEdit(&view);
+ edit->show();
+ QTRY_VERIFY(edit->isVisible());
+ edit->setFocus();
+ QTRY_VERIFY(edit->hasFocus());
+ QTRY_VERIFY(!proxy->hasFocus());
+ QTRY_COMPARE(proxy->focusOut, i + 1);
+ QTRY_VERIFY(!spinBox->hasFocus());
+ QTRY_COMPARE(spinBox->focusCount, 0);
+ delete edit;
+ }
+}
+
class EventLogger : public QWidget
{
public:
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
index 9b76ea02ff..f59544f336 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
@@ -16,3 +16,5 @@ opensuse-42.3
[itemsInRect_cosmeticAdjust]
# QTBUG-66815
ubuntu-16.04
+[fitInView]
+osx
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index c015bf85d0..9c16b1a00a 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -409,6 +409,8 @@ private slots:
void closeEvent();
void closeWithChildWindow();
+ void winIdAfterClose();
+
private:
bool ensureScreenSize(int width, int height);
@@ -11309,5 +11311,54 @@ void tst_QWidget::closeWithChildWindow()
QVERIFY(!childWidget->isVisible());
}
+class WinIdChangeSpy : public QObject
+{
+ Q_OBJECT
+public:
+ QWidget *widget = nullptr;
+ WId winId = 0;
+ explicit WinIdChangeSpy(QWidget *w, QObject *parent = nullptr)
+ : QObject(parent)
+ , widget(w)
+ , winId(widget->winId())
+ {
+ }
+
+public slots:
+ bool eventFilter(QObject *obj, QEvent *event) override
+ {
+ if (obj == widget) {
+ if (event->type() == QEvent::WinIdChange) {
+ winId = widget->winId();
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
+void tst_QWidget::winIdAfterClose()
+{
+ auto widget = new QWidget;
+ auto notifier = new QObject(widget);
+ auto deleteWidget = new QWidget(new QWidget(widget));
+ auto spy = new WinIdChangeSpy(deleteWidget);
+ deleteWidget->installEventFilter(spy);
+ connect(notifier, &QObject::destroyed, [&] { delete deleteWidget; });
+
+ widget->setAttribute(Qt::WA_NativeWindow);
+ widget->windowHandle()->create();
+ widget->show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(widget));
+ QVERIFY(spy->winId);
+
+ widget->windowHandle()->close();
+ delete widget;
+
+ QCOMPARE(spy->winId, WId(0));
+ delete spy;
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index 5d52acd1a2..999cf4a941 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -58,6 +58,23 @@ protected:
}
};
+class TestPushButton : public QPushButton
+{
+public:
+ TestPushButton(QWidget *parent = nullptr)
+ : QPushButton(parent)
+ {}
+ TestPushButton(const QString &title, QWidget *parent = nullptr)
+ : QPushButton(title, parent)
+ {}
+
+protected:
+ bool hitButton(const QPoint &pos) const override
+ {
+ return rect().contains(pos);
+ }
+};
+
#include <qbuttongroup.h>
class tst_QButtonGroup : public QObject
@@ -97,7 +114,7 @@ void tst_QButtonGroup::arrowKeyNavigation()
QGroupBox g1("1", &dlg);
QHBoxLayout g1layout(&g1);
QRadioButton bt1("Radio1", &g1);
- QPushButton pb("PB", &g1);
+ TestPushButton pb("PB", &g1);
QLineEdit le(&g1);
QRadioButton bt2("Radio2", &g1);
g1layout.addWidget(&bt1);
@@ -231,9 +248,9 @@ void tst_QButtonGroup::exclusive()
{
QDialog dlg(0);
QHBoxLayout layout(&dlg);
- QPushButton *pushButton1 = new QPushButton(&dlg);
- QPushButton *pushButton2 = new QPushButton(&dlg);
- QPushButton *pushButton3 = new QPushButton(&dlg);
+ TestPushButton *pushButton1 = new TestPushButton(&dlg);
+ TestPushButton *pushButton2 = new TestPushButton(&dlg);
+ TestPushButton *pushButton3 = new TestPushButton(&dlg);
pushButton1->setCheckable(true);
pushButton2->setCheckable(true);
pushButton3->setCheckable(true);
@@ -271,9 +288,9 @@ void tst_QButtonGroup::exclusive()
void tst_QButtonGroup::testSignals()
{
QButtonGroup buttons;
- QPushButton pb1;
- QPushButton pb2;
- QPushButton pb3;
+ TestPushButton pb1;
+ TestPushButton pb2;
+ TestPushButton pb3;
buttons.addButton(&pb1);
buttons.addButton(&pb2, 23);
buttons.addButton(&pb3);
@@ -363,9 +380,9 @@ void tst_QButtonGroup::checkedButton()
{
QButtonGroup buttons;
buttons.setExclusive(false);
- QPushButton pb1;
+ TestPushButton pb1;
pb1.setCheckable(true);
- QPushButton pb2;
+ TestPushButton pb2;
pb2.setCheckable(true);
buttons.addButton(&pb1);
buttons.addButton(&pb2, 23);
@@ -430,7 +447,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
QFETCH(int, signalCount);
qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
- QPushButton *button = new QPushButton;
+ TestPushButton *button = new TestPushButton;
QButtonGroup group;
group.addButton(button);
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 1f301fd60f..6aca84e3cd 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -47,6 +47,7 @@
#include <qtablewidget.h>
#include <qscrollbar.h>
#include <qboxlayout.h>
+#include <qstackedwidget.h>
#include <qstandarditemmodel.h>
#include <qstringlistmodel.h>
@@ -164,6 +165,7 @@ private slots:
void task_QTBUG_56693_itemFontFromModel();
void inputMethodUpdate();
void task_QTBUG_52027_mapCompleterIndex();
+ void checkMenuItemPosWhenStyleSheetIsSet();
private:
PlatformInputContext m_platformInputContext;
@@ -1206,8 +1208,7 @@ void tst_QComboBox::currentIndex()
QVERIFY(testWidget->currentText().isEmpty());
// spy on currentIndexChanged
- QSignalSpy indexChangedInt(testWidget, SIGNAL(currentIndexChanged(int)));
- QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(QString)));
+ QSignalSpy indexChangedSpy(testWidget, SIGNAL(currentIndexChanged(int, QString)));
// stuff items into it
foreach(QString text, initialItems) {
@@ -1231,16 +1232,12 @@ void tst_QComboBox::currentIndex()
QCOMPARE(testWidget->currentText(), expectedCurrentText);
// check that signal count is correct
- QCOMPARE(indexChangedInt.count(), expectedSignalCount);
- QCOMPARE(indexChangedString.count(), expectedSignalCount);
+ QCOMPARE(indexChangedSpy.count(), expectedSignalCount);
// compare with last sent signal values
- if (indexChangedInt.count())
- QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(),
- testWidget->currentIndex());
- if (indexChangedString.count())
- QCOMPARE(indexChangedString.at(indexChangedString.count() - 1).at(0).toString(),
- testWidget->currentText());
+ if (indexChangedSpy.count())
+ QCOMPARE(indexChangedSpy.at(indexChangedSpy.count() - 1).at(0).toInt(),
+ testWidget->currentIndex());
if (edit) {
testWidget->setCurrentIndex(-1);
@@ -2339,7 +2336,8 @@ public:
{
QStringList list;
list << "one" << "two";
- connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
+ connect(this, SIGNAL(currentIndexChanged(int, QString)),
+ this, SLOT(onCurrentIndexChanged(int)));
addItems(list);
}
public slots:
@@ -2765,7 +2763,7 @@ void tst_QComboBox::resetModel()
};
QComboBox cb;
StringListModel model({"1", "2"});
- QSignalSpy spy(&cb, QOverload<int>::of(&QComboBox::currentIndexChanged));
+ QSignalSpy spy(&cb, QOverload<int, const QString &>::of(&QComboBox::currentIndexChanged));
QCOMPARE(spy.count(), 0);
QCOMPARE(cb.currentIndex(), -1); //no selection
@@ -3515,5 +3513,46 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex()
QCOMPARE(arguments.at(0).toInt(), 1);
}
+void tst_QComboBox::checkMenuItemPosWhenStyleSheetIsSet()
+{
+ QString newCss = "QComboBox {font-size: 18pt;}";
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(newCss);
+
+ QWidget topLevel;
+ QVBoxLayout *layout = new QVBoxLayout(&topLevel);
+ QStackedWidget *stack = new QStackedWidget(&topLevel);
+ layout->addWidget(stack);
+ QWidget *container = new QWidget(&topLevel);
+ QHBoxLayout *cLayout = new QHBoxLayout(container);
+ QComboBox *cBox = new QComboBox;
+
+ QStandardItemModel *model = new QStandardItemModel(cBox);
+ QStandardItem *item = new QStandardItem(QStringLiteral("Item1"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item2"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item3"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item4"));
+ model->appendRow(item);
+ cBox->setModel(model);
+
+ cLayout->addWidget(cBox);
+ stack->addWidget(container);
+ topLevel.show();
+ cBox->showPopup();
+
+ QTRY_VERIFY(cBox->view());
+ QTRY_VERIFY(cBox->view()->isVisible());
+
+ int menuHeight = cBox->view()->geometry().height();
+ QRect menuItemRect = cBox->view()->visualRect(model->indexFromItem(item));
+
+ QCOMPARE(menuHeight, menuItemRect.y() + menuItemRect.height());
+
+ qApp->setStyleSheet(oldCss);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 2c5cb88ed6..1c19bf96d6 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -152,6 +152,22 @@ Q_DECLARE_METATYPE(Qt::WindowType);
Q_DECLARE_METATYPE(Qt::WindowFlags);
Q_DECLARE_METATYPE(QMdiSubWindow*);
+class TestPushButton : public QPushButton
+{
+public:
+ TestPushButton(const QString &title, QWidget *parent = nullptr)
+ : QPushButton(title, parent)
+ {
+ }
+
+protected:
+ // don't rely on style-specific button behavior in test
+ bool hitButton(const QPoint &point) const override
+ {
+ return rect().contains(point);
+ }
+};
+
class tst_QMdiSubWindow : public QObject
{
Q_OBJECT
@@ -390,7 +406,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
// the maximized subwindow's title is imposed onto the main window's titlebar.
if (!nativeMenuBar) {
QCOMPARE(mainWindow.windowTitle(), QString());
- QMdiSubWindow *window = workspace->addSubWindow(new QPushButton(QLatin1String("Test")));
+ QMdiSubWindow *window = workspace->addSubWindow(new TestPushButton(QLatin1String("Test")));
QString expectedTitle = QLatin1String("MainWindow's title is empty");
window->setWindowTitle(expectedTitle);
QCOMPARE(window->windowTitle(), expectedTitle);
@@ -1298,7 +1314,7 @@ void tst_QMdiSubWindow::changeFocusWithTab()
QTest::keyPress(widget, Qt::Key_Backtab);
QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(firstLineEdit));
- QMdiSubWindow *window = mdiArea.addSubWindow(new QPushButton);
+ QMdiSubWindow *window = mdiArea.addSubWindow(new TestPushButton(QLatin1String("test")));
window->show();
QCOMPARE(mdiArea.activeSubWindow(), window);
@@ -1907,7 +1923,7 @@ void tst_QMdiSubWindow::setFont()
QSKIP("This test function is unstable in CI, please see QTBUG-22544");
QMdiArea mdiArea;
mdiArea.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QPushButton(QLatin1String("test")));
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new TestPushButton(QLatin1String("test")));
subWindow->resize(300, 100);
subWindow->setWindowTitle(QLatin1String("Window title"));
mdiArea.show();
@@ -2057,19 +2073,19 @@ void tst_QMdiSubWindow::task_233197()
QMenuBar *menuBar = mainWindow->menuBar(); // force creation of a menubar
Q_UNUSED(menuBar);
- QPushButton *focus1 = new QPushButton(QLatin1String("Focus 1"), mainWindow);
+ QPushButton *focus1 = new TestPushButton(QLatin1String("Focus 1"), mainWindow);
QObject::connect(focus1, &QAbstractButton::clicked, subWindow1,
QOverload<>::of(&QWidget::setFocus));
focus1->move(5, 30);
focus1->show();
- QPushButton *focus2 = new QPushButton(QLatin1String("Focus 2"), mainWindow);
+ QPushButton *focus2 = new TestPushButton(QLatin1String("Focus 2"), mainWindow);
QObject::connect(focus2, &QAbstractButton::clicked, subWindow2,
QOverload<>::of(&QWidget::setFocus));
focus2->move(5, 60);
focus2->show();
- QPushButton *close = new QPushButton(QLatin1String("Close"), mainWindow);
+ QPushButton *close = new TestPushButton(QLatin1String("Close"), mainWindow);
QObject::connect(close, &QAbstractButton::clicked, mainWindow, &QWidget::close);
close->move(5, 90);
close->show();