From d4cd3d3005569e3bd6d9d840c4c30ffdfdacc5d0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 17 Nov 2016 11:52:09 +0100 Subject: [PATCH] feat(app): use wrapper --- tests/CMakeLists.txt | 7 +++-- tests/src/app/App.cpp | 4 +-- tests/src/components/core/CoreManager.cpp | 9 ++++++ tests/src/components/core/CoreManager.hpp | 31 +++++++++++++++++++ .../src/components/linphone/LinphoneCore.cpp | 5 --- .../src/components/linphone/LinphoneCore.hpp | 28 ----------------- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 tests/src/components/core/CoreManager.cpp create mode 100644 tests/src/components/core/CoreManager.hpp delete mode 100644 tests/src/components/linphone/LinphoneCore.cpp delete mode 100644 tests/src/components/linphone/LinphoneCore.hpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c89bbb7eb..5270d3e84 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,6 +26,8 @@ foreach (package ${QT5_PACKAGES}) endif () endforeach () +list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone++.so") + set(SOURCES src/app/App.cpp src/app/Logger.cpp @@ -33,7 +35,7 @@ set(SOURCES src/components/contacts/ContactModel.cpp src/components/contacts/ContactsListModel.cpp src/components/contacts/ContactsListProxyModel.cpp - src/components/linphone/LinphoneCore.cpp + src/components/core/CoreManager.cpp src/components/notifier/Notifier.cpp src/components/settings/AccountSettingsModel.cpp src/components/settings/SettingsModel.cpp @@ -48,7 +50,7 @@ set(HEADERS src/components/contacts/ContactModel.hpp src/components/contacts/ContactsListModel.hpp src/components/contacts/ContactsListProxyModel.hpp - src/components/linphone/LinphoneCore.hpp + src/components/core/CoreManager.hpp src/components/notifier/Notifier.hpp src/components/presence/Presence.hpp src/components/settings/AccountSettingsModel.hpp @@ -132,4 +134,5 @@ qt5_add_resources(RESOURCES ${QRC_RESOURCES}) add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES}) add_dependencies(${LINPHONE_EXEC} update_translations) add_dependencies(update_translations check_qml) +target_include_directories(${LINPHONE_EXEC} PRIVATE "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/include/") target_link_libraries(${LINPHONE_EXEC} ${LIBS}) diff --git a/tests/src/app/App.cpp b/tests/src/app/App.cpp index e7e71ff7e..3185fe677 100644 --- a/tests/src/app/App.cpp +++ b/tests/src/app/App.cpp @@ -5,7 +5,7 @@ #include #include "../components/contacts/ContactsListProxyModel.hpp" -#include "../components/linphone/LinphoneCore.hpp" +#include "../components/core/CoreManager.hpp" #include "../components/settings/AccountSettingsModel.hpp" #include "../components/timeline/TimelineModel.hpp" @@ -98,7 +98,7 @@ void App::addContextProperties () { context->setContextProperty("TimelineModel", new TimelineModel()); // Other. - context->setContextProperty("LinphoneCore", LinphoneCore::getInstance()); + context->setContextProperty("CoreManager", CoreManager::getInstance()); m_notifier = new Notifier(); context->setContextProperty("Notifier", m_notifier); diff --git a/tests/src/components/core/CoreManager.cpp b/tests/src/components/core/CoreManager.cpp new file mode 100644 index 000000000..e711d5756 --- /dev/null +++ b/tests/src/components/core/CoreManager.cpp @@ -0,0 +1,9 @@ +#include "CoreManager.hpp" + +// =================================================================== + +CoreManager *CoreManager::m_instance = nullptr; + +CoreManager::CoreManager (QObject *parent) : m_core( + linphone::Factory::get()->createCore(nullptr, "", "", nullptr) +) {} diff --git a/tests/src/components/core/CoreManager.hpp b/tests/src/components/core/CoreManager.hpp new file mode 100644 index 000000000..51f6ab2b2 --- /dev/null +++ b/tests/src/components/core/CoreManager.hpp @@ -0,0 +1,31 @@ +#ifndef CORE_MANAGER_H_ +#define CORE_MANAGER_H_ + +#include +#include + +// =================================================================== + +class CoreManager : public QObject { + Q_OBJECT; + +public: + static void init () { + if (!m_instance) { + m_instance = new CoreManager(); + } + } + + static CoreManager *getInstance () { + return m_instance; + } + +private: + CoreManager (QObject *parent = Q_NULLPTR); + + std::shared_ptr m_core; + + static CoreManager *m_instance; +}; + +#endif // CORE_MANAGER_H_ diff --git a/tests/src/components/linphone/LinphoneCore.cpp b/tests/src/components/linphone/LinphoneCore.cpp deleted file mode 100644 index 1fee20f3e..000000000 --- a/tests/src/components/linphone/LinphoneCore.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "LinphoneCore.hpp" - -// =================================================================== - -LinphoneCore *LinphoneCore::m_instance = nullptr; diff --git a/tests/src/components/linphone/LinphoneCore.hpp b/tests/src/components/linphone/LinphoneCore.hpp deleted file mode 100644 index 242f5a471..000000000 --- a/tests/src/components/linphone/LinphoneCore.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef LINPHONE_CORE_H_ -#define LINPHONE_CORE_H_ - -#include - -// =================================================================== - -class LinphoneCore : public QObject { - Q_OBJECT; - -public: - static void init () { - if (!m_instance) { - m_instance = new LinphoneCore(); - } - } - - static LinphoneCore *getInstance () { - return m_instance; - } - -private: - LinphoneCore (QObject *parent = Q_NULLPTR) {}; - - static LinphoneCore *m_instance; -}; - -#endif // LINPHONE_CORE_H_