summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/smpppdcs/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/plugins/smpppdcs/unittest')
-rw-r--r--kopete/plugins/smpppdcs/unittest/Makefile.am15
-rw-r--r--kopete/plugins/smpppdcs/unittest/clienttest.cpp121
-rw-r--r--kopete/plugins/smpppdcs/unittest/clienttest.h50
-rw-r--r--kopete/plugins/smpppdcs/unittest/main.cpp45
4 files changed, 231 insertions, 0 deletions
diff --git a/kopete/plugins/smpppdcs/unittest/Makefile.am b/kopete/plugins/smpppdcs/unittest/Makefile.am
new file mode 100644
index 00000000..9694bff9
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes) -I../libsmpppdclient
+METASOURCES = AUTO
+
+
+check_PROGRAMS = smpppdcstests
+
+smpppdcstests_SOURCES = main.cpp clienttest.cpp
+smpppdcstests_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+smpppdcstests_LDADD = ../libsmpppdclient/libsmpppdclient.la -lkunittestgui
+
+noinst_HEADERS = clienttest.h
+
+check:
+ kunittest ./smpppdcstests ClientTest
+
diff --git a/kopete/plugins/smpppdcs/unittest/clienttest.cpp b/kopete/plugins/smpppdcs/unittest/clienttest.cpp
new file mode 100644
index 00000000..5affd83c
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/clienttest.cpp
@@ -0,0 +1,121 @@
+/*
+ clienttest.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include "smpppdclient.h"
+
+#include "clienttest.h"
+
+ClientTest::ClientTest(const char * name)
+ : KUnitTest::SlotTester(name) {}
+
+ClientTest::~ClientTest() {}
+
+void ClientTest::testInitIsReady() {
+ SMPPPD::Client c;
+ CHECK(c.isReady(), false);
+}
+
+void ClientTest::testAfterConnectIsReady() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.isReady(), true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testConnect() {
+ SMPPPD::Client c;
+ CHECK(c.connect("warwar", 3185), true);
+ CHECK(c.connect("localhost", 3185), false);
+}
+
+void ClientTest::testCommunicationBeforeConnect() {
+ SMPPPD::Client c;
+ QStringList l = c.getInterfaceConfigurations();
+
+ CHECK(l.count() == 0, true);
+ CHECK(c.statusInterface("ifcfg0"), false);
+}
+
+void ClientTest::testServerIDBeforeConnect() {
+ SMPPPD::Client c;
+ CHECK(c.serverID(), QString::null);
+}
+
+void ClientTest::testServerVersionBeforeConnect() {
+ SMPPPD::Client c;
+ CHECK(c.serverVersion(), QString::null);
+}
+
+void ClientTest::testCommunicationAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.getInterfaceConfigurations().count() > 0, true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerIDAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.serverID().isEmpty(), false);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerVersionAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.serverVersion().isEmpty(), false);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testCommunicationAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.getInterfaceConfigurations().count() == 0, true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerIDAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.serverID(), QString::null);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerVersionAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.serverVersion(), QString::null);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+#include "clienttest.moc"
diff --git a/kopete/plugins/smpppdcs/unittest/clienttest.h b/kopete/plugins/smpppdcs/unittest/clienttest.h
new file mode 100644
index 00000000..5db7ef7b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/clienttest.h
@@ -0,0 +1,50 @@
+/*
+ clienttest.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef CLIENTTEST_H
+#define CLIENTTEST_H
+
+#include <kunittest/tester.h>
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class ClientTest : public KUnitTest::SlotTester {
+ Q_OBJECT
+
+ ClientTest(const ClientTest&);
+ ClientTest& operator=(const ClientTest&);
+
+public:
+ ClientTest(const char * name = 0);
+ virtual ~ClientTest();
+
+private slots:
+ void testInitIsReady();
+ void testAfterConnectIsReady();
+ void testConnect();
+ void testCommunicationBeforeConnect();
+ void testServerIDBeforeConnect();
+ void testServerVersionBeforeConnect();
+ void testCommunicationAfterConnect();
+ void testServerIDAfterConnect();
+ void testServerVersionAfterConnect();
+ void testCommunicationAfterDisconnect();
+ void testServerIDAfterDisconnect();
+ void testServerVersionAfterDisconnect();
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/unittest/main.cpp b/kopete/plugins/smpppdcs/unittest/main.cpp
new file mode 100644
index 00000000..ec14489b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/main.cpp
@@ -0,0 +1,45 @@
+/*
+ main.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <kunittest/runnergui.h>
+
+#include "clienttest.h"
+
+static const char description[] = I18N_NOOP("SMPPPDClientTests");
+static const char version[] = "0.1";
+static KCmdLineOptions options[] = { KCmdLineLastOption };
+
+int main( int argc, char** argv ) {
+ KAboutData about("SMPPPDClientTests", I18N_NOOP("SMPPPDClientTests"), version, description,
+ KAboutData::License_BSD, "(C) 2006 Heiko Schäfer", 0, 0, "heiko@rangun.de");
+
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions(options);
+ KApplication app;
+
+ KUnitTest::Runner::registerTester("ClientTest", new ClientTest);
+
+ KUnitTest::RunnerGUI runner(0);
+ runner.show();
+ app.setMainWidget(&runner);
+
+ return app.exec();
+}