summaryrefslogtreecommitdiff
path: root/notes/tests
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2012-06-27 08:22:11 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2012-06-27 08:22:11 (GMT)
commite51f456146457a444dab9c477c8e21bcd9faf9b4 (patch)
treeee4f5186d6e58c7a4136bf915e9c3b2efa4c5576 /notes/tests
parentad466258dc5a568260c33808827b8870777a69f7 (diff)
downloadlibcalendaring-e51f456146457a444dab9c477c8e21bcd9faf9b4.tar.gz
akonadi notes
Diffstat (limited to 'notes/tests')
-rw-r--r--notes/tests/CMakeLists.txt6
-rw-r--r--notes/tests/notestest.cpp85
2 files changed, 91 insertions, 0 deletions
diff --git a/notes/tests/CMakeLists.txt b/notes/tests/CMakeLists.txt
new file mode 100644
index 0000000..d507a04
--- /dev/null
+++ b/notes/tests/CMakeLists.txt
@@ -0,0 +1,6 @@
+set(notestest_SRCS notestest.cpp)
+
+set(CMAKE_PREFIX_PATH ../)
+
+kde4_add_unit_test(notestest TESTNAME notestest ${notestest_SRCS})
+target_link_libraries(notestest ${KDE4_KDECORE_LIBS} akonadi-notes kmime ${QT_QTTEST_LIBRARY}) \ No newline at end of file
diff --git a/notes/tests/notestest.cpp b/notes/tests/notestest.cpp
new file mode 100644
index 0000000..fcf5a0f
--- /dev/null
+++ b/notes/tests/notestest.cpp
@@ -0,0 +1,85 @@
+/*
+ Copyright (c) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#include "noteutils.h"
+
+#include <QTest>
+#include <QHash>
+#include <QDebug>
+
+#include <KDateTime>
+#include <kmime/kmime_message.h>
+
+using namespace Akonadi::NoteUtils;
+class NotesTest : public QObject
+{
+ Q_OBJECT
+ private slots:
+
+ void testSerializeAndParse()
+ {
+ NoteMessageWrapper note;
+ note.setTitle("title");
+ note.setText("title");
+ note.setUid("uid");
+ note.setClassification(NoteMessageWrapper::Private);
+ note.setFrom("from@kde.org");
+ note.setCreationDate(KDateTime(QDate(2012,3,3), QTime(3,3,3), KDateTime::UTC));
+ note.setLastModifiedDate(KDateTime(QDate(2012,3,3), QTime(4,4,4), KDateTime::UTC));
+ Attachment a("testfile2", "mimetype/mime3");
+ a.setLabel("label");
+ note.attachments() << Attachment(QUrl("file://url/to/file"), "mimetype/mime") << Attachment("testfile", "mimetype/mime2") << a;
+ note.custom().insert("key1", "value1");
+ note.custom().insert("key2", "value2");
+ note.custom().insert("key3", "value3");
+
+ KMime::MessagePtr msg = note.message();
+// qWarning() << msg->encodedContent();
+
+ NoteMessageWrapper result(msg);
+
+ QCOMPARE(result.title(), note.title());
+ QCOMPARE(result.text(), note.text());
+ QCOMPARE(result.textFormat(), note.textFormat());
+ QCOMPARE(result.uid(), note.uid());
+ QCOMPARE(result.classification(), note.classification());
+ QCOMPARE(result.from(), note.from());
+ QCOMPARE(result.creationDate(), note.creationDate());
+ QCOMPARE(result.lastModifiedDate(), note.lastModifiedDate());
+ QCOMPARE(result.custom(), note.custom());
+ QCOMPARE(result.attachments(), note.attachments());
+
+// qWarning() << result.message()->encodedContent();
+ }
+
+ void createIfEmpty()
+ {
+ NoteMessageWrapper note;
+ NoteMessageWrapper result(note.message());
+// qDebug() << result.uid();
+ QVERIFY(!result.uid().isEmpty());
+ QVERIFY(result.creationDate().isValid());
+ QVERIFY(result.lastModifiedDate().isValid());
+ }
+
+};
+
+QTEST_MAIN( NotesTest )
+
+#include "notestest.moc"