[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:21:57 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=d361b0c
The following commit has been merged in the master branch:
commit d361b0c226be1f617c09f2f40d3cb82aa5939467
Author: Lasath Fernando <kde at lasath.org>
Date: Tue May 1 16:00:04 2012 +1000
Add series of tests for UrlFilter
UrlFilter is still hardcoded in lib.
It will be moved in a later
commit, but since it's currently candidate to be replaced by
some code in ktp-common-internals, I want to make sure there's
an extensive set of tests first.
---
lib/message-processor.cpp | 2 +-
tests/message-processor-basic-tests.cpp | 64 +++++++++++++++++++++++++++++----
tests/message-processor-basic-tests.h | 6 ++++
tests/sync-processor.cpp | 9 +++++
tests/sync-processor.h | 1 +
5 files changed, 75 insertions(+), 7 deletions(-)
diff --git a/lib/message-processor.cpp b/lib/message-processor.cpp
index 8fbd4e2..6d5b078 100644
--- a/lib/message-processor.cpp
+++ b/lib/message-processor.cpp
@@ -48,8 +48,8 @@ MessageProcessor* MessageProcessor::instance()
MessageProcessor::MessageProcessor()
{
- m_filters << new UrlFilter(this);
loadAllPlugins();
+ m_filters << new UrlFilter(this);
}
diff --git a/tests/message-processor-basic-tests.cpp b/tests/message-processor-basic-tests.cpp
index 4e20656..4d15f10 100644
--- a/tests/message-processor-basic-tests.cpp
+++ b/tests/message-processor-basic-tests.cpp
@@ -17,6 +17,7 @@
*/
#include "message-processor-basic-tests.h"
+#include <KUrl>
Tp::Message normalMessage(const char* msg) {
return Tp::Message(Tp::ChannelTextMessageTypeNormal, QLatin1String(msg));
@@ -24,17 +25,68 @@ Tp::Message normalMessage(const char* msg) {
void MessageProcessorBasicTests::testEmoticons()
{
- QLatin1String smiley(":)");
- QLatin1String expected("<img align=\"center\" title=\":)\" alt=\":)\" src=\"/usr/share/emoticons/kde4/smile.png\" width=\"22\" height=\"22\" />
");
+ QString processed = this->s.getProcessedMessage(":)");
+ QString expected = QLatin1String("<img align=\"center\" title=\":)\" alt=\":)\" src=\"/usr/share/emoticons/kde4/smile.png\" width=\"22\" height=\"22\" />");
- QCOMPARE(s.processOutGoingMessage(Tp::Message(Tp::ChannelTextMessageTypeNormal, smiley)).finalizedMessage(), expected);
+ QCOMPARE(processed, expected);
}
void MessageProcessorBasicTests::testEscaping()
{
- Tp::Message msg = normalMessage("<script type=\"text/javascript>
alert(\"ha!\");
</script>");
- QString expected = QLatin1String("<script type="text/javascript><br/>alert("ha!");<br/></script>
");
- QCOMPARE(s.processOutGoingMessage(msg).finalizedMessage(), expected);
+ QString processed = this->s.getProcessedMessage("<script type=\"text/javascript>
alert(\"ha!\");
</script>");
+ QString expected = QLatin1String("<script type="text/javascript><br/>alert("ha!");<br/></script>");
+
+ QCOMPARE(processed, expected);
+}
+
+void MessageProcessorBasicTests::testUrlCatching()
+{
+ QString processed = this->s.getProcessedMessage("http://www.google.com.au/");
+ QString href = QLatin1String("<a href='http://www.google.com.au/'>http://www.google.com.au/</a>");
+
+ QCOMPARE(processed, href);
+}
+
+void MessageProcessorBasicTests::testURICatchingSMB() {
+ QString processed = this->s.getProcessedMessage("smb://user@localhost/");
+ QString href = QLatin1String("<a href='smb://user@localhost/'>smb://user@localhost/</a>");
+
+ QCOMPARE(processed, href);
+}
+
+void MessageProcessorBasicTests::testWWWCatching() {
+ QString processed = this->s.getProcessedMessage("www.google.com.au");
+ QString href = QLatin1String("<a href='http://www.google.com.au'>www.google.com.au</a>");
+
+ QCOMPARE(processed, href);
+}
+
+void MessageProcessorBasicTests::testUnsupportedProtocolCatching()
+{
+ QString processed = this->s.getProcessedMessage("fakeprotocol://fakeuser@somefakehost/");
+ QString href = QLatin1String("fakeprotocol://fakeuser@somefakehost/");
+
+ QCOMPARE(processed, href);
+}
+
+void MessageProcessorBasicTests::testMetadataGeneration()
+{
+ Message processed = this->s.processOutGoingMessage(
+ Tp::Message(
+ Tp::ChannelTextMessageTypeNormal,
+ QLatin1String("http://www.google.com.au/")
+ )
+ );
+
+ QVariantList urls = processed.property("Urls").toList();
+ QCOMPARE(urls.length(), 1);
+
+ QCOMPARE(qvariant_cast<KUrl>(urls.at(0)), KUrl("http://www.google.com.au/"));
+}
+
+void MessageProcessorBasicTests::testMultipleURLCatching()
+{
+ QFAIL("not written yet");
}
QTEST_MAIN(MessageProcessorBasicTests);
diff --git a/tests/message-processor-basic-tests.h b/tests/message-processor-basic-tests.h
index 20fc284..d739599 100644
--- a/tests/message-processor-basic-tests.h
+++ b/tests/message-processor-basic-tests.h
@@ -33,6 +33,12 @@ private:
private Q_SLOTS:
void testEmoticons();
void testEscaping();
+ void testUrlCatching();
+ void testWWWCatching();
+ void testURICatchingSMB();
+ void testUnsupportedProtocolCatching();
+ void testMetadataGeneration();
+ void testMultipleURLCatching();
};
#endif // MESSAGE_PROCESSOR_BASIC_TESTS_H
diff --git a/tests/sync-processor.cpp b/tests/sync-processor.cpp
index e7eb2dd..4798a39 100644
--- a/tests/sync-processor.cpp
+++ b/tests/sync-processor.cpp
@@ -19,6 +19,8 @@
#include "sync-processor.h"
#include <message-processor.h>
+#include <QString>
+
SyncProcessor::SyncProcessor()
{
this->instance = MessageProcessor::instance();
@@ -33,3 +35,10 @@ Message SyncProcessor::processOutGoingMessage(Tp::Message message)
{
return this->instance->processOutgoingMessage(message);
}
+
+QString SyncProcessor::getProcessedMessage(const char* contents)
+{
+ Tp::Message message = Tp::Message(Tp::ChannelTextMessageTypeNormal, QLatin1String(contents));
+ QString processed = processOutGoingMessage(message).finalizedMessage();
+ return processed.trimmed();
+}
\ No newline at end of file
diff --git a/tests/sync-processor.h b/tests/sync-processor.h
index c433d7b..6fd55d9 100644
--- a/tests/sync-processor.h
+++ b/tests/sync-processor.h
@@ -29,6 +29,7 @@ public:
Message processIncommingMessage(const Tp::ReceivedMessage& message);
Message processOutGoingMessage ( Tp::Message message );
+ QString getProcessedMessage ( const char* contents );
private:
MessageProcessor *instance;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list