summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteven Ceuppens <steven.ceuppens@icloud.com>2013-09-29 18:30:25 +0200
committerKurt Pattyn <pattyn.kurt@gmail.com>2013-09-29 18:44:19 +0200
commita8f2a1cf05e16b03eaee22de24ad73109ccf4a27 (patch)
tree223ed4c1778724eb7c9ed769945420dd116edc79 /tests
parent63e868223f83180b6385be6454cdf7da4517f961 (diff)
downloadqtwebsockets-a8f2a1cf05e16b03eaee22de24ad73109ccf4a27.tar.gz
reorganized unittests & added module pri
Change-Id: Ib1aa45f7cc07ea4564b0e5f1315273a2526a4e74 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro6
-rw-r--r--tests/auto/dataprocessor/dataprocessor.pro14
-rw-r--r--tests/auto/dataprocessor/tst_dataprocessor.cpp (renamed from tests/tst_dataprocessor.cpp)6
-rw-r--r--tests/autobahn/autobahn.pro8
-rw-r--r--tests/autobahn/compliance/compliance.pro14
-rw-r--r--tests/autobahn/compliance/tst_compliance.cpp (renamed from tests/tst_compliance.cpp)23
-rw-r--r--tests/autobahn/scripts/echoserver.py (renamed from tests/echoserver.py)0
-rw-r--r--tests/autobahn/scripts/fuzzingclient.json (renamed from tests/fuzzingclient.json)0
-rw-r--r--tests/autobahn/scripts/fuzzingserver.json (renamed from tests/fuzzingserver.json)0
-rwxr-xr-xtests/autobahn/scripts/start_basic_sockettests.sh (renamed from tests/start_basic_sockettests.sh)0
-rwxr-xr-xtests/autobahn/scripts/start_echo_server.sh (renamed from tests/start_echo_server.sh)0
-rwxr-xr-xtests/autobahn/scripts/stop_echo_server.sh (renamed from tests/stop_echo_server.sh)0
-rw-r--r--tests/autobahn/websockets/tst_websockets.cpp (renamed from tests/tst_websockets.cpp)29
-rw-r--r--tests/autobahn/websockets/websockets.pro14
-rw-r--r--tests/main.cpp3
-rw-r--r--tests/tests.pro24
-rw-r--r--tests/unittests.h86
17 files changed, 86 insertions, 141 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644
index 0000000..71c54c7
--- /dev/null
+++ b/tests/auto/auto.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ #dataprocessor
+
+
diff --git a/tests/auto/dataprocessor/dataprocessor.pro b/tests/auto/dataprocessor/dataprocessor.pro
new file mode 100644
index 0000000..1e55129
--- /dev/null
+++ b/tests/auto/dataprocessor/dataprocessor.pro
@@ -0,0 +1,14 @@
+CONFIG += console
+CONFIG += c++11
+CONFIG += testcase
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+TARGET = tst_dataprocessor
+
+QT = core testlib websockets websockets-private
+
+SOURCES += tst_dataprocessor.cpp
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/tst_dataprocessor.cpp b/tests/auto/dataprocessor/tst_dataprocessor.cpp
index b2d0d5b..a9ef66d 100644
--- a/tests/tst_dataprocessor.cpp
+++ b/tests/auto/dataprocessor/tst_dataprocessor.cpp
@@ -4,8 +4,8 @@
#include <QBuffer>
#include <QByteArray>
#include <QDebug>
-#include "dataprocessor_p.h"
-#include "unittests.h"
+
+#include "private/dataprocessor_p.h"
Q_DECLARE_METATYPE(QWebSocketProtocol::CloseCode)
Q_DECLARE_METATYPE(QWebSocketProtocol::OpCode)
@@ -1451,7 +1451,7 @@ void tst_DataProcessor::frameTooBig_data()
<< QWebSocketProtocol::CC_TOO_MUCH_DATA;
}
-DECLARE_TEST(tst_DataProcessor)
+QTEST_MAIN(tst_DataProcessor)
#include "tst_dataprocessor.moc"
diff --git a/tests/autobahn/autobahn.pro b/tests/autobahn/autobahn.pro
new file mode 100644
index 0000000..28961c4
--- /dev/null
+++ b/tests/autobahn/autobahn.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ compliance \
+ websockets
+
+
+
diff --git a/tests/autobahn/compliance/compliance.pro b/tests/autobahn/compliance/compliance.pro
new file mode 100644
index 0000000..0fd32bc
--- /dev/null
+++ b/tests/autobahn/compliance/compliance.pro
@@ -0,0 +1,14 @@
+CONFIG += console
+CONFIG += c++11
+CONFIG += testcase
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+TARGET = tst_compliance
+
+QT = core network websockets testlib
+
+SOURCES += tst_compliance.cpp
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/tst_compliance.cpp b/tests/autobahn/compliance/tst_compliance.cpp
index 71f9761..c1c9318 100644
--- a/tests/tst_compliance.cpp
+++ b/tests/autobahn/compliance/tst_compliance.cpp
@@ -4,14 +4,13 @@
#include <QHostInfo>
#include <QDebug>
#include "qwebsocket.h"
-#include "unittests.h"
-class ComplianceTest : public QObject
+class tst_ComplianceTest : public QObject
{
Q_OBJECT
public:
- ComplianceTest();
+ tst_ComplianceTest();
private Q_SLOTS:
void initTestCase();
@@ -30,28 +29,28 @@ private:
void runTestCase(int nbr, int total);
};
-ComplianceTest::ComplianceTest() :
+tst_ComplianceTest::tst_ComplianceTest() :
m_url("ws://localhost:9001")
{
}
-void ComplianceTest::initTestCase()
+void tst_ComplianceTest::initTestCase()
{
}
-void ComplianceTest::cleanupTestCase()
+void tst_ComplianceTest::cleanupTestCase()
{
}
-void ComplianceTest::init()
+void tst_ComplianceTest::init()
{
}
-void ComplianceTest::cleanup()
+void tst_ComplianceTest::cleanup()
{
}
-void ComplianceTest::runTestCase(int nbr, int total)
+void tst_ComplianceTest::runTestCase(int nbr, int total)
{
if (nbr == total)
{
@@ -85,12 +84,12 @@ void ComplianceTest::runTestCase(int nbr, int total)
runTestCase(nbr + 1, total);
}
-void ComplianceTest::runTestCases(int startNbr, int stopNbr)
+void tst_ComplianceTest::runTestCases(int startNbr, int stopNbr)
{
runTestCase(startNbr, stopNbr);
}
-void ComplianceTest::autobahnTest()
+void tst_ComplianceTest::autobahnTest()
{
//connect to autobahn server at url ws://ipaddress:port/getCaseCount
QWebSocket *pWebSocket = new QWebSocket;
@@ -120,7 +119,7 @@ void ComplianceTest::autobahnTest()
pWebSocket = 0;
}
-//DECLARE_TEST(ComplianceTest)
+QTEST_MAIN(tst_ComplianceTest)
#include "tst_compliance.moc"
diff --git a/tests/echoserver.py b/tests/autobahn/scripts/echoserver.py
index 5478eb2..5478eb2 100644
--- a/tests/echoserver.py
+++ b/tests/autobahn/scripts/echoserver.py
diff --git a/tests/fuzzingclient.json b/tests/autobahn/scripts/fuzzingclient.json
index c196070..c196070 100644
--- a/tests/fuzzingclient.json
+++ b/tests/autobahn/scripts/fuzzingclient.json
diff --git a/tests/fuzzingserver.json b/tests/autobahn/scripts/fuzzingserver.json
index 24aaca0..24aaca0 100644
--- a/tests/fuzzingserver.json
+++ b/tests/autobahn/scripts/fuzzingserver.json
diff --git a/tests/start_basic_sockettests.sh b/tests/autobahn/scripts/start_basic_sockettests.sh
index 4ba4896..4ba4896 100755
--- a/tests/start_basic_sockettests.sh
+++ b/tests/autobahn/scripts/start_basic_sockettests.sh
diff --git a/tests/start_echo_server.sh b/tests/autobahn/scripts/start_echo_server.sh
index c101287..c101287 100755
--- a/tests/start_echo_server.sh
+++ b/tests/autobahn/scripts/start_echo_server.sh
diff --git a/tests/stop_echo_server.sh b/tests/autobahn/scripts/stop_echo_server.sh
index 8c8a2a4..8c8a2a4 100755
--- a/tests/stop_echo_server.sh
+++ b/tests/autobahn/scripts/stop_echo_server.sh
diff --git a/tests/tst_websockets.cpp b/tests/autobahn/websockets/tst_websockets.cpp
index f330a88..f70a745 100644
--- a/tests/tst_websockets.cpp
+++ b/tests/autobahn/websockets/tst_websockets.cpp
@@ -4,14 +4,13 @@
#include <QHostInfo>
#include <QDebug>
#include "qwebsocket.h"
-#include "unittests.h"
-class WebSocketsTest : public QObject
+class tst_WebSocketsTest : public QObject
{
Q_OBJECT
public:
- WebSocketsTest();
+ tst_WebSocketsTest();
private Q_SLOTS:
void initTestCase();
@@ -56,13 +55,13 @@ private:
QUrl m_url;
};
-WebSocketsTest::WebSocketsTest() :
+tst_WebSocketsTest::tst_WebSocketsTest() :
m_pWebSocket(0),
m_url("ws://localhost:9000")
{
}
-void WebSocketsTest::initTestCase()
+void tst_WebSocketsTest::initTestCase()
{
m_pWebSocket = new QWebSocket();
/*m_pWebSocket->open(m_url, true);
@@ -70,7 +69,7 @@ void WebSocketsTest::initTestCase()
QVERIFY(m_pWebSocket->isValid());*/
}
-void WebSocketsTest::cleanupTestCase()
+void tst_WebSocketsTest::cleanupTestCase()
{
if (m_pWebSocket)
{
@@ -81,15 +80,15 @@ void WebSocketsTest::cleanupTestCase()
}
}
-void WebSocketsTest::init()
+void tst_WebSocketsTest::init()
{
}
-void WebSocketsTest::cleanup()
+void tst_WebSocketsTest::cleanup()
{
}
-void WebSocketsTest::testTextMessage()
+void tst_WebSocketsTest::testTextMessage()
{
const char *message = "Hello world!";
@@ -111,7 +110,7 @@ void WebSocketsTest::testTextMessage()
QCOMPARE(spy.takeFirst().at(0).toString(), qMessage);
}
-void WebSocketsTest::testBinaryMessage()
+void tst_WebSocketsTest::testBinaryMessage()
{
QSignalSpy spy(m_pWebSocket, SIGNAL(binaryMessageReceived(QByteArray)));
@@ -125,14 +124,14 @@ void WebSocketsTest::testBinaryMessage()
QCOMPARE(spy.takeFirst().at(0).toByteArray(), data);
}
-void WebSocketsTest::testLocalAddress()
+void tst_WebSocketsTest::testLocalAddress()
{
QCOMPARE(m_pWebSocket->localAddress().toString(), QString("127.0.0.1"));
quint16 localPort = m_pWebSocket->localPort();
QVERIFY2(localPort > 0, "Local port is invalid.");
}
-void WebSocketsTest::testPeerAddress()
+void tst_WebSocketsTest::testPeerAddress()
{
QHostInfo hostInfo = QHostInfo::fromName(m_url.host());
QList<QHostAddress> addresses = hostInfo.addresses();
@@ -156,7 +155,7 @@ void WebSocketsTest::testPeerAddress()
QCOMPARE(m_pWebSocket->peerPort(), (quint16)m_url.port(80));
}
-void WebSocketsTest::testProxy()
+void tst_WebSocketsTest::testProxy()
{
QNetworkProxy oldProxy = m_pWebSocket->proxy();
QNetworkProxy proxy(QNetworkProxy::HttpProxy, QString("proxy.network.com"), 80);
@@ -166,13 +165,13 @@ void WebSocketsTest::testProxy()
QCOMPARE(oldProxy, m_pWebSocket->proxy());
}
-void WebSocketsTest::testInvalidWithUnopenedSocket()
+void tst_WebSocketsTest::testInvalidWithUnopenedSocket()
{
QWebSocket qws;
QCOMPARE(qws.isValid(), false);
}
-//DECLARE_TEST(WebSocketsTest)
+QTEST_MAIN(tst_WebSocketsTest)
#include "tst_websockets.moc"
diff --git a/tests/autobahn/websockets/websockets.pro b/tests/autobahn/websockets/websockets.pro
new file mode 100644
index 0000000..a8b2edb
--- /dev/null
+++ b/tests/autobahn/websockets/websockets.pro
@@ -0,0 +1,14 @@
+CONFIG += console
+CONFIG += c++11
+CONFIG += testcase
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+TARGET = tst_websockets
+
+QT = core network websockets testlib
+
+SOURCES += tst_websockets.cpp
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/main.cpp b/tests/main.cpp
deleted file mode 100644
index 68e1242..0000000
--- a/tests/main.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "unittests.h"
-
-TEST_MAIN
diff --git a/tests/tests.pro b/tests/tests.pro
index 9cd3320..1a9ad66 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,22 +1,2 @@
-cache()
-
-QT += core network websockets testlib
-
-TARGET = unittests
-CONFIG += testcase
-CONFIG += console
-CONFIG += c++11
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-SOURCES += \
- main.cpp \
- tst_websockets.cpp \
- tst_compliance.cpp \
- tst_dataprocessor.cpp
-
-HEADERS += \
- unittests.h
-
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
+TEMPLATE = subdirs
+SUBDIRS += auto autobahn
diff --git a/tests/unittests.h b/tests/unittests.h
deleted file mode 100644
index 923c218..0000000
--- a/tests/unittests.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef UNITTESTT_H
-#define UNITTESTT_H
-
-#include <QTest>
-#include <QObject>
-#include <QList>
-#include <QString>
-#include <QSharedPointer>
-#include <QCoreApplication>
-
-namespace AutoTest
-{
-
-typedef QList<QObject*> TestList;
-
-inline TestList& testList()
-{
- static TestList list;
- return list;
-}
-
-inline bool findObject(QObject* object)
-{
- TestList& list = testList();
- if (list.contains(object))
- {
- return true;
- }
- Q_FOREACH (QObject* test, list)
- {
- if (test->objectName() == object->objectName())
- {
- return true;
- }
- }
- return false;
-}
-
-inline void addTest(QObject* object)
-{
- TestList& list = testList();
- if (!findObject(object))
- {
- list.append(object);
- }
-}
-
-inline int run(int argc, char *argv[])
-{
- int ret = 0;
-
- Q_FOREACH (QObject* test, testList())
- {
- ret += QTest::qExec(test, argc, argv);
- }
- testList().clear();
- return ret;
-}
-
-} // end namespace
-
-template <class T>
-class Test
-{
-public:
- QSharedPointer<T> child;
-
- Test(const QString& name) : child(new T)
- {
- child->setObjectName(name);
- AutoTest::addTest(child.data());
- }
-};
-
-#define DECLARE_TEST(className) static Test<className> t(#className);
-
-#define TEST_MAIN \
- int main(int argc, char *argv[]) \
-{ \
- QCoreApplication app(argc, argv); \
- int ret = AutoTest::run(argc, argv); \
- return ret; \
- }
-//return app.exec();
-
-#endif