diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-12 09:50:20 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-12 12:07:45 (GMT) |
commit | 6dcca70b2f9ed13817e3600d96dbc9af3b597241 (patch) | |
tree | 94a9083a787d83d0d2bf987d2135238177e177a8 /Swiften/Roster/UnitTest/MockTreeWidgetFactory.h | |
parent | b4604f14389aa6276f6d2c3bff2a873b4dfe0913 (diff) | |
download | swift-contrib-6dcca70b2f9ed13817e3600d96dbc9af3b597241.zip swift-contrib-6dcca70b2f9ed13817e3600d96dbc9af3b597241.tar.bz2 |
RosterController testing.
Diffstat (limited to 'Swiften/Roster/UnitTest/MockTreeWidgetFactory.h')
-rw-r--r-- | Swiften/Roster/UnitTest/MockTreeWidgetFactory.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h b/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h index 935423c..d94c859 100644 --- a/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h +++ b/Swiften/Roster/UnitTest/MockTreeWidgetFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -27,12 +27,12 @@ class MockTreeWidgetFactory : public TreeWidgetFactory { return root_; }; virtual TreeWidgetItem* createTreeWidgetItem(TreeWidgetItem* group) { - MockTreeWidgetItem* entry = new MockTreeWidgetItem(); + MockTreeWidgetItem* entry = new MockTreeWidgetItem(this); groupMembers_[group].push_back(entry); return entry; }; virtual TreeWidgetItem* createTreeWidgetItem(TreeWidget*) { - MockTreeWidgetItem* group = new MockTreeWidgetItem(); + MockTreeWidgetItem* group = new MockTreeWidgetItem(this); groups_.push_back(group); return group; }; @@ -43,6 +43,24 @@ class MockTreeWidgetFactory : public TreeWidgetFactory { } return groupNames; }; + + typedef std::map<TreeWidgetItem*, std::vector<MockTreeWidgetItem*> > itemMap; + + virtual std::vector<MockTreeWidgetItem*> getGroupMembers(const String& group) { + for (itemMap::iterator it = groupMembers_.begin(); it != groupMembers_.end(); it++) { + if (((MockTreeWidgetItem*)(it->first))->getText() == group) { + return it->second; + } + } + return std::vector<MockTreeWidgetItem*>(); + }; + + virtual void removeItem(MockTreeWidgetItem* item) { + foreach (TreeWidgetItem* groupItem, groups_) { + std::vector<MockTreeWidgetItem*>& members = groupMembers_[groupItem]; + members.erase(std::remove(members.begin(), members.end(), item), members.end()); + } + }; private: std::vector<MockTreeWidgetItem*> groups_; std::map<TreeWidgetItem*, std::vector<MockTreeWidgetItem*> > groupMembers_; |