Changeset - 9e05a8dffbe8
[Not reviewed]
0 3 0
Jan Kaluza - 14 years ago 2011-10-26 17:24:33
hanzz.k@gmail.com
more tests
3 files changed with 19 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/tests/basictest.cpp
Show inline comments
 
@@ -87,6 +87,10 @@ void BasicTest::injectPresence(boost::shared_ptr<Swift::Presence> &response) {
 
	dynamic_cast<Swift::ServerStanzaChannel *>(component->getStanzaChannel())->onPresenceReceived(response);
 
}
 

	
 
void BasicTest::injectIQ(boost::shared_ptr<Swift::IQ> iq) {
 
	dynamic_cast<Swift::ServerStanzaChannel *>(component->getStanzaChannel())->onIQReceived(iq);
 
}
 

	
 
Swift::Stanza *BasicTest::getStanza(boost::shared_ptr<Swift::Element> element) {
 
	Swift::Stanza *stanza = dynamic_cast<Swift::Stanza *>(element.get());
 
	CPPUNIT_ASSERT(stanza);
src/tests/basictest.h
Show inline comments
 
@@ -97,6 +97,7 @@ class BasicTest : public Swift::XMPPParserClient {
 
	void handleStreamEnd();
 

	
 
	void injectPresence(boost::shared_ptr<Swift::Presence> &response);
 
	void injectIQ(boost::shared_ptr<Swift::IQ> iq);
 

	
 
	Swift::Stanza *getStanza(boost::shared_ptr<Swift::Element> element);
 

	
src/tests/rostermanager.cpp
Show inline comments
 
@@ -94,21 +94,26 @@ class RosterManagerTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
		add2Buddies();
 
		CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
 

	
 
		Swift::RosterPayload::ref payload = getStanza(received[0])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload->getItems().size());
 
		Swift::RosterItemPayload item = payload->getItems()[0];
 
		Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload1);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload1->getItems().size());
 
		Swift::RosterItemPayload item = payload1->getItems()[0];
 
		CPPUNIT_ASSERT_EQUAL(std::string("buddy1"), Buddy::JIDToLegacyName(item.getJID()));
 
		CPPUNIT_ASSERT_EQUAL(std::string("Buddy 1"), item.getName());
 

	
 
		payload = getStanza(received[1])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload->getItems().size());
 
		item = payload->getItems()[0];
 
		Swift::RosterPayload::ref payload2 = getStanza(received[1])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload2);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload2->getItems().size());
 
		item = payload2->getItems()[0];
 
		CPPUNIT_ASSERT_EQUAL(std::string("buddy2"), Buddy::JIDToLegacyName(item.getJID()));
 
		CPPUNIT_ASSERT_EQUAL(std::string("Buddy 2"), item.getName());
 

	
 
		// TODO send response and check for presence
 
		// send responses back
 
		injectIQ(Swift::IQ::createResult(getStanza(received[0])->getFrom(), getStanza(received[0])->getTo(), getStanza(received[0])->getID()));
 
		injectIQ(Swift::IQ::createResult(getStanza(received[1])->getFrom(), getStanza(received[1])->getTo(), getStanza(received[1])->getID()));
 

	
 
		// we should get presences
 
		CPPUNIT_ASSERT_EQUAL(4, (int) received.size());
 
	}
 

	
 
	void disconnectUser() {
0 comments (0 inline, 0 general)