summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST1
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp178
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp60
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp5
4 files changed, 189 insertions, 55 deletions
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
index b1590a5ccf..06588188d4 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
+++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
@@ -3,3 +3,4 @@ windows
[registerTimer]
windows
winrt
+osx
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 5784f0728c..ca183752a5 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -92,77 +92,151 @@ void tst_QEventDispatcher::initTestCase()
}
}
+class TimerManager {
+ Q_DISABLE_COPY(TimerManager)
+
+public:
+ TimerManager(QAbstractEventDispatcher *eventDispatcher, QObject *parent)
+ : m_eventDispatcher(eventDispatcher), m_parent(parent)
+ {
+ }
+
+ ~TimerManager()
+ {
+ if (!registeredTimers().isEmpty())
+ m_eventDispatcher->unregisterTimers(m_parent);
+ }
+
+ TimerManager(TimerManager &&) = delete;
+ TimerManager &operator=(TimerManager &&) = delete;
+
+ int preciseTimerId() const { return m_preciseTimerId; }
+ int coarseTimerId() const { return m_coarseTimerId; }
+ int veryCoarseTimerId() const { return m_veryCoarseTimerId; }
+
+ bool foundPrecise() const { return m_preciseTimerId > 0; }
+ bool foundCoarse() const { return m_coarseTimerId > 0; }
+ bool foundVeryCoarse() const { return m_veryCoarseTimerId > 0; }
+
+ QList<QAbstractEventDispatcher::TimerInfo> registeredTimers() const
+ {
+ return m_eventDispatcher->registeredTimers(m_parent);
+ }
+
+ void registerAll()
+ {
+ // start 3 timers, each with the different timer types and different intervals
+ m_preciseTimerId = m_eventDispatcher->registerTimer(
+ PreciseTimerInterval, Qt::PreciseTimer, m_parent);
+ m_coarseTimerId = m_eventDispatcher->registerTimer(
+ CoarseTimerInterval, Qt::CoarseTimer, m_parent);
+ m_veryCoarseTimerId = m_eventDispatcher->registerTimer(
+ VeryCoarseTimerInterval, Qt::VeryCoarseTimer, m_parent);
+ QVERIFY(m_preciseTimerId > 0);
+ QVERIFY(m_coarseTimerId > 0);
+ QVERIFY(m_veryCoarseTimerId > 0);
+ findTimers();
+ }
+
+ void unregister(int timerId)
+ {
+ m_eventDispatcher->unregisterTimer(timerId);
+ findTimers();
+ }
+
+ void unregisterAll()
+ {
+ m_eventDispatcher->unregisterTimers(m_parent);
+ findTimers();
+ }
+
+private:
+ void findTimers()
+ {
+ bool foundPrecise = false;
+ bool foundCoarse = false;
+ bool foundVeryCoarse = false;
+ const QList<QAbstractEventDispatcher::TimerInfo> timers = registeredTimers();
+ for (int i = 0; i < timers.count(); ++i) {
+ const QAbstractEventDispatcher::TimerInfo &timerInfo = timers.at(i);
+ if (timerInfo.timerId == m_preciseTimerId) {
+ QCOMPARE(timerInfo.interval, int(PreciseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::PreciseTimer);
+ foundPrecise = true;
+ } else if (timerInfo.timerId == m_coarseTimerId) {
+ QCOMPARE(timerInfo.interval, int(CoarseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::CoarseTimer);
+ foundCoarse = true;
+ } else if (timerInfo.timerId == m_veryCoarseTimerId) {
+ QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer);
+ foundVeryCoarse = true;
+ }
+ }
+ if (!foundPrecise)
+ m_preciseTimerId = -1;
+ if (!foundCoarse)
+ m_coarseTimerId = -1;
+ if (!foundVeryCoarse)
+ m_veryCoarseTimerId = -1;
+ }
+
+ QAbstractEventDispatcher *m_eventDispatcher = nullptr;
+
+ int m_preciseTimerId = -1;
+ int m_coarseTimerId = -1;
+ int m_veryCoarseTimerId = -1;
+
+ QObject *m_parent = nullptr;
+};
+
// test that the eventDispatcher's timer implementation is complete and working
void tst_QEventDispatcher::registerTimer()
{
-#define FIND_TIMERS() \
- do { \
- foundPrecise = false; \
- foundCoarse = false; \
- foundVeryCoarse = false; \
- for (int i = 0; i < registeredTimers.count(); ++i) { \
- const QAbstractEventDispatcher::TimerInfo &timerInfo = registeredTimers.at(i); \
- if (timerInfo.timerId == preciseTimerId) { \
- QCOMPARE(timerInfo.interval, int(PreciseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::PreciseTimer); \
- foundPrecise = true; \
- } else if (timerInfo.timerId == coarseTimerId) { \
- QCOMPARE(timerInfo.interval, int(CoarseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::CoarseTimer); \
- foundCoarse = true; \
- } else if (timerInfo.timerId == veryCoarseTimerId) { \
- QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer); \
- foundVeryCoarse = true; \
- } \
- } \
- } while (0)
-
- // start 3 timers, each with the different timer types and different intervals
- int preciseTimerId = eventDispatcher->registerTimer(PreciseTimerInterval, Qt::PreciseTimer, this);
- int coarseTimerId = eventDispatcher->registerTimer(CoarseTimerInterval, Qt::CoarseTimer, this);
- int veryCoarseTimerId = eventDispatcher->registerTimer(VeryCoarseTimerInterval, Qt::VeryCoarseTimer, this);
- QVERIFY(preciseTimerId > 0);
- QVERIFY(coarseTimerId > 0);
- QVERIFY(veryCoarseTimerId > 0);
+ TimerManager timers(eventDispatcher, this);
+ timers.registerAll();
+ if (QTest::currentTestFailed())
+ return;
// check that all 3 are present in the eventDispatcher's registeredTimer() list
- QList<QAbstractEventDispatcher::TimerInfo> registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 3);
- bool foundPrecise, foundCoarse, foundVeryCoarse;
- FIND_TIMERS();
- QVERIFY(foundPrecise && foundCoarse && foundVeryCoarse);
+ QCOMPARE(timers.registeredTimers().count(), 3);
+ QVERIFY(timers.foundPrecise());
+ QVERIFY(timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// process events, waiting for the next event... this should only fire the precise timer
receivedEventType = -1;
timerIdFromEvent = -1;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2);
- QCOMPARE(timerIdFromEvent, preciseTimerId);
+ QCOMPARE(timerIdFromEvent, timers.preciseTimerId());
// now unregister it and make sure it's gone
- eventDispatcher->unregisterTimer(preciseTimerId);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 2);
- FIND_TIMERS();
- QVERIFY(!foundPrecise && foundCoarse && foundVeryCoarse);
+ timers.unregister(timers.preciseTimerId());
+ if (QTest::currentTestFailed())
+ return;
+ QCOMPARE(timers.registeredTimers().count(), 2);
+ QVERIFY(!timers.foundPrecise());
+ QVERIFY(timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// do the same again for the coarse timer
receivedEventType = -1;
timerIdFromEvent = -1;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2);
- QCOMPARE(timerIdFromEvent, coarseTimerId);
+ QCOMPARE(timerIdFromEvent, timers.coarseTimerId());
// now unregister it and make sure it's gone
- eventDispatcher->unregisterTimer(coarseTimerId);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 1);
- FIND_TIMERS();
- QVERIFY(!foundPrecise && !foundCoarse && foundVeryCoarse);
+ timers.unregister(timers.coarseTimerId());
+ if (QTest::currentTestFailed())
+ return;
+ QCOMPARE(timers.registeredTimers().count(), 1);
+ QVERIFY(!timers.foundPrecise());
+ QVERIFY(!timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// not going to wait for the VeryCoarseTimer, would take too long, just unregister it
- eventDispatcher->unregisterTimers(this);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QVERIFY(registeredTimers.isEmpty());
-
-#undef FIND_TIMERS
+ timers.unregisterAll();
+ if (QTest::currentTestFailed())
+ return;
+ QVERIFY(timers.registeredTimers().isEmpty());
}
void tst_QEventDispatcher::sendPostedEvents_data()
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index f45a5af5a1..bca142e245 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1025,6 +1025,26 @@ void tst_QSslSocket::protocol()
socket->abort();
}
#endif
+#ifdef TLS1_3_VERSION
+ {
+ // qt-test-server probably doesn't allow TLSV1.3
+ socket->setProtocol(QSsl::TlsV1_3);
+ QCOMPARE(socket->protocol(), QSsl::TlsV1_3);
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ if (setProxy && !socket->waitForEncrypted())
+ QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941");
+ QCOMPARE(socket->protocol(), QSsl::TlsV1_3);
+ socket->abort();
+ QCOMPARE(socket->protocol(), QSsl::TlsV1_3);
+ socket->connectToHost(QtNetworkSettings::serverName(), 443);
+ QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString()));
+ socket->startClientEncryption();
+ if (setProxy && !socket->waitForEncrypted())
+ QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941");
+ QCOMPARE(socket->sessionProtocol(), QSsl::TlsV1_3);
+ socket->abort();
+ }
+#endif // TLS1_3_VERSION
#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT)
{
// qt-test-server allows SSLV2.
@@ -1279,7 +1299,9 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::newRow("tls1.0orlater-tls1.0") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_0 << true;
QTest::newRow("tls1.0orlater-tls1.1") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_1 << true;
QTest::newRow("tls1.0orlater-tls1.2") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_2 << true;
-
+#ifdef TLS1_3_VERSION
+ QTest::newRow("tls1.0orlater-tls1.3") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_3 << true;
+#endif
#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT)
QTest::newRow("tls1.1orlater-ssl2") << QSsl::TlsV1_1OrLater << QSsl::SslV2 << false;
#endif
@@ -1290,7 +1312,9 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::newRow("tls1.1orlater-tls1.0") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_0 << false;
QTest::newRow("tls1.1orlater-tls1.1") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_1 << true;
QTest::newRow("tls1.1orlater-tls1.2") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_2 << true;
-
+#ifdef TLS1_3_VERSION
+ QTest::newRow("tls1.1orlater-tls1.3") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_3 << true;
+#endif
#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT)
QTest::newRow("tls1.2orlater-ssl2") << QSsl::TlsV1_2OrLater << QSsl::SslV2 << false;
#endif
@@ -1300,6 +1324,21 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::newRow("tls1.2orlater-tls1.0") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_0 << false;
QTest::newRow("tls1.2orlater-tls1.1") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_1 << false;
QTest::newRow("tls1.2orlater-tls1.2") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_2 << true;
+#ifdef TLS1_3_VERSION
+ QTest::newRow("tls1.2orlater-tls1.3") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_3 << true;
+#endif
+#ifdef TLS1_3_VERSION
+#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT)
+ QTest::newRow("tls1.3orlater-ssl2") << QSsl::TlsV1_3OrLater << QSsl::SslV2 << false;
+#endif
+#if !defined(OPENSSL_NO_SSL3)
+ QTest::newRow("tls1.3orlater-ssl3") << QSsl::TlsV1_3OrLater << QSsl::SslV3 << false;
+#endif
+ QTest::newRow("tls1.3orlater-tls1.0") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_0 << false;
+ QTest::newRow("tls1.3orlater-tls1.1") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_1 << false;
+ QTest::newRow("tls1.3orlater-tls1.2") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_2 << false;
+ QTest::newRow("tls1.3orlater-tls1.3") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_3 << true;
+#endif // TLS1_3_VERSION
QTest::newRow("any-tls1.0") << QSsl::AnyProtocol << QSsl::TlsV1_0 << true;
QTest::newRow("any-tls1ssl3") << QSsl::AnyProtocol << QSsl::TlsV1SslV3 << true;
@@ -3511,7 +3550,12 @@ protected:
socket = new QSslSocket(this);
socket->setSslConfiguration(config);
socket->setPeerVerifyMode(peerVerifyMode);
- socket->setProtocol(protocol);
+ if (QSslSocket::sslLibraryVersionNumber() > 0x10101000L) {
+ // FIXME. With OpenSSL 1.1.1 and TLS 1.3 PSK auto-test is broken.
+ socket->setProtocol(QSsl::TlsV1_2);
+ } else {
+ socket->setProtocol(protocol);
+ }
if (ignoreSslErrors)
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
@@ -3891,6 +3935,11 @@ void tst_QSslSocket::pskServer()
return;
QSslSocket socket;
+#ifdef TLS1_3_VERSION
+ // FIXME: with OpenSSL 1.1.1 (thus TLS 1.3) test is known to fail
+ // due to the different PSK mechanism (?) - to be investigated ASAP.
+ socket.setProtocol(QSsl::TlsV1_2);
+#endif
this->socket = &socket;
QSignalSpy connectedSpy(&socket, SIGNAL(connected()));
@@ -3976,6 +4025,11 @@ void tst_QSslSocket::signatureAlgorithm_data()
if (QSslSocket::sslLibraryVersionNumber() < 0x10002000L)
QSKIP("Signature algorithms cannot be tested with OpenSSL < 1.0.2");
+ if (QSslSocket::sslLibraryVersionNumber() >= 0x10101000L) {
+ // FIXME: investigate if this test makes any sense with TLS 1.3.
+ QSKIP("Test is not valid for TLS 1.3/OpenSSL 1.1.1");
+ }
+
QTest::addColumn<QByteArrayList>("serverSigAlgPairs");
QTest::addColumn<QSsl::SslProtocol>("serverProtocol");
QTest::addColumn<QByteArrayList>("clientSigAlgPairs");
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index 09bea20d26..b7b5b505a0 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -355,6 +355,11 @@ void tst_QGLThreads::renderInThread()
QFETCH(bool, resize);
QFETCH(bool, update);
+#if defined(Q_OS_MACOS)
+ if (resize)
+ QSKIP("gldSetZero crashes in render thread, QTBUG-68524");
+#endif
+
ThreadSafeGLWidget widget;
widget.resize(200, 200);
SceneRenderingThread thread(&widget);