~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to akonadi/plugins/tests/kcalserializertest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-07-10 06:34:50 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20090710063450-neojgew2fh0n3y0u
Tags: 4:4.2.96-0ubuntu1
* New upstream release
* Bump kde build-deps to 4.2.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
3
 
 
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.
8
 
 
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.
13
 
 
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
17
 
    02110-1301, USA.
18
 
*/
19
 
 
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>
25
 
 
26
 
using namespace Akonadi;
27
 
using namespace KCal;
28
 
 
29
 
class KCalSerializerTest : public QObject
30
 
{
31
 
  Q_OBJECT
32
 
  private slots:
33
 
    void testEventSerialize_data()
34
 
    {
35
 
      QTest::addColumn<QString>( "mimeType" );
36
 
      QTest::newRow( "specific" ) << "application/x-vnd.akonadi.calendar.event";
37
 
      QTest::newRow( "generic" ) << "text/calendar";
38
 
    }
39
 
 
40
 
    void testEventSerialize()
41
 
    {
42
 
      QFETCH( QString, mimeType );
43
 
 
44
 
      QByteArray serialized =
45
 
        "BEGIN:VCALENDAR\n"
46
 
        "PRODID:-//K Desktop Environment//NONSGML libkcal 3.5//EN\n"
47
 
        "VERSION:2.0\n"
48
 
        "BEGIN:VEVENT\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"
53
 
        "SEQUENCE:1\n"
54
 
        "LAST-MODIFIED:20070109T100625Z\n"
55
 
        "SUMMARY:Test event\n"
56
 
        "LOCATION:here\n"
57
 
        "CLASS:PUBLIC\n"
58
 
        "PRIORITY:5\n"
59
 
        "CATEGORIES:KDE\n"
60
 
        "DTSTART:20070109T183000Z\n"
61
 
        "DTEND:20070109T225900Z\n"
62
 
        "TRANSP:OPAQUE\n"
63
 
        "BEGIN:VALARM\n"
64
 
        "DESCRIPTION:\n"
65
 
        "ACTION:DISPLAY\n"
66
 
        "TRIGGER;VALUE=DURATION:-PT45M\n"
67
 
        "END:VALARM\n"
68
 
        "END:VEVENT\n"
69
 
        "END:VCALENDAR\n";
70
 
 
71
 
      // deserializing
72
 
      Item item;
73
 
      item.setMimeType( mimeType );
74
 
      item.setPayloadFromData( serialized );
75
 
 
76
 
      QVERIFY( item.hasPayload<Event::Ptr>() );
77
 
      const Event::Ptr event = item.payload<Event::Ptr>();
78
 
      QVERIFY( event != 0 );
79
 
 
80
 
      QCOMPARE( event->summary(), QString( "Test event" ) );
81
 
      QCOMPARE( event->location(), QString( "here" ) );
82
 
 
83
 
      // serializing
84
 
      const QByteArray data = item.payloadData();
85
 
      QVERIFY( !data.isEmpty() );
86
 
    }
87
 
};
88
 
 
89
 
QTEST_KDEMAIN( KCalSerializerTest, NoGUI )
90
 
 
91
 
#include "kcalserializertest.moc"