File indexing completed on 2025-02-02 04:51:35
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 "videoconferencestartjobtest.h" 0008 #include "ruqola_restapi_helper.h" 0009 #include "video-conference/videoconferencestartjob.h" 0010 #include <QJsonDocument> 0011 QTEST_GUILESS_MAIN(VideoConferenceStartJobTest) 0012 using namespace RocketChatRestApi; 0013 VideoConferenceStartJobTest::VideoConferenceStartJobTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void VideoConferenceStartJobTest::shouldHaveDefaultValue() 0019 { 0020 VideoConferenceStartJob job; 0021 verifyDefaultValue(&job); 0022 QVERIFY(job.requireHttpAuthentication()); 0023 QVERIFY(!job.hasQueryParameterSupport()); 0024 QVERIFY(!job.info().isValid()); 0025 } 0026 0027 void VideoConferenceStartJobTest::shouldGenerateRequest() 0028 { 0029 VideoConferenceStartJob job; 0030 QNetworkRequest request = QNetworkRequest(QUrl()); 0031 verifyAuthentication(&job, request); 0032 QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/video-conference.start"))); 0033 QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); 0034 } 0035 0036 void VideoConferenceStartJobTest::shouldGenerateJson() 0037 { 0038 VideoConferenceStartJob job; 0039 VideoConferenceStartJob::VideoConferenceStartInfo info; 0040 info.allowRinging = false; 0041 info.roomId = QStringLiteral("foo"); 0042 info.title = QStringLiteral("bla"); 0043 job.setInfo(info); 0044 QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral(R"({"allowRinging":false,"roomId":"foo","title":"bla"})").toLatin1()); 0045 } 0046 0047 void VideoConferenceStartJobTest::shouldNotStarting() 0048 { 0049 VideoConferenceStartJob job; 0050 0051 RestApiMethod method; 0052 method.setServerUrl(QStringLiteral("http://www.kde.org")); 0053 job.setRestApiMethod(&method); 0054 0055 QNetworkAccessManager mNetworkAccessManager; 0056 job.setNetworkAccessManager(&mNetworkAccessManager); 0057 QVERIFY(!job.canStart()); 0058 const QString auth = QStringLiteral("foo"); 0059 const QString userId = QStringLiteral("foo"); 0060 job.setAuthToken(auth); 0061 QVERIFY(!job.canStart()); 0062 job.setUserId(userId); 0063 QVERIFY(!job.canStart()); 0064 VideoConferenceStartJob::VideoConferenceStartInfo info; 0065 info.allowRinging = false; 0066 info.roomId = QStringLiteral("foo"); 0067 info.title = QStringLiteral("bla"); 0068 job.setInfo(info); 0069 QVERIFY(job.canStart()); 0070 } 0071 0072 #include "moc_videoconferencestartjobtest.cpp"