Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117880212
icalendartest.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
icalendartest.cpp
View Options
/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"icalendartest.h"
#include
<QTest>
#include
<kolabevent.h>
#include
"icalendar/icalendar.h"
#include
"testhelpers.h"
#include
"testutils.h"
#include
<kolabformat/kolabobject.h>
void
ICalendarTest
::
testFromICalEvent
()
{
std
::
vector
<
Kolab
::
Event
>
events
;
Kolab
::
Event
ev1
;
ev1
.
setStart
(
Kolab
::
cDateTime
(
2011
,
10
,
10
,
12
,
1
,
1
,
true
));
ev1
.
setEnd
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
1
,
true
));
events
.
push_back
(
ev1
);
const
std
::
vector
<
Kolab
::
Event
>
&
result
=
Kolab
::
fromICalEvents
(
Kolab
::
toICal
(
events
));
qDebug
()
<<
QString
::
fromStdString
(
Kolab
::
toICal
(
result
));
}
void
ICalendarTest
::
testFromICalEventWithExceptions
()
{
QFile
icalFile
(
getPath
(
"v3/event/exceptions.ics"
)
);
QVERIFY
(
icalFile
.
open
(
QFile
::
ReadOnly
)
);
std
::
vector
<
Kolab
::
Event
>
events
=
Kolab
::
fromICalEvents
(
icalFile
.
readAll
().
constData
());
QCOMPARE
((
int
)
events
.
size
(),
1
);
Kolab
::
Event
out
=
events
.
at
(
0
);
QCOMPARE
((
int
)
out
.
exceptions
().
size
(),
2
);
}
void
ICalendarTest
::
testFromICalEventErrorsWithSameID
()
{
/* This is not a really usecase, it should make sure,
* that the underlying KCalCore strips out events with same uid/or recurrenceID.
* 2015/02/18: KCaclCore is only returns one event with one exception for the icalFile
* testdata/v3/event/errorswithsameid.ics
*/
QFile
icalFile
(
getPath
(
"v3/event/errorswithsameid.ics"
)
);
QVERIFY
(
icalFile
.
open
(
QFile
::
ReadOnly
)
);
std
::
vector
<
Kolab
::
Event
>
events
=
Kolab
::
fromICalEvents
(
icalFile
.
readAll
().
constData
());
QCOMPARE
((
int
)
events
.
size
(),
1
);
Kolab
::
Event
out
=
events
.
at
(
0
);
QCOMPARE
((
int
)
out
.
exceptions
().
size
(),
1
);
}
void
ICalendarTest
::
testReadWriteForEventWithExceptions
()
{
std
::
vector
<
Kolab
::
Event
>
events
;
Kolab
::
Event
ev1
;
ev1
.
setUid
(
"uid"
);
ev1
.
setStart
(
Kolab
::
cDateTime
(
2011
,
10
,
10
,
12
,
1
,
1
,
true
));
ev1
.
setEnd
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
1
,
true
));
std
::
vector
<
Kolab
::
Event
>
exceptions
;
Kolab
::
Event
ex1
;
ex1
.
setUid
(
ev1
.
uid
());
ex1
.
setRecurrenceID
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
1
,
true
),
false
);
exceptions
.
push_back
(
ex1
);
ev1
.
setExceptions
(
exceptions
);
Kolab
::
RecurrenceRule
rrule
;
rrule
.
setInterval
(
1
);
rrule
.
setFrequency
(
Kolab
::
RecurrenceRule
::
Daily
);
ev1
.
setRecurrenceRule
(
rrule
);
events
.
push_back
(
ev1
);
const
std
::
vector
<
Kolab
::
Event
>
&
result
=
Kolab
::
fromICalEvents
(
Kolab
::
toICal
(
events
));
Kolab
::
Event
out
=
result
.
at
(
0
);
QCOMPARE
((
int
)
result
.
size
(),
1
);
QCOMPARE
((
int
)
out
.
exceptions
().
size
(),
1
);
QCOMPARE
(
out
.
exceptions
().
at
(
0
).
recurrenceID
(),
ex1
.
recurrenceID
());
}
void
ICalendarTest
::
testToICal
()
{
std
::
vector
<
Kolab
::
Event
>
events
;
Kolab
::
Event
ev1
;
ev1
.
setStart
(
Kolab
::
cDateTime
(
2011
,
10
,
10
,
12
,
1
,
1
,
true
));
ev1
.
setEnd
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
1
,
true
));
events
.
push_back
(
ev1
);
events
.
push_back
(
ev1
);
qDebug
()
<<
QString
::
fromStdString
(
Kolab
::
toICal
(
events
));
}
void
ICalendarTest
::
testToITip
()
{
Kolab
::
ITipHandler
handler
;
Kolab
::
Event
ev1
;
ev1
.
setStart
(
Kolab
::
cDateTime
(
2011
,
10
,
10
,
12
,
1
,
1
,
true
));
ev1
.
setEnd
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
1
,
true
));
ev1
.
setLastModified
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
2
,
true
));
ev1
.
setCreated
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
3
,
true
));
qDebug
()
<<
QString
::
fromStdString
(
handler
.
toITip
(
ev1
,
Kolab
::
ITipHandler
::
iTIPRequest
));
}
void
ICalendarTest
::
testToIMip
()
{
Kolab
::
ITipHandler
handler
;
Kolab
::
Event
ev1
;
ev1
.
setStart
(
Kolab
::
cDateTime
(
"Europe/Zurich"
,
2011
,
10
,
10
,
12
,
1
,
1
));
ev1
.
setEnd
(
Kolab
::
cDateTime
(
"Europe/Zurich"
,
2012
,
5
,
5
,
3
,
4
,
4
));
ev1
.
setLastModified
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
2
,
true
));
ev1
.
setCreated
(
Kolab
::
cDateTime
(
2011
,
10
,
11
,
12
,
1
,
3
,
true
));
std
::
vector
<
Kolab
::
Attendee
>
attendees
;
attendees
.
push_back
(
Kolab
::
Attendee
(
Kolab
::
ContactReference
(
"email1@test.org"
,
"name1"
,
"uid1"
)));
attendees
.
push_back
(
Kolab
::
Attendee
(
Kolab
::
ContactReference
(
"email2@test.org"
,
"name2"
,
"uid2"
)));
ev1
.
setAttendees
(
attendees
);
ev1
.
setOrganizer
(
Kolab
::
ContactReference
(
"organizer@test.org"
,
"organizer"
,
"uid3"
));
ev1
.
setSummary
(
"summary"
);
const
std
::
string
mimeResult
=
handler
.
toIMip
(
ev1
,
Kolab
::
ITipHandler
::
iTIPRequest
,
"test@test.com"
);
qDebug
()
<<
QString
::
fromStdString
(
mimeResult
);
qDebug
()
<<
QString
::
fromStdString
(
handler
.
toIMip
(
ev1
,
Kolab
::
ITipHandler
::
iTIPReply
,
"test@test.com"
));
const
std
::
vector
<
Kolab
::
Event
>
&
eventResult
=
handler
.
fromIMip
(
mimeResult
);
// qDebug() << QString::fromStdString(Kolab::toICal(eventResult));
QCOMPARE
((
int
)
eventResult
.
size
(),
1
);
QEXPECT_FAIL
(
""
,
"to imip converts dates to utc"
,
Continue
);
QCOMPARE
(
eventResult
.
front
().
start
(),
ev1
.
start
());
QEXPECT_FAIL
(
""
,
"to imip converts dates to utc"
,
Continue
);
QCOMPARE
(
eventResult
.
front
().
end
(),
ev1
.
end
());
}
QTEST_MAIN
(
ICalendarTest
)
#include
"icalendartest.moc"
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Apr 5, 11:17 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18830877
Default Alt Text
icalendartest.cpp (5 KB)
Attached To
Mode
rLK libkolab
Attached
Detach File
Event Timeline