diff --git a/src/app/mainview/components/ChatView.qml b/src/app/mainview/components/ChatView.qml index 6bbe6674..a45d43cf 100644 --- a/src/app/mainview/components/ChatView.qml +++ b/src/app/mainview/components/ChatView.qml @@ -252,7 +252,7 @@ Rectangle { visible: { if (CurrentAccount.type === Profile.Type.SIP) return true - if (CurrentConversation.isBlocked) + if (CurrentConversation.isBanned) return false else if (CurrentConversation.needsSyncing) return false diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4e42b307..09adc23d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -35,6 +35,7 @@ add_executable(qml_tests ${QML_RESOURCES} ${QML_RESOURCES_QML} ${TEST_QML_RESOURCES} + ${SFPM_OBJECTS} $) target_link_libraries(qml_tests diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index 4c42027c..d7b6af0c 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -17,20 +17,21 @@ * along with this program. If not, see . */ -#include "mainapplication.h" -#include "qmlregister.h" #include "appsettingsmanager.h" #include "connectivitymonitor.h" -#include "systemtray.h" +#include "mainapplication.h" #include "previewengine.h" +#include "qmlregister.h" +#include "systemtray.h" +#include "videoprovider.h" #include +#include +#include +#include #include #include -#include -#include -#include #ifdef WITH_WEBENGINE #include #include @@ -43,125 +44,119 @@ #include #endif -class Setup : public QObject -{ - Q_OBJECT +class Setup : public QObject { + Q_OBJECT public: - Setup(bool muteDring = false) - : muteDring_(muteDring) - {} + Setup(bool muteDring = false) : muteDring_(muteDring) {} - void init() - { - connectivityMonitor_.reset(new ConnectivityMonitor(this)); - settingsManager_.reset(new AppSettingsManager(this)); - systemTray_.reset(new SystemTray(settingsManager_.get(), this)); + void init() { + connectivityMonitor_.reset(new ConnectivityMonitor(this)); + settingsManager_.reset(new AppSettingsManager(this)); + systemTray_.reset(new SystemTray(settingsManager_.get(), this)); - QFontDatabase::addApplicationFont(":/images/FontAwesome.otf"); + QFontDatabase::addApplicationFont(":/images/FontAwesome.otf"); #if defined _MSC_VER && !COMPILE_ONLY - gnutls_global_init(); + gnutls_global_init(); #endif - lrcInstance_.reset( - new LRCInstance(nullptr, nullptr, "", connectivityMonitor_.get(), muteDring_)); - lrcInstance_->subscribeToDebugReceived(); + lrcInstance_.reset(new LRCInstance(nullptr, nullptr, "", + connectivityMonitor_.get(), muteDring_)); + lrcInstance_->subscribeToDebugReceived(); - auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath); - lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/"; - } + auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath); + lrcInstance_->accountModel().downloadDirectory = + downloadPath.toString() + "/"; + } - void qmlEngineRegistration(QQmlEngine* engine) - { - // Expose custom types to the QML engine. - Utils::registerTypes(engine, - systemTray_.get(), - lrcInstance_.get(), - settingsManager_.get(), - previewEngine_.get(), - &screenInfo_, - this); - } + void qmlEngineRegistration(QQmlEngine *engine) { + // Expose custom types to the QML engine. + Utils::registerTypes(engine, systemTray_.get(), lrcInstance_.get(), + settingsManager_.get(), previewEngine_.get(), + &screenInfo_, this); + } public Q_SLOTS: - /*! - * Called once before qmlEngineAvailable. - */ - void applicationAvailable() - { - init(); - } + /*! + * Called once before qmlEngineAvailable. + */ + void applicationAvailable() { init(); } - /*! - * Called when the QML engine is available. Any import paths, plugin paths, - * and extra file selectors will have been set on the engine by this point. - * This function is called once for each QML test file, so any arguments are - * unique to that test. For example, this means that each QML test file will - * have its own QML engine. - * - * This function can be used to register QML types and add import paths, - * amongst other things. - */ - void qmlEngineAvailable(QQmlEngine* engine) - { - qmlEngineRegistration(engine); - } + /*! + * Called when the QML engine is available. Any import paths, plugin paths, + * and extra file selectors will have been set on the engine by this point. + * This function is called once for each QML test file, so any arguments are + * unique to that test. For example, this means that each QML test file will + * have its own QML engine. + * + * This function can be used to register QML types and add import paths, + * amongst other things. + */ + void qmlEngineAvailable(QQmlEngine *engine) { + auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this); + engine->rootContext()->setContextProperty("videoProvider", videoProvider); +#ifdef WITH_WEBENGINE + engine->rootContext()->setContextProperty("WITH_WEBENGINE", QVariant(true)); +#else + engine->rootContext()->setContextProperty("WITH_WEBENGINE", + QVariant(false)); +#endif + qmlEngineRegistration(engine); + } - /*! - * Called once right after the all test execution has finished. Use this - * function to clean up before everything is destroyed. - */ - void cleanupTestCase() {} + /*! + * Called once right after the all test execution has finished. Use this + * function to clean up before everything is destroyed. + */ + void cleanupTestCase() {} private: - QScopedPointer lrcInstance_; + QScopedPointer lrcInstance_; - QScopedPointer connectivityMonitor_; - QScopedPointer settingsManager_; - QScopedPointer systemTray_; - QScopedPointer previewEngine_; - ScreenInfo screenInfo_; + QScopedPointer connectivityMonitor_; + QScopedPointer settingsManager_; + QScopedPointer systemTray_; + QScopedPointer previewEngine_; + ScreenInfo screenInfo_; - bool muteDring_ {false}; + bool muteDring_{false}; }; -int -main(int argc, char** argv) -{ - QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); +int main(int argc, char **argv) { + QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); - auto jamiDataDir = tempDir.absolutePath() + "\\jami_test\\jami"; - auto jamiConfigDir = tempDir.absolutePath() + "\\jami_test\\.config"; - auto jamiCacheDir = tempDir.absolutePath() + "\\jami_test\\.cache"; + auto jamiDataDir = tempDir.absolutePath() + "\\jami_test\\jami"; + auto jamiConfigDir = tempDir.absolutePath() + "\\jami_test\\.config"; + auto jamiCacheDir = tempDir.absolutePath() + "\\jami_test\\.cache"; - bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CACHE_HOME", jamiCacheDir.toLocal8Bit()); - if (!envSet) - return 1; + bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit()); + envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit()); + envSet &= qputenv("JAMI_CACHE_HOME", jamiCacheDir.toLocal8Bit()); + if (!envSet) + return 1; - bool muteDring {false}; + bool muteDring{false}; - // Remove "-mutejamid" from argv, as quick_test_main_with_setup() will - // fail if given an invalid command-line argument. - auto end = std::remove_if(argv + 1, argv + argc, [](char* argv) { - return (strcmp(argv, "-mutejamid") == 0); - }); + // Remove "-mutejamid" from argv, as quick_test_main_with_setup() will + // fail if given an invalid command-line argument. + auto end = std::remove_if(argv + 1, argv + argc, [](char *argv) { + return (strcmp(argv, "-mutejamid") == 0); + }); - if (end != argv + argc) { - muteDring = true; + if (end != argv + argc) { + muteDring = true; - // Adjust the argument count. - argc = std::distance(argv, end); - } + // Adjust the argument count. + argc = std::distance(argv, end); + } #ifdef WITH_WEBENGINE - QtWebEngineQuick::initialize(); + QtWebEngineQuick::initialize(); #endif - QTEST_SET_MAIN_SOURCE_PATH - Setup setup(muteDring); - return quick_test_main_with_setup(argc, argv, "qml_test", nullptr, &setup); + QTEST_SET_MAIN_SOURCE_PATH + Setup setup(muteDring); + return quick_test_main_with_setup(argc, argv, "qml_test", nullptr, &setup); } #include "main.moc" diff --git a/tests/qml/to_fix/tst_ChatViewFooter.qml b/tests/qml/src/tst_ChatViewFooter.qml similarity index 65% rename from tests/qml/to_fix/tst_ChatViewFooter.qml rename to tests/qml/src/tst_ChatViewFooter.qml index b0cffe1a..cebaef57 100644 --- a/tests/qml/to_fix/tst_ChatViewFooter.qml +++ b/tests/qml/src/tst_ChatViewFooter.qml @@ -22,8 +22,9 @@ import QtQuick.Layouts import QtTest -import net.jami.Models 1.1 +import net.jami.Adapters 1.1 import net.jami.Constants 1.1 +import net.jami.Models 1.1 import "../../../src/app/mainview/components" @@ -62,29 +63,6 @@ ColumnLayout { messageBarTextArea.clearText() compare(sendMessageButton.visible, false) - // File added into filesToSendContainer will cause sendMessageButton to show - filesToSendContainer.filesToSendListModel.addToPending( - ":/src/app/resources/png_test.png") - compare(filesToSendContainer.filesToSendCount, 1) - compare(sendMessageButton.visible, true) - - // Files cleared from filesToSendContainer will cause sendMessageButton to hide - filesToSendContainer.filesToSendListModel.flush() - compare(filesToSendContainer.filesToSendCount, 0) - compare(sendMessageButton.visible, false) - - // When the text and files both exist, - // clear one of them will still make sendMessageButton to show - messageBarTextArea.insertText("test") - filesToSendContainer.filesToSendListModel.addToPending( - ":/src/app/resources/png_test.png") - messageBarTextArea.clearText() - compare(sendMessageButton.visible, true) - - messageBarTextArea.insertText("test") - filesToSendContainer.filesToSendListModel.flush() - compare(sendMessageButton.visible, true) - // Both are cleared messageBarTextArea.clearText() compare(sendMessageButton.visible, false)