[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Aki] c981fbe: Added sockettest to the unit tests
From:       Keith Rusler <xzekecomax () gmail ! com>
Date:       2010-12-27 0:28:00
Message-ID: 20101227002800.BFFA0A6090 () git ! kde ! org
[Download RAW message or body]


	A	 test/socket/sockettest.hpp	 [License: GPL(v2)]


	A	 test/socket/sockettest.cxx	 [License: GPL(v2)]


	A	 test/socket/main.cxx	 [License: UNKNOWN]


	A	 test/socket/CMakeLists.txt	 [License: Trivialfile.]

commit c981fbe8f4a7fc2526c4df2449704382051d54f5
Author: Keith Rusler <xzekecomax@gmail.com>
Date:   Mon Dec 27 00:27:17 2010 +0000

    Added sockettest to the unit tests

diff --git a/test/socket/CMakeLists.txt b/test/socket/CMakeLists.txt
new file mode 100644
index 0000000..1e6a428
--- /dev/null
+++ b/test/socket/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(sockettest_SRCS main.cxx sockettest.cxx)
+kde4_add_unit_test(sockettest ${sockettest_SRCS})
+target_link_libraries(sockettest ${KDE4_KDECORE_LIBS} akicore ${QT_QTTEST_LIBRARY})
diff --git a/test/socket/main.cxx b/test/socket/main.cxx
new file mode 100644
index 0000000..7a314a1
--- /dev/null
+++ b/test/socket/main.cxx
@@ -0,0 +1,29 @@
+#include "sockettest.hpp"
+#include <QtTest/QTest>
+
+class SocketTestMain
+    : public QObject
+{
+    Q_OBJECT
+public Q_SLOTS:
+    void slotStart()
+    {
+        _socket = new SocketTest(this);
+        _socket->connectToHost();
+    }
+private:
+    SocketTest* _socket;
+};
+
+int
+main(int argc, char** argv)
+{
+    new QCoreApplication(argc, argv);
+    
+    SocketTestMain main;
+    main.slotStart();
+
+    return QCoreApplication::exec();
+}
+
+#include "tests/sockettest/sockettestmain.moc"
diff --git a/test/socket/sockettest.cxx b/test/socket/sockettest.cxx
new file mode 100644
index 0000000..8f600a0
--- /dev/null
+++ b/test/socket/sockettest.cxx
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2010  Keith Rusler <xzekecomax@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+
+#include "sockettest.hpp"
+
+SocketTest::SocketTest(QObject* parent)
+    : QObject(parent),
+    _socket(new Aki::Irc::Socket("Freenode", parent))
+{
+    QStringList addresses;
+    addresses << "irc.freenode.net/6667";
+    _socket->setAddressList(addresses);
+    _socket->setAutoIdentify(false);
+    _socket->setAutoReconnect(true);
+    _socket->setEncoding("UTF-8");
+    _socket->setIdentName("testBot");
+    _socket->setNickList(QStringList()<< "testBot1" << "testBot2" << "testBot3");
+    _socket->setRealName("Aki test bot");
+    _socket->setRetryAttemptCount(10);
+    _socket->setRetryInterval(10);
+    _socket->setServerPassword(QString());
+    _socket->setServiceName("nickserv");
+    _socket->setServicePassword(QString());
+    _socket->setSsl(false);
+
+    connect(_socket, SIGNAL(onMotdMessage(Aki::Irc::MotdReply)),
+            SLOT(slotOnMotdMessage(Aki::Irc::MotdReply)));
+    connect(_socket, SIGNAL(onStartupReply(Aki::Irc::StartupReply)),
+            SLOT(slotOnStartupReply(Aki::Irc::StartupReply)));
+}
+
+SocketTest::~SocketTest()
+{
+}
+
+void
+SocketTest::connectToHost()
+{
+    Q_ASSERT(_socket);
+    _socket->connectToHost();
+}
+
+void
+SocketTest::slotOnMotdMessage(const Aki::Irc::MotdReply& reply)
+{
+    qDebug() << reply.reply();
+}
+
+void
+SocketTest::slotOnStartupReply(const Aki::Irc::StartupReply& reply)
+{
+    qDebug() << reply.reply();
+}
diff --git a/test/socket/sockettest.hpp b/test/socket/sockettest.hpp
new file mode 100644
index 0000000..c9a8714
--- /dev/null
+++ b/test/socket/sockettest.hpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2009-2010  Keith Rusler <xzekecomax@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+
+#ifndef SOCKETTEST_HPP
+#define SOCKETTEST_HPP
+
+#include "irc/socket.hpp"
+
+class SocketTest
+    : QObject
+{
+    Q_OBJECT
+public:
+    SocketTest(QObject* parent = 0);
+    ~SocketTest();
+    void connectToHost();
+private Q_SLOTS:
+    void slotOnMotdMessage(const Aki::Irc::MotdReply& reply);
+    void slotOnStartupReply(const Aki::Irc::StartupReply& reply);
+private:
+    Aki::Irc::Socket* _socket;
+};
+
+#endif // SOCKETTEST_HPP
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic