summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/tests
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/libkopete/tests
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/libkopete/tests')
-rw-r--r--kopete/libkopete/tests/Makefile.am41
-rw-r--r--kopete/libkopete/tests/README47
-rwxr-xr-xkopete/libkopete/tests/create_test.rb56
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-1.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-1.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-10.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-10.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-2.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-2.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-3.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-3.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-4.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-4.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-5.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-5.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-6.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-6.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-7.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-7.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-8.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-8.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-9.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/broken-9.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-1.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-1.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-2.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-2.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-3.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-3.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-4.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-4.output1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-5.input1
-rw-r--r--kopete/libkopete/tests/emoticon-parser-testcases/working-5.output1
-rw-r--r--kopete/libkopete/tests/kopetecontactlist_test.cpp55
-rw-r--r--kopete/libkopete/tests/kopetecontactlist_test.h35
-rw-r--r--kopete/libkopete/tests/kopeteemoticontest.cpp132
-rw-r--r--kopete/libkopete/tests/kopeteemoticontest.h39
-rw-r--r--kopete/libkopete/tests/kopetemessage.xsd180
-rw-r--r--kopete/libkopete/tests/kopetemessage_test.cpp324
-rw-r--r--kopete/libkopete/tests/kopetemessage_test.h56
-rw-r--r--kopete/libkopete/tests/kopetepasswordtest_program.cpp132
-rw-r--r--kopete/libkopete/tests/kopetepasswordtest_program.h16
-rw-r--r--kopete/libkopete/tests/kopetepropertiestest.cpp59
-rw-r--r--kopete/libkopete/tests/kopetepropertiestest.h36
-rw-r--r--kopete/libkopete/tests/kopetewallettest_program.cpp98
-rw-r--r--kopete/libkopete/tests/kopetewallettest_program.h17
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/broken-html-1.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/broken-html-1.output1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-html-1.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-html-1.output1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-html-2.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-html-2.output1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.output1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.output1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.input1
-rw-r--r--kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.output1
-rw-r--r--kopete/libkopete/tests/mock/Makefile.am14
-rw-r--r--kopete/libkopete/tests/mock/kopeteaccount_mock.cpp61
-rw-r--r--kopete/libkopete/tests/mock/kopeteaccount_mock.h54
-rw-r--r--kopete/libkopete/tests/mock/kopetecontact_mock.cpp44
-rw-r--r--kopete/libkopete/tests/mock/kopetecontact_mock.h49
-rw-r--r--kopete/libkopete/tests/mock/kopetemessage_mock.cpp20
-rw-r--r--kopete/libkopete/tests/mock/kopetemessage_mock.h39
-rw-r--r--kopete/libkopete/tests/mock/kopetemetacontact_mock.cpp20
-rw-r--r--kopete/libkopete/tests/mock/kopetemetacontact_mock.h41
-rw-r--r--kopete/libkopete/tests/mock/kopeteprotocol_mock.cpp49
-rw-r--r--kopete/libkopete/tests/mock/kopeteprotocol_mock.h53
-rw-r--r--kopete/libkopete/tests/template_test.cpp37
-rw-r--r--kopete/libkopete/tests/template_test.h35
71 files changed, 1881 insertions, 0 deletions
diff --git a/kopete/libkopete/tests/Makefile.am b/kopete/libkopete/tests/Makefile.am
new file mode 100644
index 00000000..417ce2a8
--- /dev/null
+++ b/kopete/libkopete/tests/Makefile.am
@@ -0,0 +1,41 @@
+SUBDIRS = mock .
+AM_CPPFLAGS = -DKDE_NO_COMPAT -DQT_NO_ASCII_CAST -DQT_NO_COMPAT \
+ $(KOPETE_INCLUDES) -I$(top_srcdir)/kopete/libkopete/private -I$(top_srcdir)/kopete/libkopete/private -I$(top_srcdir)/kopete/libkopete/tests/mock $(all_includes) -DSRCDIR=\"$(top_srcdir)/kopete/libkopete/tests\"
+METASOURCES = AUTO
+
+check_LTLIBRARIES = kunittest_kopetemessage_test.la kunittest_kopetepropertiestest.la kunittest_kopetecontactlist_test.la
+noinst_LTLIBRARIES = kunittest_kopeteemoticontest.la
+
+check_PROGRAMS = kopetewallettest_program kopetepasswordtest_program
+
+kunittest_kopetepropertiestest_la_SOURCES = kopetepropertiestest.cpp ../kopeteproperties.cpp
+kunittest_kopetepropertiestest_la_LIBADD = -lkunittest ../libkopete.la
+kunittest_kopetepropertiestest_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+kunittest_kopeteemoticontest_la_SOURCES = kopeteemoticontest.cpp
+kunittest_kopeteemoticontest_la_LIBADD = -lkunittest ../libkopete.la
+kunittest_kopeteemoticontest_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+kunittest_kopetemessage_test_la_SOURCES = kopetemessage_test.cpp
+kunittest_kopetemessage_test_la_LIBADD = -lkunittest mock/libkopete_mock.la
+kunittest_kopetemessage_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+kopetewallettest_program_SOURCES = kopetewallettest_program.cpp
+kopetewallettest_program_LDFLAGS = -no-undefined $(all_libraries) $(KDE_RPATH)
+kopetewallettest_program_LDADD = ../libkopete.la
+
+kopetepasswordtest_program_SOURCES = kopetepasswordtest_program.cpp
+kopetepasswordtest_program_LDFLAGS = -no-undefined $(all_libraries) $(KDE_RPATH)
+kopetepasswordtest_program_LDADD = ../libkopete.la
+
+kunittest_kopetecontactlist_test_la_SOURCES = kopetecontactlist_test.cpp
+kunittest_kopetecontactlist_test_la_LIBADD = -lkunittest mock/libkopete_mock.la
+kunittest_kopetecontactlist_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+noinst_HEADERS = kopetepropertiestest.h kopeteemoticontest.h
+
+check-local:
+ kunittestmodrunner
+guicheck:
+ kunittestmod $(PWD)
+
diff --git a/kopete/libkopete/tests/README b/kopete/libkopete/tests/README
new file mode 100644
index 00000000..ead9fbdc
--- /dev/null
+++ b/kopete/libkopete/tests/README
@@ -0,0 +1,47 @@
+LibKopete Unit Tests
+====================
+
+KopeteSuite:
+--------------
+Emoticon Test
+Link Test
+Property Test
+
+Test Programs:
+--------------
+Password Test Program
+Wallet Test Program
+
+
+HOWTO Run
+=========
+
+You can use the console or the GUI version:
+
+ $ make guicheck
+ $ make check
+
+The 'silent' switch in make is useful to reduce output:
+
+ $ make check -s
+
+
+Tricks
+======
+
+Accessing private data?, you should not. We will kill you.
+If it is really required, do something like:
+
+ #define private public
+ #include "kopetemessage.h"
+ #undef private
+
+Add a new test quickly:
+
+ $ ./create_test.rb Kopete::ContactList
+ Creating test for class Kopete::ContactList
+ kopetecontactlist_test.h and kopetecontactlist_test.cpp writen.
+ Please add the following to Makefile.am:
+ kunittest_kopetecontactlist_test_la_SOURCES = kopetecontactlist_test.cpp
+ kunittest_kopetecontactlist_test_la_LIBADD = -lkunittest ../mock/libkopete_mock.la
+ kunittest_kopetecontactlist_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
diff --git a/kopete/libkopete/tests/create_test.rb b/kopete/libkopete/tests/create_test.rb
new file mode 100755
index 00000000..7951bf35
--- /dev/null
+++ b/kopete/libkopete/tests/create_test.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/ruby
+#
+# Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+#
+# Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+#
+# *************************************************************************
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU General Public License as published by *
+# * the Free Software Foundation; either version 2 of the License, or *
+# * (at your option) any later version. *
+# * *
+# *************************************************************************
+
+className = ARGV[0]
+
+if className.nil?
+ puts "Need a class name"
+ exit
+end
+
+puts "Creating test for class #{className}"
+
+hBase = "template_test.h"
+cppBase = "template_test.cpp"
+
+fileH = File.new(hBase).read
+fileCpp = File.new(cppBase).read
+
+fileH.gsub!(/TEMPLATE/, className.upcase.gsub(/::/,""))
+fileH.gsub!(/Template/, className.gsub(/::/,""))
+fileH.gsub!(/some requirement/, className + " class.")
+
+fileCpp.gsub!(/TEMPLATE/, className.upcase.gsub(/::/,""))
+fileCpp.gsub!(/template/, className.downcase.gsub(/::/,""))
+fileCpp.gsub!(/Template/, className.gsub(/::/,""))
+fileCpp.gsub!(/some requirement/, className + " class.")
+
+makefileAm = "kunittest_template_test_la_SOURCES = template_test.cpp\nkunittest_template_test_la_LIBADD = -lkunittest ../mock/libkopete_mock.la\nkunittest_template_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)\n"
+makefileAm.gsub!(/template/, className.downcase.gsub(/::/,""))
+
+hNew = hBase.gsub(/template/, className.downcase.gsub(/::/,""))
+cppNew = cppBase.gsub(/template/, className.downcase.gsub(/::/,""))
+
+hOut = File.new(hNew, "w")
+cppOut = File.new(cppNew, "w")
+
+hOut.write(fileH)
+cppOut.write(fileCpp)
+
+puts "#{hNew} and #{cppNew} writen."
+
+puts "Please add the following to Makefile.am:"
+puts makefileAm
+
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.input
new file mode 100644
index 00000000..795d3c7b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.input
@@ -0,0 +1 @@
+:)) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.output
new file mode 100644
index 00000000..795d3c7b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-1.output
@@ -0,0 +1 @@
+:)) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.input
new file mode 100644
index 00000000..6ddd0c7f
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.input
@@ -0,0 +1 @@
+:Ptesting:P \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.output
new file mode 100644
index 00000000..6ddd0c7f
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-10.output
@@ -0,0 +1 @@
+:Ptesting:P \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.input
new file mode 100644
index 00000000..2571b163
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.input
@@ -0,0 +1 @@
+In a sentence:practical example \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.output
new file mode 100644
index 00000000..2571b163
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-2.output
@@ -0,0 +1 @@
+In a sentence:practical example \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.input
new file mode 100644
index 00000000..2319ced9
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.input
@@ -0,0 +1 @@
+Bla (&nbsp;) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.output
new file mode 100644
index 00000000..2319ced9
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-3.output
@@ -0,0 +1 @@
+Bla (&nbsp;) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.input
new file mode 100644
index 00000000..f5d88878
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.input
@@ -0,0 +1 @@
+:D and :-D are not the same as :d and :-d \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.output
new file mode 100644
index 00000000..0d94eb97
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-4.output
@@ -0,0 +1 @@
+<img align="center" width="20" height="20" src="teeth.png" title=":D"/> and <img align="center" width="20" height="20" src="teeth.png" title=":-D"/> are not the same as :d and :-d \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.input
new file mode 100644
index 00000000..5b39691b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.input
@@ -0,0 +1 @@
+4d:D>:)F:/&gt;:-(:Pu:d9 \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.output
new file mode 100644
index 00000000..5b39691b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-5.output
@@ -0,0 +1 @@
+4d:D>:)F:/&gt;:-(:Pu:d9 \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.input
new file mode 100644
index 00000000..379e01a1
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.input
@@ -0,0 +1 @@
+&lt;::pvar:: test=1&gt; \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.output
new file mode 100644
index 00000000..379e01a1
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-6.output
@@ -0,0 +1 @@
+&lt;::pvar:: test=1&gt; \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.input
new file mode 100644
index 00000000..d6e7e6c0
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.input
@@ -0,0 +1 @@
+a non-breaking space (&nbsp;) character \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.output
new file mode 100644
index 00000000..d6e7e6c0
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-7.output
@@ -0,0 +1 @@
+a non-breaking space (&nbsp;) character \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.input
new file mode 100644
index 00000000..a3734027
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.input
@@ -0,0 +1 @@
+-+-[-:-(-:-)-:-]-+- \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.output
new file mode 100644
index 00000000..a3734027
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-8.output
@@ -0,0 +1 @@
+-+-[-:-(-:-)-:-]-+- \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.input b/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.input
new file mode 100644
index 00000000..538c5b0b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.input
@@ -0,0 +1 @@
+::shrugs:: \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.output b/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.output
new file mode 100644
index 00000000..538c5b0b
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/broken-9.output
@@ -0,0 +1 @@
+::shrugs:: \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-1.input b/kopete/libkopete/tests/emoticon-parser-testcases/working-1.input
new file mode 100644
index 00000000..a5440d64
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-1.input
@@ -0,0 +1 @@
+:):) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-1.output b/kopete/libkopete/tests/emoticon-parser-testcases/working-1.output
new file mode 100644
index 00000000..a7c018d4
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-1.output
@@ -0,0 +1 @@
+<img align="center" width="20" height="20" src="smile.png" title=":)"/><img align="center" width="20" height="20" src="smile.png" title=":)"/> \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-2.input b/kopete/libkopete/tests/emoticon-parser-testcases/working-2.input
new file mode 100644
index 00000000..223ce5be
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-2.input
@@ -0,0 +1 @@
+<img src="..." title=":-)" /> \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-2.output b/kopete/libkopete/tests/emoticon-parser-testcases/working-2.output
new file mode 100644
index 00000000..223ce5be
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-2.output
@@ -0,0 +1 @@
+<img src="..." title=":-)" /> \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-3.input b/kopete/libkopete/tests/emoticon-parser-testcases/working-3.input
new file mode 100644
index 00000000..d685c091
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-3.input
@@ -0,0 +1 @@
+End of sentence:p \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-3.output b/kopete/libkopete/tests/emoticon-parser-testcases/working-3.output
new file mode 100644
index 00000000..013515be
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-3.output
@@ -0,0 +1 @@
+End of sentence<img align="center" width="20" height="20" src="tongue.png" title=":p"/> \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-4.input b/kopete/libkopete/tests/emoticon-parser-testcases/working-4.input
new file mode 100644
index 00000000..093690c4
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-4.input
@@ -0,0 +1 @@
+http://www.kde.org \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-4.output b/kopete/libkopete/tests/emoticon-parser-testcases/working-4.output
new file mode 100644
index 00000000..093690c4
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-4.output
@@ -0,0 +1 @@
+http://www.kde.org \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-5.input b/kopete/libkopete/tests/emoticon-parser-testcases/working-5.input
new file mode 100644
index 00000000..1e3caf28
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-5.input
@@ -0,0 +1 @@
+&gt;:-) \ No newline at end of file
diff --git a/kopete/libkopete/tests/emoticon-parser-testcases/working-5.output b/kopete/libkopete/tests/emoticon-parser-testcases/working-5.output
new file mode 100644
index 00000000..3b1d4c31
--- /dev/null
+++ b/kopete/libkopete/tests/emoticon-parser-testcases/working-5.output
@@ -0,0 +1 @@
+<img align="center" width="20" height="20" src="devil.png" title="&gt;:-)"/> \ No newline at end of file
diff --git a/kopete/libkopete/tests/kopetecontactlist_test.cpp b/kopete/libkopete/tests/kopetecontactlist_test.cpp
new file mode 100644
index 00000000..001f3f0d
--- /dev/null
+++ b/kopete/libkopete/tests/kopetecontactlist_test.cpp
@@ -0,0 +1,55 @@
+/*
+ Tests for Kopete::ContactList class.
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qfile.h>
+#include <qdir.h>
+#include <kstandarddirs.h>
+#include <kunittest/module.h>
+#include "kopetecontactlist_test.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kopetecontactlist_test, "KopeteSuite");
+KUNITTEST_MODULE_REGISTER_TESTER( KopeteContactList_Test );
+
+void KopeteContactList_Test::allTests()
+{
+ testSomething();
+}
+
+void KopeteContactList_Test::testSomething()
+{
+ // change user data dir to avoid messing with user's .kde dir
+ setenv( "KDEHOME", QFile::encodeName( QDir::homeDirPath() + "/.kopete-unittest" ), true );
+
+ QString filename = locateLocal( "appdata", QString::fromLatin1( "contactlist.xml" ) );
+ if( ! filename.isEmpty() )
+ {
+ // previous test run, delete the previous contact list
+ bool removed = QFile::remove(filename);
+ // if we cant remove the file, abort test
+ if (!removed)
+ return;
+ }
+
+ int result = 1;
+ int expected = 1;
+ // result should be the expected one
+ CHECK(result, expected);
+}
+
+
diff --git a/kopete/libkopete/tests/kopetecontactlist_test.h b/kopete/libkopete/tests/kopetecontactlist_test.h
new file mode 100644
index 00000000..faab1e48
--- /dev/null
+++ b/kopete/libkopete/tests/kopetecontactlist_test.h
@@ -0,0 +1,35 @@
+/*
+ Tests for Kopete::ContactList class.
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef KOPETECONTACTLIST_TEST_H
+#define KOPETECONTACTLIST_TEST_H
+
+#include <kunittest/tester.h>
+
+// change to SlotTester when it works
+class KopeteContactList_Test : public KUnitTest::Tester
+{
+public:
+ void allTests();
+public slots:
+ void testSomething();
+private:
+
+};
+
+#endif
+
diff --git a/kopete/libkopete/tests/kopeteemoticontest.cpp b/kopete/libkopete/tests/kopeteemoticontest.cpp
new file mode 100644
index 00000000..e9a81c1d
--- /dev/null
+++ b/kopete/libkopete/tests/kopeteemoticontest.cpp
@@ -0,0 +1,132 @@
+/*
+ Tests for Kopete::Message::parseEmoticons
+
+ Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <stdlib.h>
+
+#include <qstring.h>
+#include <qdir.h>
+#include <qfile.h>
+
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+
+#include <kunittest/module.h>
+#include "kopeteemoticontest.h"
+#include "kopetemessage.h"
+#include "kopeteemoticons.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kopeteemoticontest, "KopeteSuite");
+KUNITTEST_MODULE_REGISTER_TESTER( KopeteEmoticonTest );
+
+/*
+ There are three sets of tests, the Kopete 0.7 baseline with tests that were
+ working properly in Kopete 0.7.x. When these fail it's a real regression.
+
+ The second set are those known to work in the current codebase.
+ The last set is the set with tests that are known to fail right now.
+
+ the name convention is working|broken-number.input|output
+*/
+
+
+void KopeteEmoticonTest::allTests()
+{
+ // change user data dir to avoid messing with user's .kde dir
+ setenv( "KDEHOME", QFile::encodeName( QDir::homeDirPath() + "/.kopete-unittest" ), true );
+
+ //KApplication::disableAutoDcopRegistration();
+ //KApplication app;
+
+ testEmoticonParser();
+}
+
+void KopeteEmoticonTest::testEmoticonParser()
+{
+ Kopete::Emoticons emo("Default");
+ QString basePath = QString::fromLatin1( SRCDIR ) + QString::fromLatin1("/emoticon-parser-testcases");
+ QDir testCasesDir(basePath);
+
+ QStringList inputFileNames = testCasesDir.entryList("*.input");
+ for ( QStringList::ConstIterator it = inputFileNames.begin(); it != inputFileNames.end(); ++it)
+ {
+ QString fileName = *it;
+ kdDebug() << "testcase: " << fileName << endl;
+ QString outputFileName = fileName;
+ outputFileName.replace("input","output");
+ // open the input file
+ QFile inputFile(basePath + QString::fromLatin1("/") + fileName);
+ QFile expectedFile(basePath + QString::fromLatin1("/") + outputFileName);
+ // check if the expected output file exists
+ // if it doesn't, skip the testcase
+ if ( ! expectedFile.exists() )
+ {
+ SKIP("Warning! expected output for testcase "+ *it + " not found. Skiping testcase");
+ continue;
+ }
+ if ( inputFile.open( IO_ReadOnly ) && expectedFile.open( IO_ReadOnly ))
+ {
+ QTextStream inputStream(&inputFile);
+ QTextStream expectedStream(&expectedFile);
+ QString inputData;
+ QString expectedData;
+ inputData = inputStream.read();
+ expectedData = expectedStream.read();
+
+ inputFile.close();
+ expectedFile.close();
+
+ QString path = KGlobal::dirs()->findResource( "emoticons", "Default/smile.png" ).replace( "smile.png", QString::null );
+
+ Kopete::Emoticons::self();
+ QString result = emo.parse( inputData ).replace( path, QString::null );
+
+ // HACK to know the test case we applied, concatenate testcase name to both
+ // input and expected string. WIll remove when I can add some sort of metadata
+ // to a CHECK so debug its origin testcase
+ result = fileName + QString::fromLatin1(": ") + result;
+ expectedData = fileName + QString::fromLatin1(": ") + expectedData;
+ // if the test case begins with broken, we expect it to fail, then use XFAIL
+ // otherwise use CHECK
+ if ( fileName.section("-", 0, 0) == QString::fromLatin1("broken") )
+ {
+ kdDebug() << "checking known-broken testcase: " << fileName << endl;
+ XFAIL(result, expectedData);
+ }
+ else
+ {
+ kdDebug() << "checking known-working testcase: " << fileName << endl;
+ CHECK(result, expectedData);
+ }
+ }
+ else
+ {
+ SKIP("Warning! can't open testcase files for "+ *it + ". Skiping testcase");
+ continue;
+ }
+ }
+
+}
+
+
+
+
+ \ No newline at end of file
diff --git a/kopete/libkopete/tests/kopeteemoticontest.h b/kopete/libkopete/tests/kopeteemoticontest.h
new file mode 100644
index 00000000..a885b2c4
--- /dev/null
+++ b/kopete/libkopete/tests/kopeteemoticontest.h
@@ -0,0 +1,39 @@
+/*
+ Tests for Kopete::Message::parseEmoticons
+
+ Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef KOPETE_EMOTICON_TEST_H
+#define KOPETE_EMOTICON_TEST_H
+
+#include <kunittest/tester.h>
+
+// change to SlotTester when it works
+class KopeteEmoticonTest : public KUnitTest::Tester
+{
+public:
+ //KopeteLinkTest();
+ //~KopeteLinkTest();
+ void allTests();
+public slots:
+ void testEmoticonParser();
+private:
+
+};
+
+#endif
+
+
diff --git a/kopete/libkopete/tests/kopetemessage.xsd b/kopete/libkopete/tests/kopetemessage.xsd
new file mode 100644
index 00000000..69f99d20
--- /dev/null
+++ b/kopete/libkopete/tests/kopetemessage.xsd
@@ -0,0 +1,180 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ <![CDATA[
+ This is the XSD schema of a Kopete message in XML form. This is both the
+ format that the XSL stylesheets will expect, as well as the format that
+ results from saving the chatwindow contents. This is *not* the same as
+ the format of the history plugin.
+
+ The XML format has one other little quirk - you can pass flags into the
+ engine as XML processing instructions. For example, if you add this
+ instruction to your document:
+
+ <?Kopete Flag:TransformAllMessages>
+
+ ... it will instruct the Kopete XSL engine that you want the entire contents
+ of the chat window to be re-drawn each time a new message is appended. This
+ is not the normal procedure, and is only required for special situations
+ (see the Adium style for an example).
+
+ TransformAllMessages is the only flag currently defined.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <!-- This is defined if we save a chat with multiple messages -->
+ <xsd:element name="document">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="message" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- The main message element -->
+ <xsd:element name="message">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="from" type="metaContact" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="to" type="metaContact" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="body" type="messageBody" minOccurs="1" maxOccurs="1"/>
+ </xsd:sequence>
+
+ <!-- The time only. eg 12:00 pm -->
+ <xsd:attribute name="time" type="xsd:string" use="required"/>
+
+ <!-- Full timestamp. eg Tue Feb 8 19:04:49 AST 2005 -->
+ <xsd:attribute name="timestamp" type="xsd:string" use="required"/>
+
+ <!-- Formatted timestamp. eg 12:00:57 pm -->
+ <xsd:attribute name="formattedTimestamp" type="xsd:string" use="required"/>
+
+ <!-- Message subject. Used by Jabber Email. -->
+ <xsd:attribute name="subject" type="xsd:string" use="required"/>
+
+ <!-- Message direction (Inbound, Outbound, Internal).
+ This is deprecated. Use @type and @route -->
+ <xsd:attribute name="direction" type="direction" use="required"/>
+
+ <!-- Message route (inbound, outbound, internal).-->
+ <xsd:attribute name="route" type="route" use="required"/>
+
+ <!-- Message type (normal, action).-->
+ <xsd:attribute name="type" type="type" use="required"/>
+
+ <!-- Message importance.-->
+ <xsd:attribute name="importance" type="importance" use="required"/>
+
+ <!-- This is the main contact Id - the other person in the
+ converation besides you. If it is a group chat, it is the first
+ person who was being spoken to, or the group chat name. -->
+ <xsd:attribute name="mainContactId" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Enumeration for message direction
+ (this is deprecated - use the route/type) -->
+ <xsd:simpleType name="direction">
+ <xsd:restriction base="xsd:integer">
+ <xsd:enumeration value="0"/> <!-- Inbound -->
+ <xsd:enumeration value="1"/> <!-- Outbound -->
+ <xsd:enumeration value="2"/> <!-- Internal -->
+ <xsd:enumeration value="3"/> <!-- Action -->
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Enumeration for message route -->
+ <xsd:simpleType name="route">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="inbound"/>
+ <xsd:enumeration value="outbound"/>
+ <xsd:enumeration value="internal"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Enumeration for message type -->
+ <xsd:simpleType name="type">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="normal"/>
+ <xsd:enumeration value="action"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Enumeration for message importance -->
+ <xsd:simpleType name="importance">
+ <xsd:restriction base="xsd:integer">
+ <xsd:enumeration value="0"/> <!-- Low -->
+ <xsd:enumeration value="1"/> <!-- Normal -->
+ <xsd:enumeration value="2"/> <!-- Highlight -->
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Enumeration for bidi direction -->
+ <xsd:simpleType name="bidiDirection">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="ltr"/>
+ <xsd:enumeration value="rtl"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Element for display names -->
+ <xsd:complexType name="displayName">
+ <!-- The direction of the name, for Bidi suport. -->
+ <xsd:attribute name="dir" type="bidiDirection"/>
+
+ <!-- The actual name text -->
+ <xsd:attribute name="text" type="xsd:string"/>
+ </xsd:complexType>
+
+ <!-- The contact element -->
+ <xsd:complexType name="metaContact">
+ <xsd:sequence>
+ <xsd:element name="contact">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="contactDisplayName" type="displayName" minOccurs="1" maxOccurs="1"/>
+ <xsd:element name="metaContactDisplayName" type="displayName" minOccurs="1" maxOccurs="1"/>
+ </xsd:sequence>
+
+ <!-- The contact's id -->
+ <xsd:attribute name="contactId" type="xsd:string" use="required"/>
+
+ <!-- The contact's custom color -->
+ <xsd:attribute name="color" type="xsd:string" use="required"/>
+
+ <!-- The contact's photo. This file name only remains valid
+ while the message is in transit -->
+ <xsd:attribute name="userPhoto" type="xsd:string" use="optional"/>
+
+ <!-- The contact's protocol icon -->
+ <xsd:attribute name="protocolIcon" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- The message body element -->
+ <xsd:complexType name="messageBody">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <!-- The foreground color of the message -->
+ <xsd:attribute name="color" type="xsd:string" use="optional"/>
+
+ <!-- The background color of the message -->
+ <xsd:attribute name="bgcolor" type="xsd:string" use="optional"/>
+
+ <!-- The font of the message. This is a CSS string
+ describing the font-family, font-size, text-decoration,
+ and font-weight -->
+ <xsd:attribute name="font" type="xsd:string" use="optional"/>
+
+ <!-- The direction of the message, for Bidi suport. -->
+ <xsd:attribute name="dir" type="bidiDirection" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+</xsd:schema> \ No newline at end of file
diff --git a/kopete/libkopete/tests/kopetemessage_test.cpp b/kopete/libkopete/tests/kopetemessage_test.cpp
new file mode 100644
index 00000000..1ca57123
--- /dev/null
+++ b/kopete/libkopete/tests/kopetemessage_test.cpp
@@ -0,0 +1,324 @@
+/*
+ Tests for Kopete::Message
+
+ Copyright (c) 2005 by Tommi Rantala <tommi.rantala@cs.helsinki.fi>
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+ Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <stdlib.h>
+
+#include <qdir.h>
+#include <qfile.h>
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <kinstance.h>
+#include <kprocess.h>
+#include <kunittest/module.h>
+#include <kdebug.h>
+
+#include "kopetemessage_test.h"
+#include "kopeteaccount_mock.h"
+#include "kopeteprotocol_mock.h"
+#include "kopetecontact_mock.h"
+#include "kopetemetacontact_mock.h"
+#include "kopeteaccount_mock.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kopetemessage_test, "KopeteSuite");
+KUNITTEST_MODULE_REGISTER_TESTER( KopeteMessage_Test );
+
+/*
+ There are four sets of tests: for each of plain text and html, we have those
+ known to work in the current codebase, and those known to fail right now.
+
+ the name convention is working|broken-plaintext|html-number.input|output
+*/
+
+KopeteMessage_Test::KopeteMessage_Test()
+{
+ // change user data dir to avoid messing with user's .kde dir
+ setenv( "KDEHOME", QFile::encodeName( QDir::homeDirPath() + "/.kopete-unittest" ), true );
+
+ // create fake objects needed to build a reasonable testeable message
+ m_protocol = new Kopete::Test::Mock::Protocol( new KInstance(QCString("test-kopete-message")), 0L, "test-kopete-message");
+ m_account = new Kopete::Test::Mock::Account(m_protocol, "testaccount");
+ m_metaContactMyself = new Kopete::Test::Mock::MetaContact();
+ m_metaContactOther = new Kopete::Test::Mock::MetaContact();
+ m_contactFrom = new Kopete::Test::Mock::Contact(m_account, QString::fromLatin1("test-myself"), m_metaContactMyself, QString::null);
+ m_contactTo = new Kopete::Test::Mock::Contact(m_account, QString::fromLatin1("test-dest"), m_metaContactOther, QString::null);
+ m_message = new Kopete::Message( m_contactFrom, m_contactTo, QString::null, Kopete::Message::Outbound, Kopete::Message::PlainText);
+}
+
+void KopeteMessage_Test::allTests()
+{
+ KApplication::disableAutoDcopRegistration();
+ //KCmdLineArgs::init(argc,argv,"testkopetemessage", 0, 0, 0, 0);
+
+ // At least Kopete::Message::asXML() seems to require that a QApplication
+ // is created. Running the console version doesn't create it, but the GUI
+ // version does.
+
+ if (!kapp)
+ new KApplication();
+
+ testPrimitives();
+ testLinkParser();
+}
+
+void KopeteMessage_Test::testPrimitives()
+{
+ /**********************************************
+ * from(), to()
+ *********************************************/
+
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Inbound, Kopete::Message::PlainText);
+ Q_ASSERT(msg.from());
+ Q_ASSERT(!msg.to().isEmpty());
+ }
+
+ /**********************************************
+ * Direction
+ *********************************************/
+
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Inbound, Kopete::Message::PlainText);
+ CHECK(Kopete::Message::Inbound, msg.direction());
+ }
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Outbound, Kopete::Message::RichText);
+ CHECK(Kopete::Message::Outbound, msg.direction());
+ }
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Internal, Kopete::Message::RichText);
+ CHECK(Kopete::Message::Internal, msg.direction());
+ }
+
+ /**********************************************
+ * Message Format
+ *********************************************/
+
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Inbound, Kopete::Message::PlainText);
+ CHECK(Kopete::Message::PlainText, msg.format());
+ }
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foobar", Kopete::Message::Inbound, Kopete::Message::RichText);
+ CHECK(Kopete::Message::RichText, msg.format());
+ }
+ {
+ QString m = "foobar";
+ Kopete::Message msg( m_contactFrom, m_contactTo, m, Kopete::Message::Inbound, Kopete::Message::RichText);
+
+ msg.setBody(m, Kopete::Message::PlainText);
+ CHECK(Kopete::Message::PlainText, msg.format());
+
+ msg.setBody(m, Kopete::Message::RichText);
+ CHECK(Kopete::Message::RichText, msg.format());
+
+ msg.setBody(m, Kopete::Message::ParsedHTML);
+ CHECK(Kopete::Message::ParsedHTML, msg.format());
+
+ msg.setBody(m, Kopete::Message::Crypted);
+ CHECK(Kopete::Message::Crypted, msg.format());
+ }
+
+
+ /**********************************************
+ * setBody()
+ *********************************************/
+
+ {
+ QString m = "foobar";
+ Kopete::Message msg( m_contactFrom, m_contactTo, m, Kopete::Message::Inbound, Kopete::Message::RichText);
+
+ msg.setBody("NEW", Kopete::Message::PlainText);
+ CHECK(QString("NEW"), msg.plainBody());
+
+ msg.setBody("NEW_NEW", Kopete::Message::RichText);
+ CHECK(QString("NEW_NEW"), msg.plainBody());
+ }
+ {
+ QString m = "foobar";
+ Kopete::Message msg( m_contactFrom, m_contactTo, m, Kopete::Message::Inbound, Kopete::Message::PlainText);
+
+ msg.setBody("NEW", Kopete::Message::PlainText);
+ CHECK(QString("NEW"), msg.plainBody());
+
+ msg.setBody("NEW_NEW", Kopete::Message::RichText);
+ CHECK(QString("NEW_NEW"), msg.plainBody());
+ }
+ {
+ QString m = "<html><head></head><body foo=\"bar\"> <b>HELLO WORLD</b> </body></html>";
+ Kopete::Message msg( m_contactFrom, m_contactTo, m, Kopete::Message::Inbound, Kopete::Message::PlainText);
+ CHECK(m, msg.plainBody());
+
+ msg.setBody("<simple> SIMPLE", Kopete::Message::PlainText);
+ CHECK(msg.plainBody(), QString("<simple> SIMPLE") );
+ CHECK(msg.escapedBody(), QString("&lt;simple&gt; SIMPLE") );
+
+ msg.setBody("<simple>SIMPLE</simple>", Kopete::Message::RichText);
+ CHECK(msg.plainBody(), QString("SIMPLE") );
+ CHECK(msg.escapedBody(), QString("<simple>SIMPLE</simple>") );
+
+ CHECK(Kopete::Message::unescape( QString( "<simple>SIMPLE</simple>" ) ), QString("SIMPLE") );
+ CHECK(Kopete::Message::unescape( QString( "Foo <img src=\"foo.png\" />" ) ), QString("Foo ") );
+ CHECK(Kopete::Message::unescape( QString( "Foo <img src=\"foo.png\" title=\"Bar\" />" ) ), QString("Foo Bar") );
+
+ msg.setBody(m, Kopete::Message::RichText);
+
+ // FIXME: Should setBody() also strip extra white space?
+ //CHECK(msg.plainBody(), QString("HELLO WORLD"));
+ //CHECK(msg.escapedBody(), QString("<b>HELLO WORLD</b>"));
+
+ CHECK(msg.escapedBody(), QString(" &nbsp; <b>HELLO WORLD</b> &nbsp; "));
+ CHECK(msg.plainBody(), QString(" HELLO WORLD "));
+ CHECK(msg.plainBody().stripWhiteSpace(), QString("HELLO WORLD"));
+ CHECK(msg.escapedBody().stripWhiteSpace(), QString("&nbsp; <b>HELLO WORLD</b> &nbsp;"));
+ }
+ {
+ Kopete::Message msg( m_contactFrom, m_contactTo, "foo", Kopete::Message::Inbound, Kopete::Message::PlainText);
+
+ msg.setBody("<p>foo", Kopete::Message::RichText);
+ CHECK(msg.escapedBody(), QString("foo"));
+
+ msg.setBody("<p>foo</p>", Kopete::Message::RichText);
+ CHECK(msg.escapedBody(), QString("foo"));
+
+ msg.setBody("\n<p>foo</p>\n<br/>", Kopete::Message::RichText);
+ CHECK(msg.escapedBody(), QString("foo<br/>"));
+ }
+
+ /**********************************************
+ * Copy constructor
+ *********************************************/
+
+ {
+ Kopete::Message msg1(m_contactFrom, m_contactTo, "foo", Kopete::Message::Inbound, Kopete::Message::RichText);
+ Kopete::Message msg2(msg1);
+
+ CHECK(msg1.plainBody(), msg2.plainBody());
+ CHECK(msg1.escapedBody(), msg2.escapedBody());
+
+ msg1.setBody("NEW", Kopete::Message::PlainText);
+ CHECK(msg1.plainBody(), QString("NEW"));
+ CHECK(msg2.plainBody(), QString("foo"));
+ }
+
+ /**********************************************
+ * operator=
+ *********************************************/
+
+ {
+ Kopete::Message msg1(m_contactFrom, m_contactTo, "foo", Kopete::Message::Inbound, Kopete::Message::RichText);
+ {
+ Kopete::Message msg2;
+
+ CHECK(msg2.plainBody(), QString::null);
+
+ msg2 = msg1;
+
+ CHECK(msg1.plainBody(), msg2.plainBody());
+ CHECK(msg1.escapedBody(), msg2.escapedBody());
+
+ msg1.setBody("NEW", Kopete::Message::PlainText);
+ CHECK(msg1.plainBody(), QString("NEW"));
+ CHECK(msg2.plainBody(), QString("foo"));
+ }
+ CHECK(msg1.plainBody(), QString("NEW"));
+
+ msg1 = msg1;
+ CHECK(msg1.plainBody(), QString("NEW"));
+ }
+}
+
+void KopeteMessage_Test::setup()
+{
+}
+
+void KopeteMessage_Test::testLinkParser()
+{
+ QString basePath = QString::fromLatin1( SRCDIR ) + QString::fromLatin1("/link-parser-testcases");
+ QDir testCasesDir(basePath);
+
+ QStringList inputFileNames = testCasesDir.entryList("*.input");
+ for ( QStringList::ConstIterator it = inputFileNames.begin(); it != inputFileNames.end(); ++it)
+ {
+ QString fileName = *it;
+ QString outputFileName = fileName;
+ outputFileName.replace("input","output");
+ // open the input file
+ QFile inputFile(basePath + QString::fromLatin1("/") + fileName);
+ QFile expectedFile(basePath + QString::fromLatin1("/") + outputFileName);
+ // check if the expected output file exists
+ // if it doesn't, skip the testcase
+ if ( ! expectedFile.exists() )
+ {
+ SKIP("Warning! expected output for testcase "+ *it + " not found. Skiping testcase");
+ continue;
+ }
+ if ( inputFile.open( IO_ReadOnly ) && expectedFile.open( IO_ReadOnly ))
+ {
+ QTextStream inputStream(&inputFile);
+ QTextStream expectedStream(&expectedFile);
+ QString inputData;
+ QString expectedData;
+ inputData = inputStream.read();
+ expectedData = expectedStream.read();
+
+ inputFile.close();
+ expectedFile.close();
+
+ // use a concrete url
+ inputData.replace( "$URL","http://www.kde.org" );
+ expectedData.replace( "$URL","http://www.kde.org" );
+
+ // set message format for parsing according to textcase filename convention
+ Kopete::Message::MessageFormat format;
+ if ( fileName.section("-", 1, 1) == QString::fromLatin1("plaintext") )
+ format = Kopete::Message::PlainText;
+ else
+ format = Kopete::Message::RichText;
+
+ QString result = Kopete::Message::parseLinks( inputData, format );
+
+ // HACK to know the test case we applied, concatenate testcase name to both
+ // input and expected string. WIll remove when I can add some sort of metadata
+ // to a CHECK so debug its origin testcase
+ result = fileName + QString::fromLatin1(": ") + result;
+ expectedData = fileName + QString::fromLatin1(": ") + expectedData;
+ // if the test case begins with broken, we expect it to fail, then use XFAIL
+ // otherwise use CHECK
+ if ( fileName.section("-", 0, 0) == QString::fromLatin1("broken") )
+ {
+ //kdDebug() << "checking known-broken testcase: " << fileName << endl;
+ XFAIL(result, expectedData);
+ }
+ else
+ {
+ //kdDebug() << "checking known-working testcase: " << fileName << endl;
+ CHECK(result, expectedData);
+ }
+ }
+ else
+ {
+ SKIP("Warning! can't open testcase files for "+ *it + ". Skiping testcase");
+ continue;
+ }
+ }
+}
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/libkopete/tests/kopetemessage_test.h b/kopete/libkopete/tests/kopetemessage_test.h
new file mode 100644
index 00000000..52d09fb8
--- /dev/null
+++ b/kopete/libkopete/tests/kopetemessage_test.h
@@ -0,0 +1,56 @@
+/*
+ Tests for Kopete::Message
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+ Copyright (c) 2005 by Tommi Rantala <tommi.rantala@cs.helsinki.fi>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef KOPETEMESSAGE_TEST_H
+#define KOPETEMESSAGE_TEST_H
+
+#include <kunittest/tester.h>
+
+#define private public
+#include "kopetemessage.h"
+#undef private
+
+class Kopete::Protocol;
+class Kopete::Account;
+class Kopete::MetaContact;
+class Kopete::Contact;
+
+// change to SlotTester when it works
+class KopeteMessage_Test : public KUnitTest::Tester
+{
+public:
+ KopeteMessage_Test();
+ void allTests();
+
+public slots:
+ void testPrimitives();
+ void testLinkParser();
+
+private:
+ void setup();
+ Kopete::Message *m_message;
+ Kopete::Protocol *m_protocol;
+ Kopete::Account *m_account;
+ Kopete::MetaContact *m_metaContactMyself;
+ Kopete::MetaContact *m_metaContactOther;
+ Kopete::Contact *m_contactFrom;
+ Kopete::Contact *m_contactTo;
+};
+
+#endif
+
diff --git a/kopete/libkopete/tests/kopetepasswordtest_program.cpp b/kopete/libkopete/tests/kopetepasswordtest_program.cpp
new file mode 100644
index 00000000..a1f3a50e
--- /dev/null
+++ b/kopete/libkopete/tests/kopetepasswordtest_program.cpp
@@ -0,0 +1,132 @@
+/*
+ Tests for the Kopete::Password class
+
+ Copyright (c) 2003 by Richard Smith <kde@metafoo.co.uk>
+ Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopetepasswordtest_program.h"
+#include "kopetepassword.h"
+
+#include <qtextstream.h>
+#include <qpixmap.h>
+#include <qtimer.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+static QTextStream _out( stdout, IO_WriteOnly );
+
+static KCmdLineOptions opts[] =
+{
+ { "id <id>", I18N_NOOP("Config group to store password in"), "TestAccount" },
+ { "set <new>", I18N_NOOP("Set password to new"), 0 },
+ { "error", I18N_NOOP("Claim password was erroneous"), 0 },
+ { "prompt <prompt>", I18N_NOOP("Password prompt"), "Enter a password" },
+ { "image <filename>", I18N_NOOP("Image to display in password dialog"), 0 },
+ KCmdLineLastOption
+};
+
+using namespace Kopete;
+
+QString retrieve( Password &pwd, const QPixmap &image, const QString &prompt )
+{
+ PasswordRetriever r;
+ pwd.request( &r, SLOT( gotPassword( const QString & ) ), image, prompt );
+ QTimer tmr;
+ r.connect( &tmr, SIGNAL( timeout() ), SLOT( timer() ) );
+ tmr.start( 1000 );
+ qApp->exec();
+ return r.password;
+}
+
+void PasswordRetriever::gotPassword( const QString &pass )
+{
+ password = pass;
+ qApp->quit();
+}
+
+void PasswordRetriever::timer()
+{
+ _out << "." << flush;
+}
+
+int main( int argc, char *argv[] )
+{
+ KAboutData aboutData( "kopetepasswordtest", "kopetepasswordtest", "version" );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( opts );
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ KApplication app( "kopetepasswordtest" );
+
+ bool setPassword = args->isSet("set");
+ QString newPwd = args->getOption("set");
+ QString passwordId = args->getOption("id");
+ bool error = args->isSet("error");
+ QString prompt = args->getOption("prompt");
+ QPixmap image = QString(args->getOption("image"));
+
+ _out << (image.isNull() ? "image is null" : "image is valid") << endl;
+
+ Password pwd( passwordId, 0, false );
+ pwd.setWrong( error );
+
+ _out << "Cached value is null: " << pwd.cachedValue().isNull() << endl;
+
+ QString pass = retrieve( pwd, image, prompt );
+
+ if ( !pass.isNull() )
+ _out << "Read password: " << pass << endl;
+ else
+ _out << "Could not read a password" << endl;
+
+ _out << "Cached value: " << (pwd.cachedValue().isNull() ? "null" : pwd.cachedValue()) << endl;
+
+ if ( setPassword )
+ {
+ if ( newPwd.isEmpty() )
+ {
+ _out << "Clearing password" << endl;
+ newPwd = QString::null;
+ }
+ else
+ {
+ _out << "Setting password to " << newPwd << endl;
+ }
+ pwd.set( newPwd );
+ }
+
+ // without this, setting passwords will fail since they're
+ // set asynchronously.
+ QTimer::singleShot( 0, &app, SLOT( deref() ) );
+ app.exec();
+
+ if ( setPassword )
+ {
+ pass = retrieve( pwd, image, i18n("Hopefully this popped up because you set the password to the empty string.") );
+ if( pass == newPwd )
+ _out << "Password successfully set." << endl;
+ else
+ _out << "Failed: password ended up as " << pass << endl;
+ }
+
+ return 0;
+}
+
+#include "kopetepasswordtest_program.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/libkopete/tests/kopetepasswordtest_program.h b/kopete/libkopete/tests/kopetepasswordtest_program.h
new file mode 100644
index 00000000..507da2a1
--- /dev/null
+++ b/kopete/libkopete/tests/kopetepasswordtest_program.h
@@ -0,0 +1,16 @@
+#ifndef KOPETEPASSWORDTEST_H
+#define KOPETEPASSWORDTEST_H
+
+#include <qobject.h>
+
+class PasswordRetriever : public QObject
+{
+ Q_OBJECT
+public:
+ QString password;
+public slots:
+ void timer();
+ void gotPassword( const QString & );
+};
+
+#endif
diff --git a/kopete/libkopete/tests/kopetepropertiestest.cpp b/kopete/libkopete/tests/kopetepropertiestest.cpp
new file mode 100644
index 00000000..1e60c77c
--- /dev/null
+++ b/kopete/libkopete/tests/kopetepropertiestest.cpp
@@ -0,0 +1,59 @@
+/*
+ Tests for Kopete Properties
+
+ Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <kunittest/module.h>
+
+#include "kopeteproperties.h"
+
+#include <qstring.h>
+#include <qtextstream.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+#include "kopetepropertiestest.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kopetepropertiestest, "KopeteSuite");
+KUNITTEST_MODULE_REGISTER_TESTER( KopetePropertiesTest );
+
+using namespace Kopete::Properties;
+
+static QTextStream _out( stdout, IO_WriteOnly );
+
+class PropertyHost : public WithProperties<PropertyHost> {};
+
+class FooProperty : public SimpleDataProperty<PropertyHost, QString>
+{
+public:
+ const char *name() const { return "foo"; }
+} fooProperty;
+
+void KopetePropertiesTest::allTests()
+{
+ PropertyHost myPropertyHost;
+ CHECK( myPropertyHost.property(fooProperty).isNull(), true);
+ myPropertyHost.setProperty( fooProperty, QString::fromLatin1("Foo!") );
+ CHECK( myPropertyHost.property(fooProperty), QString::fromLatin1("Foo!") );
+}
+
+
+ \ No newline at end of file
diff --git a/kopete/libkopete/tests/kopetepropertiestest.h b/kopete/libkopete/tests/kopetepropertiestest.h
new file mode 100644
index 00000000..c997dd80
--- /dev/null
+++ b/kopete/libkopete/tests/kopetepropertiestest.h
@@ -0,0 +1,36 @@
+/*
+ Tests for Kopete Properties
+
+ Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef KOPETE_PROPERTIES_TEST_H
+#define KOPETE_PROPERTIES_TEST_H
+
+#include <kunittest/tester.h>
+
+// change to SlotTester when it works
+class KopetePropertiesTest : public KUnitTest::Tester
+{
+public:
+ void allTests();
+public slots:
+private:
+
+};
+
+#endif
+
+
diff --git a/kopete/libkopete/tests/kopetewallettest_program.cpp b/kopete/libkopete/tests/kopetewallettest_program.cpp
new file mode 100644
index 00000000..29de1edc
--- /dev/null
+++ b/kopete/libkopete/tests/kopetewallettest_program.cpp
@@ -0,0 +1,98 @@
+/*
+ Tests for the wallet manager
+
+ Copyright (c) 2003 by Richard Smith <kde@metafoo.co.uk>
+ Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qtextstream.h>
+#include <qtimer.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <dcopclient.h>
+#include <kwallet.h>
+
+#include "kopetewalletmanager.h"
+#include "kopetewallettest_program.h"
+
+static QTextStream _out( stdout, IO_WriteOnly );
+
+void closeWallet()
+{
+ Kopete::WalletManager::self()->closeWallet();
+}
+
+void delay()
+{
+ QTimer::singleShot( 3000, qApp, SLOT( quit() ) );
+ qApp->exec();
+}
+
+void openWalletAsync()
+{
+ WalletReciever *r = new WalletReciever;
+ _out << "[ASYNC] About to open wallet, receiver: " << r << endl;
+ Kopete::WalletManager::self()->openWallet( r, SLOT( gotWallet( KWallet::Wallet* ) ) );
+}
+
+void WalletReciever::gotWallet( KWallet::Wallet *w )
+{
+ _out << "[ASYNC] Received wallet pointer: " << w << " for receiver: " << this << endl;
+}
+
+void WalletReciever::timer()
+{
+ _out << "Timer..." << endl;
+}
+
+int main( int argc, char *argv[] )
+{
+ KAboutData aboutData( "kopetewallettest", "kopetewallettest", "version" );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineOptions opts[] = { {"+action",0,0}, KCmdLineLastOption };
+ KCmdLineArgs::addCmdLineOptions( opts );
+ KApplication app( "kopetewallettest" );
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ // must register with DCOP or async callbacks will fail
+ _out << "DCOP registration returned " << app.dcopClient()->registerAs(app.name()) << endl;
+
+ for( int i = 0; i < args->count(); ++i )
+ {
+ QString arg = args->arg( i );
+ _out << "Processing " << arg << endl;
+ if( arg == QString::fromLatin1( "open" ) ) openWalletAsync();
+ if( arg == QString::fromLatin1( "close" ) ) closeWallet();
+ if( arg == QString::fromLatin1( "delay" ) ) delay();
+ _out << "Done." << endl;
+ }
+
+ WalletReciever *r = new WalletReciever;
+
+ QTimer timer;
+ r->connect( &timer, SIGNAL( timeout() ), SLOT( timer() ) );
+ timer.start( 1000 );
+
+ _out << "About to start 30 second event loop" << endl;
+ QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
+ return qApp->exec();
+}
+
+#include "kopetewallettest_program.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/libkopete/tests/kopetewallettest_program.h b/kopete/libkopete/tests/kopetewallettest_program.h
new file mode 100644
index 00000000..58bdbb6e
--- /dev/null
+++ b/kopete/libkopete/tests/kopetewallettest_program.h
@@ -0,0 +1,17 @@
+#ifndef KOPETEWALLETTEST_H
+#define KOPETEWALLETTEST_H
+
+#include <qobject.h>
+
+namespace KWallet { class Wallet; }
+
+class WalletReciever : public QObject
+{
+ Q_OBJECT
+public slots:
+ void timer();
+private slots:
+ void gotWallet( KWallet::Wallet *w );
+};
+
+#endif
diff --git a/kopete/libkopete/tests/link-parser-testcases/broken-html-1.input b/kopete/libkopete/tests/link-parser-testcases/broken-html-1.input
new file mode 100644
index 00000000..ecaf4b7e
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/broken-html-1.input
@@ -0,0 +1 @@
+<a href="$URL" title="$URL">$URL</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/broken-html-1.output b/kopete/libkopete/tests/link-parser-testcases/broken-html-1.output
new file mode 100644
index 00000000..5bf3f88a
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/broken-html-1.output
@@ -0,0 +1 @@
+<a href="$URL" title="$URL">$URL</a>
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-html-1.input b/kopete/libkopete/tests/link-parser-testcases/working-html-1.input
new file mode 100644
index 00000000..306ab458
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-html-1.input
@@ -0,0 +1 @@
+$URL \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-html-1.output b/kopete/libkopete/tests/link-parser-testcases/working-html-1.output
new file mode 100644
index 00000000..ecaf4b7e
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-html-1.output
@@ -0,0 +1 @@
+<a href="$URL" title="$URL">$URL</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-html-2.input b/kopete/libkopete/tests/link-parser-testcases/working-html-2.input
new file mode 100644
index 00000000..4480dee7
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-html-2.input
@@ -0,0 +1 @@
+<a href="$URL">KDE</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-html-2.output b/kopete/libkopete/tests/link-parser-testcases/working-html-2.output
new file mode 100644
index 00000000..4480dee7
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-html-2.output
@@ -0,0 +1 @@
+<a href="$URL">KDE</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.input b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.input
new file mode 100644
index 00000000..306ab458
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.input
@@ -0,0 +1 @@
+$URL \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.output b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.output
new file mode 100644
index 00000000..ecaf4b7e
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-1.output
@@ -0,0 +1 @@
+<a href="$URL" title="$URL">$URL</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.input b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.input
new file mode 100644
index 00000000..14e0e606
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.input
@@ -0,0 +1 @@
+$URL/ \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.output b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.output
new file mode 100644
index 00000000..109c616b
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-2.output
@@ -0,0 +1 @@
+<a href="$URL/" title="$URL/">$URL/</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.input b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.input
new file mode 100644
index 00000000..828cd483
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.input
@@ -0,0 +1 @@
+www.kde.org/ \ No newline at end of file
diff --git a/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.output b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.output
new file mode 100644
index 00000000..9e898eb0
--- /dev/null
+++ b/kopete/libkopete/tests/link-parser-testcases/working-plaintext-3.output
@@ -0,0 +1 @@
+<a href="$URL/" title="$URL/">www.kde.org/</a> \ No newline at end of file
diff --git a/kopete/libkopete/tests/mock/Makefile.am b/kopete/libkopete/tests/mock/Makefile.am
new file mode 100644
index 00000000..b132a2a5
--- /dev/null
+++ b/kopete/libkopete/tests/mock/Makefile.am
@@ -0,0 +1,14 @@
+METASOURCES = AUTO
+AM_CPPFLAGS = -DKDE_NO_COMPAT -DQT_NO_COMPAT -DQT_NO_CAST_ASCII -DQT_NO_ASCII_CAST \
+ $(KOPETE_INCLUDES) -I$(top_srcdir)/kopete/libkopete/private $(all_includes)
+
+noinst_LTLIBRARIES = libkopete_mock.la
+
+libkopete_mock_la_SOURCES = kopetemessage_mock.cpp kopeteaccount_mock.cpp kopetecontact_mock.cpp kopetemetacontact_mock.cpp kopeteprotocol_mock.cpp
+
+libkopete_mock_la_LDFLAGS = $(all_libraries) -lkabc
+libkopete_mock_la_LIBADD = ../../libkopete.la ../../private/libkopeteprivate.la $(LIB_KHTML)
+
+noinst_HEADERS = kopetemessage_mock.h kopetecontact_mock.h kopetemetacontact_mock.h kopeteaccount_mock.h kopeteprotocol_mock.h
+
+
diff --git a/kopete/libkopete/tests/mock/kopeteaccount_mock.cpp b/kopete/libkopete/tests/mock/kopeteaccount_mock.cpp
new file mode 100644
index 00000000..8a8425bc
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopeteaccount_mock.cpp
@@ -0,0 +1,61 @@
+/*
+ Account mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopeteaccount_mock.h"
+#include "kopetemetacontact.h"
+#include "kopeteaccount_mock.h"
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+Account::Account(Kopete::Protocol *parent, const QString &accountID, const char *name) : Kopete::Account(parent, accountID, name)
+{
+
+}
+
+Account::~Account()
+{
+
+}
+
+bool Account::createContact( const QString &contactId, Kopete::MetaContact *parentContact )
+{
+ return true;
+}
+
+void Account::connect( const Kopete::OnlineStatus& initialStatus)
+{
+ // do nothing
+}
+
+void Account::disconnect()
+{
+ // do nothing
+}
+
+void Account::setOnlineStatus( const Kopete::OnlineStatus& status , const QString &reason)
+{
+ // do nothing
+}
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
diff --git a/kopete/libkopete/tests/mock/kopeteaccount_mock.h b/kopete/libkopete/tests/mock/kopeteaccount_mock.h
new file mode 100644
index 00000000..55ba15cc
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopeteaccount_mock.h
@@ -0,0 +1,54 @@
+/*
+ Account mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef _KOPETEACCOUNT_MOCK_H_
+#define _KOPETEACCOUNT_MOCK_H_
+
+#include "kopeteaccount.h"
+
+class Kopete::Protocol;
+class Kopete::OnlineStatus;
+class Kopete::MetaContact;
+
+class QString;
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+class Account : public Kopete::Account
+{
+public:
+ Account(Kopete::Protocol *parent, const QString &accountID, const char *name=0L);
+ ~Account();
+ // pure virtual functions implementation
+ virtual bool createContact( const QString &contactId, MetaContact *parentContact );
+ virtual void connect( const Kopete::OnlineStatus& initialStatus = OnlineStatus() );
+ virtual void disconnect();
+ virtual void setOnlineStatus( const Kopete::OnlineStatus& status , const QString &reason = QString::null );
+};
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
+
+
+#endif
+
diff --git a/kopete/libkopete/tests/mock/kopetecontact_mock.cpp b/kopete/libkopete/tests/mock/kopetecontact_mock.cpp
new file mode 100644
index 00000000..19cfa7b0
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetecontact_mock.cpp
@@ -0,0 +1,44 @@
+/*
+ Contact mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopetecontact_mock.h"
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+Contact::Contact( Kopete::Account *account, const QString &id, Kopete::MetaContact *parent, const QString &icon) : Kopete::Contact( account, id, parent, icon)
+{
+
+}
+
+Contact::~Contact()
+{
+
+}
+
+Kopete::ChatSession* Contact::manager( CanCreateFlags canCreate)
+{
+ return 0L;
+}
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete \ No newline at end of file
diff --git a/kopete/libkopete/tests/mock/kopetecontact_mock.h b/kopete/libkopete/tests/mock/kopetecontact_mock.h
new file mode 100644
index 00000000..e445a571
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetecontact_mock.h
@@ -0,0 +1,49 @@
+/*
+ Contact mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef _KOPETECONTACT_MOCK_H_
+#define _KOPETECONTACT_MOCK_H_
+
+#include "kopetecontact.h"
+
+class Kopete::MetaContact;
+class Kopete::Account;
+class Kopete::ChatSession;
+class QString;
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+class Contact : public Kopete::Contact
+{
+public:
+ Contact( Kopete::Account *account, const QString &id, Kopete::MetaContact *parent, const QString &icon = QString::null );
+ ~Contact();
+ virtual Kopete::ChatSession* manager( CanCreateFlags canCreate = CannotCreate );
+};
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
+
+
+#endif
+
diff --git a/kopete/libkopete/tests/mock/kopetemessage_mock.cpp b/kopete/libkopete/tests/mock/kopetemessage_mock.cpp
new file mode 100644
index 00000000..a3e543e3
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetemessage_mock.cpp
@@ -0,0 +1,20 @@
+/*
+ Message mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopetemessage_mock.h"
+
+
diff --git a/kopete/libkopete/tests/mock/kopetemessage_mock.h b/kopete/libkopete/tests/mock/kopetemessage_mock.h
new file mode 100644
index 00000000..13c92574
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetemessage_mock.h
@@ -0,0 +1,39 @@
+/*
+ Message mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef _KOPETEMESSAGE_MOCK_H_
+#define _KOPETEMESSAGE_MOCK_H_
+
+#include "kopetemessage.h"
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+class Message : public Kopete::Message
+{
+
+};
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
+
+#endif \ No newline at end of file
diff --git a/kopete/libkopete/tests/mock/kopetemetacontact_mock.cpp b/kopete/libkopete/tests/mock/kopetemetacontact_mock.cpp
new file mode 100644
index 00000000..32f0fe1c
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetemetacontact_mock.cpp
@@ -0,0 +1,20 @@
+/*
+ MetaContact Mock Object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopetemetacontact_mock.h"
+
+
diff --git a/kopete/libkopete/tests/mock/kopetemetacontact_mock.h b/kopete/libkopete/tests/mock/kopetemetacontact_mock.h
new file mode 100644
index 00000000..f3311713
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopetemetacontact_mock.h
@@ -0,0 +1,41 @@
+/*
+ MetaContact Mock Object
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef _KOPETEMETACONTACT_MOCK_H_
+#define _KOPETEMETACONTACT_MOCK_H_
+
+#include "kopetemetacontact.h"
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+class MetaContact : public Kopete::MetaContact
+{
+
+};
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
+
+
+#endif
+
diff --git a/kopete/libkopete/tests/mock/kopeteprotocol_mock.cpp b/kopete/libkopete/tests/mock/kopeteprotocol_mock.cpp
new file mode 100644
index 00000000..d3bbd0e2
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopeteprotocol_mock.cpp
@@ -0,0 +1,49 @@
+/*
+ Protocol mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "kopeteprotocol_mock.h"
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+Protocol::Protocol( KInstance *instance, QObject *parent, const char *name ) : Kopete::Protocol(instance, parent, name)
+{
+
+}
+
+Account* Protocol::createNewAccount( const QString &accountId )
+{
+ return 0L;
+}
+
+AddContactPage* Protocol::createAddContactWidget( QWidget *parent, Kopete::Account *account )
+{
+ return 0L;
+}
+
+KopeteEditAccountWidget* Protocol::createEditAccountWidget( Kopete::Account *account, QWidget *parent )
+{
+ return 0L;
+}
+
+} // end ns mock
+} // end ns test
+} // end ns kopete
diff --git a/kopete/libkopete/tests/mock/kopeteprotocol_mock.h b/kopete/libkopete/tests/mock/kopeteprotocol_mock.h
new file mode 100644
index 00000000..189f7d79
--- /dev/null
+++ b/kopete/libkopete/tests/mock/kopeteprotocol_mock.h
@@ -0,0 +1,53 @@
+/*
+ Protocol mock object class
+
+ Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef _KOPETEPROTOCOL_MOCK_H_
+#define _KOPETEPROTOCOL_MOCK_H_
+
+#include "kopeteprotocol.h"
+
+class KInstance;
+class QObject;
+
+class KopeteEditAccountWidget;
+class AddContactPage;
+class KopeteEditAccountWidget;
+
+namespace Kopete
+{
+namespace Test
+{
+namespace Mock
+{
+
+class Protocol : public Kopete::Protocol
+{
+public:
+ Protocol( KInstance *instance, QObject *parent, const char *name );
+ // pure virtual functions implemented
+ virtual Account *createNewAccount( const QString &accountId );
+ virtual AddContactPage *createAddContactWidget( QWidget *parent, Kopete::Account *account );
+ virtual KopeteEditAccountWidget * createEditAccountWidget( Kopete::Account *account, QWidget *parent );
+};
+
+} // end ns Kopete::Test::Mock
+} // end ns Kopete::Test
+} // end ns Kopete
+
+
+#endif
+
diff --git a/kopete/libkopete/tests/template_test.cpp b/kopete/libkopete/tests/template_test.cpp
new file mode 100644
index 00000000..8598f79f
--- /dev/null
+++ b/kopete/libkopete/tests/template_test.cpp
@@ -0,0 +1,37 @@
+/*
+ Tests for some requirement
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <kunittest/module.h>
+#include "template_test.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_template_test, "KopeteSuite");
+KUNITTEST_MODULE_REGISTER_TESTER( Template_Test );
+
+void Template_Test::allTests()
+{
+ testSomething();
+}
+
+void Template_Test::testSomething()
+{
+ int result = 1;
+ int expected = 1;
+ // result should be the expected one
+ CHECK(result, expected);
+}
diff --git a/kopete/libkopete/tests/template_test.h b/kopete/libkopete/tests/template_test.h
new file mode 100644
index 00000000..4d0f1617
--- /dev/null
+++ b/kopete/libkopete/tests/template_test.h
@@ -0,0 +1,35 @@
+/*
+ Tests for some requirement
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef TEMPLATE_TEST_H
+#define TEMPLATE_TEST_H
+
+#include <kunittest/tester.h>
+
+// change to SlotTester when it works
+class Template_Test : public KUnitTest::Tester
+{
+public:
+ void allTests();
+public slots:
+ void testSomething();
+private:
+
+};
+
+#endif
+