summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp')
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp60
1 files changed, 2 insertions, 58 deletions
diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
index 5f0c9fd..77993ea 100644
--- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
+++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2011 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -9,69 +9,13 @@
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
-#include <vector>
-
+#include "Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h"
#include "Swiften/Roster/XMPPRosterImpl.h"
using namespace Swift;
-enum XMPPRosterEvents {None, Add, Remove, Update};
-
-class XMPPRosterSignalHandler {
-public:
- XMPPRosterSignalHandler(XMPPRoster* roster) {
- lastEvent_ = None;
- roster->onJIDAdded.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDAdded, this, _1));
- roster->onJIDRemoved.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDRemoved, this, _1));
- roster->onJIDUpdated.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDUpdated, this, _1, _2, _3));
- }
-
- XMPPRosterEvents getLastEvent() {
- return lastEvent_;
- }
-
- JID getLastJID() {
- return lastJID_;
- }
-
- String getLastOldName() {
- return lastOldName_;
- }
-
- std::vector<String> getLastOldGroups() {
- return lastOldGroups_;
- }
- void reset() {
- lastEvent_ = None;
- }
-
-private:
- void handleJIDAdded(const JID& jid) {
- lastJID_ = jid;
- lastEvent_ = Add;
- }
-
- void handleJIDRemoved(const JID& jid) {
- lastJID_ = jid;
- lastEvent_ = Remove;
- }
-
- void handleJIDUpdated(const JID& jid, const String& oldName, const std::vector<String>& oldGroups) {
- CPPUNIT_ASSERT_EQUAL(None, lastEvent_);
- lastJID_ = jid;
- lastOldName_ = oldName;
- lastOldGroups_ = oldGroups;
- lastEvent_ = Update;
- }
-
- XMPPRosterEvents lastEvent_;
- JID lastJID_;
- String lastOldName_;
- std::vector<String> lastOldGroups_;
-
-};
class XMPPRosterImplTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(XMPPRosterImplTest);