aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-01-22 16:38:34 +0100
committerGitHub <noreply@github.com>2021-01-22 16:38:34 +0100
commit0e3973cade9348946a3675a242723711b9b75ad1 (patch)
tree243fc6758f175e0e9d2d2a8581b7072400b63566
parent9fb2970eadf810f7ae38389b333b543c22fb8be7 (diff)
parent390162a0c707c51590acb27df81e98a85d3b6cf7 (diff)
downloadlibquotient-0e3973cade9348946a3675a242723711b9b75ad1.tar.gz
libquotient-0e3973cade9348946a3675a242723711b9b75ad1.zip
Merge pull request #440 from ognarb/callcandidateupdate
Add more properties to CallCandidateEvent
-rw-r--r--CMakeLists.txt10
-rw-r--r--autotests/CMakeLists.txt14
-rw-r--r--autotests/callcandidateseventtest.cpp47
-rw-r--r--autotests/callcandidateseventtest.h13
-rw-r--r--lib/events/callcandidatesevent.h11
-rw-r--r--quotest/.valgrind.supp (renamed from tests/.valgrind.supp)0
-rw-r--r--quotest/CMakeLists.txt8
-rw-r--r--quotest/quotest.cpp (renamed from tests/quotest.cpp)0
-rw-r--r--tests/CMakeLists.txt71
9 files changed, 98 insertions, 76 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29dea14a..0bc3a559 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,8 +259,6 @@ endif()
# new files and if it has, re-run cmake.
file(GLOB_RECURSE api_SRCS ${add_CONFIGURE_DEPENDS} ${FULL_CSAPI_DIR}/*.cpp)
-set(tests_SRCS tests/quotest.cpp)
-
add_library(${PROJECT_NAME} ${lib_SRCS} ${api_SRCS})
target_compile_definitions(${PROJECT_NAME} PRIVATE QT_NO_JAVA_STYLE_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_CAST_TO_ASCII)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0"
@@ -290,9 +288,11 @@ if (${PROJECT_NAME}_ENABLE_E2EE)
endif()
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Multimedia)
-set(TEST_BINARY quotest)
-add_executable(${TEST_BINARY} ${tests_SRCS})
-target_link_libraries(${TEST_BINARY} Qt5::Core Qt5::Test ${PROJECT_NAME})
+if (BUILD_TESTING)
+ enable_testing()
+ add_subdirectory(quotest)
+ add_subdirectory(autotests)
+endif()
configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY NEWLINE_STYLE UNIX)
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
new file mode 100644
index 00000000..07f1f046
--- /dev/null
+++ b/autotests/CMakeLists.txt
@@ -0,0 +1,14 @@
+# SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+#
+# 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(NAME callcandidateseventtest)
diff --git a/autotests/callcandidateseventtest.cpp b/autotests/callcandidateseventtest.cpp
new file mode 100644
index 00000000..f103e4d3
--- /dev/null
+++ b/autotests/callcandidateseventtest.cpp
@@ -0,0 +1,47 @@
+// SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
+//
+// 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 = document.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 <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include <QtTest/QtTest>
+
+class TestCallCandidatesEvent : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void fromJson();
+};
diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h
index b9de7556..c2ccac3b 100644
--- a/lib/events/callcandidatesevent.h
+++ b/lib/events/callcandidatesevent.h
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2017 Marius Gripsgard <marius@ubports.com>
// SPDX-FileCopyrightText: 2018 Josip Delic <delijati@googlemail.com>
// SPDX-FileCopyrightText: 2018 Kitsune Ral <Kitsune-Ral@users.sf.net>
+// SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
@@ -26,6 +27,16 @@ public:
{
return content<QJsonArray>("candidates"_ls);
}
+
+ QString callId() const
+ {
+ return content<QString>("call_id");
+ }
+
+ int version() const
+ {
+ return content<int>("version");
+ }
};
REGISTER_EVENT_TYPE(CallCandidatesEvent)
diff --git a/tests/.valgrind.supp b/quotest/.valgrind.supp
index d65fb52e..d65fb52e 100644
--- a/tests/.valgrind.supp
+++ b/quotest/.valgrind.supp
diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt
new file mode 100644
index 00000000..d17e8620
--- /dev/null
+++ b/quotest/CMakeLists.txt
@@ -0,0 +1,8 @@
+# SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+set(quotest_SRCS quotest.cpp)
+
+add_executable(quotest ${quotest_SRCS})
+target_link_libraries(quotest PRIVATE Qt5::Core Qt5::Test ${PROJECT_NAME})
diff --git a/tests/quotest.cpp b/quotest/quotest.cpp
index 5098bc02..5098bc02 100644
--- a/tests/quotest.cpp
+++ b/quotest/quotest.cpp
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
deleted file mode 100644
index cb8c99f8..00000000
--- a/tests/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-cmake_minimum_required(VERSION 3.1)
-
-# This CMakeLists file assumes that the library is installed to CMAKE_INSTALL_PREFIX
-# and ignores the in-tree library code. You can use this to start work on your own client.
-
-project(quotest CXX)
-
-include(CheckCXXCompilerFlag)
-if (NOT WIN32)
- include(GNUInstallDirs)
-endif(NOT WIN32)
-
-# Find includes in corresponding build directories
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-# Instruct CMake to run moc automatically when needed.
-set(CMAKE_AUTOMOC ON)
-
-# Set a default build type if none was specified
-if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
- message(STATUS "Setting build type to 'Debug' as none was specified")
- set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
- # Set the possible values of build type for cmake-gui
- set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
- "MinSizeRel" "RelWithDebInfo")
-endif()
-
-if (NOT CMAKE_INSTALL_LIBDIR)
- set(CMAKE_INSTALL_LIBDIR ".")
-endif()
-
-if (NOT CMAKE_INSTALL_BINDIR)
- set(CMAKE_INSTALL_BINDIR ".")
-endif()
-
-if (NOT CMAKE_INSTALL_INCLUDEDIR)
- set(CMAKE_INSTALL_INCLUDEDIR "include")
-endif()
-
-set(CMAKE_CXX_STANDARD 14)
-
-foreach (FLAG all "" pedantic extra error=return-type no-unused-parameter no-gnu-zero-variadic-macro-arguments)
- CHECK_CXX_COMPILER_FLAG("-W${FLAG}" WARN_${FLAG}_SUPPORTED)
- if ( WARN_${FLAG}_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "(^| )-W?${FLAG}($| )")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${FLAG}")
- endif ()
-endforeach ()
-
-find_package(Qt5 5.9 REQUIRED Network Gui Multimedia Test)
-get_filename_component(Qt5_Prefix "${Qt5_DIR}/../../../.." ABSOLUTE)
-
-set(LIBRARY_NAME "Quotient")
-
-find_package(${LIBRARY_NAME} REQUIRED)
-get_filename_component(Quotient_Prefix "${Quotient_DIR}/../.." ABSOLUTE)
-
-message( STATUS "${PROJECT_NAME} configuration:" )
-if (CMAKE_BUILD_TYPE)
- message( STATUS " Build type: ${CMAKE_BUILD_TYPE}")
-endif(CMAKE_BUILD_TYPE)
-message( STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
-message( STATUS " Qt: ${Qt5_VERSION} at ${Qt5_Prefix}" )
-message( STATUS " ${LIBRARY_NAME}: ${${LIBRARY_NAME}_VERSION} at ${${LIBRARY_NAME}_Prefix}" )
-
-set(example_SRCS quotest.cpp)
-
-add_executable(${PROJECT_NAME} ${example_SRCS})
-target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Test ${LIBRARY_NAME})
-
-# Installation
-
-install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})