summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-24 13:37:06 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-24 13:39:13 +0100
commit34aba4724f196e34ed02cf50073f41968f119bb6 (patch)
tree0ebdfcabda989ab76ee6de53c6461553c7a767a5 /tests/auto/corelib/kernel
parentb86b2a742afae118bf974c82ba966ddb0cae4afb (diff)
parentb1cf07f495e10c93e53651ac03e46ebdaea0a97e (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/corelib/io/qiodevice.cpp src/plugins/bearer/linux_common/qofonoservice_linux.cpp src/plugins/bearer/linux_common/qofonoservice_linux_p.h src/plugins/platforms/android/qandroidplatformtheme.cpp src/tools/bootstrap/bootstrap.pro src/widgets/styles/qmacstyle_mac.mm Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp52
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp19
-rw-r--r--tests/auto/corelib/kernel/qvariant/qvariant.pro1
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp12
4 files changed, 64 insertions, 20 deletions
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index 5cfbce0d7a..befd45018a 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -40,6 +40,7 @@
#include <private/qeventloop_p.h>
#if defined(Q_OS_UNIX)
#include <private/qeventdispatcher_unix_p.h>
+ #include <QtCore/private/qcore_unix_p.h>
#if defined(HAVE_GLIB)
#include <private/qeventdispatcher_glib_p.h>
#endif
@@ -172,7 +173,9 @@ private slots:
void execAfterExit();
void wakeUp();
void quit();
+#if defined(Q_OS_UNIX)
void processEventsExcludeSocket();
+#endif
void processEventsExcludeTimers();
void deliverInDefinedOrder();
@@ -383,6 +386,7 @@ void tst_QEventLoop::customEvent(QEvent *e)
}
}
+#if defined(Q_OS_UNIX)
class SocketEventsTester: public QObject
{
Q_OBJECT
@@ -391,8 +395,10 @@ public:
{
socket = 0;
server = 0;
- dataArrived = false;
+ dataSent = false;
+ dataReadable = false;
testResult = false;
+ dataArrived = false;
}
~SocketEventsTester()
{
@@ -415,8 +421,10 @@ public:
QTcpSocket *socket;
QTcpServer *server;
- bool dataArrived;
+ bool dataSent;
+ bool dataReadable;
bool testResult;
+ bool dataArrived;
public slots:
void sendAck()
{
@@ -428,12 +436,26 @@ public slots:
qint64 size = sizeof(data);
QTcpSocket *serverSocket = server->nextPendingConnection();
+ QCoreApplication::processEvents();
serverSocket->write(data, size);
- serverSocket->flush();
- QTest::qSleep(200); //allow the TCP/IP stack time to loopback the data, so our socket is ready to read
- QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
- testResult = dataArrived;
- QCoreApplication::processEvents(); //check the deferred event is processed
+ dataSent = serverSocket->waitForBytesWritten(-1);
+
+ if (dataSent) {
+ fd_set fdread;
+ int fd = socket->socketDescriptor();
+ FD_ZERO(&fdread);
+ FD_SET(fd, &fdread);
+ dataReadable = (1 == qt_safe_select(fd + 1, &fdread, 0, 0, 0));
+ }
+
+ if (!dataReadable) {
+ testResult = dataArrived;
+ } else {
+ QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
+ testResult = dataArrived;
+ // to check if the deferred event is processed
+ QCoreApplication::processEvents();
+ }
serverSocket->close();
QThread::currentThread()->exit(0);
}
@@ -449,12 +471,16 @@ public:
SocketEventsTester *tester = new SocketEventsTester();
if (tester->init())
exec();
+ dataSent = tester->dataSent;
+ dataReadable = tester->dataReadable;
testResult = tester->testResult;
dataArrived = tester->dataArrived;
delete tester;
}
- bool testResult;
- bool dataArrived;
+ bool dataSent;
+ bool dataReadable;
+ bool testResult;
+ bool dataArrived;
};
void tst_QEventLoop::processEventsExcludeSocket()
@@ -462,9 +488,17 @@ void tst_QEventLoop::processEventsExcludeSocket()
SocketTestThread thread;
thread.start();
QVERIFY(thread.wait());
+ QVERIFY(thread.dataSent);
+ QVERIFY(thread.dataReadable);
+ #if defined(HAVE_GLIB)
+ QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher();
+ if (qobject_cast<QEventDispatcherGlib *>(eventDispatcher))
+ QEXPECT_FAIL("", "ExcludeSocketNotifiers is currently broken in the Glib dispatchers", Continue);
+ #endif
QVERIFY(!thread.testResult);
QVERIFY(thread.dataArrived);
}
+#endif
class TimerReceiver : public QObject
{
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 78c75b44e8..5833123dfe 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -642,18 +642,25 @@ struct CountedStruct
QThread *thread;
};
-static QEventLoop _e;
+static QScopedPointer<QEventLoop> _e;
static QThread *_t = Q_NULLPTR;
class StaticEventLoop
{
public:
- static void quitEventLoop() { _e.quit(); if (_t) QCOMPARE(QThread::currentThread(), _t); }
+ static void quitEventLoop()
+ {
+ QVERIFY(!_e.isNull());
+ _e->quit();
+ if (_t)
+ QCOMPARE(QThread::currentThread(), _t);
+ }
};
void tst_QTimer::singleShotToFunctors()
{
int count = 0;
+ _e.reset(new QEventLoop);
QEventLoop e;
QTimer::singleShot(0, CountedStruct(&count));
@@ -661,7 +668,7 @@ void tst_QTimer::singleShotToFunctors()
QCOMPARE(count, 1);
QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
- QCOMPARE(_e.exec(), 0);
+ QCOMPARE(_e->exec(), 0);
QThread t1;
QObject c1;
@@ -687,7 +694,7 @@ void tst_QTimer::singleShotToFunctors()
QCOMPARE(e.exec(), 0);
QTimer::singleShot(0, &c2, &StaticEventLoop::quitEventLoop);
- QCOMPARE(_e.exec(), 0);
+ QCOMPARE(_e->exec(), 0);
_t->quit();
_t->wait();
@@ -721,8 +728,10 @@ void tst_QTimer::singleShotToFunctors()
thread.quit();
thread.wait();
#endif
-}
+ _e.reset();
+ _t = Q_NULLPTR;
+}
class DontBlockEvents : public QObject
{
diff --git a/tests/auto/corelib/kernel/qvariant/qvariant.pro b/tests/auto/corelib/kernel/qvariant/qvariant.pro
index f8d054f70c..39178ba9e6 100644
--- a/tests/auto/corelib/kernel/qvariant/qvariant.pro
+++ b/tests/auto/corelib/kernel/qvariant/qvariant.pro
@@ -6,3 +6,4 @@ INCLUDEPATH += $$PWD/../../../other/qvariant_common
SOURCES = tst_qvariant.cpp
RESOURCES += qvariant.qrc
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+contains(QT_CONFIG, c++11): CONFIG += c++11
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index eae6311854..301db37233 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -3840,11 +3840,10 @@ struct ContainerAPI<Container, QByteArray>
}
};
-// We have no built-in defines to check the stdlib features.
-// #define TEST_FORWARD_LIST
-
-#ifdef TEST_FORWARD_LIST
-#include <forward_list>
+#ifdef __has_include
+# if __has_include(<forward_list>)
+# define TEST_FORWARD_LIST
+# include <forward_list>
Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(std::forward_list)
@@ -3898,7 +3897,8 @@ struct ContainerAPI<std::forward_list<QString> >
return variant == value;
}
};
-#endif
+# endif // __has_include(<forward_list>)
+#endif // __has_include
template<typename Container>
struct KeyGetter