File indexing completed on 2024-12-01 04:35:30

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "videoconferenceinfotest.h"
0008 #include "ruqola_autotest_helper.h"
0009 #include "videoconference/videoconferenceinfo.h"
0010 
0011 QTEST_GUILESS_MAIN(VideoConferenceInfoTest)
0012 VideoConferenceInfoTest::VideoConferenceInfoTest(QObject *parent)
0013     : QObject{parent}
0014 {
0015 }
0016 
0017 void VideoConferenceInfoTest::shouldHaveDefaultValues()
0018 {
0019     VideoConferenceInfo info;
0020     QVERIFY(info.url().isEmpty());
0021     QCOMPARE(info.status(), -1);
0022     QVERIFY(!info.ringing());
0023     QVERIFY(info.roomId().isEmpty());
0024     QCOMPARE(info.conferenceType(), VideoConferenceInfo::VideoConferenceType::Unknown);
0025     QVERIFY(info.providerName().isEmpty());
0026     QVERIFY(info.users().isEmpty());
0027     QVERIFY(info.messageId().isEmpty());
0028     QVERIFY(info.blockId().isEmpty());
0029     QVERIFY(!info.isValid());
0030     QVERIFY(!info.canJoin());
0031 }
0032 
0033 void VideoConferenceInfoTest::shouldLoadVideoConferenceInfo_data()
0034 {
0035     QTest::addColumn<QString>("fileName");
0036     QTest::addColumn<VideoConferenceInfo>("videoconferenceInfo");
0037     {
0038         VideoConferenceInfo info;
0039         info.setProviderName(QStringLiteral("jitsi"));
0040         info.setUrl(QStringLiteral("https://bla/RocketChat63ebad0405c6c93252c0f337"));
0041         info.setConferenceType(VideoConferenceInfo::Conference);
0042         info.setRoomId(QStringLiteral("hE6RS3iv5ND5EGWC6"));
0043         info.setStatus(1);
0044         info.setRinging(false);
0045         info.setCreatedAtDateTime(1676389636880);
0046         info.setMessageId(QStringLiteral("NusivujrtX38F8too"));
0047         info.setBlockId(QStringLiteral("63ebad0405c6c93252c0f337"));
0048         QTest::addRow("videoconferenceinfo") << QStringLiteral("videoconferenceinfo") << info;
0049     }
0050     {
0051         VideoConferenceInfo info;
0052         info.setProviderName(QStringLiteral("jitsi"));
0053         info.setUrl(QStringLiteral("https://goo/RocketChat639593184ef3f3baa965910c"));
0054         info.setConferenceType(VideoConferenceInfo::Conference);
0055         info.setRoomId(QStringLiteral("hE6RS3iv5ND5EGWC6"));
0056         info.setStatus(2);
0057         info.setRinging(false);
0058         info.setCreatedAtDateTime(1670746904785);
0059         info.setEndedAtDateTime(1670835600213);
0060         User user;
0061         user.setUserName(QStringLiteral("laurent"));
0062         user.setName(QStringLiteral("Laurent Montel"));
0063         user.setUserId(QStringLiteral("uKK39zoewTkdacidH"));
0064         user.setUtcOffset(0);
0065         user.setActive(true);
0066         user.setStatus(User::PresenceStatus::Unknown);
0067         info.setUsers({user});
0068         info.setMessageId(QStringLiteral("PmWesYrnRJkyTTi"));
0069         info.setBlockId(QStringLiteral("639593184ef3f3baa965910c"));
0070         QTest::addRow("videoconferenceinfo1") << QStringLiteral("videoconferenceinfo1") << info;
0071     }
0072 }
0073 
0074 void VideoConferenceInfoTest::shouldLoadVideoConferenceInfo()
0075 {
0076     QFETCH(QString, fileName);
0077     QFETCH(VideoConferenceInfo, videoconferenceInfo);
0078     const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/videoconferenceinfo/") + fileName + QLatin1String(".json");
0079     const QJsonObject obj = AutoTestHelper::loadJsonObject(originalJsonFile);
0080 
0081     VideoConferenceInfo r;
0082     r.parse(obj);
0083     const bool result = (r == videoconferenceInfo);
0084     if (!result) {
0085         qDebug() << "result " << r;
0086         qDebug() << "expected " << videoconferenceInfo;
0087     }
0088     QVERIFY(result);
0089 }
0090 
0091 #include "moc_videoconferenceinfotest.cpp"