2
Copyright (c) 2009 Volker Krause <vkrause@kde.org>
4
This library is free software; you can redistribute it and/or modify it
5
under the terms of the GNU Library General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or (at your
7
option) any later version.
9
This library is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12
License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to the
16
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
#include <akonadi/item.h>
21
#include <kcal/event.h>
22
#include <qtest_kde.h>
23
#include <QtCore/QObject>
24
#include <boost/shared_ptr.hpp>
26
using namespace Akonadi;
29
class KCalSerializerTest : public QObject
33
void testEventSerialize_data()
35
QTest::addColumn<QString>( "mimeType" );
36
QTest::newRow( "specific" ) << "application/x-vnd.akonadi.calendar.event";
37
QTest::newRow( "generic" ) << "text/calendar";
40
void testEventSerialize()
42
QFETCH( QString, mimeType );
44
QByteArray serialized =
46
"PRODID:-//K Desktop Environment//NONSGML libkcal 3.5//EN\n"
49
"DTSTAMP:20070109T100625Z\n"
50
"ORGANIZER;CN=\"Volker Krause\":MAILTO:vkrause@kde.org\n"
51
"CREATED:20070109T100553Z\n"
52
"UID:libkcal-1135684253.945\n"
54
"LAST-MODIFIED:20070109T100625Z\n"
55
"SUMMARY:Test event\n"
60
"DTSTART:20070109T183000Z\n"
61
"DTEND:20070109T225900Z\n"
66
"TRIGGER;VALUE=DURATION:-PT45M\n"
73
item.setMimeType( mimeType );
74
item.setPayloadFromData( serialized );
76
QVERIFY( item.hasPayload<Event::Ptr>() );
77
const Event::Ptr event = item.payload<Event::Ptr>();
78
QVERIFY( event != 0 );
80
QCOMPARE( event->summary(), QString( "Test event" ) );
81
QCOMPARE( event->location(), QString( "here" ) );
84
const QByteArray data = item.payloadData();
85
QVERIFY( !data.isEmpty() );
89
QTEST_KDEMAIN( KCalSerializerTest, NoGUI )
91
#include "kcalserializertest.moc"