From a9987b1bc7f789f3063c06ed23e1f51024341463 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 21 Jan 2021 19:16:31 +0100 Subject: Move tests --- autotests/CMakeLists.txt | 14 +++++++++++ autotests/callcandidateseventtest.cpp | 47 +++++++++++++++++++++++++++++++++++ autotests/callcandidateseventtest.h | 13 ++++++++++ 3 files changed, 74 insertions(+) create mode 100644 autotests/CMakeLists.txt create mode 100644 autotests/callcandidateseventtest.cpp create mode 100644 autotests/callcandidateseventtest.h (limited to 'autotests') diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt new file mode 100644 index 00000000..abfcb49a --- /dev/null +++ b/autotests/CMakeLists.txt @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2021 Carl Schwan +# +# SPDX-License-Identifier: BSD-3-Clause + +include(CMakeParseArguments) + +function(QUOTIENT_ADD_TEST) + cmake_parse_arguments(ARG "" "NAME" "" ${ARGN}) + add_executable(${ARG_NAME} ${ARG_NAME}.cpp) + target_link_libraries(${ARG_NAME} Qt5::Core Qt5::Test Quotient) + add_test(NAME ${ARG_NAME} COMMAND ${ARG_NAME}) +endfunction() + +quotient_add_test(callcandidateseventtest.cpp NAME callcandidateseventtest) diff --git a/autotests/callcandidateseventtest.cpp b/autotests/callcandidateseventtest.cpp new file mode 100644 index 00000000..ca908db3 --- /dev/null +++ b/autotests/callcandidateseventtest.cpp @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: 2020 Carl Schwan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include "events/callcandidatesevent.h" +#include "callcandidateseventtest.h" + +void TestCallCandidatesEvent::fromJson() +{ + auto document = QJsonDocument::fromJson(R"({ + "age": 242352, + "content": { + "call_id": "12345", + "candidates": [ + { + "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0", + "sdpMLineIndex": 0, + "sdpMid": "audio" + } + ], + "version": 0 + }, + "event_id": "$WLGTSEFSEF:localhost", + "origin_server_ts": 1431961217939, + "room_id": "!Cuyf34gef24t:localhost", + "sender": "@example:localhost", + "type": "m.call.candidates" + })"); + + QVERIFY(document.isObject()); + + auto object = documemt.object(); + + Quotient::CallCandidatesEvent callCandidatesEvent(object); + + QCOMPARE(callCandidatesEvent.version(), 0); + QCOMPARE(callCandidatesEvent.callId(), "12345"); + QCOMPARE(callCandidatesEvent.candidates().count(), 1); + + const QJsonObject &candidate = callCandidatesEvent.candidates().at(0).toObject(); + QCOMPARE(candidate.value("sdpMid").toString(), "audio"); + QCOMPARE(candidate.value("sdpMLineIndex").toInt(), 0); + QCOMPARE(candidate.value("candidate").toString(), "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0"); +} + +QTEST_MAIN(TestCallCandidatesEvent) +#include "callcandidateseventtest.moc" diff --git a/autotests/callcandidateseventtest.h b/autotests/callcandidateseventtest.h new file mode 100644 index 00000000..b81c9c9b --- /dev/null +++ b/autotests/callcandidateseventtest.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2020 Carl Schwan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include + +class TestCallCandidatesEvent : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void fromJson(); +}; -- cgit v1.2.3 From ba9c361b6ee18401fcd9a79175f56758a11d7f7d Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 21 Jan 2021 19:21:00 +0100 Subject: fix build --- autotests/CMakeLists.txt | 2 +- autotests/callcandidateseventtest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'autotests') diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index abfcb49a..07f1f046 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -11,4 +11,4 @@ function(QUOTIENT_ADD_TEST) add_test(NAME ${ARG_NAME} COMMAND ${ARG_NAME}) endfunction() -quotient_add_test(callcandidateseventtest.cpp NAME callcandidateseventtest) +quotient_add_test(NAME callcandidateseventtest) diff --git a/autotests/callcandidateseventtest.cpp b/autotests/callcandidateseventtest.cpp index ca908db3..f103e4d3 100644 --- a/autotests/callcandidateseventtest.cpp +++ b/autotests/callcandidateseventtest.cpp @@ -29,7 +29,7 @@ void TestCallCandidatesEvent::fromJson() QVERIFY(document.isObject()); - auto object = documemt.object(); + auto object = document.object(); Quotient::CallCandidatesEvent callCandidatesEvent(object); -- cgit v1.2.3