File: testconference.cpp

package info (click to toggle)
kcalcore 5%3A5.78.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,736 kB
  • sloc: cpp: 23,105; perl: 136; sh: 11; makefile: 7
file content (107 lines) | stat: -rw-r--r-- 3,183 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
  This file is part of the kcalcore library.
  SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org>

  SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "testconference.h"
#include "conference.h"
#include "memorycalendar.h"
#include "filestorage.h"

#include <QDataStream>
#include <QTest>

QTEST_MAIN(ConferenceTest)

using namespace KCalendarCore;

void ConferenceTest::testValidity()
{
    {
        Conference test;
        QVERIFY(test.isNull());
    }

    {
        Conference test(QUrl(QStringLiteral("tel:000326870")),
                        QStringLiteral("Phone call for conference"));
        QVERIFY(!test.isNull());
    }
}

void ConferenceTest::testCompare()
{
    Conference conf1{QUrl{QStringLiteral("tel:123456789")},
                     QStringLiteral("Conference call"),
                     {QStringLiteral("PHONE")},
                     QStringLiteral("en")};
    Conference conf2{QUrl{QStringLiteral("xmpp:conference@conference.conference")},
                     QStringLiteral("Conference chat"),
                     {QStringLiteral("CHAT")},
                     QStringLiteral("en")};
    QVERIFY(conf1 != conf2);

    conf2.setUri(QUrl{QStringLiteral("tel:123456789")});
    conf2.setLabel(QStringLiteral("Conference call"));
    conf2.setFeatures({QStringLiteral("PHONE")});
    conf2.setLanguage(QStringLiteral("en"));

    QVERIFY(conf1 == conf2);
}

void ConferenceTest::testAssign()
{
    Conference conf1{QUrl{QStringLiteral("sip:1234-5678@sip.example")}, QStringLiteral("SIP Call")};
    Conference conf2 = conf1;
    QCOMPARE(conf1, conf2);

    conf2.setLanguage(QStringLiteral("en"));
    QVERIFY(!(conf1 == conf2));

    Conference conf3(conf1);
    QCOMPARE(conf3, conf1);
}

void ConferenceTest::testDataStream()
{
    Conference conf1;
    conf1.setUri(QUrl{QStringLiteral("tel:000326870")});
    conf1.setLabel(QStringLiteral("Phone conference"));
    conf1.addFeature(QStringLiteral("PHONE"));
    conf1.setLanguage(QStringLiteral("en"));

    QByteArray byteArray;
    QDataStream out_stream(&byteArray, QIODevice::WriteOnly);

    out_stream << conf1;

    QDataStream in_stream(&byteArray, QIODevice::ReadOnly);

    Conference conf2;

    in_stream >> conf2;

    QCOMPARE(conf2.uri(), conf1.uri());
    QCOMPARE(conf2.label(), conf1.label());
    QCOMPARE(conf2.features(), conf1.features());
    QCOMPARE(conf2.language(), conf1.language());
}

void ConferenceTest::testLoading()
{
    MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc()));
    FileStorage store(cal, QLatin1String(ICALTESTDATADIR) + QLatin1String("test_conference.ics"));
    QVERIFY(store.load());
    const auto events = cal->events();
    QCOMPARE(events.size(), 1);

    const auto event = events.at(0);
    const auto conferences = event->conferences();
    QCOMPARE(conferences.size(), 1);
    const auto conference = conferences.at(0);
    QCOMPARE(conference.uri(), QUrl{QStringLiteral("https://corp.kde.example/call/efi83r28")});
    QCOMPARE(conference.features(), (QStringList{QStringLiteral("AUDIO"), QStringLiteral("VIDEO")}));
    QCOMPARE(conference.label(), QStringLiteral("Join NextCloud Talk, password is 12345"));
}