summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp')
-rw-r--r--Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp
index 52fdbaa..67d27c0 100644
--- a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -9,6 +9,8 @@
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Disco/CapsInfoGenerator.h>
+#include <Swiften/Crypto/CryptoProvider.h>
+#include <Swiften/Crypto/PlatformCryptoProvider.h>
using namespace Swift;
@@ -19,6 +21,10 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp() {
+ crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
+ }
+
void testGenerate_XEP0115SimpleExample() {
DiscoInfo discoInfo;
discoInfo.addIdentity(DiscoInfo::Identity("Exodus 0.9.1", "client", "pc"));
@@ -27,7 +33,7 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture {
discoInfo.addFeature("http://jabber.org/protocol/disco#info");
discoInfo.addFeature("http://jabber.org/protocol/muc");
- CapsInfoGenerator testling("http://code.google.com/p/exodus");
+ CapsInfoGenerator testling("http://code.google.com/p/exodus", crypto.get());
CapsInfo result = testling.generateCapsInfo(discoInfo);
CPPUNIT_ASSERT_EQUAL(std::string("http://code.google.com/p/exodus"), result.getNode());
@@ -45,40 +51,36 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture {
discoInfo.addFeature("http://jabber.org/protocol/muc");
Form::ref extension(new Form(Form::ResultType));
- FormField::ref field = HiddenFormField::create("urn:xmpp:dataforms:softwareinfo");
+ FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "urn:xmpp:dataforms:softwareinfo");
field->setName("FORM_TYPE");
extension->addField(field);
- std::vector<std::string> ipVersions;
- ipVersions.push_back("ipv6");
- ipVersions.push_back("ipv4");
- field = ListMultiFormField::create(ipVersions);
- field->addRawValue("ipv6");
- field->addRawValue("ipv4");
+ field = boost::make_shared<FormField>(FormField::ListMultiType);
+ field->addValue("ipv6");
+ field->addValue("ipv4");
field->setName("ip_version");
extension->addField(field);
- field = TextSingleFormField::create("Psi");
- field->addRawValue("Psi");
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Psi");
field->setName("software");
extension->addField(field);
- field = TextSingleFormField::create("0.11");
- field->addRawValue("0.11");
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "0.11");
field->setName("software_version");
extension->addField(field);
- field = TextSingleFormField::create("Mac");
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "Mac");
field->setName("os");
- field->addRawValue("Mac");
extension->addField(field);
- field = TextSingleFormField::create("10.5.1");
+ field = boost::make_shared<FormField>(FormField::TextSingleType, "10.5.1");
field->setName("os_version");
- field->addRawValue("10.5.1");
extension->addField(field);
discoInfo.addExtension(extension);
- CapsInfoGenerator testling("http://psi-im.org");
+ CapsInfoGenerator testling("http://psi-im.org", crypto.get());
CapsInfo result = testling.generateCapsInfo(discoInfo);
CPPUNIT_ASSERT_EQUAL(std::string("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion());
}
+
+ private:
+ boost::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(CapsInfoGeneratorTest);