summaryrefslogtreecommitdiffstats
path: root/libcommuni/tests/auto/ircuser/tst_ircuser.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2014-10-06 15:03:54 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2014-10-06 15:03:54 +0200
commit529f38bd8878b6b1bea2b5457031ce936aab8d80 (patch)
tree1193caefcad12f6a36f818048e4547e60add4398 /libcommuni/tests/auto/ircuser/tst_ircuser.cpp
parent3b58b5536935adff242928ed9f30e1c0262fbd7c (diff)
downloadmanager-529f38bd8878b6b1bea2b5457031ce936aab8d80.tar.gz
manager-529f38bd8878b6b1bea2b5457031ce936aab8d80.zip
addedd communi
Diffstat (limited to 'libcommuni/tests/auto/ircuser/tst_ircuser.cpp')
-rw-r--r--libcommuni/tests/auto/ircuser/tst_ircuser.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/libcommuni/tests/auto/ircuser/tst_ircuser.cpp b/libcommuni/tests/auto/ircuser/tst_ircuser.cpp
new file mode 100644
index 0000000..c575c14
--- /dev/null
+++ b/libcommuni/tests/auto/ircuser/tst_ircuser.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2008-2014 The Communi Project
+ *
+ * This test is free, and not covered by the BSD license. There is no
+ * restriction applied to their modification, redistribution, using and so on.
+ * You can study them, modify them, use them in your own program - either
+ * completely or partially.
+ */
+
+#include "ircuser.h"
+#include <QtTest/QtTest>
+#include <QtCore/QRegExp>
+#ifdef Q_OS_LINUX
+#include "ircuser_p.h"
+#endif // Q_OS_LINUX
+
+class tst_IrcUser : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testDefaults();
+ void testSignals();
+ void testDebug();
+};
+
+void tst_IrcUser::testDefaults()
+{
+ IrcUser user;
+ QVERIFY(user.title().isEmpty());
+ QVERIFY(user.name().isEmpty());
+ QVERIFY(user.prefix().isEmpty());
+ QVERIFY(user.mode().isEmpty());
+ QVERIFY(!user.isServOp());
+ QVERIFY(!user.isAway());
+ QVERIFY(!user.channel());
+}
+
+void tst_IrcUser::testSignals()
+{
+ IrcUser user;
+ QSignalSpy titleSpy(&user, SIGNAL(titleChanged(QString)));
+ QSignalSpy nameSpy(&user, SIGNAL(nameChanged(QString)));
+ QSignalSpy prefixSpy(&user, SIGNAL(prefixChanged(QString)));
+ QSignalSpy modeSpy(&user, SIGNAL(modeChanged(QString)));
+ QSignalSpy servOpSpy(&user, SIGNAL(servOpChanged(bool)));
+ QSignalSpy awaySpy(&user, SIGNAL(awayChanged(bool)));
+ QVERIFY(titleSpy.isValid());
+ QVERIFY(nameSpy.isValid());
+ QVERIFY(prefixSpy.isValid());
+ QVERIFY(modeSpy.isValid());
+ QVERIFY(servOpSpy.isValid());
+ QVERIFY(awaySpy.isValid());
+}
+
+void tst_IrcUser::testDebug()
+{
+ QString str;
+ QDebug dbg(&str);
+
+ dbg << static_cast<IrcUser*>(0);
+ QCOMPARE(str.trimmed(), QString::fromLatin1("IrcUser(0x0)"));
+ str.clear();
+
+ IrcUser user;
+ dbg << &user;
+ QVERIFY(QRegExp("IrcUser\\(0x[0-9A-Fa-f]+\\) ").exactMatch(str));
+ str.clear();
+
+ user.setObjectName("obj");
+ dbg << &user;
+ QVERIFY(QRegExp("IrcUser\\(0x[0-9A-Fa-f]+, name=obj\\) ").exactMatch(str));
+ str.clear();
+
+#ifdef Q_OS_LINUX
+ // others have problems with symbols (win) or private headers (osx frameworks)
+ IrcUserPrivate::get(&user)->setName("usr");
+ dbg << &user;
+ QVERIFY(QRegExp("IrcUser\\(0x[0-9A-Fa-f]+, name=obj, user=usr\\) ").exactMatch(str));
+ str.clear();
+#endif // Q_OS_LINUX
+}
+
+QTEST_MAIN(tst_IrcUser)
+
+#include "tst_ircuser.moc"