From 5566c1a96816f39a43888f40bde224d7d49f3b75 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Wed, 29 Mar 2023 12:39:47 -0400 Subject: [PATCH] tests: qml: initialize the preview engine This was causing invalid connections during test setup. Not having a null preview engine will prevent dereferencing a null pointer once messaging tests are implemented, however, the webengine will not work correctly due to missing resources which may be corrected in a subsequent patch. This commit also moves .clang-format to the root repo dir so it will apply to the test source code (the test source code should be within the src dir). Gitlab: #899 Change-Id: I8cac1fb937a0c60a91219b11ed1e0b5f323b1816 --- src/.clang-format => .clang-format | 0 tests/qml/main.cpp | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) rename src/.clang-format => .clang-format (100%) diff --git a/src/.clang-format b/.clang-format similarity index 100% rename from src/.clang-format rename to .clang-format diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index 50a533012..0f974e64e 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -1,7 +1,5 @@ /* * Copyright (C) 2021-2023 Savoir-faire Linux Inc. - * Author: Albert Babà Oller <albert.babi@savoirfairelinux.com> - * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * * 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 @@ -32,10 +30,12 @@ #include <QQmlEngine> #include <QScopedPointer> #include <QtQuickTest/quicktest.h> + #ifdef WITH_WEBENGINE #include <QtWebEngineCore> #include <QtWebEngineQuick> #endif + #ifdef Q_OS_WIN #include <windows.h> #endif @@ -54,6 +54,7 @@ public: connectivityMonitor_.reset(new ConnectivityMonitor(this)); settingsManager_.reset(new AppSettingsManager(this)); systemTray_.reset(new SystemTray(settingsManager_.get(), this)); + previewEngine_.reset(new PreviewEngine(this)); QFontDatabase::addApplicationFont(":/images/FontAwesome.otf"); @@ -65,7 +66,7 @@ public: lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/"; } - void qmlEngineRegistration(QQmlEngine* engine) + void registerQmlTypes(QQmlEngine* engine) { // Expose custom types to the QML engine. Utils::registerTypes(engine, @@ -79,12 +80,15 @@ public: public Q_SLOTS: - /*! + /* * Called once before qmlEngineAvailable. */ - void applicationAvailable() { init(); } + 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 @@ -96,6 +100,7 @@ public Q_SLOTS: */ void qmlEngineAvailable(QQmlEngine* engine) { + registerQmlTypes(engine); auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this); engine->rootContext()->setContextProperty("videoProvider", videoProvider); #ifdef WITH_WEBENGINE @@ -103,10 +108,9 @@ public Q_SLOTS: #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. */ -- GitLab