summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swift/Controllers/UnitTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swift/Controllers/UnitTest')
-rw-r--r--Swift/Controllers/UnitTest/ChatMessageSummarizerTest.cpp202
-rw-r--r--Swift/Controllers/UnitTest/ContactSuggesterTest.cpp204
-rw-r--r--Swift/Controllers/UnitTest/HighlightRuleTest.cpp484
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h196
-rw-r--r--Swift/Controllers/UnitTest/MockMainWindow.h38
-rw-r--r--Swift/Controllers/UnitTest/MockMainWindowFactory.h24
-rw-r--r--Swift/Controllers/UnitTest/PresenceNotifierTest.cpp520
-rw-r--r--Swift/Controllers/UnitTest/PreviousStatusStoreTest.cpp40
8 files changed, 854 insertions, 854 deletions
diff --git a/Swift/Controllers/UnitTest/ChatMessageSummarizerTest.cpp b/Swift/Controllers/UnitTest/ChatMessageSummarizerTest.cpp
index 118c502..59c57b9 100644
--- a/Swift/Controllers/UnitTest/ChatMessageSummarizerTest.cpp
+++ b/Swift/Controllers/UnitTest/ChatMessageSummarizerTest.cpp
@@ -13,109 +13,109 @@ using namespace Swift;
using namespace std;
class ChatMessageSummarizerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ChatMessageSummarizerTest);
- CPPUNIT_TEST(testEmpty);
- CPPUNIT_TEST(testCurrentNone);
- CPPUNIT_TEST(testCurrentCount);
- CPPUNIT_TEST(testCurrentCountOthersNone);
- CPPUNIT_TEST(testCurrentCountOtherCount);
- CPPUNIT_TEST(testCurrentNoneOtherCount);
- CPPUNIT_TEST(testCurrentCountOthersCount);
- CPPUNIT_TEST(testCurrentNoneOthersCount);
- CPPUNIT_TEST(testCurrentCountSomeOthersCount);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ChatMessageSummarizerTest);
+ CPPUNIT_TEST(testEmpty);
+ CPPUNIT_TEST(testCurrentNone);
+ CPPUNIT_TEST(testCurrentCount);
+ CPPUNIT_TEST(testCurrentCountOthersNone);
+ CPPUNIT_TEST(testCurrentCountOtherCount);
+ CPPUNIT_TEST(testCurrentNoneOtherCount);
+ CPPUNIT_TEST(testCurrentCountOthersCount);
+ CPPUNIT_TEST(testCurrentNoneOthersCount);
+ CPPUNIT_TEST(testCurrentCountSomeOthersCount);
+ CPPUNIT_TEST_SUITE_END();
public:
- ChatMessageSummarizerTest() {}
-
- void setUp() {
-
- }
-
- void testEmpty() {
- string current("");
- vector<UnreadPair> unreads;
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(current, summary.getSummary(current, unreads));
- }
-
- void testCurrentNone() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bob", 0));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(current, summary.getSummary(current, unreads));
- }
-
- void testCurrentCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bob", 3));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob (3)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentCountOthersNone() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 0));
- unreads.push_back(UnreadPair("Bob", 3));
- unreads.push_back(UnreadPair("Betty", 0));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob (3)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentCountOtherCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 0));
- unreads.push_back(UnreadPair("Bob", 3));
- unreads.push_back(UnreadPair("Betty", 7));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob (3); Betty (7)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentNoneOtherCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 0));
- unreads.push_back(UnreadPair("Bob", 0));
- unreads.push_back(UnreadPair("Betty", 7));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob; Betty (7)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentNoneOthersCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 2));
- unreads.push_back(UnreadPair("Bob", 0));
- unreads.push_back(UnreadPair("Betty", 7));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob and 2 others (9)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentCountOthersCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 2));
- unreads.push_back(UnreadPair("Bob", 11));
- unreads.push_back(UnreadPair("Betty", 7));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob (11) and 2 others (9)"), summary.getSummary(current, unreads));
- }
-
- void testCurrentCountSomeOthersCount() {
- string current("Bob");
- vector<UnreadPair> unreads;
- unreads.push_back(UnreadPair("Bert", 2));
- unreads.push_back(UnreadPair("Beverly", 0));
- unreads.push_back(UnreadPair("Bob", 11));
- unreads.push_back(UnreadPair("Beatrice", 0));
- unreads.push_back(UnreadPair("Betty", 7));
- ChatMessageSummarizer summary;
- CPPUNIT_ASSERT_EQUAL(string("Bob (11) and 2 others (9)"), summary.getSummary(current, unreads));
- }
+ ChatMessageSummarizerTest() {}
+
+ void setUp() {
+
+ }
+
+ void testEmpty() {
+ string current("");
+ vector<UnreadPair> unreads;
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(current, summary.getSummary(current, unreads));
+ }
+
+ void testCurrentNone() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bob", 0));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(current, summary.getSummary(current, unreads));
+ }
+
+ void testCurrentCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bob", 3));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob (3)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentCountOthersNone() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 0));
+ unreads.push_back(UnreadPair("Bob", 3));
+ unreads.push_back(UnreadPair("Betty", 0));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob (3)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentCountOtherCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 0));
+ unreads.push_back(UnreadPair("Bob", 3));
+ unreads.push_back(UnreadPair("Betty", 7));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob (3); Betty (7)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentNoneOtherCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 0));
+ unreads.push_back(UnreadPair("Bob", 0));
+ unreads.push_back(UnreadPair("Betty", 7));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob; Betty (7)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentNoneOthersCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 2));
+ unreads.push_back(UnreadPair("Bob", 0));
+ unreads.push_back(UnreadPair("Betty", 7));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob and 2 others (9)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentCountOthersCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 2));
+ unreads.push_back(UnreadPair("Bob", 11));
+ unreads.push_back(UnreadPair("Betty", 7));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob (11) and 2 others (9)"), summary.getSummary(current, unreads));
+ }
+
+ void testCurrentCountSomeOthersCount() {
+ string current("Bob");
+ vector<UnreadPair> unreads;
+ unreads.push_back(UnreadPair("Bert", 2));
+ unreads.push_back(UnreadPair("Beverly", 0));
+ unreads.push_back(UnreadPair("Bob", 11));
+ unreads.push_back(UnreadPair("Beatrice", 0));
+ unreads.push_back(UnreadPair("Betty", 7));
+ ChatMessageSummarizer summary;
+ CPPUNIT_ASSERT_EQUAL(string("Bob (11) and 2 others (9)"), summary.getSummary(current, unreads));
+ }
};
diff --git a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
index 9b625fe..2bfca4b 100644
--- a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
+++ b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp
@@ -18,111 +18,111 @@
using namespace Swift;
class ContactSuggesterTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ContactSuggesterTest);
- CPPUNIT_TEST(equalityTest);
- CPPUNIT_TEST(lexicographicalSortTest);
- CPPUNIT_TEST(sortTest);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ContactSuggesterTest);
+ CPPUNIT_TEST(equalityTest);
+ CPPUNIT_TEST(lexicographicalSortTest);
+ CPPUNIT_TEST(sortTest);
+ CPPUNIT_TEST_SUITE_END();
public:
- std::vector<std::string> wordList() {
- const std::string words[] = {
- "abc",
- "ab",
- "bc",
- "d"
- };
-
- return std::vector<std::string>(words, words+sizeof(words)/sizeof(*words));
- }
-
- std::vector<StatusShow::Type> statusList() {
- StatusShow::Type types[] = {
- StatusShow::Online,
- StatusShow::Away,
- StatusShow::FFC,
- StatusShow::XA,
- StatusShow::DND,
- StatusShow::None
- };
-
- return std::vector<StatusShow::Type>(types, types+sizeof(types)/sizeof(*types));
- }
-
- std::vector<Contact::ref> contactList() {
- std::vector<Contact::ref> contacts;
- std::vector<std::string> words = wordList();
- std::vector<StatusShow::Type> statuses = statusList();
- foreach (const std::string& name, words) {
- foreach (const std::string& jid, words) {
- foreach (const StatusShow::Type& status, statuses) {
- contacts.push_back(boost::make_shared<Contact>(name, jid, status, ""));
- }
- }
- }
- return contacts;
- }
-
- /* a = a */
- bool isReflexive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
- std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
- if (!comparitor(a, a)) {
- return false;
- }
- }
- return true;
- }
-
- /* a = b -> b = a */
- bool isSymmetric(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
- std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
- foreach (const Contact::ref& b, contacts) {
- if (comparitor(a, b)) {
- if (!comparitor(b, a)) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- /* a = b && b = c -> a = c */
- bool isTransitive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
- std::vector<Contact::ref> contacts = contactList();
- foreach (const Contact::ref& a, contacts) {
- foreach (const Contact::ref& b, contacts) {
- foreach (const Contact::ref& c, contacts) {
- if (comparitor(a, b) && comparitor(b, c)) {
- if (!comparitor(a, c)) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- void equalityTest() {
- CPPUNIT_ASSERT(isReflexive(Contact::equalityPredicate));
- CPPUNIT_ASSERT(isSymmetric(Contact::equalityPredicate));
- CPPUNIT_ASSERT(isTransitive(Contact::equalityPredicate));
- }
-
- void lexicographicalSortTest() {
- CPPUNIT_ASSERT(isTransitive(Contact::lexicographicalSortPredicate));
- }
-
- void sortTest() {
- std::vector<std::string> words = wordList();
- foreach (const std::string& word, words) {
- CPPUNIT_ASSERT(isTransitive(boost::bind(Contact::sortPredicate, _1, _2, word)));
- }
- }
+ std::vector<std::string> wordList() {
+ const std::string words[] = {
+ "abc",
+ "ab",
+ "bc",
+ "d"
+ };
+
+ return std::vector<std::string>(words, words+sizeof(words)/sizeof(*words));
+ }
+
+ std::vector<StatusShow::Type> statusList() {
+ StatusShow::Type types[] = {
+ StatusShow::Online,
+ StatusShow::Away,
+ StatusShow::FFC,
+ StatusShow::XA,
+ StatusShow::DND,
+ StatusShow::None
+ };
+
+ return std::vector<StatusShow::Type>(types, types+sizeof(types)/sizeof(*types));
+ }
+
+ std::vector<Contact::ref> contactList() {
+ std::vector<Contact::ref> contacts;
+ std::vector<std::string> words = wordList();
+ std::vector<StatusShow::Type> statuses = statusList();
+ foreach (const std::string& name, words) {
+ foreach (const std::string& jid, words) {
+ foreach (const StatusShow::Type& status, statuses) {
+ contacts.push_back(boost::make_shared<Contact>(name, jid, status, ""));
+ }
+ }
+ }
+ return contacts;
+ }
+
+ /* a = a */
+ bool isReflexive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
+ std::vector<Contact::ref> contacts = contactList();
+ foreach (const Contact::ref& a, contacts) {
+ if (!comparitor(a, a)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* a = b -> b = a */
+ bool isSymmetric(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
+ std::vector<Contact::ref> contacts = contactList();
+ foreach (const Contact::ref& a, contacts) {
+ foreach (const Contact::ref& b, contacts) {
+ if (comparitor(a, b)) {
+ if (!comparitor(b, a)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /* a = b && b = c -> a = c */
+ bool isTransitive(const boost::function<bool (const Contact::ref&, const Contact::ref&)>& comparitor) {
+ std::vector<Contact::ref> contacts = contactList();
+ foreach (const Contact::ref& a, contacts) {
+ foreach (const Contact::ref& b, contacts) {
+ foreach (const Contact::ref& c, contacts) {
+ if (comparitor(a, b) && comparitor(b, c)) {
+ if (!comparitor(a, c)) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ void equalityTest() {
+ CPPUNIT_ASSERT(isReflexive(Contact::equalityPredicate));
+ CPPUNIT_ASSERT(isSymmetric(Contact::equalityPredicate));
+ CPPUNIT_ASSERT(isTransitive(Contact::equalityPredicate));
+ }
+
+ void lexicographicalSortTest() {
+ CPPUNIT_ASSERT(isTransitive(Contact::lexicographicalSortPredicate));
+ }
+
+ void sortTest() {
+ std::vector<std::string> words = wordList();
+ foreach (const std::string& word, words) {
+ CPPUNIT_ASSERT(isTransitive(boost::bind(Contact::sortPredicate, _1, _2, word)));
+ }
+ }
};
diff --git a/Swift/Controllers/UnitTest/HighlightRuleTest.cpp b/Swift/Controllers/UnitTest/HighlightRuleTest.cpp
index 62c403f..8d49d5d 100644
--- a/Swift/Controllers/UnitTest/HighlightRuleTest.cpp
+++ b/Swift/Controllers/UnitTest/HighlightRuleTest.cpp
@@ -21,304 +21,304 @@
using namespace Swift;
class HighlightRuleTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(HighlightRuleTest);
- CPPUNIT_TEST(testEmptyRuleNeverMatches);
- CPPUNIT_TEST(testKeyword);
- CPPUNIT_TEST(testNickKeyword);
- CPPUNIT_TEST(testNickWithoutOtherKeywords);
- CPPUNIT_TEST(testSender);
- CPPUNIT_TEST(testSenderAndKeyword);
- CPPUNIT_TEST(testWholeWords);
- CPPUNIT_TEST(testCase);
- CPPUNIT_TEST(testWholeWordsAndCase);
- CPPUNIT_TEST(testMUC);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- std::vector<std::string> keywords;
- keywords.push_back("keyword1");
- keywords.push_back("KEYWORD2");
-
- std::vector<std::string> senders;
- senders.push_back("sender1");
- senders.push_back("SENDER2");
-
- emptyRule = new HighlightRule();
-
- keywordRule = new HighlightRule();
- keywordRule->setKeywords(keywords);
-
- keywordChatRule = new HighlightRule();
- keywordChatRule->setKeywords(keywords);
- keywordChatRule->setMatchChat(true);
-
- keywordNickChatRule = new HighlightRule();
- keywordNickChatRule->setKeywords(keywords);
- keywordNickChatRule->setNickIsKeyword(true);
- keywordNickChatRule->setMatchChat(true);
-
- nickChatRule = new HighlightRule();
- nickChatRule->setNickIsKeyword(true);
- nickChatRule->setMatchChat(true);
-
- nickRule = new HighlightRule();
- nickRule->setNickIsKeyword(true);
-
- senderRule = new HighlightRule();
- senderRule->setSenders(senders);
-
- senderChatRule = new HighlightRule();
- senderChatRule->setSenders(senders);
- senderChatRule->setMatchChat(true);
-
- senderKeywordChatRule = new HighlightRule();
- senderKeywordChatRule->setSenders(senders);
- senderKeywordChatRule->setKeywords(keywords);
- senderKeywordChatRule->setMatchChat(true);
-
- senderKeywordNickChatRule = new HighlightRule();
- senderKeywordNickChatRule->setSenders(senders);
- senderKeywordNickChatRule->setKeywords(keywords);
- senderKeywordNickChatRule->setNickIsKeyword(true);
- senderKeywordNickChatRule->setMatchChat(true);
-
- senderKeywordNickWordChatRule = new HighlightRule();
- senderKeywordNickWordChatRule->setSenders(senders);
- senderKeywordNickWordChatRule->setKeywords(keywords);
- senderKeywordNickWordChatRule->setNickIsKeyword(true);
- senderKeywordNickWordChatRule->setMatchWholeWords(true);
- senderKeywordNickWordChatRule->setMatchChat(true);
-
- senderKeywordNickCaseChatRule = new HighlightRule();
- senderKeywordNickCaseChatRule->setSenders(senders);
- senderKeywordNickCaseChatRule->setKeywords(keywords);
- senderKeywordNickCaseChatRule->setNickIsKeyword(true);
- senderKeywordNickCaseChatRule->setMatchCase(true);
- senderKeywordNickCaseChatRule->setMatchChat(true);
-
- senderKeywordNickCaseWordChatRule = new HighlightRule();
- senderKeywordNickCaseWordChatRule->setSenders(senders);
- senderKeywordNickCaseWordChatRule->setKeywords(keywords);
- senderKeywordNickCaseWordChatRule->setNickIsKeyword(true);
- senderKeywordNickCaseWordChatRule->setMatchCase(true);
- senderKeywordNickCaseWordChatRule->setMatchWholeWords(true);
- senderKeywordNickCaseWordChatRule->setMatchChat(true);
-
- senderKeywordNickMUCRule = new HighlightRule();
- senderKeywordNickMUCRule->setSenders(senders);
- senderKeywordNickMUCRule->setKeywords(keywords);
- senderKeywordNickMUCRule->setNickIsKeyword(true);
- senderKeywordNickMUCRule->setMatchMUC(true);
- }
+ CPPUNIT_TEST_SUITE(HighlightRuleTest);
+ CPPUNIT_TEST(testEmptyRuleNeverMatches);
+ CPPUNIT_TEST(testKeyword);
+ CPPUNIT_TEST(testNickKeyword);
+ CPPUNIT_TEST(testNickWithoutOtherKeywords);
+ CPPUNIT_TEST(testSender);
+ CPPUNIT_TEST(testSenderAndKeyword);
+ CPPUNIT_TEST(testWholeWords);
+ CPPUNIT_TEST(testCase);
+ CPPUNIT_TEST(testWholeWordsAndCase);
+ CPPUNIT_TEST(testMUC);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ std::vector<std::string> keywords;
+ keywords.push_back("keyword1");
+ keywords.push_back("KEYWORD2");
+
+ std::vector<std::string> senders;
+ senders.push_back("sender1");
+ senders.push_back("SENDER2");
+
+ emptyRule = new HighlightRule();
+
+ keywordRule = new HighlightRule();
+ keywordRule->setKeywords(keywords);
+
+ keywordChatRule = new HighlightRule();
+ keywordChatRule->setKeywords(keywords);
+ keywordChatRule->setMatchChat(true);
+
+ keywordNickChatRule = new HighlightRule();
+ keywordNickChatRule->setKeywords(keywords);
+ keywordNickChatRule->setNickIsKeyword(true);
+ keywordNickChatRule->setMatchChat(true);
+
+ nickChatRule = new HighlightRule();
+ nickChatRule->setNickIsKeyword(true);
+ nickChatRule->setMatchChat(true);
+
+ nickRule = new HighlightRule();
+ nickRule->setNickIsKeyword(true);
+
+ senderRule = new HighlightRule();
+ senderRule->setSenders(senders);
+
+ senderChatRule = new HighlightRule();
+ senderChatRule->setSenders(senders);
+ senderChatRule->setMatchChat(true);
+
+ senderKeywordChatRule = new HighlightRule();
+ senderKeywordChatRule->setSenders(senders);
+ senderKeywordChatRule->setKeywords(keywords);
+ senderKeywordChatRule->setMatchChat(true);
+
+ senderKeywordNickChatRule = new HighlightRule();
+ senderKeywordNickChatRule->setSenders(senders);
+ senderKeywordNickChatRule->setKeywords(keywords);
+ senderKeywordNickChatRule->setNickIsKeyword(true);
+ senderKeywordNickChatRule->setMatchChat(true);
+
+ senderKeywordNickWordChatRule = new HighlightRule();
+ senderKeywordNickWordChatRule->setSenders(senders);
+ senderKeywordNickWordChatRule->setKeywords(keywords);
+ senderKeywordNickWordChatRule->setNickIsKeyword(true);
+ senderKeywordNickWordChatRule->setMatchWholeWords(true);
+ senderKeywordNickWordChatRule->setMatchChat(true);
+
+ senderKeywordNickCaseChatRule = new HighlightRule();
+ senderKeywordNickCaseChatRule->setSenders(senders);
+ senderKeywordNickCaseChatRule->setKeywords(keywords);
+ senderKeywordNickCaseChatRule->setNickIsKeyword(true);
+ senderKeywordNickCaseChatRule->setMatchCase(true);
+ senderKeywordNickCaseChatRule->setMatchChat(true);
+
+ senderKeywordNickCaseWordChatRule = new HighlightRule();
+ senderKeywordNickCaseWordChatRule->setSenders(senders);
+ senderKeywordNickCaseWordChatRule->setKeywords(keywords);
+ senderKeywordNickCaseWordChatRule->setNickIsKeyword(true);
+ senderKeywordNickCaseWordChatRule->setMatchCase(true);
+ senderKeywordNickCaseWordChatRule->setMatchWholeWords(true);
+ senderKeywordNickCaseWordChatRule->setMatchChat(true);
+
+ senderKeywordNickMUCRule = new HighlightRule();
+ senderKeywordNickMUCRule->setSenders(senders);
+ senderKeywordNickMUCRule->setKeywords(keywords);
+ senderKeywordNickMUCRule->setNickIsKeyword(true);
+ senderKeywordNickMUCRule->setMatchMUC(true);
+ }
- void tearDown() {
- delete emptyRule;
+ void tearDown() {
+ delete emptyRule;
- delete keywordRule;
- delete keywordChatRule;
- delete keywordNickChatRule;
- delete nickChatRule;
- delete nickRule;
-
- delete senderRule;
- delete senderChatRule;
- delete senderKeywordChatRule;
- delete senderKeywordNickChatRule;
+ delete keywordRule;
+ delete keywordChatRule;
+ delete keywordNickChatRule;
+ delete nickChatRule;
+ delete nickRule;
+
+ delete senderRule;
+ delete senderChatRule;
+ delete senderKeywordChatRule;
+ delete senderKeywordNickChatRule;
- delete senderKeywordNickWordChatRule;
- delete senderKeywordNickCaseChatRule;
- delete senderKeywordNickCaseWordChatRule;
+ delete senderKeywordNickWordChatRule;
+ delete senderKeywordNickCaseChatRule;
+ delete senderKeywordNickCaseWordChatRule;
- delete senderKeywordNickMUCRule;
- }
+ delete senderKeywordNickMUCRule;
+ }
- void testEmptyRuleNeverMatches() {
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
+ void testEmptyRuleNeverMatches() {
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "from", "", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("body", "", "", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "from", "", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "", HighlightRule::MUCMessage), false);
- }
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(emptyRule->isMatch("", "", "", HighlightRule::MUCMessage), false);
+ }
- void testKeyword() {
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
+ void testKeyword() {
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "sender contains keyword1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body", "sender contains keyword1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abc keyword1 xyz", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abckeyword1xyz", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abc keyword1 xyz", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abckeyword1xyz", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("KEYword1", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abc KEYword1 xyz", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abcKEYword1xyz", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("KEYword1", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abc KEYword1 xyz", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("abcKEYword1xyz", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword2", "from", "nick", HighlightRule::ChatMessage), true);
- }
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("keyword2", "from", "nick", HighlightRule::ChatMessage), true);
+ }
- void testNickKeyword() {
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), false);
+ void testNickKeyword() {
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body", "sender contains nick", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body", "sender contains nick", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains mixed-case NiCk", "sender", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body contains mixed-case NiCk", "sender", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("nickname", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("NIckNAME", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("nickname", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("NIckNAME", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body", "from", "", HighlightRule::ChatMessage), false);
- }
+ CPPUNIT_ASSERT_EQUAL(keywordNickChatRule->isMatch("body", "from", "", HighlightRule::ChatMessage), false);
+ }
- void testNickWithoutOtherKeywords() {
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(nickRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), false);
+ void testNickWithoutOtherKeywords() {
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains nick", "from", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(nickRule->isMatch("body contains nick", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body", "sender contains nick but it does't matter", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body", "sender contains nick but it does't matter", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains mixed-case NiCk", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body contains mixed-case NiCk", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("nickname", "from", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("NIckNAME", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("nickname", "from", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("NIckNAME", "from", "nick", HighlightRule::ChatMessage), true);
- // there are no keywords in this rule and empty nick is not treated as a keyword, so we don't check for keywords to get a match
- CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body", "from", "", HighlightRule::ChatMessage), true);
- }
+ // there are no keywords in this rule and empty nick is not treated as a keyword, so we don't check for keywords to get a match
+ CPPUNIT_ASSERT_EQUAL(nickChatRule->isMatch("body", "from", "", HighlightRule::ChatMessage), true);
+ }
- void testSender() {
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
+ void testSender() {
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "from", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender1", "nick", HighlightRule::MUCMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender1", "nick", HighlightRule::MUCMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderRule->isMatch("body contains sender1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderRule->isMatch("body contains sender1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abc sender1 xyz", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abcsender1xyz", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abc sender1 xyz", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abcsender1xyz", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "SENDer1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abc SENDer1 xyz", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abcSENDer1xyz", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "SENDer1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abc SENDer1 xyz", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "abcSENDer1xyz", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender2", "nick", HighlightRule::ChatMessage), true);
- }
+ CPPUNIT_ASSERT_EQUAL(senderChatRule->isMatch("body", "sender2", "nick", HighlightRule::ChatMessage), true);
+ }
- void testSenderAndKeyword() {
- CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
- }
+ void testSenderAndKeyword() {
+ CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
+ }
- void testWholeWords() {
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
+ void testWholeWords() {
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("xkeyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "xsender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("xkeyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("keyword1", "xsender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), true);
- }
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickWordChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), true);
+ }
- void testCase() {
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
+ void testCase() {
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("xkeyword1", "xsender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("xkeyword1", "xsender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("KEYword1", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), false);
- }
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("keyword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("KEYword1", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), false);
+ }
- void testWholeWordsAndCase() {
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
+ void testWholeWordsAndCase() {
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "from", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("xkeyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "xsender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("xkeyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "xsender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::ChatMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains xnick", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("KEYword1", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), false);
- }
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("KEYword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("keyword1", "SENDer1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("KEYword1", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickCaseWordChatRule->isMatch("body contains NiCk", "sender1", "nick", HighlightRule::ChatMessage), false);
+ }
- void testMUC() {
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
+ void testMUC() {
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("body", "from", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("keyword1", "sender1", "nick", HighlightRule::MUCMessage), true);
- CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::MUCMessage), true);
- }
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("keyword1", "sender1", "nick", HighlightRule::ChatMessage), false);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("keyword1", "sender1", "nick", HighlightRule::MUCMessage), true);
+ CPPUNIT_ASSERT_EQUAL(senderKeywordNickMUCRule->isMatch("body contains nick", "sender1", "nick", HighlightRule::MUCMessage), true);
+ }
- private:
- HighlightRule* emptyRule;
+ private:
+ HighlightRule* emptyRule;
- HighlightRule* keywordRule;
- HighlightRule* keywordChatRule;
- HighlightRule* keywordNickChatRule;
- HighlightRule* nickChatRule;
- HighlightRule* nickRule;
+ HighlightRule* keywordRule;
+ HighlightRule* keywordChatRule;
+ HighlightRule* keywordNickChatRule;
+ HighlightRule* nickChatRule;
+ HighlightRule* nickRule;
- HighlightRule* senderRule;
- HighlightRule* senderChatRule;
- HighlightRule* senderKeywordChatRule;
- HighlightRule* senderKeywordNickChatRule;
+ HighlightRule* senderRule;
+ HighlightRule* senderChatRule;
+ HighlightRule* senderKeywordChatRule;
+ HighlightRule* senderKeywordNickChatRule;
- HighlightRule* senderKeywordNickWordChatRule;
- HighlightRule* senderKeywordNickCaseChatRule;
- HighlightRule* senderKeywordNickCaseWordChatRule;
+ HighlightRule* senderKeywordNickWordChatRule;
+ HighlightRule* senderKeywordNickCaseChatRule;
+ HighlightRule* senderKeywordNickCaseWordChatRule;
- HighlightRule* senderKeywordNickMUCRule;
+ HighlightRule* senderKeywordNickMUCRule;
};
CPPUNIT_TEST_SUITE_REGISTRATION(HighlightRuleTest);
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 20c51bc..b4588e7 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -13,103 +13,103 @@
#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
namespace Swift {
- class MockChatWindow : public ChatWindow {
- public:
- MockChatWindow() : labelsEnabled_(false), impromptuMUCSupported_(false) {}
- virtual ~MockChatWindow();
-
- virtual std::string addMessage(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, boost::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
- lastMessageBody_ = bodyFromMessage(message);
- return "id";
- }
-
- virtual std::string addAction(const ChatMessage& /*message*/, const std::string& /*senderName*/, bool /*senderIsSelf*/, boost::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {return "id";}
-
- virtual std::string addSystemMessage(const ChatMessage& message, Direction /*direction*/) {
- lastAddedSystemMessage_ = message;
- return "id";
- }
-
- virtual void addPresenceMessage(const ChatMessage& message, Direction /*direction*/) {
- lastAddedPresence_ = message;
- }
-
- virtual void addErrorMessage(const ChatMessage& /*message*/) {}
- virtual void replaceMessage(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/) {}
- virtual void replaceWithAction(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/) {}
- virtual void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour /*timestampBehaviour*/) {
- lastReplacedMessage_ = message;
- }
- virtual void replaceSystemMessage(const ChatMessage& /*message*/, const std::string& /*id*/, const TimestampBehaviour /*timestampBehaviour*/) {}
-
- // File transfer related stuff
- virtual std::string addFileTransfer(const std::string& /*senderName*/, bool /*senderIsSelf*/,const std::string& /*filename*/, const boost::uintmax_t /*sizeInBytes*/, const std::string& /*description*/) { return 0; }
- virtual void setFileTransferProgress(std::string /*id*/, const int /*alreadyTransferedBytes*/) { }
- virtual void setFileTransferStatus(std::string /*id*/, const FileTransferState /*state*/, const std::string& /*msg*/) { }
-
- virtual void setMessageReceiptState(const std::string &/* id */, ReceiptState /* state */) { }
-
- virtual void setContactChatState(ChatState::ChatStateType /*state*/) {}
- virtual void setName(const std::string& name) {name_ = name;}
- virtual void show() {}
- virtual bool isVisible() const { return true; }
- virtual void activate() {}
- virtual void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels) {labels_ = labels;}
- virtual void setSecurityLabelsEnabled(bool enabled) {labelsEnabled_ = enabled;}
- virtual void setUnreadMessageCount(int /*count*/) {}
- virtual void convertToMUC(MUCType /*mucType*/) {}
- virtual void setSecurityLabelsError() {}
- virtual SecurityLabelsCatalog::Item getSelectedSecurityLabel() {return label_;}
- virtual void setOnline(bool /*online*/) {}
- virtual void setRosterModel(Roster* roster) { roster_ = roster; }
- Roster* getRosterModel() { return roster_; }
- virtual void setTabComplete(TabComplete*) {}
-
- void setAckState(const std::string& /*id*/, AckState /*state*/) {}
- virtual void flash() {}
- virtual AlertID addAlert(const std::string& /*alertText*/) { return 0; }
- virtual void removeAlert(const AlertID /*id*/) {}
- virtual void setCorrectionEnabled(Tristate /*enabled*/) {}
- virtual void setFileTransferEnabled(Tristate /*enabled*/) {}
- void setAvailableOccupantActions(const std::vector<OccupantAction>&/* actions*/) {}
- void setSubject(const std::string& /*subject*/) {}
- virtual void showRoomConfigurationForm(Form::ref) {}
- virtual void addMUCInvitation(const std::string& /*senderName*/, const JID& /*jid*/, const std::string& /*reason*/, const std::string& /*password*/, bool = true, bool = false, bool = false) {}
-
- virtual std::string addWhiteboardRequest(bool) {return "";}
- virtual void setWhiteboardSessionStatus(std::string, const ChatWindow::WhiteboardSessionState){}
-
- virtual void setAffiliations(MUCOccupant::Affiliation, const std::vector<JID>&) {}
- virtual void setAvailableRoomActions(const std::vector<RoomAction> &) {}
-
- virtual void setBlockingState(BlockingState) {}
- virtual void setCanInitiateImpromptuChats(bool supportsImpromptu) {
- impromptuMUCSupported_ = supportsImpromptu;
- }
-
- virtual void showBookmarkWindow(const MUCBookmark& /*bookmark*/) {}
- virtual void setBookmarkState(RoomBookmarkState) {}
-
- static std::string bodyFromMessage(const ChatMessage& message) {
- boost::shared_ptr<ChatTextMessagePart> text;
- foreach (boost::shared_ptr<ChatMessagePart> part, message.getParts()) {
- if ((text = boost::dynamic_pointer_cast<ChatTextMessagePart>(part))) {
- return text->text;
- }
- }
- return "";
- }
-
- std::string name_;
- std::string lastMessageBody_;
- ChatMessage lastAddedPresence_;
- ChatMessage lastReplacedMessage_;
- ChatMessage lastAddedSystemMessage_;
- std::vector<SecurityLabelsCatalog::Item> labels_;
- bool labelsEnabled_;
- bool impromptuMUCSupported_;
- SecurityLabelsCatalog::Item label_;
- Roster* roster_;
- };
+ class MockChatWindow : public ChatWindow {
+ public:
+ MockChatWindow() : labelsEnabled_(false), impromptuMUCSupported_(false) {}
+ virtual ~MockChatWindow();
+
+ virtual std::string addMessage(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, boost::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
+ lastMessageBody_ = bodyFromMessage(message);
+ return "id";
+ }
+
+ virtual std::string addAction(const ChatMessage& /*message*/, const std::string& /*senderName*/, bool /*senderIsSelf*/, boost::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {return "id";}
+
+ virtual std::string addSystemMessage(const ChatMessage& message, Direction /*direction*/) {
+ lastAddedSystemMessage_ = message;
+ return "id";
+ }
+
+ virtual void addPresenceMessage(const ChatMessage& message, Direction /*direction*/) {
+ lastAddedPresence_ = message;
+ }
+
+ virtual void addErrorMessage(const ChatMessage& /*message*/) {}
+ virtual void replaceMessage(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/) {}
+ virtual void replaceWithAction(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/) {}
+ virtual void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour /*timestampBehaviour*/) {
+ lastReplacedMessage_ = message;
+ }
+ virtual void replaceSystemMessage(const ChatMessage& /*message*/, const std::string& /*id*/, const TimestampBehaviour /*timestampBehaviour*/) {}
+
+ // File transfer related stuff
+ virtual std::string addFileTransfer(const std::string& /*senderName*/, bool /*senderIsSelf*/,const std::string& /*filename*/, const boost::uintmax_t /*sizeInBytes*/, const std::string& /*description*/) { return 0; }
+ virtual void setFileTransferProgress(std::string /*id*/, const int /*alreadyTransferedBytes*/) { }
+ virtual void setFileTransferStatus(std::string /*id*/, const FileTransferState /*state*/, const std::string& /*msg*/) { }
+
+ virtual void setMessageReceiptState(const std::string &/* id */, ReceiptState /* state */) { }
+
+ virtual void setContactChatState(ChatState::ChatStateType /*state*/) {}
+ virtual void setName(const std::string& name) {name_ = name;}
+ virtual void show() {}
+ virtual bool isVisible() const { return true; }
+ virtual void activate() {}
+ virtual void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels) {labels_ = labels;}
+ virtual void setSecurityLabelsEnabled(bool enabled) {labelsEnabled_ = enabled;}
+ virtual void setUnreadMessageCount(int /*count*/) {}
+ virtual void convertToMUC(MUCType /*mucType*/) {}
+ virtual void setSecurityLabelsError() {}
+ virtual SecurityLabelsCatalog::Item getSelectedSecurityLabel() {return label_;}
+ virtual void setOnline(bool /*online*/) {}
+ virtual void setRosterModel(Roster* roster) { roster_ = roster; }
+ Roster* getRosterModel() { return roster_; }
+ virtual void setTabComplete(TabComplete*) {}
+
+ void setAckState(const std::string& /*id*/, AckState /*state*/) {}
+ virtual void flash() {}
+ virtual AlertID addAlert(const std::string& /*alertText*/) { return 0; }
+ virtual void removeAlert(const AlertID /*id*/) {}
+ virtual void setCorrectionEnabled(Tristate /*enabled*/) {}
+ virtual void setFileTransferEnabled(Tristate /*enabled*/) {}
+ void setAvailableOccupantActions(const std::vector<OccupantAction>&/* actions*/) {}
+ void setSubject(const std::string& /*subject*/) {}
+ virtual void showRoomConfigurationForm(Form::ref) {}
+ virtual void addMUCInvitation(const std::string& /*senderName*/, const JID& /*jid*/, const std::string& /*reason*/, const std::string& /*password*/, bool = true, bool = false, bool = false) {}
+
+ virtual std::string addWhiteboardRequest(bool) {return "";}
+ virtual void setWhiteboardSessionStatus(std::string, const ChatWindow::WhiteboardSessionState){}
+
+ virtual void setAffiliations(MUCOccupant::Affiliation, const std::vector<JID>&) {}
+ virtual void setAvailableRoomActions(const std::vector<RoomAction> &) {}
+
+ virtual void setBlockingState(BlockingState) {}
+ virtual void setCanInitiateImpromptuChats(bool supportsImpromptu) {
+ impromptuMUCSupported_ = supportsImpromptu;
+ }
+
+ virtual void showBookmarkWindow(const MUCBookmark& /*bookmark*/) {}
+ virtual void setBookmarkState(RoomBookmarkState) {}
+
+ static std::string bodyFromMessage(const ChatMessage& message) {
+ boost::shared_ptr<ChatTextMessagePart> text;
+ foreach (boost::shared_ptr<ChatMessagePart> part, message.getParts()) {
+ if ((text = boost::dynamic_pointer_cast<ChatTextMessagePart>(part))) {
+ return text->text;
+ }
+ }
+ return "";
+ }
+
+ std::string name_;
+ std::string lastMessageBody_;
+ ChatMessage lastAddedPresence_;
+ ChatMessage lastReplacedMessage_;
+ ChatMessage lastAddedSystemMessage_;
+ std::vector<SecurityLabelsCatalog::Item> labels_;
+ bool labelsEnabled_;
+ bool impromptuMUCSupported_;
+ SecurityLabelsCatalog::Item label_;
+ Roster* roster_;
+ };
}
diff --git a/Swift/Controllers/UnitTest/MockMainWindow.h b/Swift/Controllers/UnitTest/MockMainWindow.h
index af4267f..9177bdc 100644
--- a/Swift/Controllers/UnitTest/MockMainWindow.h
+++ b/Swift/Controllers/UnitTest/MockMainWindow.h
@@ -9,24 +9,24 @@
#include <Swift/Controllers/UIInterfaces/MainWindow.h>
namespace Swift {
- class Roster;
- class MockMainWindow : public MainWindow {
- public:
- MockMainWindow() : roster(NULL) {}
- virtual ~MockMainWindow() {}
- virtual void setRosterModel(Roster* roster) {this->roster = roster;}
- virtual void setMyNick(const std::string& /*name*/) {}
- virtual void setMyJID(const JID& /*jid*/) {}
- virtual void setMyAvatarPath(const std::string& /*path*/) {}
- virtual void setMyStatusText(const std::string& /*status*/) {}
- virtual void setMyStatusType(StatusShow::Type /*type*/) {}
- virtual void setMyContactRosterItem(boost::shared_ptr<ContactRosterItem> /*contact*/) {}
- virtual void setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& /*commands*/) {}
- virtual void setConnecting() {}
- virtual void setStreamEncryptionStatus(bool /*tlsInPlaceAndValid*/) {}
- virtual void openCertificateDialog(const std::vector<Certificate::ref>& /*chain*/) {}
- virtual void setBlockingCommandAvailable(bool /*isAvailable*/) {}
- Roster* roster;
+ class Roster;
+ class MockMainWindow : public MainWindow {
+ public:
+ MockMainWindow() : roster(NULL) {}
+ virtual ~MockMainWindow() {}
+ virtual void setRosterModel(Roster* roster) {this->roster = roster;}
+ virtual void setMyNick(const std::string& /*name*/) {}
+ virtual void setMyJID(const JID& /*jid*/) {}
+ virtual void setMyAvatarPath(const std::string& /*path*/) {}
+ virtual void setMyStatusText(const std::string& /*status*/) {}
+ virtual void setMyStatusType(StatusShow::Type /*type*/) {}
+ virtual void setMyContactRosterItem(boost::shared_ptr<ContactRosterItem> /*contact*/) {}
+ virtual void setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& /*commands*/) {}
+ virtual void setConnecting() {}
+ virtual void setStreamEncryptionStatus(bool /*tlsInPlaceAndValid*/) {}
+ virtual void openCertificateDialog(const std::vector<Certificate::ref>& /*chain*/) {}
+ virtual void setBlockingCommandAvailable(bool /*isAvailable*/) {}
+ Roster* roster;
- };
+ };
}
diff --git a/Swift/Controllers/UnitTest/MockMainWindowFactory.h b/Swift/Controllers/UnitTest/MockMainWindowFactory.h
index 0298bf2..4af0c79 100644
--- a/Swift/Controllers/UnitTest/MockMainWindowFactory.h
+++ b/Swift/Controllers/UnitTest/MockMainWindowFactory.h
@@ -11,18 +11,18 @@
namespace Swift {
- class MockMainWindowFactory : public MainWindowFactory {
- public:
- MockMainWindowFactory() : last(NULL) {}
-
- virtual ~MockMainWindowFactory() {}
-
- /**
- * Transfers ownership of result.
- */
- virtual MainWindow* createMainWindow(UIEventStream*) {last = new MockMainWindow();return last;}
- MockMainWindow* last;
- };
+ class MockMainWindowFactory : public MainWindowFactory {
+ public:
+ MockMainWindowFactory() : last(NULL) {}
+
+ virtual ~MockMainWindowFactory() {}
+
+ /**
+ * Transfers ownership of result.
+ */
+ virtual MainWindow* createMainWindow(UIEventStream*) {last = new MockMainWindow();return last;}
+ MockMainWindow* last;
+ };
}
diff --git a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
index 40530dc..e1284fd 100644
--- a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
+++ b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp
@@ -26,297 +26,297 @@
using namespace Swift;
class PresenceNotifierTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PresenceNotifierTest);
- CPPUNIT_TEST(testReceiveFirstPresenceCreatesAvailableNotification);
- CPPUNIT_TEST(testReceiveSecondPresenceCreatesStatusChangeNotification);
- CPPUNIT_TEST(testReceiveUnavailablePresenceAfterAvailablePresenceCreatesUnavailableNotification);
- CPPUNIT_TEST(testReceiveUnavailablePresenceWithoutAvailableDoesNotCreateNotification);
- CPPUNIT_TEST(testReceiveAvailablePresenceAfterUnavailableCreatesAvailableNotification);
- CPPUNIT_TEST(testReceiveAvailablePresenceAfterReconnectCreatesAvailableNotification);
- CPPUNIT_TEST(testReceiveAvailablePresenceFromMUCDoesNotCreateNotification);
- CPPUNIT_TEST(testNotificationSubjectContainsNameForJIDInRoster);
- CPPUNIT_TEST(testNotificationSubjectContainsJIDForJIDNotInRoster);
- CPPUNIT_TEST(testNotificationSubjectContainsStatus);
- CPPUNIT_TEST(testNotificationMessageContainsStatusMessage);
- CPPUNIT_TEST(testNotificationPicture);
- CPPUNIT_TEST(testNotificationActivationEmitsSignal);
- CPPUNIT_TEST(testReceiveFirstPresenceWithQuietPeriodDoesNotNotify);
- CPPUNIT_TEST(testReceiveFirstPresenceWithQuietPeriodDoesNotCountAsQuietPeriod);
- CPPUNIT_TEST(testReceivePresenceDuringQuietPeriodDoesNotNotify);
- CPPUNIT_TEST(testReceivePresenceDuringQuietPeriodResetsTimer);
- CPPUNIT_TEST(testReceivePresenceAfterQuietPeriodNotifies);
- CPPUNIT_TEST(testReceiveFirstPresenceAfterReconnectWithQuietPeriodDoesNotNotify);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- stanzaChannel = new DummyStanzaChannel();
- notifier = new LoggingNotifier();
- mucRegistry = new MUCRegistry();
- user1 = JID("user1@bar.com/bla");
- user2 = JID("user2@foo.com/baz");
- avatarManager = new DummyAvatarManager();
- roster = new XMPPRosterImpl();
- nickResolver = new NickResolver(JID("foo@bar.com"), roster, NULL, mucRegistry);
- presenceOracle = new PresenceOracle(stanzaChannel, roster);
- timerFactory = new DummyTimerFactory();
- }
-
- void tearDown() {
- delete timerFactory;
- delete presenceOracle;
- delete nickResolver;
- delete roster;
- delete avatarManager;
- delete mucRegistry;
- delete notifier;
- delete stanzaChannel;
- }
-
- void testReceiveFirstPresenceCreatesAvailableNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
-
- sendPresence(user1, StatusShow::Online);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
- }
-
- void testReceiveSecondPresenceCreatesStatusChangeNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
- notifier->notifications.clear();
-
- sendPresence(user1, StatusShow::Online);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(Notifier::ContactStatusChange, notifier->notifications[0].type);
- }
-
- void testReceiveUnavailablePresenceAfterAvailablePresenceCreatesUnavailableNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
- notifier->notifications.clear();
-
- sendUnavailablePresence(user1);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(Notifier::ContactUnavailable, notifier->notifications[0].type);
- }
-
- void testReceiveUnavailablePresenceWithoutAvailableDoesNotCreateNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
-
- sendUnavailablePresence(user1);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
-
- void testReceiveAvailablePresenceAfterUnavailableCreatesAvailableNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
- sendUnavailablePresence(user1);
- notifier->notifications.clear();
-
- sendPresence(user1, StatusShow::Away);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
- }
-
- void testReceiveAvailablePresenceAfterReconnectCreatesAvailableNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
- stanzaChannel->setAvailable(false);
- stanzaChannel->setAvailable(true);
- notifier->notifications.clear();
-
- sendPresence(user1, StatusShow::Away);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
- }
+ CPPUNIT_TEST_SUITE(PresenceNotifierTest);
+ CPPUNIT_TEST(testReceiveFirstPresenceCreatesAvailableNotification);
+ CPPUNIT_TEST(testReceiveSecondPresenceCreatesStatusChangeNotification);
+ CPPUNIT_TEST(testReceiveUnavailablePresenceAfterAvailablePresenceCreatesUnavailableNotification);
+ CPPUNIT_TEST(testReceiveUnavailablePresenceWithoutAvailableDoesNotCreateNotification);
+ CPPUNIT_TEST(testReceiveAvailablePresenceAfterUnavailableCreatesAvailableNotification);
+ CPPUNIT_TEST(testReceiveAvailablePresenceAfterReconnectCreatesAvailableNotification);
+ CPPUNIT_TEST(testReceiveAvailablePresenceFromMUCDoesNotCreateNotification);
+ CPPUNIT_TEST(testNotificationSubjectContainsNameForJIDInRoster);
+ CPPUNIT_TEST(testNotificationSubjectContainsJIDForJIDNotInRoster);
+ CPPUNIT_TEST(testNotificationSubjectContainsStatus);
+ CPPUNIT_TEST(testNotificationMessageContainsStatusMessage);
+ CPPUNIT_TEST(testNotificationPicture);
+ CPPUNIT_TEST(testNotificationActivationEmitsSignal);
+ CPPUNIT_TEST(testReceiveFirstPresenceWithQuietPeriodDoesNotNotify);
+ CPPUNIT_TEST(testReceiveFirstPresenceWithQuietPeriodDoesNotCountAsQuietPeriod);
+ CPPUNIT_TEST(testReceivePresenceDuringQuietPeriodDoesNotNotify);
+ CPPUNIT_TEST(testReceivePresenceDuringQuietPeriodResetsTimer);
+ CPPUNIT_TEST(testReceivePresenceAfterQuietPeriodNotifies);
+ CPPUNIT_TEST(testReceiveFirstPresenceAfterReconnectWithQuietPeriodDoesNotNotify);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ stanzaChannel = new DummyStanzaChannel();
+ notifier = new LoggingNotifier();
+ mucRegistry = new MUCRegistry();
+ user1 = JID("user1@bar.com/bla");
+ user2 = JID("user2@foo.com/baz");
+ avatarManager = new DummyAvatarManager();
+ roster = new XMPPRosterImpl();
+ nickResolver = new NickResolver(JID("foo@bar.com"), roster, NULL, mucRegistry);
+ presenceOracle = new PresenceOracle(stanzaChannel, roster);
+ timerFactory = new DummyTimerFactory();
+ }
+
+ void tearDown() {
+ delete timerFactory;
+ delete presenceOracle;
+ delete nickResolver;
+ delete roster;
+ delete avatarManager;
+ delete mucRegistry;
+ delete notifier;
+ delete stanzaChannel;
+ }
+
+ void testReceiveFirstPresenceCreatesAvailableNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+
+ sendPresence(user1, StatusShow::Online);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
+ }
+
+ void testReceiveSecondPresenceCreatesStatusChangeNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ sendPresence(user1, StatusShow::Away);
+ notifier->notifications.clear();
+
+ sendPresence(user1, StatusShow::Online);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(Notifier::ContactStatusChange, notifier->notifications[0].type);
+ }
+
+ void testReceiveUnavailablePresenceAfterAvailablePresenceCreatesUnavailableNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ sendPresence(user1, StatusShow::Away);
+ notifier->notifications.clear();
+
+ sendUnavailablePresence(user1);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(Notifier::ContactUnavailable, notifier->notifications[0].type);
+ }
+
+ void testReceiveUnavailablePresenceWithoutAvailableDoesNotCreateNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+
+ sendUnavailablePresence(user1);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
+
+ void testReceiveAvailablePresenceAfterUnavailableCreatesAvailableNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ sendPresence(user1, StatusShow::Away);
+ sendUnavailablePresence(user1);
+ notifier->notifications.clear();
+
+ sendPresence(user1, StatusShow::Away);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
+ }
+
+ void testReceiveAvailablePresenceAfterReconnectCreatesAvailableNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ sendPresence(user1, StatusShow::Away);
+ stanzaChannel->setAvailable(false);
+ stanzaChannel->setAvailable(true);
+ notifier->notifications.clear();
+
+ sendPresence(user1, StatusShow::Away);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(Notifier::ContactAvailable, notifier->notifications[0].type);
+ }
- void testReceiveAvailablePresenceFromMUCDoesNotCreateNotification() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- mucRegistry->addMUC(JID("teaparty@wonderland.lit"));
+ void testReceiveAvailablePresenceFromMUCDoesNotCreateNotification() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ mucRegistry->addMUC(JID("teaparty@wonderland.lit"));
- sendPresence(JID("teaparty@wonderland.lit/Alice"), StatusShow::Away);
+ sendPresence(JID("teaparty@wonderland.lit/Alice"), StatusShow::Away);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
- void testNotificationPicture() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- avatarManager->avatars[user1] = createByteArray("abcdef");
+ void testNotificationPicture() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ avatarManager->avatars[user1] = createByteArray("abcdef");
- sendPresence(user1, StatusShow::Online);
+ sendPresence(user1, StatusShow::Online);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT_EQUAL(boost::filesystem::path("/avatars/user1@bar.com/bla"), notifier->notifications[0].picture);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT_EQUAL(boost::filesystem::path("/avatars/user1@bar.com/bla"), notifier->notifications[0].picture);
+ }
- void testNotificationActivationEmitsSignal() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ void testNotificationActivationEmitsSignal() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Online);
- CPPUNIT_ASSERT(notifier->notifications[0].callback);
- notifier->notifications[0].callback();
+ sendPresence(user1, StatusShow::Online);
+ CPPUNIT_ASSERT(notifier->notifications[0].callback);
+ notifier->notifications[0].callback();
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(activatedNotifications.size()));
- CPPUNIT_ASSERT_EQUAL(user1, activatedNotifications[0]);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(activatedNotifications.size()));
+ CPPUNIT_ASSERT_EQUAL(user1, activatedNotifications[0]);
+ }
- void testNotificationSubjectContainsNameForJIDInRoster() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- roster->addContact(user1.toBare(), "User 1", std::vector<std::string>(), RosterItemPayload::Both);
+ void testNotificationSubjectContainsNameForJIDInRoster() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ roster->addContact(user1.toBare(), "User 1", std::vector<std::string>(), RosterItemPayload::Both);
- sendPresence(user1, StatusShow::Online);
+ sendPresence(user1, StatusShow::Online);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- std::string subject = notifier->notifications[0].subject;
- CPPUNIT_ASSERT(subject.find("User 1") != std::string::npos);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ std::string subject = notifier->notifications[0].subject;
+ CPPUNIT_ASSERT(subject.find("User 1") != std::string::npos);
+ }
- void testNotificationSubjectContainsJIDForJIDNotInRoster() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ void testNotificationSubjectContainsJIDForJIDNotInRoster() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Online);
+ sendPresence(user1, StatusShow::Online);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- std::string subject = notifier->notifications[0].subject;
- CPPUNIT_ASSERT(subject.find(user1.toBare().toString()) != std::string::npos);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ std::string subject = notifier->notifications[0].subject;
+ CPPUNIT_ASSERT(subject.find(user1.toBare().toString()) != std::string::npos);
+ }
- void testNotificationSubjectContainsStatus() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ void testNotificationSubjectContainsStatus() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
+ sendPresence(user1, StatusShow::Away);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- std::string subject = notifier->notifications[0].subject;
- CPPUNIT_ASSERT(subject.find("Away") != std::string::npos);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ std::string subject = notifier->notifications[0].subject;
+ CPPUNIT_ASSERT(subject.find("Away") != std::string::npos);
+ }
- void testNotificationMessageContainsStatusMessage() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ void testNotificationMessageContainsStatusMessage() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- sendPresence(user1, StatusShow::Away);
+ sendPresence(user1, StatusShow::Away);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- CPPUNIT_ASSERT(notifier->notifications[0].description.find("Status Message") != std::string::npos);
- }
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ CPPUNIT_ASSERT(notifier->notifications[0].description.find("Status Message") != std::string::npos);
+ }
- void testReceiveFirstPresenceWithQuietPeriodDoesNotNotify() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
+ void testReceiveFirstPresenceWithQuietPeriodDoesNotNotify() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
- sendPresence(user1, StatusShow::Online);
+ sendPresence(user1, StatusShow::Online);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
- void testReceivePresenceDuringQuietPeriodDoesNotNotify() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
+ void testReceivePresenceDuringQuietPeriodDoesNotNotify() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
- sendPresence(user1, StatusShow::Online);
- timerFactory->setTime(1);
- sendPresence(user2, StatusShow::Away);
+ sendPresence(user1, StatusShow::Online);
+ timerFactory->setTime(1);
+ sendPresence(user2, StatusShow::Away);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
- void testReceivePresenceDuringQuietPeriodResetsTimer() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
+ void testReceivePresenceDuringQuietPeriodResetsTimer() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
- sendPresence(user1, StatusShow::Online);
- timerFactory->setTime(9);
- sendPresence(user2, StatusShow::Away);
- timerFactory->setTime(18);
- sendPresence(user1, StatusShow::Away);
+ sendPresence(user1, StatusShow::Online);
+ timerFactory->setTime(9);
+ sendPresence(user2, StatusShow::Away);
+ timerFactory->setTime(18);
+ sendPresence(user1, StatusShow::Away);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
- void testReceivePresenceAfterQuietPeriodNotifies() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
-
- sendPresence(user1, StatusShow::Online);
- timerFactory->setTime(11);
- sendPresence(user2, StatusShow::Away);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
- }
-
- void testReceiveFirstPresenceWithQuietPeriodDoesNotCountAsQuietPeriod() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
-
- timerFactory->setTime(11);
- sendPresence(user1, StatusShow::Away);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
-
- void testReceiveFirstPresenceAfterReconnectWithQuietPeriodDoesNotNotify() {
- boost::shared_ptr<PresenceNotifier> testling = createNotifier();
- testling->setInitialQuietPeriodMS(10);
- sendPresence(user1, StatusShow::Online);
- timerFactory->setTime(15);
- notifier->notifications.clear();
-
- stanzaChannel->setAvailable(false);
- stanzaChannel->setAvailable(true);
- sendPresence(user1, StatusShow::Online);
- timerFactory->setTime(21);
- sendPresence(user2, StatusShow::Online);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
- }
-
-
- private:
- boost::shared_ptr<PresenceNotifier> createNotifier() {
- boost::shared_ptr<PresenceNotifier> result(new PresenceNotifier(stanzaChannel, notifier, mucRegistry, avatarManager, nickResolver, presenceOracle, timerFactory));
- result->onNotificationActivated.connect(boost::bind(&PresenceNotifierTest::handleNotificationActivated, this, _1));
- result->setInitialQuietPeriodMS(0);
- return result;
- }
-
- void sendPresence(const JID& jid, StatusShow::Type type) {
- boost::shared_ptr<Presence> presence(new Presence());
- presence->setFrom(jid);
- presence->setShow(type);
- presence->setStatus("Status Message");
- stanzaChannel->onPresenceReceived(presence);
- }
-
- void sendUnavailablePresence(const JID& jid) {
- boost::shared_ptr<Presence> presence(new Presence());
- presence->setType(Presence::Unavailable);
- presence->setFrom(jid);
- stanzaChannel->onPresenceReceived(presence);
- }
-
- void handleNotificationActivated(const JID& j) {
- activatedNotifications.push_back(j);
- }
-
- private:
- DummyStanzaChannel* stanzaChannel;
- LoggingNotifier* notifier;
- MUCRegistry* mucRegistry;
- DummyAvatarManager* avatarManager;
- XMPPRosterImpl* roster;
- NickResolver* nickResolver;
- PresenceOracle* presenceOracle;
- DummyTimerFactory* timerFactory;
- JID user1;
- JID user2;
- std::vector<JID> activatedNotifications;
+ void testReceivePresenceAfterQuietPeriodNotifies() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
+
+ sendPresence(user1, StatusShow::Online);
+ timerFactory->setTime(11);
+ sendPresence(user2, StatusShow::Away);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size()));
+ }
+
+ void testReceiveFirstPresenceWithQuietPeriodDoesNotCountAsQuietPeriod() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
+
+ timerFactory->setTime(11);
+ sendPresence(user1, StatusShow::Away);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
+
+ void testReceiveFirstPresenceAfterReconnectWithQuietPeriodDoesNotNotify() {
+ boost::shared_ptr<PresenceNotifier> testling = createNotifier();
+ testling->setInitialQuietPeriodMS(10);
+ sendPresence(user1, StatusShow::Online);
+ timerFactory->setTime(15);
+ notifier->notifications.clear();
+
+ stanzaChannel->setAvailable(false);
+ stanzaChannel->setAvailable(true);
+ sendPresence(user1, StatusShow::Online);
+ timerFactory->setTime(21);
+ sendPresence(user2, StatusShow::Online);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(notifier->notifications.size()));
+ }
+
+
+ private:
+ boost::shared_ptr<PresenceNotifier> createNotifier() {
+ boost::shared_ptr<PresenceNotifier> result(new PresenceNotifier(stanzaChannel, notifier, mucRegistry, avatarManager, nickResolver, presenceOracle, timerFactory));
+ result->onNotificationActivated.connect(boost::bind(&PresenceNotifierTest::handleNotificationActivated, this, _1));
+ result->setInitialQuietPeriodMS(0);
+ return result;
+ }
+
+ void sendPresence(const JID& jid, StatusShow::Type type) {
+ boost::shared_ptr<Presence> presence(new Presence());
+ presence->setFrom(jid);
+ presence->setShow(type);
+ presence->setStatus("Status Message");
+ stanzaChannel->onPresenceReceived(presence);
+ }
+
+ void sendUnavailablePresence(const JID& jid) {
+ boost::shared_ptr<Presence> presence(new Presence());
+ presence->setType(Presence::Unavailable);
+ presence->setFrom(jid);
+ stanzaChannel->onPresenceReceived(presence);
+ }
+
+ void handleNotificationActivated(const JID& j) {
+ activatedNotifications.push_back(j);
+ }
+
+ private:
+ DummyStanzaChannel* stanzaChannel;
+ LoggingNotifier* notifier;
+ MUCRegistry* mucRegistry;
+ DummyAvatarManager* avatarManager;
+ XMPPRosterImpl* roster;
+ NickResolver* nickResolver;
+ PresenceOracle* presenceOracle;
+ DummyTimerFactory* timerFactory;
+ JID user1;
+ JID user2;
+ std::vector<JID> activatedNotifications;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PresenceNotifierTest);
diff --git a/Swift/Controllers/UnitTest/PreviousStatusStoreTest.cpp b/Swift/Controllers/UnitTest/PreviousStatusStoreTest.cpp
index 266cd64..be35468 100644
--- a/Swift/Controllers/UnitTest/PreviousStatusStoreTest.cpp
+++ b/Swift/Controllers/UnitTest/PreviousStatusStoreTest.cpp
@@ -12,33 +12,33 @@
using namespace Swift;
class PreviousStatusStoreTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PreviousStatusStoreTest);
- CPPUNIT_TEST(testGetAll);
- //CPPUNIT_TEST(testGetAllLimited);
- //CPPUNIT_TEST(testGetSuggestionsInexact);
- //CPPUNIT_TEST(testGetSuggestionsExact);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PreviousStatusStoreTest);
+ CPPUNIT_TEST(testGetAll);
+ //CPPUNIT_TEST(testGetAllLimited);
+ //CPPUNIT_TEST(testGetSuggestionsInexact);
+ //CPPUNIT_TEST(testGetSuggestionsExact);
+ CPPUNIT_TEST_SUITE_END();
public:
- void setUp() {
- store_ = new PreviousStatusStore();
- store_->addStatus(StatusShow::Online, "At home in the study");
- store_->addStatus(StatusShow::DND, "In a meeting");
- store_->addStatus(StatusShow::DND, "With a client");
- store_->addStatus(StatusShow::Away, "Walking the elephant");
- store_->addStatus(StatusShow::Online, "In the office, at my desk");
- }
+ void setUp() {
+ store_ = new PreviousStatusStore();
+ store_->addStatus(StatusShow::Online, "At home in the study");
+ store_->addStatus(StatusShow::DND, "In a meeting");
+ store_->addStatus(StatusShow::DND, "With a client");
+ store_->addStatus(StatusShow::Away, "Walking the elephant");
+ store_->addStatus(StatusShow::Online, "In the office, at my desk");
+ }
- void tearDown() {
- delete store_;
- }
+ void tearDown() {
+ delete store_;
+ }
- void testGetAll() {
+ void testGetAll() {
- }
+ }
private:
- PreviousStatusStore* store_;
+ PreviousStatusStore* store_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PreviousStatusStoreTest);