reorganized unittests & added module pri
authorSteven Ceuppens <steven.ceuppens@icloud.com>
Sun, 29 Sep 2013 16:30:25 +0000 (18:30 +0200)
committerKurt Pattyn <pattyn.kurt@gmail.com>
Sun, 29 Sep 2013 16:44:19 +0000 (18:44 +0200)
Change-Id: Ib1aa45f7cc07ea4564b0e5f1315273a2526a4e74
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
19 files changed:
modules/qt_websockets.pri [new file with mode: 0644]
sync.profile
tests/auto/auto.pro [new file with mode: 0644]
tests/auto/dataprocessor/dataprocessor.pro [new file with mode: 0644]
tests/auto/dataprocessor/tst_dataprocessor.cpp [moved from tests/tst_dataprocessor.cpp with 99% similarity]
tests/autobahn/autobahn.pro [new file with mode: 0644]
tests/autobahn/compliance/compliance.pro [new file with mode: 0644]
tests/autobahn/compliance/tst_compliance.cpp [moved from tests/tst_compliance.cpp with 84% similarity]
tests/autobahn/scripts/echoserver.py [moved from tests/echoserver.py with 100% similarity]
tests/autobahn/scripts/fuzzingclient.json [moved from tests/fuzzingclient.json with 100% similarity]
tests/autobahn/scripts/fuzzingserver.json [moved from tests/fuzzingserver.json with 100% similarity]
tests/autobahn/scripts/start_basic_sockettests.sh [moved from tests/start_basic_sockettests.sh with 100% similarity]
tests/autobahn/scripts/start_echo_server.sh [moved from tests/start_echo_server.sh with 100% similarity]
tests/autobahn/scripts/stop_echo_server.sh [moved from tests/stop_echo_server.sh with 100% similarity]
tests/autobahn/websockets/tst_websockets.cpp [moved from tests/tst_websockets.cpp with 87% similarity]
tests/autobahn/websockets/websockets.pro [new file with mode: 0644]
tests/main.cpp [deleted file]
tests/tests.pro
tests/unittests.h [deleted file]

diff --git a/modules/qt_websockets.pri b/modules/qt_websockets.pri
new file mode 100644 (file)
index 0000000..dc0fb3e
--- /dev/null
@@ -0,0 +1,8 @@
+QT.websockets.name = QtWebSockets
+QT.websockets.bins = $$QT_MODULE_BIN_BASE
+QT.websockets.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtWebSockets
+QT.websockets.private_includes = $$QT_MODULE_INCLUDE_BASE/QtWebSockets/$$QT.websockets.VERSION/QtWebSockets/private
+QT.websockets.sources = $$QT_MODULE_BASE/src/websockets
+QT.websockets.libs = $$QT_MODULE_LIB_BASE
+QT.websockets.plugins = $$QT_MODULE_PLUGIN_BASE
+
index b26d76c..ed0c60a 100644 (file)
@@ -5,6 +5,10 @@
 %moduleheaders = (
 );
 
+%modulepris = (
+    "QtWebSockets" => "$basedir/modules/qt_websockets.pri",
+);
+
 %classnames = (
     "qtwebsockets.h" => "QtWebSockets",
 );
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644 (file)
index 0000000..71c54c7
--- /dev/null
@@ -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 (file)
index 0000000..1e55129
--- /dev/null
@@ -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
similarity index 99%
rename from tests/tst_dataprocessor.cpp
rename to tests/auto/dataprocessor/tst_dataprocessor.cpp
index b2d0d5b..a9ef66d 100644 (file)
@@ -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 (file)
index 0000000..28961c4
--- /dev/null
@@ -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 (file)
index 0000000..0fd32bc
--- /dev/null
@@ -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
similarity index 84%
rename from tests/tst_compliance.cpp
rename to tests/autobahn/compliance/tst_compliance.cpp
index 71f9761..c1c9318 100644 (file)
@@ -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"
 
similarity index 87%
rename from tests/tst_websockets.cpp
rename to tests/autobahn/websockets/tst_websockets.cpp
index f330a88..f70a745 100644 (file)
@@ -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 (file)
index 0000000..a8b2edb
--- /dev/null
@@ -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 (file)
index 68e1242..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "unittests.h"
-
-TEST_MAIN
index 9cd3320..1a9ad66 100644 (file)
@@ -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 (file)
index 923c218..0000000
+++ /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