summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-14 16:17:30 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-14 19:48:53 (GMT)
commitef5a4dc3a5b0224628a225ef0dccc679287478be (patch)
tree126d8f752f18d3d5891cd32cacf2a21734ab0b92 /Swiften/Parser/PayloadParsers/UnitTest
parent9ecba612d790c1f613dc959888f62e5d3575faae (diff)
downloadswift-contrib-ef5a4dc3a5b0224628a225ef0dccc679287478be.zip
swift-contrib-ef5a4dc3a5b0224628a225ef0dccc679287478be.tar.bz2
Add extended disco support to caps verifier.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp22
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp12
2 files changed, 33 insertions, 1 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
index 2e7e7af..79b28db 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
@@ -16,6 +16,7 @@ class DiscoInfoParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(DiscoInfoParserTest);
CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Form);
CPPUNIT_TEST_SUITE_END();
public:
@@ -48,6 +49,27 @@ class DiscoInfoParserTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]);
CPPUNIT_ASSERT_EQUAL(String("baz-feature"), payload->getFeatures()[2]);
}
+
+ void testParse_Form() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
+ "<feature var=\"foo-feature\"/>"
+ "<x type=\"submit\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "<instructions>Hello!</instructions>"
+ "</x>"
+ "<feature var=\"bar-feature\"/>"
+ "</query>"));
+
+ DiscoInfo* payload = dynamic_cast<DiscoInfo*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getExtensions().size()));
+ CPPUNIT_ASSERT_EQUAL(String("Bot Configuration"), payload->getExtensions()[0]->getTitle());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFeatures().size()));
+ CPPUNIT_ASSERT_EQUAL(String("foo-feature"), payload->getFeatures()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
index 0d6e85e..aede75d 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
@@ -75,11 +75,15 @@ class FormParserTest : public CppUnit::TestFixture {
"<value>foo@bar.com</value>"
"<value>baz@fum.org</value>"
"</field>"
+ "<field var=\"untyped\">"
+ "<value>foo</value>"
+ "<value>baz</value>"
+ "</field>"
"</x>"));
Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(payload->getFields().size()));
+ CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size()));
CPPUNIT_ASSERT_EQUAL(String("jabber:bot"), boost::dynamic_pointer_cast<HiddenFormField>(payload->getFields()[0])->getValue());
CPPUNIT_ASSERT_EQUAL(String("FORM_TYPE"), payload->getFields()[0]->getName());
CPPUNIT_ASSERT(!payload->getFields()[0]->getRequired());
@@ -92,9 +96,12 @@ class FormParserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(true, boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getValue());
CPPUNIT_ASSERT(payload->getFields()[4]->getRequired());
+ CPPUNIT_ASSERT_EQUAL(String("1"), boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getRawValues()[0]);
CPPUNIT_ASSERT_EQUAL(String("news"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("news"), payload->getFields()[6]->getRawValues()[0]);
CPPUNIT_ASSERT_EQUAL(String("search"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[1]);
+ CPPUNIT_ASSERT_EQUAL(String("search"), payload->getFields()[6]->getRawValues()[1]);
CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(payload->getFields()[6]->getOptions().size()));
CPPUNIT_ASSERT_EQUAL(String("Contests"), payload->getFields()[6]->getOptions()[0].label);
CPPUNIT_ASSERT_EQUAL(String("contests"), payload->getFields()[6]->getOptions()[0].value);
@@ -106,6 +113,9 @@ class FormParserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[0]);
CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[1]);
CPPUNIT_ASSERT_EQUAL(String("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription());
+
+ CPPUNIT_ASSERT_EQUAL(String("foo"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("baz"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[1]);
}
};