summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-03-08 15:17:30 (GMT)
committerTobias Markmann <tm@ayena.de>2013-03-27 14:12:26 (GMT)
commit497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04 (patch)
treedc81e56199f54cf20f834c78bda7fc26ffbc38f9 /Swiften/Parser/PayloadParsers/UnitTest
parent20ead0a84fdd8c9e870e98ee6a2712bfa263d7fb (diff)
downloadswift-497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04.zip
swift-497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04.tar.bz2
Adding support for Blocking Command (XEP-0191) to Swift(-en).
Change-Id: I7c92518dc389474d520d4cf96f96a11459f73d26 License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp
new file mode 100644
index 0000000..ddd3a88
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <Swiften/Parser/PayloadParsers/BlockParser.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+#include <Swiften/Elements/BlockPayload.h>
+#include <Swiften/Elements/UnblockPayload.h>
+#include <Swiften/Elements/BlockListPayload.h>
+
+using namespace Swift;
+
+class BlockParserTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(BlockParserTest);
+ CPPUNIT_TEST(testExample4);
+ CPPUNIT_TEST(testExample6);
+ CPPUNIT_TEST(testExample10);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ BlockParserTest() {}
+
+ void testExample4() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<blocklist xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "<item jid='iago@shakespeare.lit'/>"
+ "</blocklist>"));
+
+ BlockListPayload* payload = dynamic_cast<BlockListPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(2 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ CPPUNIT_ASSERT_EQUAL(JID("iago@shakespeare.lit"), payload->getItems()[1]);
+ }
+
+ void testExample6() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<block xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "</block>"));
+
+ BlockPayload* payload = dynamic_cast<BlockPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(1 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ }
+
+ void testExample10() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<unblock xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "</unblock>"));
+
+ UnblockPayload* payload = dynamic_cast<UnblockPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(1 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(BlockParserTest);