summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-21 20:21:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-21 20:21:45 (GMT)
commitaf61db1e108d17afcf84a97492dd6b79426688ec (patch)
treefd765135ebbb67be56ea4eefbfed73c05c00d214 /Swiften/Queries/UnitTest
parentd0c2985c34b65f0d85d35948bb0cfadd3b2af7bd (diff)
downloadswift-af61db1e108d17afcf84a97492dd6b79426688ec.zip
swift-af61db1e108d17afcf84a97492dd6b79426688ec.tar.bz2
Make sure Component always sets 'from' on outgoing IQ stanzas.
Diffstat (limited to 'Swiften/Queries/UnitTest')
-rw-r--r--Swiften/Queries/UnitTest/IQRouterTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Swiften/Queries/UnitTest/IQRouterTest.cpp b/Swiften/Queries/UnitTest/IQRouterTest.cpp
index 919711e..2d6b2cb 100644
--- a/Swiften/Queries/UnitTest/IQRouterTest.cpp
+++ b/Swiften/Queries/UnitTest/IQRouterTest.cpp
@@ -24,6 +24,9 @@ class IQRouterTest : public CppUnit::TestFixture
CPPUNIT_TEST(testHandleIQ_SuccesfulHandlerLast);
CPPUNIT_TEST(testHandleIQ_NoSuccesfulHandler);
CPPUNIT_TEST(testHandleIQ_HandlerRemovedDuringHandle);
+ CPPUNIT_TEST(testSendIQ_WithFrom);
+ CPPUNIT_TEST(testSendIQ_WithoutFrom);
+ CPPUNIT_TEST(testHandleIQ_WithFrom);
CPPUNIT_TEST_SUITE_END();
public:
@@ -109,6 +112,33 @@ class IQRouterTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(2, handler2.called);
}
+ void testSendIQ_WithFrom() {
+ IQRouter testling(channel_);
+ testling.setFrom(JID("foo@bar.com/baz"));
+
+ testling.sendIQ(boost::shared_ptr<IQ>(new IQ()));
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom());
+ }
+
+ void testSendIQ_WithoutFrom() {
+ IQRouter testling(channel_);
+
+ testling.sendIQ(boost::shared_ptr<IQ>(new IQ()));
+
+ CPPUNIT_ASSERT_EQUAL(JID(), channel_->iqs_[0]->getFrom());
+ }
+
+ void testHandleIQ_WithFrom() {
+ IQRouter testling(channel_);
+ testling.setFrom(JID("foo@bar.com/baz"));
+ DummyIQHandler handler(false, &testling);
+
+ channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom());
+ }
+
private:
struct DummyIQHandler : public IQHandler {
DummyIQHandler(bool handle, IQRouter* router) : handle(handle), router(router), called(0) {