diff --git a/src/rocketchatrestapi-qt5/autotests/CMakeLists.txt b/src/rocketchatrestapi-qt5/autotests/CMakeLists.txt index 34bf72c3..1a7a47ff 100644 --- a/src/rocketchatrestapi-qt5/autotests/CMakeLists.txt +++ b/src/rocketchatrestapi-qt5/autotests/CMakeLists.txt @@ -1,86 +1,87 @@ macro(add_ruqola_test _source) set( _test ${_source}) get_filename_component( _name ${_source} NAME_WE ) add_executable( ${_name} ${_test} ) add_test(NAME ${_name} COMMAND ${_name} ) ecm_mark_as_test(${_name}) target_link_libraries( ${_name} Qt5::Test librocketchatrestapi-qt5) endmacro() add_ruqola_test(restapiutiltest.cpp) add_ruqola_test(restapimethodtest.cpp) add_ruqola_test(serverinfojobtest.cpp) add_ruqola_test(uploadfilejobtest.cpp) add_ruqola_test(owninfojobtest.cpp) add_ruqola_test(getavatarjobtest.cpp) add_ruqola_test(logoutjobtest.cpp) add_ruqola_test(loginjobtest.cpp) add_ruqola_test(privateinfojobtest.cpp) add_ruqola_test(channellistjobtest.cpp) add_ruqola_test(starmessagejobtest.cpp) add_ruqola_test(downloadfilejobtest.cpp) add_ruqola_test(pinmessagejobtest.cpp) add_ruqola_test(postmessagejobtest.cpp) add_ruqola_test(changechanneltopicjobtest.cpp) add_ruqola_test(changechannelannouncementjobtest.cpp) add_ruqola_test(changegroupstopicjobtest.cpp) add_ruqola_test(changegroupsannouncementjobtest.cpp) add_ruqola_test(changechannelnamejobtest.cpp) add_ruqola_test(changegroupsnamejobtest.cpp) add_ruqola_test(deletemessagejobtest.cpp) add_ruqola_test(createchanneljobtest.cpp) add_ruqola_test(creategroupsjobtest.cpp) add_ruqola_test(leavechanneljobtest.cpp) add_ruqola_test(leavegroupsjobtest.cpp) add_ruqola_test(updatemessagejobtest.cpp) add_ruqola_test(reactonmessagejobtest.cpp) add_ruqola_test(channelclosejobtest.cpp) add_ruqola_test(createdmjobtest.cpp) add_ruqola_test(channelhistoryjobtest.cpp) add_ruqola_test(changechanneldescriptionjobtest.cpp) add_ruqola_test(changegroupsdescriptionjobtest.cpp) add_ruqola_test(changechannelreadonlyjobtest.cpp) add_ruqola_test(archivechanneljobtest.cpp) add_ruqola_test(archivegroupsjobtest.cpp) add_ruqola_test(channelfilesjobtest.cpp) add_ruqola_test(channelinvitejobtest.cpp) add_ruqola_test(groupsinvitejobtest.cpp) add_ruqola_test(loademojicustomjobtest.cpp) add_ruqola_test(spotlightjobtest.cpp) add_ruqola_test(searchmessagejobtest.cpp) add_ruqola_test(savenotificationjobtest.cpp) add_ruqola_test(markroomasreadjobtest.cpp) add_ruqola_test(settingsoauthjobtest.cpp) add_ruqola_test(facebookauthjobtest.cpp) add_ruqola_test(googleauthjobtest.cpp) add_ruqola_test(twitterauthjobtest.cpp) add_ruqola_test(roomfavoritejobtest.cpp) add_ruqola_test(setjoincodechanneljobtest.cpp) add_ruqola_test(setavatarjobtest.cpp) add_ruqola_test(markroomasunreadjobtest.cpp) add_ruqola_test(forgotpasswordjobtest.cpp) add_ruqola_test(usersinfojobtest.cpp) add_ruqola_test(ignoreuserjobtest.cpp) add_ruqola_test(channelremoveownerjobtest.cpp) add_ruqola_test(getpresencejobtest.cpp) add_ruqola_test(reportmessagejobtest.cpp) add_ruqola_test(resetavatarjobtest.cpp) add_ruqola_test(setgrouptypejobtest.cpp) add_ruqola_test(setchanneltypejobtest.cpp) add_ruqola_test(getchannelrolesjobtest.cpp) add_ruqola_test(getgrouprolesjobtest.cpp) add_ruqola_test(getusernamesuggestionjobtest.cpp) add_ruqola_test(listpermissionsjobtest.cpp) add_ruqola_test(listcommandsjobtest.cpp) add_ruqola_test(channeladdownerjobtest.cpp) add_ruqola_test(channeladdmoderatorjobtest.cpp) add_ruqola_test(groupaddmoderatorjobtest.cpp) add_ruqola_test(groupaddownerjobtest.cpp) add_ruqola_test(getmessagejobtest.cpp) add_ruqola_test(channelkickjobtest.cpp) add_ruqola_test(groupskickjobtest.cpp) add_ruqola_test(fetchmykeysjobtest.cpp) add_ruqola_test(setuserpublicandprivatekeysjobtest.cpp) add_ruqola_test(channeljoinjobtest.cpp) add_ruqola_test(roomleavejobtest.cpp) add_ruqola_test(getroomsjobtest.cpp) +add_ruqola_test(channelinfojobtest.cpp) diff --git a/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp new file mode 100644 index 00000000..a2df5221 --- /dev/null +++ b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp @@ -0,0 +1,72 @@ +/* + Copyright (c) 2019 Montel Laurent + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2 of the License or + ( at your option ) version 3 or, at the discretion of KDE e.V. + ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "channelinfojobtest.h" +#include "channels/channelinfojob.h" +#include "ruqola_restapi_helper.h" +#include +QTEST_GUILESS_MAIN(ChannelInfoJobTest) +using namespace RocketChatRestApi; +ChannelInfoJobTest::ChannelInfoJobTest(QObject *parent) + : QObject(parent) +{ +} + +void ChannelInfoJobTest::shouldHaveDefaultValue() +{ + ChannelInfoJob job; + verifyDefaultValue(&job); + QVERIFY(job.requireHttpAuthentication()); + QVERIFY(job.roomId().isEmpty()); +} + +void ChannelInfoJobTest::shouldGenerateRequest() +{ + ChannelInfoJob job; + job.setRoomId(QStringLiteral("foo")); + QNetworkRequest request = QNetworkRequest(QUrl()); + verifyAuthentication(&job, request); + QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.info?roomId=foo"))); +} + +void ChannelInfoJobTest::shouldNotStarting() +{ + ChannelInfoJob job; + + RestApiMethod *method = new RestApiMethod; + method->setServerUrl(QStringLiteral("http://www.kde.org")); + job.setRestApiMethod(method); + + QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; + job.setNetworkAccessManager(mNetworkAccessManager); + QVERIFY(!job.canStart()); + const QString auth = QStringLiteral("foo"); + const QString userId = QStringLiteral("foo"); + job.setAuthToken(auth); + QVERIFY(!job.canStart()); + job.setUserId(userId); + QVERIFY(!job.canStart()); + const QString roomId = QStringLiteral("foo1"); + job.setRoomId(roomId); + QVERIFY(job.canStart()); + + delete method; + delete mNetworkAccessManager; +} diff --git a/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.h b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.h new file mode 100644 index 00000000..3e539cfe --- /dev/null +++ b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.h @@ -0,0 +1,38 @@ +/* + Copyright (c) 2019 Montel Laurent + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2 of the License or + ( at your option ) version 3 or, at the discretion of KDE e.V. + ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef CHANNELINFOJOBTEST_H +#define CHANNELINFOJOBTEST_H + +#include + +class ChannelInfoJobTest : public QObject +{ + Q_OBJECT +public: + explicit ChannelInfoJobTest(QObject *parent = nullptr); + ~ChannelInfoJobTest() = default; +private Q_SLOTS: + void shouldHaveDefaultValue(); + void shouldGenerateRequest(); + void shouldNotStarting(); +}; + +#endif // CHANNELINFOJOBTEST_H