From ea5e3849ba0d93f89ff2c2271ecf79bd96d8a099 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 17 Jul 2017 12:27:33 +0200 Subject: [PATCH 01/28] fix(ContactEdit): set correctly focus on username field when the `add button` of the smart bar is clicked --- ui/views/App/Main/ContactEdit.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/views/App/Main/ContactEdit.qml b/ui/views/App/Main/ContactEdit.qml index d0f69a41c..24746d6d5 100644 --- a/ui/views/App/Main/ContactEdit.qml +++ b/ui/views/App/Main/ContactEdit.qml @@ -109,7 +109,7 @@ ColumnLayout { onEditingFinished: Logic.setUsername(text) onReadOnlyChanged: { if (!readOnly) { - focus = true + forceActiveFocus() } } } From c457fbadc59abe098714f3ddf5b0218de39577f2 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 17 Jul 2017 17:20:00 +0200 Subject: [PATCH 02/28] feat(App): provide a way to run tests (in progress) --- CMakeLists.txt | 99 +++++++++++++++++-------- src/{main.cpp => app/AppController.cpp} | 45 ++++++----- src/app/AppController.hpp | 42 +++++++++++ src/app/main.cpp | 41 ++++++++++ src/tests/SelfTest.cpp | 36 +++++++++ src/tests/main.cpp | 41 ++++++++++ 6 files changed, 248 insertions(+), 56 deletions(-) rename src/{main.cpp => app/AppController.cpp} (81%) create mode 100644 src/app/AppController.hpp create mode 100644 src/app/main.cpp create mode 100644 src/tests/SelfTest.cpp create mode 100644 src/tests/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 07c834dbc..2f37878ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,14 @@ cmake_minimum_required(VERSION 3.1) project(linphoneqt VERSION 4.0) +set(APP_LIBRARY app-library) + set(EXECUTABLE_NAME linphone) +set(TESTER_EXECUTABLE_NAME "${EXECUTABLE_NAME}-tester") + set(TARGET_NAME linphone-qt) +set(TESTER_TARGET_NAME "${TARGET_NAME}-tester") + set(CMAKE_CXX_STANDARD 11) set(ASSETS_DIR assets) @@ -98,6 +104,7 @@ endif () set(SOURCES src/app/App.cpp + src/app/AppController.cpp src/app/cli/Cli.cpp src/app/logger/Logger.cpp src/app/paths/Paths.cpp @@ -144,7 +151,6 @@ set(SOURCES src/components/telephone-numbers/TelephoneNumbersModel.cpp src/components/timeline/TimelineModel.cpp src/components/url-handlers/UrlHandlers.cpp - src/main.cpp src/utils/LinphoneUtils.cpp src/utils/Utils.cpp src/utils/QExifImageHeader.cpp @@ -152,6 +158,7 @@ set(SOURCES set(HEADERS src/app/App.hpp + src/app/AppController.hpp src/app/cli/Cli.hpp src/app/logger/Logger.hpp src/app/paths/Paths.hpp @@ -205,6 +212,13 @@ set(HEADERS src/utils/QExifImageHeader.h ) +set(TESTS + src/tests/SelfTest.cpp +) + +set(MAIN_FILE src/app/main.cpp) +set(TESTER_MAIN_FILE src/tests/main.cpp) + if(APPLE) list(APPEND SOURCES src/components/core/MessagesCountNotifierMacOS.m) endif() @@ -288,6 +302,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BIN find_package(Qt5 COMPONENTS ${QT5_PACKAGES} REQUIRED) find_package(Qt5 COMPONENTS ${QT5_PACKAGES_OPTIONAL} QUIET) +find_package(Qt5 COMPONENTS Test REQUIRED) if (CMAKE_INSTALL_RPATH) get_target_property(LUPDATE_PATH Qt5::lupdate LOCATION) @@ -304,46 +319,44 @@ list(APPEND QRC_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGES_DIRECTORY}/${ qt5_add_resources(RESOURCES ${QRC_RESOURCES}) # Build. -# Note: `update_translations` is provided by `languages/CMakeLists.txt`. +add_library(${APP_LIBRARY} OBJECT ${SOURCES} ${HEADERS} ${RESOURCES} ${QML_SOURCES}) +set_property(TARGET ${APP_LIBRARY} PROPERTY POSITION_INDEPENDENT_CODE ON) + +bc_git_version(${TARGET_NAME} ${PROJECT_VERSION}) +add_dependencies(${APP_LIBRARY} ${TARGET_NAME}-git-version) +add_dependencies(${APP_LIBRARY} update_translations) + if (WIN32) - add_executable(${TARGET_NAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} assets/linphone.rc) + add_executable(${TARGET_NAME} WIN32 $ assets/linphone.rc ${MAIN_FILE}) + add_executable(${TESTER_TARGET_NAME} WIN32 $ assets/linphone.rc ${TESTER_MAIN_FILE} ${TESTS}) else () - add_executable(${TARGET_NAME} ${SOURCES} ${HEADERS} ${RESOURCES} ${QML_SOURCES}) + add_executable(${TARGET_NAME} $ ${MAIN_FILE}) + add_executable(${TESTER_TARGET_NAME} $ ${TESTER_MAIN_FILE} ${TESTS}) endif () - bc_git_version(${TARGET_NAME} ${PROJECT_VERSION}) - add_dependencies(${TARGET_NAME} ${TARGET_NAME}-git-version) - add_dependencies(${TARGET_NAME} update_translations) + if (NOT WIN32) add_dependencies(update_translations check_qml) endif () set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}") -target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${LINPHONECXX_INCLUDE_DIRS}" "${LINPHONE_INCLUDE_DIRS}" "${BELCARD_INCLUDE_DIRS}" "${BCTOOLBOX_INCLUDE_DIRS}") +set_target_properties(${TESTER_TARGET_NAME} PROPERTIES OUTPUT_NAME "${TESTER_EXECUTABLE_NAME}") -# To start better integration into IDE. -source_group( - "Qml" REGULAR_EXPRESSION ".+\.qml$" -) -source_group( - "Js" REGULAR_EXPRESSION ".+\.js)$" -) -source_group( - "Svg" REGULAR_EXPRESSION ".+\.svg$" -) +set(INCLUDED_DIRECTORIES "${LINPHONECXX_INCLUDE_DIRS}" "${LINPHONE_INCLUDE_DIRS}" "${BELCARD_INCLUDE_DIRS}" "${BCTOOLBOX_INCLUDE_DIRS}") +set(LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES} ${BELCARD_LIBRARIES} ${LINPHONE_LIBRARIES} ${LINPHONECXX_LIBRARIES}) foreach (package ${QT5_PACKAGES}) - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${Qt5${package}_INCLUDE_DIRS}") + list(APPEND INCLUDED_DIRECTORIES "${Qt5${package}_INCLUDE_DIRS}") # `qt5_create_translation` is provided from `LinguistTools` package. # But the `Qt5::LinguistTools` lib does not exist. Remove it. if (NOT (${package} STREQUAL LinguistTools)) - target_link_libraries(${TARGET_NAME} ${Qt5${package}_LIBRARIES}) + list(APPEND LIBRARIES ${Qt5${package}_LIBRARIES}) endif () endforeach () foreach (package ${QT5_PACKAGES_OPTIONAL}) if ("${Qt5${package}_FOUND}") message("Optional package ${package} found.") - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${Qt5${package}_INCLUDE_DIRS}") - target_link_libraries(${TARGET_NAME} ${Qt5${package}_LIBRARIES}) + list(APPEND INCLUDED_DIRECTORIES "${Qt5${package}_INCLUDE_DIRS}") + list(APPEND LIBRARIES ${Qt5${package}_LIBRARIES}) string(TOUPPER "${package}" INCLUDE_NAME) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${INCLUDE_NAME}_ENABLED") @@ -352,17 +365,25 @@ foreach (package ${QT5_PACKAGES_OPTIONAL}) endif () endforeach () -target_link_libraries(${TARGET_NAME} ${BCTOOLBOX_CORE_LIBRARIES} ${BELCARD_LIBRARIES} ${LINPHONE_LIBRARIES} ${LINPHONECXX_LIBRARIES}) -if(APPLE) - target_link_libraries(${TARGET_NAME} "-framework Cocoa") -endif() +if (APPLE) + list(APPEND LIBRARIES "-framework Cocoa") +endif () -install(TARGETS ${TARGET_NAME} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) +target_include_directories(${APP_LIBRARY} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES}) +target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES}) +target_include_directories(${TESTER_TARGET_NAME} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES}) + +target_link_libraries(${TARGET_NAME} ${LIBRARIES}) +target_link_libraries(${TESTER_TARGET_NAME} ${LIBRARIES} Qt5::Test) + +foreach (target ${TARGET_NAME} ${TESTER_TARGET_NAME}) + install(TARGETS ${target} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) +endforeach () install(FILES "assets/linphone.desktop" DESTINATION "${CMAKE_INSTALL_DATADIR}/applications" @@ -392,3 +413,17 @@ install(FILES "${ASSETS_ASSISTANT_DIR}/create-linphone-sip-account.rc" install(FILES "${ASSETS_ASSISTANT_DIR}/use-linphone-sip-account.rc" DESTINATION "${ASSISTANT_INSTALL_DATADIR}" ) + +# ------------------------------------------------------------------------------ +# To start better integration into IDE. +# ------------------------------------------------------------------------------ + +source_group( + "Qml" REGULAR_EXPRESSION ".+\.qml$" +) +source_group( + "Js" REGULAR_EXPRESSION ".+\.js)$" +) +source_group( + "Svg" REGULAR_EXPRESSION ".+\.svg$" +) diff --git a/src/main.cpp b/src/app/AppController.cpp similarity index 81% rename from src/main.cpp rename to src/app/AppController.cpp index 36fdb5e30..f0f607c55 100644 --- a/src/main.cpp +++ b/src/app/AppController.cpp @@ -1,5 +1,5 @@ /* - * main.cpp + * AppController.cpp * Copyright (C) 2017 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Created on: February 2, 2017 + * Created on: July 17, 2017 * Author: Ronan Abhamon */ @@ -26,7 +26,7 @@ #include "gitversion.h" -#include "app/App.hpp" +#include "AppController.hpp" // Must be unique. Used by `SingleApplication` and `Paths`. #define APPLICATION_NAME "linphone" @@ -39,7 +39,14 @@ using namespace std; // ============================================================================= -int main (int argc, char *argv[]) { +#ifndef QT_NO_DEBUG + bool AppController::mCreated = false; +#endif // ifndef QT_NO_DEBUG + +AppController::AppController (int &argc, char *argv[]) { + Q_ASSERT(!mCreated); + mCreated = true; + QT_REQUIRE_VERSION(argc, argv, APPLICATION_MINIMAL_QT_VERSION); // Disable QML cache. Avoid malformed cache. @@ -81,12 +88,11 @@ int main (int argc, char *argv[]) { QCoreApplication::setApplicationName(APPLICATION_NAME); QCoreApplication::setApplicationVersion(APPLICATION_VERSION); - App app(argc, argv); - - if (app.isSecondary()) { - QString command = app.getCommandArgument(); - app.sendMessage(command.isEmpty() ? "show" : command.toLocal8Bit(), -1); - return 0; + mApp = new App(argc, argv); + if (mApp->isSecondary()) { + QString command = mApp->getCommandArgument(); + mApp->sendMessage(command.isEmpty() ? "show" : command.toLocal8Bit(), -1); + return; } // --------------------------------------------------------------------------- @@ -104,18 +110,9 @@ int main (int argc, char *argv[]) { } } - app.setFont(QFont(DEFAULT_FONT)); - - // --------------------------------------------------------------------------- - // Init and run! - // --------------------------------------------------------------------------- - - qInfo() << QStringLiteral("Running app..."); - - int ret; - do { - app.initContentApp(); - ret = app.exec(); - } while (ret == APP_CODE_RESTART); - return ret; + mApp->setFont(QFont(DEFAULT_FONT)); +} + +AppController::~AppController () { + delete mApp; } diff --git a/src/app/AppController.hpp b/src/app/AppController.hpp new file mode 100644 index 000000000..4711e0c5a --- /dev/null +++ b/src/app/AppController.hpp @@ -0,0 +1,42 @@ +/* + * AppController.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 17, 2017 + * Author: Ronan Abhamon + */ + +#include "App.hpp" + +// ============================================================================= + +class AppController { +public: + AppController (int &argc, char *argv[]); + ~AppController (); + + App *getApp () const { + return mApp; + } + +private: + App *mApp = nullptr; + + #ifndef QT_NO_DEBUG + static bool mCreated; + #endif // ifndef QT_NO_DEBUG +}; diff --git a/src/app/main.cpp b/src/app/main.cpp new file mode 100644 index 000000000..f3394c8fa --- /dev/null +++ b/src/app/main.cpp @@ -0,0 +1,41 @@ +/* + * main.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: February 2, 2017 + * Author: Ronan Abhamon + */ + +#include "AppController.hpp" + +// ============================================================================= + +int main (int argc, char *argv[]) { + AppController controller(argc, argv); + App *app = controller.getApp(); + if (app->isSecondary()) + return 0; + + qInfo() << QStringLiteral("Running app..."); + + int ret; + do { + app->initContentApp(); + ret = app->exec(); + } while (ret == APP_CODE_RESTART); + return ret; +} diff --git a/src/tests/SelfTest.cpp b/src/tests/SelfTest.cpp new file mode 100644 index 000000000..0daf4bcd4 --- /dev/null +++ b/src/tests/SelfTest.cpp @@ -0,0 +1,36 @@ +/* + * SelfTest.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 17, 2017 + * Author: Ronan Abhamon + */ + +#include + +// ============================================================================= + +class SelfTest : public QObject { + Q_OBJECT; + +private slots: + void t1 () { + QVERIFY(true); + } +}; + +#include "SelfTest.moc" diff --git a/src/tests/main.cpp b/src/tests/main.cpp new file mode 100644 index 000000000..3c0050fd1 --- /dev/null +++ b/src/tests/main.cpp @@ -0,0 +1,41 @@ +/* + * main.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 17, 2017 + * Author: Ronan Abhamon + */ + +#include "../app/AppController.hpp" + +// ============================================================================= + +int main (int argc, char *argv[]) { + AppController controller(argc, argv); + App *app = controller.getApp(); + if (app->isSecondary()) + return 0; + + qInfo() << QStringLiteral("Running test..."); + + int ret; + do { + app->initContentApp(); + ret = app->exec(); + } while (ret == APP_CODE_RESTART); + return ret; +} From 4524a4036ef96536a3b3e3913f78a43aedd24cee Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Mon, 17 Jul 2017 20:48:46 +0200 Subject: [PATCH 03/28] feat(App): supports test, `self-test` is now a test and not a program option --- CMakeLists.txt | 3 +- assets/languages/en.ts | 8 ---- assets/languages/fr.ts | 8 ---- src/app/App.cpp | 31 +++---------- src/app/App.hpp | 2 - src/app/AppController.cpp | 8 +--- src/app/AppController.hpp | 5 +- src/app/main.cpp | 2 +- src/tests/main.cpp | 64 ++++++++++++++++++++++---- src/tests/{ => self-test}/SelfTest.cpp | 21 +++++---- src/tests/self-test/SelfTest.hpp | 35 ++++++++++++++ 11 files changed, 113 insertions(+), 74 deletions(-) rename src/tests/{ => self-test}/SelfTest.cpp (76%) create mode 100644 src/tests/self-test/SelfTest.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f37878ce..1b7ec363c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,7 +213,8 @@ set(HEADERS ) set(TESTS - src/tests/SelfTest.cpp + src/tests/self-test/SelfTest.cpp + src/tests/self-test/SelfTest.hpp ) set(MAIN_FILE src/app/main.cpp) diff --git a/assets/languages/en.ts b/assets/languages/en.ts index 6b7d385cc..281b50462 100644 --- a/assets/languages/en.ts +++ b/assets/languages/en.ts @@ -40,10 +40,6 @@ App - - selfTestResult - Linphone seems to be running correctly. - commandLineOptionVerbose log to stdout some debug information while running @@ -52,10 +48,6 @@ commandLineOptionConfig specify the linphone configuration file to be used - - commandLineOptionSelfTest - run self test and exit 0 if it succeeded - applicationDescription A free (libre) SIP video-phone. diff --git a/assets/languages/fr.ts b/assets/languages/fr.ts index 350620590..0c9f5defa 100644 --- a/assets/languages/fr.ts +++ b/assets/languages/fr.ts @@ -40,10 +40,6 @@ App - - selfTestResult - Linphone semble fonctionner normalement. - commandLineOptionVerbose afficher sur stdout les informations de debug @@ -52,10 +48,6 @@ commandLineOptionConfig spécifier un fichier de configuration à utiliser - - commandLineOptionSelfTest - éxécuter un test automatique et retourner 0 en cas de succès - applicationDescription Un logiciel libre de voix sur IP SIP. diff --git a/src/app/App.cpp b/src/app/App.cpp index f6b684171..9a6f4df3c 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -55,8 +55,6 @@ #define QML_VIEW_SPLASH_SCREEN "qrc:/ui/views/App/SplashScreen/SplashScreen.qml" -#define SELF_TEST_DELAY 300000 - #define VERSION_UPDATE_CHECK_INTERVAL 86400000 // 24 hours in milliseconds. using namespace std; @@ -202,19 +200,12 @@ void App::initContentApp () { mNotifier = new Notifier(mEngine); // Load splashscreen. - bool selfTest = mParser->isSet("self-test"); - if (!selfTest) { - #ifdef Q_OS_MACOS + #ifdef Q_OS_MACOS + ::activeSplashScreen(mEngine); + #else + if (!mParser->isSet("iconified")) ::activeSplashScreen(mEngine); - #else - if (!mParser->isSet("iconified")) - ::activeSplashScreen(mEngine); - #endif // ifdef Q_OS_MACOS - } else - // Set a self test limit. - QTimer::singleShot(SELF_TEST_DELAY, this, [] { - qFatal("Self test failed. :("); - }); + #endif // ifdef Q_OS_MACOS // Load main view. qInfo() << QStringLiteral("Loading main view..."); @@ -225,7 +216,7 @@ void App::initContentApp () { QObject::connect( CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted, - this, selfTest ? &App::quit : &App::openAppAfterInit + this, &App::openAppAfterInit ); } @@ -308,7 +299,6 @@ void App::createParser () { #ifndef Q_OS_MACOS { "iconified", tr("commandLineOptionIconified") }, #endif // ifndef Q_OS_MACOS - { "self-test", tr("commandLineOptionSelfTest") }, { { "V", "verbose" }, tr("commandLineOptionVerbose") } // TODO: Enable me in future version! // , @@ -569,12 +559,3 @@ void App::checkForUpdate () { ::Utils::appStringToCoreString(applicationVersion()) ); } - -// ----------------------------------------------------------------------------- - -void App::quit () { - if (mParser->isSet("self-test")) - cout << tr("selfTestResult").toStdString() << endl; - - QApplication::quit(); -} diff --git a/src/app/App.hpp b/src/app/App.hpp index 8bfa69522..06d825e40 100644 --- a/src/app/App.hpp +++ b/src/app/App.hpp @@ -71,8 +71,6 @@ public: bool hasFocus () const; - void quit () override; - static App *getInstance () { return static_cast(QApplication::instance()); } diff --git a/src/app/AppController.cpp b/src/app/AppController.cpp index f0f607c55..7453b3e6f 100644 --- a/src/app/AppController.cpp +++ b/src/app/AppController.cpp @@ -39,15 +39,9 @@ using namespace std; // ============================================================================= -#ifndef QT_NO_DEBUG - bool AppController::mCreated = false; -#endif // ifndef QT_NO_DEBUG - AppController::AppController (int &argc, char *argv[]) { - Q_ASSERT(!mCreated); - mCreated = true; - QT_REQUIRE_VERSION(argc, argv, APPLICATION_MINIMAL_QT_VERSION); + Q_ASSERT(!mApp); // Disable QML cache. Avoid malformed cache. qputenv("QML_DISABLE_DISK_CACHE", "true"); diff --git a/src/app/AppController.hpp b/src/app/AppController.hpp index 4711e0c5a..2fe9729c2 100644 --- a/src/app/AppController.hpp +++ b/src/app/AppController.hpp @@ -30,13 +30,10 @@ public: ~AppController (); App *getApp () const { + Q_CHECK_PTR(mApp); return mApp; } private: App *mApp = nullptr; - - #ifndef QT_NO_DEBUG - static bool mCreated; - #endif // ifndef QT_NO_DEBUG }; diff --git a/src/app/main.cpp b/src/app/main.cpp index f3394c8fa..9d483face 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -28,7 +28,7 @@ int main (int argc, char *argv[]) { AppController controller(argc, argv); App *app = controller.getApp(); if (app->isSecondary()) - return 0; + return EXIT_SUCCESS; qInfo() << QStringLiteral("Running app..."); diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 3c0050fd1..a39fa6ca8 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -20,22 +20,70 @@ * Author: Ronan Abhamon */ +#include +#include + #include "../app/AppController.hpp" +#include "../utils/Utils.hpp" + +#include "self-test/SelfTest.hpp" // ============================================================================= +static QHash initializeTests () { + QHash hash; + // TODO: Add tests here. + return hash; +} + +// ----------------------------------------------------------------------------- + int main (int argc, char *argv[]) { - AppController controller(argc, argv); + int fakeArgc = 1; + AppController controller(fakeArgc, argv); App *app = controller.getApp(); if (app->isSecondary()) - return 0; + qFatal("Unable to run test with secondary app."); - qInfo() << QStringLiteral("Running test..."); + const QHash tests = initializeTests(); + + QObject *test = nullptr; + if (argc > 1) { + if (!strcmp(argv[1], "self-test")) + // Execute only self-test. + QTimer::singleShot(0, [app] { + QTest::qExec(new SelfTest(app)); + QCoreApplication::quit(); + }); + else { + // Execute only one test. + const QString testName = ::Utils::coreStringToAppString(argv[1]); + test = tests[testName]; + if (!test) { + qWarning() << QStringLiteral("Unable to run invalid test: `%1`.").arg(testName); + return EXIT_FAILURE; + } + + QTimer::singleShot(0, [app, test, argc, argv] { + QTest::qExec(new SelfTest(app)); + QTest::qExec(test, argc - 1, argv + 1); + QCoreApplication::quit(); + }); + } + } else + // Execute all tests. + QTimer::singleShot(0, [app, &tests] { + QTest::qExec(new SelfTest(app)); + for (const auto &test : tests) + QTest::qExec(test); + QCoreApplication::quit(); + }); + + app->initContentApp(); + int ret = app->exec(); + + for (auto &test : tests) + delete test; - int ret; - do { - app->initContentApp(); - ret = app->exec(); - } while (ret == APP_CODE_RESTART); return ret; } diff --git a/src/tests/SelfTest.cpp b/src/tests/self-test/SelfTest.cpp similarity index 76% rename from src/tests/SelfTest.cpp rename to src/tests/self-test/SelfTest.cpp index 0daf4bcd4..65acfef8d 100644 --- a/src/tests/SelfTest.cpp +++ b/src/tests/self-test/SelfTest.cpp @@ -20,17 +20,18 @@ * Author: Ronan Abhamon */ +#include #include +#include "../../components/core/CoreManager.hpp" + +#include "SelfTest.hpp" + +#define SELF_TEST_DELAY 5000 + // ============================================================================= -class SelfTest : public QObject { - Q_OBJECT; - -private slots: - void t1 () { - QVERIFY(true); - } -}; - -#include "SelfTest.moc" +void SelfTest::checkAppStartup () { + QSignalSpy spy(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted); + QVERIFY(spy.wait(SELF_TEST_DELAY)); +} diff --git a/src/tests/self-test/SelfTest.hpp b/src/tests/self-test/SelfTest.hpp new file mode 100644 index 000000000..978dc2b39 --- /dev/null +++ b/src/tests/self-test/SelfTest.hpp @@ -0,0 +1,35 @@ +/* + * SelfTest.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 17, 2017 + * Author: Ronan Abhamon + */ + +#include + +// ============================================================================= + +class SelfTest : public QObject { + Q_OBJECT; + +public: + SelfTest (QObject *parent = Q_NULLPTR) : QObject(parent) {} + +private slots: + void checkAppStartup (); +}; From c7509acd9bd1ca49f6c2ccd5598c7cdc52fed55b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 18 Jul 2017 13:40:36 +0200 Subject: [PATCH 04/28] feat(tests/MainViewTest): add a `showManageAccountsPopup` method --- CMakeLists.txt | 4 + src/components/notifier/Notifier.cpp | 2 +- src/tests/TestUtils.cpp | 103 ++++++++++++++++++ src/tests/TestUtils.hpp | 34 ++++++ src/tests/main-view/MainViewTest.cpp | 45 ++++++++ src/tests/main-view/MainViewTest.hpp | 35 ++++++ src/tests/main.cpp | 3 +- src/tests/self-test/SelfTest.cpp | 14 ++- ui/modules/Common/Popup/DesktopPopup.qml | 2 +- .../Notifications/Notification.spec.qml | 2 +- ui/views/App/Main/Dialogs/ManageAccounts.qml | 1 + 11 files changed, 237 insertions(+), 8 deletions(-) create mode 100644 src/tests/TestUtils.cpp create mode 100644 src/tests/TestUtils.hpp create mode 100644 src/tests/main-view/MainViewTest.cpp create mode 100644 src/tests/main-view/MainViewTest.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b7ec363c..d49b1ddd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,8 +213,12 @@ set(HEADERS ) set(TESTS + src/tests/main-view/MainViewTest.cpp + src/tests/main-view/MainViewTest.hpp src/tests/self-test/SelfTest.cpp src/tests/self-test/SelfTest.hpp + src/tests/TestUtils.cpp + src/tests/TestUtils.hpp ) set(MAIN_FILE src/app/main.cpp) diff --git a/src/components/notifier/Notifier.cpp b/src/components/notifier/Notifier.cpp index d06657bd4..cffdae7cc 100644 --- a/src/components/notifier/Notifier.cpp +++ b/src/components/notifier/Notifier.cpp @@ -43,7 +43,7 @@ #define NOTIFICATION_PROPERTY_X "popupX" #define NOTIFICATION_PROPERTY_Y "popupY" -#define NOTIFICATION_PROPERTY_WINDOW "__internalWindow" +#define NOTIFICATION_PROPERTY_WINDOW "internalWindow" #define NOTIFICATION_PROPERTY_TIMER "__timer" diff --git a/src/tests/TestUtils.cpp b/src/tests/TestUtils.cpp new file mode 100644 index 000000000..4fe2be7c6 --- /dev/null +++ b/src/tests/TestUtils.cpp @@ -0,0 +1,103 @@ +/* + * TestUtils.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 18, 2017 + * Author: Ronan Abhamon + */ + +#ifdef QT_NO_DEBUG + #undef QT_NO_DEBUG +#endif // ifdef QT_NO_DEBUG + +#include + +#include "../app/App.hpp" + +#include "TestUtils.hpp" + +// ============================================================================= + +static void printItemTree (const QQuickItem *item, QString &output, int spaces) { + output.append(QString().leftJustified(spaces, ' ')); + output.append(item->metaObject()->className()); + output.append("\n"); + + for (const auto &childItem : item->childItems()) + printItemTree(childItem, output, spaces + 2); +} + +void TestUtils::printItemTree (const QQuickItem *item) { + QString output; + ::printItemTree(item, output, 0); + qInfo().noquote() << output; +} + +// ----------------------------------------------------------------------------- + +QQuickItem *TestUtils::getMainLoaderFromMainWindow () { + QQuickWindow *window = App::getInstance()->getMainWindow(); + Q_CHECK_PTR(window); + + QList items = window->contentItem()->childItems(); + Q_ASSERT(!items.empty()); + + for (int i = 0; i < 3; ++i) { + items = items.at(0)->childItems(); + Q_ASSERT(!items.empty()); + } + + QQuickItem *loader = items.at(0); + Q_ASSERT(!strcmp(loader->metaObject()->className(), "QQuickLoader")); + + return loader; +} + +// ----------------------------------------------------------------------------- + +QQuickItem *TestUtils::getVirtualWindow (const QQuickWindow *window) { + Q_CHECK_PTR(window); + + QList items = window->contentItem()->childItems(); + Q_ASSERT(!items.empty()); + + items = items.at(0)->childItems(); + Q_ASSERT(!items.empty()); + + items = items.at(0)->childItems(); + Q_ASSERT(items.size() == 2); + + const char name[] = "VirtualWindow_QMLTYPE_"; + QQuickItem *virtualWindow = items.at(1); + Q_ASSERT(!strncmp(virtualWindow->metaObject()->className(), name, sizeof name - 1)); + + return virtualWindow; +} + +// ----------------------------------------------------------------------------- + +QQuickItem *TestUtils::getVirtualWindowContainer (const QQuickItem *virtualWindow) { + Q_CHECK_PTR(virtualWindow); + + QList items = virtualWindow->childItems(); + Q_ASSERT(items.size() == 2); + + QQuickItem *container = items.at(1); + Q_ASSERT(!container->childItems().empty()); + + return container; +} diff --git a/src/tests/TestUtils.hpp b/src/tests/TestUtils.hpp new file mode 100644 index 000000000..3a3d6eb0c --- /dev/null +++ b/src/tests/TestUtils.hpp @@ -0,0 +1,34 @@ +/* + * TestUtils.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 18, 2017 + * Author: Ronan Abhamon + */ + +#include +#include + +// ============================================================================= + +namespace TestUtils { + void printItemTree (const QQuickItem *item); + + QQuickItem *getMainLoaderFromMainWindow (); + QQuickItem *getVirtualWindow (const QQuickWindow *window); + QQuickItem *getVirtualWindowContainer (const QQuickItem *virtualWindow); +} diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp new file mode 100644 index 000000000..2ecd50e5b --- /dev/null +++ b/src/tests/main-view/MainViewTest.cpp @@ -0,0 +1,45 @@ +/* + * MainViewTest.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 18, 2017 + * Author: Ronan Abhamon + */ + +#include + +#include "../../app/App.hpp" +#include "../TestUtils.hpp" + +#include "MainViewTest.hpp" + +// ============================================================================= + +void MainViewTest::showManageAccountsPopup () { + QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); + + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 35)); + QTest::qWait(1000); + + const char name[] = "DialogPlus_QMLTYPE_"; + QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContainer( + TestUtils::getVirtualWindow(mainWindow) + )->childItems().at(0); + + QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), name, sizeof name - 1)); + QVERIFY(virtualWindowContent->objectName() == "manageAccounts"); +} diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp new file mode 100644 index 000000000..6d08745ec --- /dev/null +++ b/src/tests/main-view/MainViewTest.hpp @@ -0,0 +1,35 @@ +/* + * MainViewTest.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 18, 2017 + * Author: Ronan Abhamon + */ + +#include + +// ============================================================================= + +class MainViewTest : public QObject { + Q_OBJECT; + +public: + MainViewTest () = default; + +private slots: + void showManageAccountsPopup (); +}; diff --git a/src/tests/main.cpp b/src/tests/main.cpp index a39fa6ca8..3b6984afb 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -26,13 +26,14 @@ #include "../app/AppController.hpp" #include "../utils/Utils.hpp" +#include "main-view/MainViewTest.hpp" #include "self-test/SelfTest.hpp" // ============================================================================= static QHash initializeTests () { QHash hash; - // TODO: Add tests here. + hash["main-view"] = new MainViewTest(); return hash; } diff --git a/src/tests/self-test/SelfTest.cpp b/src/tests/self-test/SelfTest.cpp index 65acfef8d..f8e23b8c2 100644 --- a/src/tests/self-test/SelfTest.cpp +++ b/src/tests/self-test/SelfTest.cpp @@ -24,14 +24,20 @@ #include #include "../../components/core/CoreManager.hpp" +#include "../TestUtils.hpp" #include "SelfTest.hpp" -#define SELF_TEST_DELAY 5000 - // ============================================================================= void SelfTest::checkAppStartup () { - QSignalSpy spy(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted); - QVERIFY(spy.wait(SELF_TEST_DELAY)); + QSignalSpy spyCoreStarted(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted); + QSignalSpy spyLoaderReady(TestUtils::getMainLoaderFromMainWindow(), SIGNAL(loaded())); + + QVERIFY(spyCoreStarted.wait(5000)); + + if (spyLoaderReady.count() == 1) + return; + + QVERIFY(spyLoaderReady.wait(1000)); } diff --git a/ui/modules/Common/Popup/DesktopPopup.qml b/ui/modules/Common/Popup/DesktopPopup.qml index d641d0002..7f7374fce 100644 --- a/ui/modules/Common/Popup/DesktopPopup.qml +++ b/ui/modules/Common/Popup/DesktopPopup.qml @@ -48,7 +48,7 @@ Item { id: window // Used for internal purposes only. Like Notifications. - objectName: '__internalWindow' + objectName: 'internalWindow' flags: wrapper.flags opacity: 0 diff --git a/ui/modules/Linphone/Notifications/Notification.spec.qml b/ui/modules/Linphone/Notifications/Notification.spec.qml index 4a74fa077..ffbd5b540 100644 --- a/ui/modules/Linphone/Notifications/Notification.spec.qml +++ b/ui/modules/Linphone/Notifications/Notification.spec.qml @@ -39,6 +39,6 @@ TestCase { var window = notification.data[0] compare(Utils.qmlTypeof(window, 'QQuickWindowQmlImpl'), true) - compare(window.objectName === '__internalWindow', true) + compare(window.objectName === 'internalWindow', true) } } diff --git a/ui/views/App/Main/Dialogs/ManageAccounts.qml b/ui/views/App/Main/Dialogs/ManageAccounts.qml index 98f6319fe..83e2ddcaa 100644 --- a/ui/views/App/Main/Dialogs/ManageAccounts.qml +++ b/ui/views/App/Main/Dialogs/ManageAccounts.qml @@ -18,6 +18,7 @@ DialogPlus { ] centeredButtons: true + objectName: 'manageAccounts' height: ManageAccountsStyle.height width: ManageAccountsStyle.width From 31f2ec673f47b4ba6f054f02f98191146a80d64c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 18 Jul 2017 13:53:45 +0200 Subject: [PATCH 05/28] feat(tests/MainViewTest): close popup in `showManageAccountsPopup` --- src/tests/TestUtils.cpp | 10 ++-------- src/tests/main-view/MainViewTest.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/tests/TestUtils.cpp b/src/tests/TestUtils.cpp index 4fe2be7c6..1cb5c9f4a 100644 --- a/src/tests/TestUtils.cpp +++ b/src/tests/TestUtils.cpp @@ -50,10 +50,7 @@ void TestUtils::printItemTree (const QQuickItem *item) { // ----------------------------------------------------------------------------- QQuickItem *TestUtils::getMainLoaderFromMainWindow () { - QQuickWindow *window = App::getInstance()->getMainWindow(); - Q_CHECK_PTR(window); - - QList items = window->contentItem()->childItems(); + QList items = App::getInstance()->getMainWindow()->contentItem()->childItems(); Q_ASSERT(!items.empty()); for (int i = 0; i < 3; ++i) { @@ -96,8 +93,5 @@ QQuickItem *TestUtils::getVirtualWindowContainer (const QQuickItem *virtualWindo QList items = virtualWindow->childItems(); Q_ASSERT(items.size() == 2); - QQuickItem *container = items.at(1); - Q_ASSERT(!container->childItems().empty()); - - return container; + return items.at(1); } diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 2ecd50e5b..59bfecbbd 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -32,14 +32,21 @@ void MainViewTest::showManageAccountsPopup () { QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); + // Open popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 35)); QTest::qWait(1000); const char name[] = "DialogPlus_QMLTYPE_"; - QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContainer( - TestUtils::getVirtualWindow(mainWindow) - )->childItems().at(0); + QQuickItem *virtualWindow = TestUtils::getVirtualWindow(mainWindow); + QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContainer(virtualWindow)->childItems().at(0); + QVERIFY(virtualWindowContent); QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), name, sizeof name - 1)); QVERIFY(virtualWindowContent->objectName() == "manageAccounts"); + + // Close popup. + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); + QTest::qWait(1000); + + QVERIFY(TestUtils::getVirtualWindowContainer(virtualWindow)->childItems().empty()); } From 7f8db020016c83cf52c3d17298e2bfcc630a0eb1 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 18 Jul 2017 14:08:55 +0200 Subject: [PATCH 06/28] feat(tests): return an error code at program termination, logs tests status --- src/tests/main-view/MainViewTest.hpp | 1 + src/tests/main.cpp | 31 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp index 6d08745ec..e1dd11a36 100644 --- a/src/tests/main-view/MainViewTest.hpp +++ b/src/tests/main-view/MainViewTest.hpp @@ -29,6 +29,7 @@ class MainViewTest : public QObject { public: MainViewTest () = default; + ~MainViewTest () = default; private slots: void showManageAccountsPopup (); diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 3b6984afb..1433f6de8 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -46,14 +46,16 @@ int main (int argc, char *argv[]) { if (app->isSecondary()) qFatal("Unable to run test with secondary app."); + int testsRet = 0; + const QHash tests = initializeTests(); QObject *test = nullptr; if (argc > 1) { if (!strcmp(argv[1], "self-test")) // Execute only self-test. - QTimer::singleShot(0, [app] { - QTest::qExec(new SelfTest(app)); + QTimer::singleShot(0, [app, &testsRet] { + testsRet = QTest::qExec(new SelfTest(app)); QCoreApplication::quit(); }); else { @@ -65,18 +67,22 @@ int main (int argc, char *argv[]) { return EXIT_FAILURE; } - QTimer::singleShot(0, [app, test, argc, argv] { - QTest::qExec(new SelfTest(app)); - QTest::qExec(test, argc - 1, argv + 1); + QTimer::singleShot(0, [app, &testsRet, test, argc, argv] { + testsRet = QTest::qExec(new SelfTest(app)); + if (!testsRet) + QTest::qExec(test, argc - 1, argv + 1); QCoreApplication::quit(); }); } } else // Execute all tests. - QTimer::singleShot(0, [app, &tests] { - QTest::qExec(new SelfTest(app)); - for (const auto &test : tests) - QTest::qExec(test); + QTimer::singleShot(0, [app, &testsRet, &tests] { + testsRet = QTest::qExec(new SelfTest(app)); + if (!testsRet) + for (const auto &test : tests) { + testsRet |= QTest::qExec(test); + } + QCoreApplication::quit(); }); @@ -86,5 +92,10 @@ int main (int argc, char *argv[]) { for (auto &test : tests) delete test; - return ret; + if (testsRet) + qWarning() << QStringLiteral("One or many tests are failed. :("); + else + qInfo() << QStringLiteral("Tests seems OK. :)"); + + return testsRet || ret; } From f979695b179a5d967edd4de9cf5a37a5f967d74f Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 18 Jul 2017 14:45:02 +0200 Subject: [PATCH 07/28] chore(CHANGELOG): add 4.1.0 changelog --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a21cbc580 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Changelog + +## 4.1.0 - 2017-07-19 + +### Features + +- Add tooltips on `recording` and `screenshot` buttons in `Calls Window`. +- Show notifications on `recording` and `screenshot`. +- Show `XXX is typing...` in `Timeline` and `Chat View`. +- Handle correctly `SIGINT`. +- Handle clicks on SIP URI in chat messages. +- Show video framerate in `Calls Stats`. +- Add a `Logs` menu entry in `Settings Window`, it provides send, remove, activate buttons... +- Supports EXIF orientation for file transfer images preview. +- Echo canceller supports 48kHz. + +### Fixes + +- Handle correctly ringer device changes in `Settings Window`. +- In `Video Settings`, display FPS field only in `custom preset` mode. +- Use now the directory containing user documents files for saved video/audio/screenshots. +- Update `Chat View` correctly if it is used in many windows. +- Update correctly selected language when app is restarted. +- Avoid a deadlock on Mac OS when a call ends in fullscreen mode. +- Application can be started from one binary only. +- Single instance is now supported with flatpak. (It uses D-Bus.) From 5ccc977754cf156d53a3972ae5e4c38d73690cac Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Tue, 18 Jul 2017 18:18:39 +0200 Subject: [PATCH 08/28] feat(tests/self-test): wait exposed window --- src/tests/self-test/SelfTest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tests/self-test/SelfTest.cpp b/src/tests/self-test/SelfTest.cpp index f8e23b8c2..4c0a02647 100644 --- a/src/tests/self-test/SelfTest.cpp +++ b/src/tests/self-test/SelfTest.cpp @@ -23,6 +23,7 @@ #include #include +#include "../../app/App.hpp" #include "../../components/core/CoreManager.hpp" #include "../TestUtils.hpp" @@ -36,8 +37,8 @@ void SelfTest::checkAppStartup () { QVERIFY(spyCoreStarted.wait(5000)); - if (spyLoaderReady.count() == 1) - return; + if (spyLoaderReady.count() != 1) + QVERIFY(spyLoaderReady.wait(1000)); - QVERIFY(spyLoaderReady.wait(1000)); + QVERIFY(QTest::qWaitForWindowExposed(App::getInstance()->getMainWindow())); } From 76e660bb4fbccea31b47cd3c5b80f0b03a80b015 Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Tue, 18 Jul 2017 18:25:09 +0200 Subject: [PATCH 09/28] feat(tests/main-view): use QCOMPARE instead of QVERIFY for object name --- src/tests/main-view/MainViewTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 59bfecbbd..6c0088da3 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -42,7 +42,7 @@ void MainViewTest::showManageAccountsPopup () { QVERIFY(virtualWindowContent); QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), name, sizeof name - 1)); - QVERIFY(virtualWindowContent->objectName() == "manageAccounts"); + QCOMPARE(virtualWindowContent->objectName(), QStringLiteral("manageAccounts")); // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); From e35927d1fdb709f6b26f5578b4968821446e1bbd Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Tue, 18 Jul 2017 19:21:36 +0200 Subject: [PATCH 10/28] fix(App): register `linphone::ProxyConfig` to avoid unusable type in qml (close #41) --- src/app/App.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/app/App.cpp b/src/app/App.cpp index 9a6f4df3c..4939df467 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -321,11 +321,6 @@ void App::createParser () { "Linphone", 1, 0, NAME, NAME " is uncreatable." \ ) -template -void registerMetaType (const char *name) { - qRegisterMetaType(name); -} - template void registerSingletonType (const char *name) { qmlRegisterSingletonType("Linphone", 1, 0, name, [](QQmlEngine *engine, QJSEngine *) -> QObject *{ @@ -357,6 +352,9 @@ void registerToolType (const char *name) { void App::registerTypes () { qInfo() << QStringLiteral("Registering types..."); + qRegisterMetaType >(); + qRegisterMetaType(); + registerType("AssistantModel"); registerType("AuthenticationNotifier"); registerType("CallsListProxyModel"); @@ -377,8 +375,6 @@ void App::registerTypes () { registerSingletonType("UrlHandlers"); registerSingletonType("VideoCodecsModel"); - registerMetaType("ChatModel::EntryType"); - registerUncreatableType(CallModel, "CallModel"); registerUncreatableType(ChatModel, "ChatModel"); registerUncreatableType(ConferenceHelperModel::ConferenceAddModel, "ConferenceAddModel"); From 55b07cb119da12d4cd394be800ecb3a3e33f410b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 10:41:08 +0200 Subject: [PATCH 11/28] fix(tests/self-test): fix test for mac os --- src/components/core/CoreManager.cpp | 2 ++ src/components/core/CoreManager.hpp | 6 ++++++ src/tests/main-view/MainViewTest.cpp | 2 +- src/tests/self-test/SelfTest.cpp | 13 +++++++++---- ui/modules/Common/Popup/DesktopPopup.qml | 2 +- .../Linphone/Notifications/Notification.spec.qml | 2 +- ui/views/App/Main/Dialogs/ManageAccounts.qml | 2 +- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index 1774c3584..9f1994f02 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -63,6 +63,8 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : mInstance->mSettingsModel = new SettingsModel(mInstance); mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance); + mInstance->mStarted = true; + emit mInstance->coreStarted(); }); diff --git a/src/components/core/CoreManager.hpp b/src/components/core/CoreManager.hpp index 2de5786eb..b8474b9b4 100644 --- a/src/components/core/CoreManager.hpp +++ b/src/components/core/CoreManager.hpp @@ -47,6 +47,10 @@ class CoreManager : public QObject { public: ~CoreManager () = default; + bool started () const { + return mStarted; + } + std::shared_ptr getCore () { Q_CHECK_PTR(mCore); return mCore; @@ -151,6 +155,8 @@ private: std::shared_ptr mCore; std::shared_ptr mHandlers; + bool mStarted = false; + CallsListModel *mCallsListModel = nullptr; ContactsListModel *mContactsListModel = nullptr; SipAddressesModel *mSipAddressesModel = nullptr; diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 6c0088da3..3afba733d 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -42,7 +42,7 @@ void MainViewTest::showManageAccountsPopup () { QVERIFY(virtualWindowContent); QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), name, sizeof name - 1)); - QCOMPARE(virtualWindowContent->objectName(), QStringLiteral("manageAccounts")); + QCOMPARE(virtualWindowContent->objectName(), QStringLiteral("__manageAccounts")); // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); diff --git a/src/tests/self-test/SelfTest.cpp b/src/tests/self-test/SelfTest.cpp index 4c0a02647..006988adc 100644 --- a/src/tests/self-test/SelfTest.cpp +++ b/src/tests/self-test/SelfTest.cpp @@ -20,6 +20,7 @@ * Author: Ronan Abhamon */ +#include #include #include @@ -32,12 +33,16 @@ // ============================================================================= void SelfTest::checkAppStartup () { - QSignalSpy spyCoreStarted(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted); - QSignalSpy spyLoaderReady(TestUtils::getMainLoaderFromMainWindow(), SIGNAL(loaded())); + CoreManager *coreManager = CoreManager::getInstance(); + QQuickItem *mainLoader = TestUtils::getMainLoaderFromMainWindow(); - QVERIFY(spyCoreStarted.wait(5000)); + QSignalSpy spyCoreStarted(coreManager->getHandlers().get(), &CoreHandlers::coreStarted); + QSignalSpy spyLoaderReady(mainLoader, SIGNAL(loaded())); - if (spyLoaderReady.count() != 1) + if (!coreManager->started()) + QVERIFY(spyCoreStarted.wait(5000)); + + if (!QQmlProperty::read(mainLoader, "item").value()) QVERIFY(spyLoaderReady.wait(1000)); QVERIFY(QTest::qWaitForWindowExposed(App::getInstance()->getMainWindow())); diff --git a/ui/modules/Common/Popup/DesktopPopup.qml b/ui/modules/Common/Popup/DesktopPopup.qml index 7f7374fce..d641d0002 100644 --- a/ui/modules/Common/Popup/DesktopPopup.qml +++ b/ui/modules/Common/Popup/DesktopPopup.qml @@ -48,7 +48,7 @@ Item { id: window // Used for internal purposes only. Like Notifications. - objectName: 'internalWindow' + objectName: '__internalWindow' flags: wrapper.flags opacity: 0 diff --git a/ui/modules/Linphone/Notifications/Notification.spec.qml b/ui/modules/Linphone/Notifications/Notification.spec.qml index ffbd5b540..4a74fa077 100644 --- a/ui/modules/Linphone/Notifications/Notification.spec.qml +++ b/ui/modules/Linphone/Notifications/Notification.spec.qml @@ -39,6 +39,6 @@ TestCase { var window = notification.data[0] compare(Utils.qmlTypeof(window, 'QQuickWindowQmlImpl'), true) - compare(window.objectName === 'internalWindow', true) + compare(window.objectName === '__internalWindow', true) } } diff --git a/ui/views/App/Main/Dialogs/ManageAccounts.qml b/ui/views/App/Main/Dialogs/ManageAccounts.qml index 83e2ddcaa..f20adba52 100644 --- a/ui/views/App/Main/Dialogs/ManageAccounts.qml +++ b/ui/views/App/Main/Dialogs/ManageAccounts.qml @@ -18,7 +18,7 @@ DialogPlus { ] centeredButtons: true - objectName: 'manageAccounts' + objectName: '__manageAccounts' height: ManageAccountsStyle.height width: ManageAccountsStyle.width From 38a4df6090c3dcb764f65a8fa915f70ac9446d38 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 11:23:02 +0200 Subject: [PATCH 12/28] feat(tests/main-view): add a `showAboutPopup` method --- src/tests/TestUtils.cpp | 29 +++++++++++++++++----------- src/tests/TestUtils.hpp | 14 ++++++++++++-- src/tests/main-view/MainViewTest.cpp | 26 +++++++++++++++++-------- src/tests/main-view/MainViewTest.hpp | 1 + ui/views/App/Main/Dialogs/About.qml | 1 + 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/tests/TestUtils.cpp b/src/tests/TestUtils.cpp index 1cb5c9f4a..30aae8410 100644 --- a/src/tests/TestUtils.cpp +++ b/src/tests/TestUtils.cpp @@ -24,6 +24,7 @@ #undef QT_NO_DEBUG #endif // ifdef QT_NO_DEBUG +#include #include #include "../app/App.hpp" @@ -32,6 +33,19 @@ // ============================================================================= +void TestUtils::executeKeySequence (QQuickWindow *window, QKeySequence sequence) { + for (int i = 0; i < sequence.count(); ++i) { + int key = sequence[i]; + QTest::keyClick( + window, + Qt::Key(key & ~Qt::KeyboardModifierMask), + Qt::KeyboardModifiers(key & Qt::KeyboardModifierMask) + ); + } +} + +// ----------------------------------------------------------------------------- + static void printItemTree (const QQuickItem *item, QString &output, int spaces) { output.append(QString().leftJustified(spaces, ' ')); output.append(item->metaObject()->className()); @@ -66,7 +80,7 @@ QQuickItem *TestUtils::getMainLoaderFromMainWindow () { // ----------------------------------------------------------------------------- -QQuickItem *TestUtils::getVirtualWindow (const QQuickWindow *window) { +QQuickItem *TestUtils::getVirtualWindowContent (const QQuickWindow *window) { Q_CHECK_PTR(window); QList items = window->contentItem()->childItems(); @@ -82,16 +96,9 @@ QQuickItem *TestUtils::getVirtualWindow (const QQuickWindow *window) { QQuickItem *virtualWindow = items.at(1); Q_ASSERT(!strncmp(virtualWindow->metaObject()->className(), name, sizeof name - 1)); - return virtualWindow; -} - -// ----------------------------------------------------------------------------- - -QQuickItem *TestUtils::getVirtualWindowContainer (const QQuickItem *virtualWindow) { - Q_CHECK_PTR(virtualWindow); - - QList items = virtualWindow->childItems(); + items = virtualWindow->childItems(); Q_ASSERT(items.size() == 2); - return items.at(1); + items = items.at(1)->childItems(); + return items.empty() ? nullptr : items.at(0); } diff --git a/src/tests/TestUtils.hpp b/src/tests/TestUtils.hpp index 3a3d6eb0c..a6372a86a 100644 --- a/src/tests/TestUtils.hpp +++ b/src/tests/TestUtils.hpp @@ -25,10 +25,20 @@ // ============================================================================= +#define CHECK_VIRTUAL_WINDOW_CONTENT_INFO(WINDOW, TYPE, NAME) \ + do { \ + QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContent(WINDOW); \ + QVERIFY(virtualWindowContent); \ + QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), TYPE, sizeof TYPE - 1)); \ + QCOMPARE(virtualWindowContent->objectName(), QStringLiteral(NAME)); \ + } while (0) + namespace TestUtils { + void executeKeySequence (QQuickWindow *window, QKeySequence sequence); + void printItemTree (const QQuickItem *item); QQuickItem *getMainLoaderFromMainWindow (); - QQuickItem *getVirtualWindow (const QQuickWindow *window); - QQuickItem *getVirtualWindowContainer (const QQuickItem *virtualWindow); + + QQuickItem *getVirtualWindowContent (const QQuickWindow *window); } diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 3afba733d..be81e03d0 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -29,6 +29,22 @@ // ============================================================================= +void MainViewTest::showAboutPopup () { + QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); + + // Open popup. + TestUtils::executeKeySequence(mainWindow, QKeySequence::HelpContents); + QTest::qWait(1000); + + CHECK_VIRTUAL_WINDOW_CONTENT_INFO(mainWindow, "DialogPlus_QMLTYPE_", "__about"); + + // Close popup. + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); + QTest::qWait(1000); + + QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); +} + void MainViewTest::showManageAccountsPopup () { QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); @@ -36,17 +52,11 @@ void MainViewTest::showManageAccountsPopup () { QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 35)); QTest::qWait(1000); - const char name[] = "DialogPlus_QMLTYPE_"; - QQuickItem *virtualWindow = TestUtils::getVirtualWindow(mainWindow); - QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContainer(virtualWindow)->childItems().at(0); - - QVERIFY(virtualWindowContent); - QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), name, sizeof name - 1)); - QCOMPARE(virtualWindowContent->objectName(), QStringLiteral("__manageAccounts")); + CHECK_VIRTUAL_WINDOW_CONTENT_INFO(mainWindow, "DialogPlus_QMLTYPE_", "__manageAccounts"); // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); QTest::qWait(1000); - QVERIFY(TestUtils::getVirtualWindowContainer(virtualWindow)->childItems().empty()); + QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); } diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp index e1dd11a36..6d42e7983 100644 --- a/src/tests/main-view/MainViewTest.hpp +++ b/src/tests/main-view/MainViewTest.hpp @@ -32,5 +32,6 @@ public: ~MainViewTest () = default; private slots: + void showAboutPopup (); void showManageAccountsPopup (); }; diff --git a/ui/views/App/Main/Dialogs/About.qml b/ui/views/App/Main/Dialogs/About.qml index e9f40b5d9..2deffe785 100644 --- a/ui/views/App/Main/Dialogs/About.qml +++ b/ui/views/App/Main/Dialogs/About.qml @@ -19,6 +19,7 @@ DialogPlus { ] centeredButtons: true + objectName: '__about' height: AboutStyle.height width: AboutStyle.width From dd794f92cd0c06addc9f055e9ef2446dde091a20 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 11:52:24 +0200 Subject: [PATCH 13/28] feat(tests/main-view): add a `showSettingsWindow` method --- src/tests/TestUtils.hpp | 4 ++-- src/tests/main-view/MainViewTest.cpp | 24 ++++++++++++++++-------- src/tests/main-view/MainViewTest.hpp | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/tests/TestUtils.hpp b/src/tests/TestUtils.hpp index a6372a86a..ba8a91c33 100644 --- a/src/tests/TestUtils.hpp +++ b/src/tests/TestUtils.hpp @@ -27,8 +27,8 @@ #define CHECK_VIRTUAL_WINDOW_CONTENT_INFO(WINDOW, TYPE, NAME) \ do { \ - QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContent(WINDOW); \ - QVERIFY(virtualWindowContent); \ + QQuickItem *virtualWindowContent; \ + QTRY_VERIFY_WITH_TIMEOUT(virtualWindowContent = TestUtils::getVirtualWindowContent(WINDOW), 1000); \ QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), TYPE, sizeof TYPE - 1)); \ QCOMPARE(virtualWindowContent->objectName(), QStringLiteral(NAME)); \ } while (0) diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index be81e03d0..4aa068f73 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -34,15 +34,12 @@ void MainViewTest::showAboutPopup () { // Open popup. TestUtils::executeKeySequence(mainWindow, QKeySequence::HelpContents); - QTest::qWait(1000); CHECK_VIRTUAL_WINDOW_CONTENT_INFO(mainWindow, "DialogPlus_QMLTYPE_", "__about"); // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); - QTest::qWait(1000); - - QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); + QTRY_VERIFY_WITH_TIMEOUT(!TestUtils::getVirtualWindowContent(mainWindow), 1000); } void MainViewTest::showManageAccountsPopup () { @@ -50,13 +47,24 @@ void MainViewTest::showManageAccountsPopup () { // Open popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 35)); - QTest::qWait(1000); CHECK_VIRTUAL_WINDOW_CONTENT_INFO(mainWindow, "DialogPlus_QMLTYPE_", "__manageAccounts"); // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); - QTest::qWait(1000); - - QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); + QTRY_VERIFY_WITH_TIMEOUT(!TestUtils::getVirtualWindowContent(mainWindow), 1000); +} + +void MainViewTest::showSettingsWindow () { + App *app = App::getInstance(); + + // Open window. + QTest::keyClick(app->getMainWindow(), Qt::Key_P, Qt::ControlModifier); + QQuickWindow *settingsWindow = app->getSettingsWindow(); + + QVERIFY(QTest::qWaitForWindowExposed(settingsWindow)); + + // Hide window. + TestUtils::executeKeySequence(settingsWindow, QKeySequence::Close); + QVERIFY(!settingsWindow->isVisible()); } diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp index 6d42e7983..2f35b89b3 100644 --- a/src/tests/main-view/MainViewTest.hpp +++ b/src/tests/main-view/MainViewTest.hpp @@ -34,4 +34,5 @@ public: private slots: void showAboutPopup (); void showManageAccountsPopup (); + void showSettingsWindow (); }; From 62e9a393517e3551fd4b8c814d5ddb25e57773d0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 12:08:51 +0200 Subject: [PATCH 14/28] fix(tests/main-view): avoid usage of QTRY_VERIFY_WITH_TIMEOUT --- src/tests/TestUtils.hpp | 4 ++-- src/tests/main-view/MainViewTest.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/TestUtils.hpp b/src/tests/TestUtils.hpp index ba8a91c33..a6372a86a 100644 --- a/src/tests/TestUtils.hpp +++ b/src/tests/TestUtils.hpp @@ -27,8 +27,8 @@ #define CHECK_VIRTUAL_WINDOW_CONTENT_INFO(WINDOW, TYPE, NAME) \ do { \ - QQuickItem *virtualWindowContent; \ - QTRY_VERIFY_WITH_TIMEOUT(virtualWindowContent = TestUtils::getVirtualWindowContent(WINDOW), 1000); \ + QQuickItem *virtualWindowContent = TestUtils::getVirtualWindowContent(WINDOW); \ + QVERIFY(virtualWindowContent); \ QVERIFY(!strncmp(virtualWindowContent->metaObject()->className(), TYPE, sizeof TYPE - 1)); \ QCOMPARE(virtualWindowContent->objectName(), QStringLiteral(NAME)); \ } while (0) diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 4aa068f73..4547aebd0 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -39,7 +39,7 @@ void MainViewTest::showAboutPopup () { // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); - QTRY_VERIFY_WITH_TIMEOUT(!TestUtils::getVirtualWindowContent(mainWindow), 1000); + QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); } void MainViewTest::showManageAccountsPopup () { @@ -52,7 +52,7 @@ void MainViewTest::showManageAccountsPopup () { // Close popup. QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(476, 392)); - QTRY_VERIFY_WITH_TIMEOUT(!TestUtils::getVirtualWindowContent(mainWindow), 1000); + QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); } void MainViewTest::showSettingsWindow () { From 29b90408942c423806bf8e4e6fdbf7a65a84521a Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 14:52:29 +0200 Subject: [PATCH 15/28] feat(tests/main-view): add a `testMainMenuEntries` method --- src/tests/main-view/MainViewTest.cpp | 32 ++++++++++++++++++++++++++++ src/tests/main-view/MainViewTest.hpp | 3 +++ ui/views/App/Main/MainWindow.qml | 2 ++ 3 files changed, 37 insertions(+) diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 4547aebd0..5c691dc76 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -20,6 +20,8 @@ * Author: Ronan Abhamon */ +#include +#include #include #include "../../app/App.hpp" @@ -42,6 +44,8 @@ void MainViewTest::showAboutPopup () { QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); } +// ----------------------------------------------------------------------------- + void MainViewTest::showManageAccountsPopup () { QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); @@ -55,6 +59,8 @@ void MainViewTest::showManageAccountsPopup () { QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); } +// ----------------------------------------------------------------------------- + void MainViewTest::showSettingsWindow () { App *app = App::getInstance(); @@ -68,3 +74,29 @@ void MainViewTest::showSettingsWindow () { TestUtils::executeKeySequence(settingsWindow, QKeySequence::Close); QVERIFY(!settingsWindow->isVisible()); } + +// ----------------------------------------------------------------------------- + +void MainViewTest::testMainMenuEntries_data () { + QTest::addColumn("y"); + QTest::addColumn("source"); + + QTest::newRow("home view 1") << 100 << "qrc:/ui/views/App/Main/Home.qml"; + QTest::newRow("contacts view 1") << 150 << "qrc:/ui/views/App/Main/Contacts.qml"; + QTest::newRow("home view 2") << 100 << "qrc:/ui/views/App/Main/Home.qml"; + QTest::newRow("contacts view 2") << 150 << "qrc:/ui/views/App/Main/Contacts.qml"; +} + +void MainViewTest::testMainMenuEntries () { + QQuickItem *contentLoader = App::getInstance()->getMainWindow()->findChild("__contentLoader"); + QVERIFY(contentLoader); + + QSignalSpy spyLoaderReady(contentLoader, SIGNAL(loaded())); + + QFETCH(int, y); + QTest::mouseClick(App::getInstance()->getMainWindow(), Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, y)); + QVERIFY(spyLoaderReady.count() == 1); + + QFETCH(QString, source); + QCOMPARE(QQmlProperty::read(contentLoader, "source").toString(), source); +} diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp index 2f35b89b3..cf00d9bec 100644 --- a/src/tests/main-view/MainViewTest.hpp +++ b/src/tests/main-view/MainViewTest.hpp @@ -35,4 +35,7 @@ private slots: void showAboutPopup (); void showManageAccountsPopup (); void showSettingsWindow (); + + void testMainMenuEntries_data (); + void testMainMenuEntries (); }; diff --git a/ui/views/App/Main/MainWindow.qml b/ui/views/App/Main/MainWindow.qml index 931d3cc23..b3a01fc22 100644 --- a/ui/views/App/Main/MainWindow.qml +++ b/ui/views/App/Main/MainWindow.qml @@ -231,6 +231,8 @@ ApplicationWindow { Loader { id: contentLoader + objectName: '__contentLoader' + Layout.fillHeight: true Layout.fillWidth: true From 659a6a5f71d81343a5574915f5d57ae7832237a0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 14:59:52 +0200 Subject: [PATCH 16/28] fix(app): display locale only if help or version is not displayed --- src/app/App.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/App.cpp b/src/app/App.cpp index 4939df467..aa029324b 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -102,6 +102,8 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U if (mParser->isSet("version")) mParser->showVersion(); + + qInfo() << QStringLiteral("Use locale: %1").arg(mLocale); } App::~App () { @@ -462,7 +464,6 @@ void App::initLocale (const shared_ptr &config) { if (!locale.isEmpty() && ::installLocale(*this, *mTranslator, QLocale(locale))) { mLocale = locale; - qInfo() << QStringLiteral("Use preferred locale: %1").arg(locale); return; } @@ -470,7 +471,6 @@ void App::initLocale (const shared_ptr &config) { QLocale sysLocale = QLocale::system(); if (::installLocale(*this, *mTranslator, sysLocale)) { mLocale = sysLocale.name(); - qInfo() << QStringLiteral("Use system locale: %1").arg(mLocale); return; } @@ -478,7 +478,6 @@ void App::initLocale (const shared_ptr &config) { mLocale = DEFAULT_LOCALE; if (!::installLocale(*this, *mTranslator, QLocale(mLocale))) qFatal("Unable to install default translator."); - qInfo() << QStringLiteral("Use default locale: %1").arg(mLocale); } QString App::getConfigLocale () const { From 1fb8e3e7a7b10a39f6bbcf2d9994c6b0c71fbf32 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 15:20:28 +0200 Subject: [PATCH 17/28] fix(AccountSettingsModel): test if identity address of proxy config is valid --- src/components/settings/AccountSettingsModel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index 97f110aeb..9ab0a052f 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -136,7 +136,11 @@ bool AccountSettingsModel::addOrUpdateProxyConfig ( return false; } - proxyConfig->setIdentityAddress(address); + if (proxyConfig->setIdentityAddress(address)) { + qWarning() << QStringLiteral("Unable to set identity address: `%1`.") + .arg(::Utils::coreStringToAppString(address->asStringUriOnly())); + return false; + } } // Server address. From e8f5964fc33bb3322e3bfe7b66e67b220b2f1a71 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 15:36:47 +0200 Subject: [PATCH 18/28] fix(ComboBox): change background color if ComboBox instance is disabled --- ui/modules/Common/Form/ComboBox.qml | 5 ++++- ui/modules/Common/Styles/Form/ComboBoxStyle.qml | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/modules/Common/Form/ComboBox.qml b/ui/modules/Common/Form/ComboBox.qml index e208714c6..f1c45bc9b 100644 --- a/ui/modules/Common/Form/ComboBox.qml +++ b/ui/modules/Common/Form/ComboBox.qml @@ -26,7 +26,10 @@ ComboBox { width: ComboBoxStyle.background.border.width } - color: ComboBoxStyle.background.color + color: comboBox.enabled + ? ComboBoxStyle.background.color.normal + : ComboBoxStyle.background.color.readOnly + radius: ComboBoxStyle.background.radius implicitHeight: ComboBoxStyle.background.height diff --git a/ui/modules/Common/Styles/Form/ComboBoxStyle.qml b/ui/modules/Common/Styles/Form/ComboBoxStyle.qml index f1df642a9..e2567976b 100644 --- a/ui/modules/Common/Styles/Form/ComboBoxStyle.qml +++ b/ui/modules/Common/Styles/Form/ComboBoxStyle.qml @@ -8,7 +8,6 @@ import Units 1.0 QtObject { property QtObject background: QtObject { - property color color: Colors.k property int height: 36 property int iconSize: 10 property int radius: 4 @@ -18,6 +17,11 @@ QtObject { property color color: Colors.c property int width: 1 } + + property QtObject color: QtObject { + property color normal: Colors.k + property color readOnly: Colors.e + } } property QtObject contentItem: QtObject { From ff985c090ce29315d2adbc56557c6e5e892937bb Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 15:47:09 +0200 Subject: [PATCH 19/28] feat(AccountSettingsModel): `addOrUpdateProxyConfig` load nom xml config file before create config --- src/components/settings/AccountSettingsModel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index 9ab0a052f..af1dc735e 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -20,6 +20,7 @@ * Author: Ronan Abhamon */ +#include "../../app/paths/Paths.hpp" #include "../../utils/Utils.hpp" #include "../core/CoreManager.hpp" @@ -168,7 +169,13 @@ bool AccountSettingsModel::addOrUpdateProxyConfig ( } shared_ptr AccountSettingsModel::createProxyConfig () { - return CoreManager::getInstance()->getCore()->createProxyConfig(); + shared_ptr core = CoreManager::getInstance()->getCore(); + + core->getConfig()->loadFromXmlFile( + Paths::getAssistantConfigDirPath() + "create-linphone-sip-account.rc" + ); + + return core->createProxyConfig(); } void AccountSettingsModel::addAuthInfo ( From 1a31ab06d719a68d7f91313d0c937fc11857b4be Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 16:00:55 +0200 Subject: [PATCH 20/28] fix(SettingsSipAccountsEdit): detect correctly sip addresses --- src/components/sip-addresses/SipAddressesModel.cpp | 11 +++++++++-- src/components/sip-addresses/SipAddressesModel.hpp | 1 + .../App/Settings/Dialogs/SettingsSipAccountsEdit.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/sip-addresses/SipAddressesModel.cpp b/src/components/sip-addresses/SipAddressesModel.cpp index c2fcaf0d8..091afbd28 100644 --- a/src/components/sip-addresses/SipAddressesModel.cpp +++ b/src/components/sip-addresses/SipAddressesModel.cpp @@ -175,12 +175,19 @@ QString SipAddressesModel::interpretUrl (const QUrl &sipAddress) { return sipAddress.toString(); } -bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) { +bool SipAddressesModel::addressIsValid (const QString &address) { return !!linphone::Factory::get()->createAddress( - ::Utils::appStringToCoreString(sipAddress) + ::Utils::appStringToCoreString(address) ); } +bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) { + shared_ptr address = linphone::Factory::get()->createAddress( + ::Utils::appStringToCoreString(sipAddress) + ); + return address && !address->getUsername().empty(); +} + // ----------------------------------------------------------------------------- bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) { diff --git a/src/components/sip-addresses/SipAddressesModel.hpp b/src/components/sip-addresses/SipAddressesModel.hpp index dacee0566..90111865e 100644 --- a/src/components/sip-addresses/SipAddressesModel.hpp +++ b/src/components/sip-addresses/SipAddressesModel.hpp @@ -59,6 +59,7 @@ public: Q_INVOKABLE static QString interpretUrl (const QString &sipAddress); Q_INVOKABLE static QString interpretUrl (const QUrl &sipAddress); + Q_INVOKABLE static bool addressIsValid (const QString &address); Q_INVOKABLE static bool sipAddressIsValid (const QString &sipAddress); // --------------------------------------------------------------------------- diff --git a/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js b/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js index 46aab78c4..15461fa6c 100644 --- a/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js +++ b/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js @@ -73,7 +73,7 @@ function validProxyConfig () { // ----------------------------------------------------------------------------- function handleRouteChanged (route) { - dialog._routeOk = route.length === 0 || Linphone.SipAddressesModel.sipAddressIsValid(route) + dialog._routeOk = route.length === 0 || Linphone.SipAddressesModel.addressIsValid(route) } function handleServerAddressChanged (address) { From f02d9054e64b0784de5eb10d2cef369dc01a1853 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 16:19:00 +0200 Subject: [PATCH 21/28] feat(SettingsSipAccountsEdit): deal with errors --- CHANGELOG.md | 1 + assets/languages/en.ts | 12 ++++++++++++ assets/languages/fr.ts | 12 ++++++++++++ .../App/Settings/Dialogs/SettingsSipAccountsEdit.qml | 6 ++++++ 4 files changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a21cbc580..ea6db76d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Add a `Logs` menu entry in `Settings Window`, it provides send, remove, activate buttons... - Supports EXIF orientation for file transfer images preview. - Echo canceller supports 48kHz. +- Better GUI when a proxy config is modified in `Settings Window`. ### Fixes diff --git a/assets/languages/en.ts b/assets/languages/en.ts index 281b50462..5e4627089 100644 --- a/assets/languages/en.ts +++ b/assets/languages/en.ts @@ -1319,6 +1319,18 @@ your friend's SIP address or username. confirm CONFIRM + + invalidSipAddress + Invalid sip address. + + + invalidServerAddress + Invalid server address. + + + invalidRoute + Invalid route. + SettingsUi diff --git a/assets/languages/fr.ts b/assets/languages/fr.ts index 0c9f5defa..b77ec8b69 100644 --- a/assets/languages/fr.ts +++ b/assets/languages/fr.ts @@ -1317,6 +1317,18 @@ Cliquez ici : <a href="%1">%1</a> confirm CONFIRMER + + invalidSipAddress + Adresse sip invalide. + + + invalidServerAddress + Adresse du serveur invalide. + + + invalidRoute + Route invalide. + SettingsUi diff --git a/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml b/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml index 596fe2ad2..e9f252166 100644 --- a/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml +++ b/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml @@ -52,6 +52,8 @@ DialogPlus { TextField { id: sipAddress + error: dialog._sipAddressOk ? '' : qsTr('invalidSipAddress') + onTextChanged: Logic.handleSipAddressChanged(text) } } @@ -64,6 +66,8 @@ DialogPlus { TextField { id: serverAddress + error: dialog._serverAddressOk ? '' : qsTr('invalidServerAddress') + onTextChanged: Logic.handleServerAddressChanged(text) } } @@ -101,6 +105,8 @@ DialogPlus { TextField { id: route + error: dialog._routeOk ? '' : qsTr('invalidRoute') + onTextChanged: Logic.handleRouteChanged(text) } } From ca984f9beed1aa288ead9e7fd56deb4c0d924cc9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 19 Jul 2017 16:58:19 +0200 Subject: [PATCH 22/28] chore(submodules): update all --- submodules/bctoolbox | 2 +- submodules/belcard | 2 +- submodules/belle-sip | 2 +- submodules/belr | 2 +- submodules/bzrtp | 2 +- submodules/linphone | 2 +- submodules/mediastreamer2 | 2 +- submodules/mswasapi | 2 +- submodules/mswebrtc | 2 +- submodules/ortp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/submodules/bctoolbox b/submodules/bctoolbox index a21cab956..a11248a22 160000 --- a/submodules/bctoolbox +++ b/submodules/bctoolbox @@ -1 +1 @@ -Subproject commit a21cab956fc9ae8d9e870c97005481e199e14dd7 +Subproject commit a11248a2211a32cb74743e51a2f45af36688e154 diff --git a/submodules/belcard b/submodules/belcard index 38eba4c26..8cb34798a 160000 --- a/submodules/belcard +++ b/submodules/belcard @@ -1 +1 @@ -Subproject commit 38eba4c264b5e45c8650c8ccf05f359541d8c4ae +Subproject commit 8cb34798a60bf2548fafa8931d31888dd8638dd5 diff --git a/submodules/belle-sip b/submodules/belle-sip index 19e4ff7d8..7d62ce9fa 160000 --- a/submodules/belle-sip +++ b/submodules/belle-sip @@ -1 +1 @@ -Subproject commit 19e4ff7d876b108ce0c3a1b6bb62e5d273787dcf +Subproject commit 7d62ce9fa00f0a745d458e739422282d2eb4b27c diff --git a/submodules/belr b/submodules/belr index df0f66406..9d5194462 160000 --- a/submodules/belr +++ b/submodules/belr @@ -1 +1 @@ -Subproject commit df0f6640647925b1225eba011a40ce988ede5c57 +Subproject commit 9d519446241a330e82967cf08a9437f4ea3ff0e8 diff --git a/submodules/bzrtp b/submodules/bzrtp index 8475e1439..bac853a1d 160000 --- a/submodules/bzrtp +++ b/submodules/bzrtp @@ -1 +1 @@ -Subproject commit 8475e143929af1cd442f3dc4cd2baf4790d74a4d +Subproject commit bac853a1daad009d5c80d426e4f1df5919ba18bf diff --git a/submodules/linphone b/submodules/linphone index 4b8dd8670..c673c854c 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 4b8dd8670ed881400c73dda7271e3bcb65468b54 +Subproject commit c673c854cbd6558e01ecc6be308ed357b26a5127 diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2 index 0ee1f589d..c70efb55a 160000 --- a/submodules/mediastreamer2 +++ b/submodules/mediastreamer2 @@ -1 +1 @@ -Subproject commit 0ee1f589d1d63b16861332ec034c200ea487e613 +Subproject commit c70efb55a2675d9f777995ab2187d9ee6f6e9ed0 diff --git a/submodules/mswasapi b/submodules/mswasapi index 55679b23e..0fd04f29d 160000 --- a/submodules/mswasapi +++ b/submodules/mswasapi @@ -1 +1 @@ -Subproject commit 55679b23ef130eab190b4f0dc0267761a712dc33 +Subproject commit 0fd04f29dcc3eb2d60f4053cb75cca7d14691d5d diff --git a/submodules/mswebrtc b/submodules/mswebrtc index 8ece6b276..bf46e597a 160000 --- a/submodules/mswebrtc +++ b/submodules/mswebrtc @@ -1 +1 @@ -Subproject commit 8ece6b276966fdf8414f82bb6f8c381d219867dc +Subproject commit bf46e597a9f60bcdb8b3e72c70fa5520db138158 diff --git a/submodules/ortp b/submodules/ortp index b9e17f852..69400d79c 160000 --- a/submodules/ortp +++ b/submodules/ortp @@ -1 +1 @@ -Subproject commit b9e17f85265c32b5739a3938507529f2e13d514c +Subproject commit 69400d79c523fa685c13179946d4ad21f1b7def8 From ab6027079fa39d474604d4f5d6037da6071fe1ee Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 19 Jul 2017 17:41:16 +0200 Subject: [PATCH 23/28] Add --package-source option to prepare.py. --- prepare.py | 1 + 1 file changed, 1 insertion(+) diff --git a/prepare.py b/prepare.py index 86daf00e7..97d05fd19 100755 --- a/prepare.py +++ b/prepare.py @@ -112,6 +112,7 @@ class DesktopPreparator(prepare.Preparator): self.argparser.add_argument('-ac', '--all-codecs', help="Enable all codecs, including the non-free ones", action='store_true') self.argparser.add_argument('-sys', '--use-system-dependencies', help="Find dependencies on the system.", action='store_true') self.argparser.add_argument('-p', '--package', help="Build an installation package (only on Mac OSX and Windows).", action='store_true') + self.argparser.add_argument('-ps', '--package-source', help="Build source packages for the dependencies.", action='store_true') def parse_args(self): prepare.Preparator.parse_args(self) From 651d3103eb5399ef9a9bea12da77e86169b66f41 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 20 Jul 2017 10:24:49 +0200 Subject: [PATCH 24/28] chore(submodules): update cmake-builder --- submodules/cmake-builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/cmake-builder b/submodules/cmake-builder index e50cc61c9..ee98b0c3c 160000 --- a/submodules/cmake-builder +++ b/submodules/cmake-builder @@ -1 +1 @@ -Subproject commit e50cc61c9c263565f20a6e952eafe0211024858a +Subproject commit ee98b0c3ca8df2a5f87fe2efd3cfe97aa9021d2a From 8ea7ec79fa19dd572607e1c735155abb05a4d4eb Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 20 Jul 2017 10:53:59 +0200 Subject: [PATCH 25/28] feat(tests): add AssistantViewTest --- CMakeLists.txt | 2 + src/tests/TestUtils.hpp | 5 ++ .../assistant-view/AssistantViewTest.cpp | 50 +++++++++++++++++++ .../assistant-view/AssistantViewTest.hpp | 41 +++++++++++++++ src/tests/main-view/MainViewTest.cpp | 6 ++- src/tests/main-view/MainViewTest.hpp | 5 ++ src/tests/main.cpp | 2 + src/tests/self-test/SelfTest.hpp | 5 ++ 8 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 src/tests/assistant-view/AssistantViewTest.cpp create mode 100644 src/tests/assistant-view/AssistantViewTest.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d49b1ddd2..d89e22a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,8 @@ set(HEADERS ) set(TESTS + src/tests/assistant-view/AssistantViewTest.cpp + src/tests/assistant-view/AssistantViewTest.hpp src/tests/main-view/MainViewTest.cpp src/tests/main-view/MainViewTest.hpp src/tests/self-test/SelfTest.cpp diff --git a/src/tests/TestUtils.hpp b/src/tests/TestUtils.hpp index a6372a86a..75ba72d8f 100644 --- a/src/tests/TestUtils.hpp +++ b/src/tests/TestUtils.hpp @@ -20,6 +20,9 @@ * Author: Ronan Abhamon */ +#ifndef TEST_UTILS_H_ +#define TEST_UTILS_H_ + #include #include @@ -42,3 +45,5 @@ namespace TestUtils { QQuickItem *getVirtualWindowContent (const QQuickWindow *window); } + +#endif // ifndef TEST_UTILS_H_ diff --git a/src/tests/assistant-view/AssistantViewTest.cpp b/src/tests/assistant-view/AssistantViewTest.cpp new file mode 100644 index 000000000..f883814d4 --- /dev/null +++ b/src/tests/assistant-view/AssistantViewTest.cpp @@ -0,0 +1,50 @@ +/* + * AssistantViewTest.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 20, 2017 + * Author: Ronan Abhamon + */ + +#include +#include +#include +#include + +#include "../../app/App.hpp" + +#include "AssistantViewTest.hpp" + +// ============================================================================= + +void AssistantViewTest::showAssistantView () { + QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); + + // Ensure home view is selected. + QQuickItem *contentLoader = mainWindow->findChild("__contentLoader"); + QVERIFY(contentLoader); + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, 100)); + + // Show assistant view. + QSignalSpy spyLoaderReady(contentLoader, SIGNAL(loaded())); + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(705, 485)); + QVERIFY(spyLoaderReady.count() == 1); + QCOMPARE( + QQmlProperty::read(contentLoader, "source").toString(), + QStringLiteral("qrc:/ui/views/App/Main/Assistant.qml") + ); +} diff --git a/src/tests/assistant-view/AssistantViewTest.hpp b/src/tests/assistant-view/AssistantViewTest.hpp new file mode 100644 index 000000000..de660577c --- /dev/null +++ b/src/tests/assistant-view/AssistantViewTest.hpp @@ -0,0 +1,41 @@ +/* + * AssistantViewTest.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: July 20, 2017 + * Author: Ronan Abhamon + */ + +#ifndef ASSISTANT_VIEW_TEST_H_ +#define ASSISTANT_VIEW_TEST_H_ + +#include + +// ============================================================================= + +class AssistantViewTest : public QObject { + Q_OBJECT; + +public: + AssistantViewTest () = default; + ~AssistantViewTest () = default; + +private slots: + void showAssistantView (); +}; + +#endif // ifndef ASSISTANT_VIEW_TEST_H_ diff --git a/src/tests/main-view/MainViewTest.cpp b/src/tests/main-view/MainViewTest.cpp index 5c691dc76..e5520b790 100644 --- a/src/tests/main-view/MainViewTest.cpp +++ b/src/tests/main-view/MainViewTest.cpp @@ -88,13 +88,15 @@ void MainViewTest::testMainMenuEntries_data () { } void MainViewTest::testMainMenuEntries () { - QQuickItem *contentLoader = App::getInstance()->getMainWindow()->findChild("__contentLoader"); + QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); + + QQuickItem *contentLoader = mainWindow->findChild("__contentLoader"); QVERIFY(contentLoader); QSignalSpy spyLoaderReady(contentLoader, SIGNAL(loaded())); QFETCH(int, y); - QTest::mouseClick(App::getInstance()->getMainWindow(), Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, y)); + QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, y)); QVERIFY(spyLoaderReady.count() == 1); QFETCH(QString, source); diff --git a/src/tests/main-view/MainViewTest.hpp b/src/tests/main-view/MainViewTest.hpp index cf00d9bec..82d37e0c6 100644 --- a/src/tests/main-view/MainViewTest.hpp +++ b/src/tests/main-view/MainViewTest.hpp @@ -20,6 +20,9 @@ * Author: Ronan Abhamon */ +#ifndef MAIN_VIEW_TEST_H_ +#define MAIN_VIEW_TEST_H_ + #include // ============================================================================= @@ -39,3 +42,5 @@ private slots: void testMainMenuEntries_data (); void testMainMenuEntries (); }; + +#endif // ifndef MAIN_VIEW_TEST_H_ diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 1433f6de8..8aa02129e 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -26,6 +26,7 @@ #include "../app/AppController.hpp" #include "../utils/Utils.hpp" +#include "assistant-view/AssistantViewTest.hpp" #include "main-view/MainViewTest.hpp" #include "self-test/SelfTest.hpp" @@ -33,6 +34,7 @@ static QHash initializeTests () { QHash hash; + hash["assistant-view"] = new AssistantViewTest(); hash["main-view"] = new MainViewTest(); return hash; } diff --git a/src/tests/self-test/SelfTest.hpp b/src/tests/self-test/SelfTest.hpp index 978dc2b39..3eab7c6c6 100644 --- a/src/tests/self-test/SelfTest.hpp +++ b/src/tests/self-test/SelfTest.hpp @@ -20,6 +20,9 @@ * Author: Ronan Abhamon */ +#ifndef SELF_TEST_H_ +#define SELF_TEST_H_ + #include // ============================================================================= @@ -33,3 +36,5 @@ public: private slots: void checkAppStartup (); }; + +#endif // ifndef SELF_TEST_H_ From 998427610939290c4aa0e876f7c5f04f9bfde51f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 20 Jul 2017 15:53:32 +0200 Subject: [PATCH 26/28] Replace libmatroska-c submodule by bcmatroska2. --- .gitmodules | 6 +++--- submodules/bcmatroska2 | 1 + submodules/externals/libmatroska-c | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) create mode 160000 submodules/bcmatroska2 delete mode 160000 submodules/externals/libmatroska-c diff --git a/.gitmodules b/.gitmodules index 89571ee73..b805414ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,9 +34,6 @@ [submodule "submodules/belr"] path = submodules/belr url = git://git.linphone.org/belr.git -[submodule "submodules/externals/libmatroska-c"] - path = submodules/externals/libmatroska-c - url = git://git.linphone.org/libmatroska-c.git [submodule "submodules/bctoolbox"] path = submodules/bctoolbox url = git://git.linphone.org/bctoolbox.git @@ -101,3 +98,6 @@ [submodule "submodules/mswasapi"] path = submodules/mswasapi url = git://git.linphone.org/mswasapi.git +[submodule "submodules/bcmatroska2"] + path = submodules/bcmatroska2 + url = git://git.linphone.org/bcmatroska2.git diff --git a/submodules/bcmatroska2 b/submodules/bcmatroska2 new file mode 160000 index 000000000..4c7acea97 --- /dev/null +++ b/submodules/bcmatroska2 @@ -0,0 +1 @@ +Subproject commit 4c7acea973ac94e559d52e45312e90cf4d0f6247 diff --git a/submodules/externals/libmatroska-c b/submodules/externals/libmatroska-c deleted file mode 160000 index 0c7250913..000000000 --- a/submodules/externals/libmatroska-c +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0c7250913a2f87d4640b64a347918280569f3148 From 888980cb5f483597106589d15212eccc53d56509 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 20 Jul 2017 16:15:20 +0200 Subject: [PATCH 27/28] Update submodules. --- submodules/bcg729 | 2 +- submodules/bcmatroska2 | 2 +- submodules/bctoolbox | 2 +- submodules/bcunit | 2 +- submodules/belcard | 2 +- submodules/belle-sip | 2 +- submodules/belr | 2 +- submodules/bzrtp | 2 +- submodules/cmake-builder | 2 +- submodules/linphone | 2 +- submodules/mediastreamer2 | 2 +- submodules/msamr | 2 +- submodules/msopenh264 | 2 +- submodules/mssilk | 2 +- submodules/mswebrtc | 2 +- submodules/ortp | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/submodules/bcg729 b/submodules/bcg729 index fdd4b15cd..9ada79d7f 160000 --- a/submodules/bcg729 +++ b/submodules/bcg729 @@ -1 +1 @@ -Subproject commit fdd4b15cd773ecdd01c4aeb65a8ec2cbde65637e +Subproject commit 9ada79d7ff53815e85432e7442810a2fd49dbd0e diff --git a/submodules/bcmatroska2 b/submodules/bcmatroska2 index 4c7acea97..46f30179f 160000 --- a/submodules/bcmatroska2 +++ b/submodules/bcmatroska2 @@ -1 +1 @@ -Subproject commit 4c7acea973ac94e559d52e45312e90cf4d0f6247 +Subproject commit 46f30179fcc9d00f35f7d0ef8eacce0a204e4d07 diff --git a/submodules/bctoolbox b/submodules/bctoolbox index a11248a22..99472e6e0 160000 --- a/submodules/bctoolbox +++ b/submodules/bctoolbox @@ -1 +1 @@ -Subproject commit a11248a2211a32cb74743e51a2f45af36688e154 +Subproject commit 99472e6e08368ff843c7905f785c98f4f038a29d diff --git a/submodules/bcunit b/submodules/bcunit index cf1aaa36c..d8d2f4b40 160000 --- a/submodules/bcunit +++ b/submodules/bcunit @@ -1 +1 @@ -Subproject commit cf1aaa36c5738c25e59c8fafbade388a0081cd53 +Subproject commit d8d2f4b40209e06b400f893cce58e4c6ba73341d diff --git a/submodules/belcard b/submodules/belcard index 8cb34798a..a2e36ce33 160000 --- a/submodules/belcard +++ b/submodules/belcard @@ -1 +1 @@ -Subproject commit 8cb34798a60bf2548fafa8931d31888dd8638dd5 +Subproject commit a2e36ce337b7cba0bd6fddec5912b7134dc627ba diff --git a/submodules/belle-sip b/submodules/belle-sip index 7d62ce9fa..a19b7e3e8 160000 --- a/submodules/belle-sip +++ b/submodules/belle-sip @@ -1 +1 @@ -Subproject commit 7d62ce9fa00f0a745d458e739422282d2eb4b27c +Subproject commit a19b7e3e833dc121f91452e40658dd80f8f0c145 diff --git a/submodules/belr b/submodules/belr index 9d5194462..a6380eccb 160000 --- a/submodules/belr +++ b/submodules/belr @@ -1 +1 @@ -Subproject commit 9d519446241a330e82967cf08a9437f4ea3ff0e8 +Subproject commit a6380eccb56bb070712971189912f41eb7f047a3 diff --git a/submodules/bzrtp b/submodules/bzrtp index bac853a1d..721fc7700 160000 --- a/submodules/bzrtp +++ b/submodules/bzrtp @@ -1 +1 @@ -Subproject commit bac853a1daad009d5c80d426e4f1df5919ba18bf +Subproject commit 721fc7700f4dc55fb7f975b52f2c3204f40c2844 diff --git a/submodules/cmake-builder b/submodules/cmake-builder index ee98b0c3c..659a481fb 160000 --- a/submodules/cmake-builder +++ b/submodules/cmake-builder @@ -1 +1 @@ -Subproject commit ee98b0c3ca8df2a5f87fe2efd3cfe97aa9021d2a +Subproject commit 659a481fbad8ea37b1d43668e148f9c5b4e05ab3 diff --git a/submodules/linphone b/submodules/linphone index c673c854c..f7a4846e3 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit c673c854cbd6558e01ecc6be308ed357b26a5127 +Subproject commit f7a4846e36cb17ec07355e9e272468856df648dc diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2 index c70efb55a..3bd6daab8 160000 --- a/submodules/mediastreamer2 +++ b/submodules/mediastreamer2 @@ -1 +1 @@ -Subproject commit c70efb55a2675d9f777995ab2187d9ee6f6e9ed0 +Subproject commit 3bd6daab8496eefc0b67db8d703487d81f2bfa52 diff --git a/submodules/msamr b/submodules/msamr index d86b907b3..49e8e5a9a 160000 --- a/submodules/msamr +++ b/submodules/msamr @@ -1 +1 @@ -Subproject commit d86b907b31eb7ecd6a3fd4409d5c9633d4366164 +Subproject commit 49e8e5a9af7781043fd5ee6c9bb9219f05ef7432 diff --git a/submodules/msopenh264 b/submodules/msopenh264 index 5544086f4..c2f3a2c61 160000 --- a/submodules/msopenh264 +++ b/submodules/msopenh264 @@ -1 +1 @@ -Subproject commit 5544086f478c13150eda5df683d914ecbf13ea89 +Subproject commit c2f3a2c619682bacab6307186154989fa4780a0c diff --git a/submodules/mssilk b/submodules/mssilk index 3a61f5dec..b9324a8e3 160000 --- a/submodules/mssilk +++ b/submodules/mssilk @@ -1 +1 @@ -Subproject commit 3a61f5decf634f5fb311b2c5f2984525fccd81d9 +Subproject commit b9324a8e3dd3953ec13677c7ea70c87f9c383d25 diff --git a/submodules/mswebrtc b/submodules/mswebrtc index bf46e597a..9c8f7fe88 160000 --- a/submodules/mswebrtc +++ b/submodules/mswebrtc @@ -1 +1 @@ -Subproject commit bf46e597a9f60bcdb8b3e72c70fa5520db138158 +Subproject commit 9c8f7fe88cf3f083253ee5320955f1e6e038dc8d diff --git a/submodules/ortp b/submodules/ortp index 69400d79c..3529d0842 160000 --- a/submodules/ortp +++ b/submodules/ortp @@ -1 +1 @@ -Subproject commit 69400d79c523fa685c13179946d4ad21f1b7def8 +Subproject commit 3529d0842dafaef8a9084647f93cb2454866d469 From 6641414dbe158d9b320546f919569ca50b980293 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 21 Jul 2017 09:39:23 +0200 Subject: [PATCH 28/28] chore(submodules): update before release --- CMakeLists.txt | 2 +- submodules/linphone | 2 +- submodules/msx264 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d89e22a17..15f53a39b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ ################################################################################ cmake_minimum_required(VERSION 3.1) -project(linphoneqt VERSION 4.0) +project(linphoneqt VERSION 4.1.0) set(APP_LIBRARY app-library) diff --git a/submodules/linphone b/submodules/linphone index f7a4846e3..74fd021a4 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit f7a4846e36cb17ec07355e9e272468856df648dc +Subproject commit 74fd021a47989e543e217c9f00c5a3b7bdd7e03b diff --git a/submodules/msx264 b/submodules/msx264 index 1898b96a9..a565b8116 160000 --- a/submodules/msx264 +++ b/submodules/msx264 @@ -1 +1 @@ -Subproject commit 1898b96a946c61b866c09c63e60622cf32dd2d2e +Subproject commit a565b81167438a851b53bdbab3ce5e2f1eddabe6