diff options
40 files changed, 684 insertions, 24 deletions
@@ -24,6 +24,7 @@ branch-coverage .qmake.* *.pch *.log +*.rcc config.tests/*/* !config.tests/*/*[.]* diff --git a/doc/configuration.qdoc b/doc/configuration.qdoc index 98bc8c46..1a60184c 100644 --- a/doc/configuration.qdoc +++ b/doc/configuration.qdoc @@ -226,6 +226,12 @@ or across multiple config files, the final value is resolved based on these rule \li string \li If set, the given style is used by QtQuickControls 2. \row + \li [\c ui/resources] + \li array<string> + \li Takes a list of \l{The Qt Resource System}{Qt resource} files (.rcc) or libraries that + have resources \l{Compiled-In Resources}{compiled-in} and registers them within the + System UI process. Resources can be accessed with the ":" or "qrc://" file path prefix. + \row \li [\c plugins] \li map<array<string>> \li A string-to-string-list map that defines plugins that the application manager should diff --git a/doc/manifest.qdoc b/doc/manifest.qdoc index 17f6e2bc..d38a4d00 100644 --- a/doc/manifest.qdoc +++ b/doc/manifest.qdoc @@ -271,6 +271,13 @@ that specifies which runtime a configuration option applies to: \li A list of paths to add to the QML-engine's import paths. Use of this parameter is equivalent to setting \c QML2_IMPORT_PATH for a program started from the command line. \row + \li \c resources + \li qml, qml-in-process + \li array<string> + \li Takes a list of \l{The Qt Resource System}{Qt resource} files (.rcc) or libraries that have + resources \l{Compiled-In Resources}{compiled-in} and registers them within the application + process. Resources can be accessed with the ":" or "qrc://" file path prefix. +\row \li \c arguments \li native \li array<string> diff --git a/qmake-features/am-qml-testcase.prf b/qmake-features/am-qml-testcase.prf index b475deed..923920fe 100644 --- a/qmake-features/am-qml-testcase.prf +++ b/qmake-features/am-qml-testcase.prf @@ -55,7 +55,8 @@ OTHER_FILES += $$IMPORTS_DIR # Read a config file for(config, AM_CONFIG) { - COMMAND += -c $$absolute_path($$config, $$_PRO_FILE_PWD_) + isEmpty(TESTRUN_CWD): COMMAND += -c $$absolute_path($$config, $$_PRO_FILE_PWD_) + else: COMMAND += -c $$config } OTHER_FILES += $$AM_CONFIG @@ -82,8 +83,7 @@ OTHER_FILES += $$TEST_FILES # Copy assets to build folder for (d , DIRECTORIES) { - win32: do_copydata.commands += $(COPY_DIR) $$shell_path($$_PRO_FILE_PWD_/$${d}) $$shell_path($$OUT_PWD/$${d}) $$escape_expand(\n\t) - else: do_copydata.commands += $(COPY_DIR) $$shell_path($$_PRO_FILE_PWD_/$${d}) $$shell_path($$OUT_PWD) $$escape_expand(\n\t) + do_copydata.commands += $(COPY_DIR) $$shell_path($$_PRO_FILE_PWD_/$${d}) $$shell_path($$OUT_PWD/$${d}) $$escape_expand(\n\t) } for (f , FILES) { do_copydata.commands += $(COPY) $$shell_path($$_PRO_FILE_PWD_/$${f}) $$shell_path($$OUT_PWD/$${f}) $$escape_expand(\n\t) diff --git a/qmake-features/generate-resource.prf b/qmake-features/generate-resource.prf new file mode 100644 index 00000000..54c40cea --- /dev/null +++ b/qmake-features/generate-resource.prf @@ -0,0 +1,10 @@ +load(resources) + +generate_rcc.input = RESOURCE_SOURCE +generate_rcc.name = RCC Generator +generate_rcc.depend_command = $$QMAKE_RCC_DEP -list -binary ${QMAKE_FILE_IN} +generate_rcc.CONFIG += dep_lines target_predeps no_link +generate_rcc.output = ${QMAKE_FILE_BASE}.rcc +generate_rcc.commands = $$QMAKE_RCC -binary ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + +QMAKE_EXTRA_COMPILERS += generate_rcc diff --git a/src/application-lib/applicationinfo.cpp b/src/application-lib/applicationinfo.cpp index ca9130be..661ffa3c 100644 --- a/src/application-lib/applicationinfo.cpp +++ b/src/application-lib/applicationinfo.cpp @@ -47,6 +47,7 @@ #include "exception.h" #include "installationreport.h" #include "packageinfo.h" +#include "utilities.h" QT_BEGIN_NAMESPACE_AM @@ -167,8 +168,7 @@ QVariantMap ApplicationInfo::toVariantMap() const QString ApplicationInfo::absoluteCodeFilePath() const { - QString code = m_codeFilePath; - return code.isEmpty() ? QString() : QDir(packageInfo()->baseDir()).absoluteFilePath(code); + return toAbsoluteFilePath(m_codeFilePath, packageInfo()->baseDir().path()); } QString ApplicationInfo::codeFilePath() const diff --git a/src/common-lib/utilities.h b/src/common-lib/utilities.h index ba8c7006..86d5b6ba 100644 --- a/src/common-lib/utilities.h +++ b/src/common-lib/utilities.h @@ -46,6 +46,11 @@ #include <QByteArray> #include <QMultiMap> #include <QVariant> +#include <QString> +#include <QUrl> +#include <QDir> +#include <QResource> +#include <QLibrary> #include <QtAppManCommon/global.h> @@ -70,6 +75,28 @@ inline QStringList variantToStringList(const QVariant &v) : v.toStringList(); } +// Translate between QFile and QUrl (resource) representations. +// For some weird reason, QFile cannot cope with "qrc:" and QUrl cannot cope with ":". +inline QUrl filePathToUrl(const QString &path, const QString &baseDir) +{ + return path.startsWith(qSL(":")) ? QUrl(qSL("qrc") + path) + : QUrl::fromUserInput(path, baseDir, QUrl::AssumeLocalFile); +} + +inline QString urlToLocalFilePath(const QUrl &url) +{ + if (url.isLocalFile()) + return url.toLocalFile(); + else if (url.scheme() == qSL("qrc")) + return qL1C(':') + url.path(); + return QString(); +} + +inline QString toAbsoluteFilePath(const QString &path, const QString &baseDir = QDir::currentPath()) +{ + return path.startsWith(qSL("qrc:")) ? path.mid(3) : QDir(baseDir).absoluteFilePath(path); +} + /*! \internal Recursively merge the second QVariantMap into the first one */ @@ -120,4 +147,12 @@ QVector<T *> loadPlugins(const char *type, const QStringList &files) Q_DECL_NOEX return result; } +// Load a Qt resource, either in the form of a resource file or a plugin +inline bool loadResource(const QString &resource) +{ + return QLibrary::isLibrary(resource) + ? (QLibrary(QDir().absoluteFilePath(resource)).load() || QResource::registerResource(resource)) + : (QResource::registerResource(resource) || QLibrary(QDir().absoluteFilePath(resource)).load()); +} + QT_END_NAMESPACE_AM diff --git a/src/main-lib/defaultconfiguration.cpp b/src/main-lib/defaultconfiguration.cpp index a0e5f930..3974f128 100644 --- a/src/main-lib/defaultconfiguration.cpp +++ b/src/main-lib/defaultconfiguration.cpp @@ -56,6 +56,7 @@ #include <QtAppManCommon/logging.h> #include "defaultconfiguration.h" +#include "utilities.h" QT_BEGIN_NAMESPACE_AM @@ -256,7 +257,7 @@ QStringList DefaultConfiguration::importPaths() const QStringList importPaths = value<QStringList>("I", { "ui", "importPaths" }); for (int i = 0; i < importPaths.size(); ++i) - importPaths[i] = QFileInfo(importPaths.at(i)).absoluteFilePath(); + importPaths[i] = toAbsoluteFilePath(importPaths.at(i)); return importPaths; } @@ -373,6 +374,11 @@ QString DefaultConfiguration::dltDescription() const return value<QString>(nullptr, { "logging", "dlt", "description" }); } +QStringList DefaultConfiguration::resources() const +{ + return value<QStringList>(nullptr, { "ui", "resources" }); +} + QVariantMap DefaultConfiguration::openGLConfiguration() const { return value<QVariant>(nullptr, { "ui", "opengl" }).toMap(); diff --git a/src/main-lib/defaultconfiguration.h b/src/main-lib/defaultconfiguration.h index b6317ba3..686f8b5a 100644 --- a/src/main-lib/defaultconfiguration.h +++ b/src/main-lib/defaultconfiguration.h @@ -98,6 +98,7 @@ public: bool enableTouchEmulation() const; QString dltId() const; QString dltDescription() const; + QStringList resources() const; QVariantMap openGLConfiguration() const; diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp index 5f7d6d67..e66a3710 100644 --- a/src/main-lib/main.cpp +++ b/src/main-lib/main.cpp @@ -226,6 +226,8 @@ void Main::setup(const DefaultConfiguration *cfg, const QStringList &deploymentW for (const QString &warning : deploymentWarnings) qCWarning(LogDeployment).noquote() << warning; + registerResources(cfg->resources()); + setupOpenGL(cfg->openGLConfiguration()); setupIconTheme(cfg->iconThemeSearchPaths(), cfg->iconThemeName()); @@ -326,6 +328,14 @@ QQmlApplicationEngine *Main::qmlEngine() const return m_engine; } +void Main::registerResources(const QStringList &resources) const +{ + for (const QString &resource: resources) { + if (!loadResource(resource)) + qCWarning(LogSystem) << "Cannot register resource:" << resource; + } +} + void Main::loadStartupPlugins(const QStringList &startupPluginPaths) Q_DECL_NOEXCEPT_EXPR(false) { m_startupPlugins = loadPlugins<StartupInterface>("startup", startupPluginPaths); @@ -358,15 +368,8 @@ void Main::setMainQmlFile(const QString &mainQml) Q_DECL_NOEXCEPT_EXPR(false) // For some weird reason, QFile cannot cope with "qrc:/" and QUrl cannot cope with ":/", // so we have to translate ourselves between those two "worlds". - if (mainQml.startsWith(qSL(":/"))) - m_mainQml = QUrl(qSL("qrc") + mainQml); - else - m_mainQml = QUrl::fromUserInput(mainQml, QDir::currentPath(), QUrl::AssumeLocalFile); - - if (m_mainQml.isLocalFile()) - m_mainQmlLocalFile = m_mainQml.toLocalFile(); - else if (m_mainQml.scheme() == qSL("qrc")) - m_mainQmlLocalFile = qL1C(':') + m_mainQml.path(); + m_mainQml = filePathToUrl(mainQml, QDir::currentPath()); + m_mainQmlLocalFile = urlToLocalFilePath(m_mainQml); if (!QFileInfo(m_mainQmlLocalFile).isFile()) { if (mainQml.isEmpty()) diff --git a/src/main-lib/main.h b/src/main-lib/main.h index b7a38cee..703ee7ca 100644 --- a/src/main-lib/main.h +++ b/src/main-lib/main.h @@ -105,6 +105,7 @@ public: QQmlApplicationEngine *qmlEngine() const; protected: + void registerResources(const QStringList &resources) const; void loadStartupPlugins(const QStringList &startupPluginPaths) Q_DECL_NOEXCEPT_EXPR(false); void parseSystemProperties(const QVariantMap &rawSystemProperties); void setupDBus(const std::function<QString(const char *)> &busForInterface, diff --git a/src/manager-lib/qmlinprocessruntime.cpp b/src/manager-lib/qmlinprocessruntime.cpp index 7f769b7d..0cbd9f6a 100644 --- a/src/manager-lib/qmlinprocessruntime.cpp +++ b/src/manager-lib/qmlinprocessruntime.cpp @@ -105,6 +105,19 @@ bool QmlInProcessRuntime::start() return false; } + const QString codeDir = m_app->codeDir() + QDir::separator(); + + const QStringList resources = variantToStringList(m_app->runtimeParameters().value(qSL("resources"))); + for (const QString &resource : resources) { + const QString path = QFileInfo(resource).isRelative() ? codeDir + resource : resource; + static QStringList cache; + if (!cache.contains(path)) { + if (!loadResource(path)) + qCWarning(LogQmlRuntime) << "Cannot register resource:" << path; + cache.append(path); + } + } + if (m_app->runtimeParameters().value(qSL("loadDummyData")).toBool()) { qCDebug(LogSystem) << "Loading dummy-data"; loadQmlDummyDataFiles(m_inProcessQmlEngine, QFileInfo(m_app->info()->absoluteCodeFilePath()).path()); @@ -113,14 +126,14 @@ bool QmlInProcessRuntime::start() const QStringList importPaths = variantToStringList(configuration().value(qSL("importPaths"))) + variantToStringList(m_app->runtimeParameters().value(qSL("importPaths"))); if (!importPaths.isEmpty()) { - const QString codeDir = m_app->codeDir() + QDir::separator(); for (const QString &path : importPaths) m_inProcessQmlEngine->addImportPath(QFileInfo(path).isRelative() ? codeDir + path : path); qCDebug(LogSystem) << "Updated Qml import paths:" << m_inProcessQmlEngine->importPathList(); } - QQmlComponent *component = new QQmlComponent(m_inProcessQmlEngine, m_app->info()->absoluteCodeFilePath()); + const QUrl qmlFileUrl = filePathToUrl(m_app->info()->absoluteCodeFilePath(), codeDir); + QQmlComponent *component = new QQmlComponent(m_inProcessQmlEngine, qmlFileUrl); if (!component->isReady()) { qCDebug(LogSystem) << "qml-file (" << m_app->info()->absoluteCodeFilePath() << "): component not ready:\n" << component->errorString(); diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index 421eb174..9588f848 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -349,7 +349,18 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile return; } - if (!QFile::exists(qmlFile)) { + QVariant resVar = runtimeParameters.value(qSL("resources")); + const QVariantList resources = (resVar.type() == QVariant::String) ? QVariantList{resVar} + : qdbus_cast<QVariantList>(resVar); + for (const QVariant &resource : resources) { + if (!loadResource(resource.toString())) + qCWarning(LogQmlRuntime) << "Cannot register resource:" << resource.toString(); + } + + const QUrl qmlFileUrl = filePathToUrl(qmlFile, baseDir); + const QString qmlFileStr = urlToLocalFilePath(qmlFileUrl); + + if (!QFile::exists(qmlFileStr)) { qCCritical(LogQmlRuntime) << "could not load" << qmlFile << ": file does not exist"; QCoreApplication::exit(2); return; @@ -399,7 +410,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile if (loadDummyData) { qCDebug(LogQmlRuntime) << "loading dummy-data"; - loadQmlDummyDataFiles(&m_engine, QFileInfo(qmlFile).path()); + loadQmlDummyDataFiles(&m_engine, QFileInfo(qmlFileStr).path()); } QVariant imports = runtimeParameters.value(qSL("importPaths")); @@ -407,8 +418,9 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile : qdbus_cast<QVariantList>(imports); for (const QVariant &v : vl) { const QString path = v.toString(); - if (QFileInfo(path).isRelative()) - m_engine.addImportPath(QDir().absoluteFilePath(path)); + const QFileInfo fi(path); + if (!(fi.isNativePath() && fi.isAbsolute())) + m_engine.addImportPath(toAbsoluteFilePath(path)); else qCWarning(LogQmlRuntime) << "Omitting absolute import path in info file for safety reasons:" << path; } @@ -425,7 +437,6 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile qmlProtectModule("QtApplicationManager", 2); qmlProtectModule("QtApplicationManager.Application", 2); - QUrl qmlFileUrl = QUrl::fromLocalFile(qmlFile); m_engine.rootContext()->setContextProperty(qSL("StartupTimer"), StartupTimer::instance()); m_engine.load(qmlFileUrl); @@ -434,7 +445,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile auto topLevels = m_engine.rootObjects(); if (Q_UNLIKELY(topLevels.isEmpty() || !topLevels.at(0))) { - qCCritical(LogSystem) << "could not load" << qmlFile << ": no root object"; + qCCritical(LogSystem) << "could not load" << qmlFileStr << ": no root object"; QCoreApplication::exit(3); return; } diff --git a/tests/qml/qml.pro b/tests/qml/qml.pro index d6a064f6..83cca142 100644 --- a/tests/qml/qml.pro +++ b/tests/qml/qml.pro @@ -15,4 +15,5 @@ SUBDIRS = \ crash/apps/tld.test.crash/terminator2 \ crash \ configs \ - lifecycle + lifecycle \ + resources diff --git a/tests/qml/resources/am-config.yaml b/tests/qml/resources/am-config.yaml new file mode 100644 index 00000000..8e3f8ee6 --- /dev/null +++ b/tests/qml/resources/am-config.yaml @@ -0,0 +1,13 @@ +formatVersion: 1 +formatType: am-configuration +--- +applications: + builtinAppsManifestDir: "${CONFIG_PWD}/apps" + installedAppsManifestDir: "/tmp/am-resource-test/manifests" + installationDir: "/tmp/am-resource-test/apps" + appImageMountDir: "/tmp/am-resource-test/image-mounts" + +ui: + importPaths: "qrc:///qml" + resources: [ "${CONFIG_PWD}/systemuifile.rcc", + "${CONFIG_PWD}/libsystemuiplugin.so" ] diff --git a/tests/qml/resources/apps/app1/app1.pro b/tests/qml/resources/apps/app1/app1.pro new file mode 100644 index 00000000..b8a1fcac --- /dev/null +++ b/tests/qml/resources/apps/app1/app1.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +TARGET = app1plugin +CONFIG += plugin +RESOURCES = app1plugin.qrc + +RESOURCE_SOURCE = app1file.qrc +load(generate-resource) diff --git a/tests/qml/resources/apps/app1/app1.qml b/tests/qml/resources/apps/app1/app1.qml new file mode 100644 index 00000000..9ab04279 --- /dev/null +++ b/tests/qml/resources/apps/app1/app1.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtApplicationManager.Application 2.0 +import forms 1.0 + +ApplicationManagerWindow { + YellowRect {} + AquaRect {} +} diff --git a/tests/qml/resources/apps/app1/app1file.qrc b/tests/qml/resources/apps/app1/app1file.qrc new file mode 100644 index 00000000..be8a925f --- /dev/null +++ b/tests/qml/resources/apps/app1/app1file.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>app1.qml</file> + <file>qml/forms/YellowRect.qml</file> + <file>qml/forms/qmldir</file> +</qresource> +</RCC> diff --git a/tests/qml/resources/apps/app1/app1plugin.qrc b/tests/qml/resources/apps/app1/app1plugin.qrc new file mode 100644 index 00000000..6b963fab --- /dev/null +++ b/tests/qml/resources/apps/app1/app1plugin.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>qml/forms/AquaRect.qml</file> +</qresource> +</RCC> diff --git a/tests/qml/resources/apps/app1/icon.png b/tests/qml/resources/apps/app1/icon.png Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/resources/apps/app1/icon.png diff --git a/tests/qml/resources/apps/app1/info.yaml b/tests/qml/resources/apps/app1/info.yaml new file mode 100644 index 00000000..69cf336e --- /dev/null +++ b/tests/qml/resources/apps/app1/info.yaml @@ -0,0 +1,16 @@ +formatVersion: 1 +formatType: am-package +--- +id: 'app1' +icon: 'icon.png' +name: + en: 'Resource Test App 1' + +applications: + - id: 'app1' + code: 'qrc:///app1.qml' + runtime: 'qml' + runtimeParameters: + importPaths: "qrc:///qml" + resources: [ "app1file.rcc", + "libapp1plugin.so" ] diff --git a/tests/qml/resources/apps/app1/qml/forms/AquaRect.qml b/tests/qml/resources/apps/app1/qml/forms/AquaRect.qml new file mode 100644 index 00000000..8bd906a6 --- /dev/null +++ b/tests/qml/resources/apps/app1/qml/forms/AquaRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "aqua" +} diff --git a/tests/qml/resources/apps/app1/qml/forms/YellowRect.qml b/tests/qml/resources/apps/app1/qml/forms/YellowRect.qml new file mode 100644 index 00000000..a4b5d9cb --- /dev/null +++ b/tests/qml/resources/apps/app1/qml/forms/YellowRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "yellow" +} diff --git a/tests/qml/resources/apps/app1/qml/forms/qmldir b/tests/qml/resources/apps/app1/qml/forms/qmldir new file mode 100644 index 00000000..50c588d1 --- /dev/null +++ b/tests/qml/resources/apps/app1/qml/forms/qmldir @@ -0,0 +1,4 @@ +module forms +YellowRect 1.0 qrc:///qml/forms/YellowRect.qml +# :/qml/forms/YellowRect.qml would not work +AquaRect 1.0 AquaRect.qml diff --git a/tests/qml/resources/apps/app2/BlueRect.qml b/tests/qml/resources/apps/app2/BlueRect.qml new file mode 100644 index 00000000..151dd1eb --- /dev/null +++ b/tests/qml/resources/apps/app2/BlueRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "blue" +} diff --git a/tests/qml/resources/apps/app2/app2.pro b/tests/qml/resources/apps/app2/app2.pro new file mode 100644 index 00000000..b3ce1bd0 --- /dev/null +++ b/tests/qml/resources/apps/app2/app2.pro @@ -0,0 +1,4 @@ +TEMPLATE = aux + +RESOURCE_SOURCE = app2.qrc +load(generate-resource) diff --git a/tests/qml/resources/apps/app2/app2.qml b/tests/qml/resources/apps/app2/app2.qml new file mode 100644 index 00000000..b8e34ae7 --- /dev/null +++ b/tests/qml/resources/apps/app2/app2.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtApplicationManager.Application 2.0 +import appwidgets 1.0 + +ApplicationManagerWindow { + BlueRect {} + GreenRect {} +} diff --git a/tests/qml/resources/apps/app2/app2.qrc b/tests/qml/resources/apps/app2/app2.qrc new file mode 100644 index 00000000..80bc560c --- /dev/null +++ b/tests/qml/resources/apps/app2/app2.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>app2.qml</file> + <file>BlueRect.qml</file> +</qresource> +</RCC> diff --git a/tests/qml/resources/apps/app2/icon.png b/tests/qml/resources/apps/app2/icon.png Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/resources/apps/app2/icon.png diff --git a/tests/qml/resources/apps/app2/info.yaml b/tests/qml/resources/apps/app2/info.yaml new file mode 100644 index 00000000..6eda565b --- /dev/null +++ b/tests/qml/resources/apps/app2/info.yaml @@ -0,0 +1,15 @@ +formatVersion: 1 +formatType: am-package +--- +id: 'app2' +icon: 'icon.png' +name: + en: 'Resource Test App 2' + +applications: + - id: 'app2' + code: ':/app2.qml' + runtime: 'qml' + runtimeParameters: + importPaths: "qml" + resources: "app2.rcc" diff --git a/tests/qml/resources/apps/app2/qml/appwidgets/GreenRect.qml b/tests/qml/resources/apps/app2/qml/appwidgets/GreenRect.qml new file mode 100644 index 00000000..d727e11e --- /dev/null +++ b/tests/qml/resources/apps/app2/qml/appwidgets/GreenRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "green" +} diff --git a/tests/qml/resources/apps/app2/qml/appwidgets/qmldir b/tests/qml/resources/apps/app2/qml/appwidgets/qmldir new file mode 100644 index 00000000..a158bf25 --- /dev/null +++ b/tests/qml/resources/apps/app2/qml/appwidgets/qmldir @@ -0,0 +1,2 @@ +module appwidgets +GreenRect 1.0 GreenRect.qml diff --git a/tests/qml/resources/qml/widgets/MagentaRect.qml b/tests/qml/resources/qml/widgets/MagentaRect.qml new file mode 100644 index 00000000..a90cf23b --- /dev/null +++ b/tests/qml/resources/qml/widgets/MagentaRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "magenta" +} diff --git a/tests/qml/resources/qml/widgets/RedRect.qml b/tests/qml/resources/qml/widgets/RedRect.qml new file mode 100644 index 00000000..b22b895b --- /dev/null +++ b/tests/qml/resources/qml/widgets/RedRect.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + color: "red" +} diff --git a/tests/qml/resources/qml/widgets/qmldir b/tests/qml/resources/qml/widgets/qmldir new file mode 100644 index 00000000..be36132a --- /dev/null +++ b/tests/qml/resources/qml/widgets/qmldir @@ -0,0 +1,3 @@ +module widgets +RedRect 1.0 RedRect.qml +MagentaRect 1.0 MagentaRect.qml diff --git a/tests/qml/resources/resources.pro b/tests/qml/resources/resources.pro new file mode 100644 index 00000000..90144104 --- /dev/null +++ b/tests/qml/resources/resources.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = test.pro \ + apps/app1 \ + apps/app2 diff --git a/tests/qml/resources/systemuifile.qrc b/tests/qml/resources/systemuifile.qrc new file mode 100644 index 00000000..ce48e1a4 --- /dev/null +++ b/tests/qml/resources/systemuifile.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>qml/widgets/RedRect.qml</file> + <file>qml/widgets/qmldir</file> +</qresource> +</RCC> diff --git a/tests/qml/resources/systemuiplugin.qrc b/tests/qml/resources/systemuiplugin.qrc new file mode 100644 index 00000000..7fe63a54 --- /dev/null +++ b/tests/qml/resources/systemuiplugin.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>qml/widgets/MagentaRect.qml</file> +</qresource> +</RCC> diff --git a/tests/qml/resources/test.pro b/tests/qml/resources/test.pro new file mode 100644 index 00000000..fd145a2e --- /dev/null +++ b/tests/qml/resources/test.pro @@ -0,0 +1,18 @@ +AM_CONFIG = am-config.yaml +TEST_FILES = tst_resource.qml +TEST_APPS = app1 app2 + +DIRECTORIES = apps/app2/qml +FILES = am-config.yaml \ + apps/app1/icon.png apps/app1/info.yaml \ + apps/app2/icon.png apps/app2/info.yaml +DESTDIR = $$OUT_PWD +load(am-qml-testcase) + +RESOURCE_SOURCE = systemuifile.qrc +load(generate-resource) + +TEMPLATE = lib +TARGET = systemuiplugin +CONFIG += plugin +RESOURCES = systemuiplugin.qrc diff --git a/tests/qml/resources/tst_resource.qml b/tests/qml/resources/tst_resource.qml new file mode 100644 index 00000000..5c523131 --- /dev/null +++ b/tests/qml/resources/tst_resource.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 +import QtQuick.Window 2.11 +import QtTest 1.0 +import QtApplicationManager.SystemUI 2.0 +import widgets 1.0 + +TestCase { + id: testCase + when: windowShown + name: "ResourceTest" + + RedRect {} + MagentaRect {} + + SignalSpy { + id: runStateChangedSpy + target: ApplicationManager + signalName: "applicationRunStateChanged" + } + + function test_basic_data() { + return [ { tag: "app1" }, + { tag: "app2" } ]; + } + + function test_basic(data) { + var app = ApplicationManager.application(data.tag); + app.start(); + runStateChangedSpy.wait(3000); + runStateChangedSpy.wait(3000); + compare(app.runState, ApplicationObject.Running); + app.stop(); + runStateChangedSpy.wait(3000); + runStateChangedSpy.wait(3000); + compare(app.runState, ApplicationObject.NotRunning); + } +} |