summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/applicationinfo/CMakeLists.txt13
-rw-r--r--tests/auto/applicationinfo/data/full/info.yaml118
-rw-r--r--tests/auto/applicationinfo/data/inherit/info.yaml28
-rw-r--r--tests/auto/applicationinfo/data/legacy/info.yaml (renamed from tests/data/manifests/com.pelagicore.test/info.yaml)11
-rw-r--r--tests/auto/applicationinfo/data/minimal/info.yaml8
-rw-r--r--tests/auto/applicationinfo/tst_applicationinfo.cpp456
-rw-r--r--tests/auto/main/tst_main.cpp12
-rw-r--r--tests/auto/packager-tool/tst_packager-tool.cpp1
-rw-r--r--tests/data/manifests/com.pelagicore.json-legacy/info.yaml19
9 files changed, 525 insertions, 141 deletions
diff --git a/tests/auto/applicationinfo/CMakeLists.txt b/tests/auto/applicationinfo/CMakeLists.txt
index 7c9320fe..fed2b365 100644
--- a/tests/auto/applicationinfo/CMakeLists.txt
+++ b/tests/auto/applicationinfo/CMakeLists.txt
@@ -3,13 +3,22 @@ qt_internal_add_test(tst_applicationinfo
SOURCES
../error-checking.h
tst_applicationinfo.cpp
- DEFINES
- AM_TESTDATA_DIR=\\\"${CMAKE_CURRENT_BINARY_DIR}/../../data/\\\"
PUBLIC_LIBRARIES
Qt::Network
Qt::AppManApplicationPrivate
Qt::AppManCommonPrivate
Qt::AppManManagerPrivate
+ Qt::AppManIntentServerPrivate
+)
+
+qt_internal_add_resource(tst_applicationinfo "yaml_testdata"
+ PREFIX
+ "/"
+ FILES
+ "data/legacy/info.yaml"
+ "data/minimal/info.yaml"
+ "data/inherit/info.yaml"
+ "data/full/info.yaml"
)
qt_internal_extend_target(tst_applicationinfo CONDITION TARGET Qt::DBus
diff --git a/tests/auto/applicationinfo/data/full/info.yaml b/tests/auto/applicationinfo/data/full/info.yaml
new file mode 100644
index 00000000..1ff2c7f5
--- /dev/null
+++ b/tests/auto/applicationinfo/data/full/info.yaml
@@ -0,0 +1,118 @@
+formatVersion: 1
+formatType: am-package
+---
+id: 'full'
+icon: 'full.png'
+version: 'v1'
+name:
+ en: 'pkg.name.en'
+ de: 'pkg.name.de'
+description:
+ en: 'pkg.desc.en'
+ de: 'pkg.desc.de'
+categories:
+ - pkg.cat.1
+ - pkg.cat.2
+applications:
+ - id: 'full.app.1'
+ code: 'app1.qml'
+ runtime: 'qml'
+ runtimeParameters:
+ loadDummyDate: true
+ importPaths: [ a, b ]
+ resources: [ c, d ]
+ pluginPaths: [ e, f ]
+ environmentVariables:
+ foo: bar
+ supportsApplicationInterface: yes
+ capabilities:
+ - app1.cap
+ opengl:
+ desktopProfile: core
+ esMajorVersion: 3
+ esMinorVersion: 2
+ applicationProperties:
+ protected:
+ custom.app1.key: 42
+ private:
+ not: visible
+ logging:
+ dlt:
+ id: app1.dlt.id
+ description: "app1.dlt.desc"
+ icon: 'app1.png'
+ name:
+ en: 'app1.name.en'
+ de: 'app1.name.de'
+ description:
+ en: 'app1.desc.en'
+ de: 'app1.desc.de'
+ categories:
+ - app1.cat.1
+ - app1.cat.2
+ - id: 'full.app.2'
+ code: 'app2.exe'
+ runtime: 'native'
+ runtimeParameters:
+ arguments: [ "-3", "-4" ]
+ environmentVariables:
+ bar: foo
+ supportsApplicationInterface: yes
+ capabilities:
+ - app2.cap.1
+ - app2.cap.2
+ opengl:
+ desktopProfile: compatibility
+ esMajorVersion: 2
+ esMinorVersion: 0
+ applicationProperties:
+ protected:
+ custom.app2.key: "custom.app2.value"
+ logging:
+ dlt:
+ id: app2.dlt.id
+ description: "app2.dlt.desc"
+ icon: 'app2.png'
+ name:
+ en: 'app2.name.en'
+ de: 'app2.name.de'
+ description:
+ en: 'app2.desc.en'
+ de: 'app2.desc.de'
+ categories:
+ - app2.cat.1
+ - app2.cat.2
+
+intents:
+- id: full.int.1
+ handlingApplicationId: full.app.1
+ visibility: private
+ requiredCapabilities: [ 'int1.cap.1', 'int1.cap.2' ]
+ parameterMatch:
+ mimeType: "^image/.*\\.png$"
+ icon: 'int1.png'
+ name:
+ en: 'int1.name.en'
+ de: 'int1.name.de'
+ description:
+ en: 'int1.desc.en'
+ de: 'int1.desc.de'
+ categories:
+ - int1.cat.1
+ - int1.cat.2
+- id: full.int.2
+ handlingApplicationId: full.app.2
+ visibility: public
+ requiredCapabilities: [ 'int2.cap.1', 'int2.cap.2' ]
+ parameterMatch:
+ test: "foo"
+ icon: 'int2.png'
+ name:
+ en: 'int2.name.en'
+ de: 'int2.name.de'
+ description:
+ en: 'int2.desc.en'
+ de: 'int2.desc.de'
+ categories:
+ - int2.cat.1
+ - int2.cat.2
diff --git a/tests/auto/applicationinfo/data/inherit/info.yaml b/tests/auto/applicationinfo/data/inherit/info.yaml
new file mode 100644
index 00000000..0c5fe3fd
--- /dev/null
+++ b/tests/auto/applicationinfo/data/inherit/info.yaml
@@ -0,0 +1,28 @@
+formatVersion: 1
+formatType: am-package
+---
+id: 'inherit'
+icon: 'pkg.png'
+name:
+ en: 'pkg.name.en'
+ de: 'pkg.name.de'
+description:
+ en: 'pkg.desc.en'
+ de: 'pkg.desc.de'
+categories:
+ - pkg.cat.1
+ - pkg.cat.2
+
+applications:
+ - id: 'inherit.app.1'
+ code: 'app1.qml'
+ runtime: 'qml'
+ - id: 'inherit.app.2'
+ code: 'app2.exe'
+ runtime: 'native'
+
+intents:
+- id: inherit.int.1
+ handlingApplicationId: inherit.app.1
+- id: inherit.int.2
+ handlingApplicationId: inherit.app.2
diff --git a/tests/data/manifests/com.pelagicore.test/info.yaml b/tests/auto/applicationinfo/data/legacy/info.yaml
index 0c4b3fd0..77272547 100644
--- a/tests/data/manifests/com.pelagicore.test/info.yaml
+++ b/tests/auto/applicationinfo/data/legacy/info.yaml
@@ -1,15 +1,15 @@
formatVersion: 1
formatType: am-application
---
-id: 'com.pelagicore.test'
-icon: 'icon.png'
-code: 'Test.qml'
+id: 'legacy'
+icon: 'icon.png'
+code: 'legacy.qml'
runtime: 'qml'
runtimeParameters:
loadDummyData: true
name:
- en: 'english'
- de: 'deutsch'
+ en: 'legacy.en'
+ de: 'legacy.de'
version: v1
@@ -24,4 +24,3 @@ capabilities:
categories:
- "foo"
- "bar"
-
diff --git a/tests/auto/applicationinfo/data/minimal/info.yaml b/tests/auto/applicationinfo/data/minimal/info.yaml
new file mode 100644
index 00000000..e7f2999b
--- /dev/null
+++ b/tests/auto/applicationinfo/data/minimal/info.yaml
@@ -0,0 +1,8 @@
+formatVersion: 1
+formatType: am-package
+---
+id: 'minimal'
+applications:
+ - id: 'minimal.app'
+ code: 'minimal.qml'
+ runtime: 'qml'
diff --git a/tests/auto/applicationinfo/tst_applicationinfo.cpp b/tests/auto/applicationinfo/tst_applicationinfo.cpp
index 0d8888ad..6dd42255 100644
--- a/tests/auto/applicationinfo/tst_applicationinfo.cpp
+++ b/tests/auto/applicationinfo/tst_applicationinfo.cpp
@@ -34,6 +34,9 @@
#include "global.h"
#include "application.h"
#include "applicationinfo.h"
+#include "intent.h"
+#include "intentinfo.h"
+#include "package.h"
#include "packageinfo.h"
#include "yamlpackagescanner.h"
#include "exception.h"
@@ -44,105 +47,374 @@ class tst_ApplicationInfo : public QObject
{
Q_OBJECT
-public:
- tst_ApplicationInfo();
-
private slots:
- void initTestCase();
- void cleanupTestCase();
- void application_data();
- void application();
+ void full();
+ void minimal();
+ void inherit();
+ void legacy();
void validApplicationId_data();
void validApplicationId();
- void validIcon_data();
- void validIcon();
-
-private:
- QVector<PackageInfo *> m_pkgs;
};
-tst_ApplicationInfo::tst_ApplicationInfo()
-{ }
+QT_BEGIN_NAMESPACE_AM
-
-void tst_ApplicationInfo::initTestCase()
+class TestPackageLoader
{
- if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists())
- QSKIP("No test packages available in the data/ directory");
-
- YamlPackageScanner scanner;
- QDir baseDir(qL1S(AM_TESTDATA_DIR "manifests"));
- const QStringList pkgDirNames = baseDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
- for (const QString &pkgDirName : pkgDirNames) {
- QDir dir = baseDir.absoluteFilePath(pkgDirName);
+public:
+ TestPackageLoader(const char *name)
+ : m_dataDir(qL1S(":/data"))
+ {
try {
- PackageInfo *pi = scanner.scan(dir.absoluteFilePath(qSL("info.yaml")));
- QVERIFY(pi);
- QCOMPARE(pkgDirName, pi->id());
- m_pkgs << pi;
- } catch (const std::exception &e) {
- QFAIL(e.what());
+ static YamlPackageScanner scanner;
+ QString path = QString::fromLatin1(name) % qL1S("/info.yaml");
+
+ m_pi = scanner.scan(m_dataDir.absoluteFilePath(path));
+ if (m_pi) {
+ m_p = new Package(m_pi);
+ const auto ais = m_pi->applications();
+ for (const auto &ai : ais) {
+ auto a = new Application(ai, m_p);
+ m_a << a;
+ m_p->addApplication(a);
+ }
+ const auto iis = m_pi->intents();
+ for (const auto &ii : iis) {
+ m_i << new Intent(ii->id(), m_pi->id(), ii->handlingApplicationId(),
+ ii->requiredCapabilities(),
+ ii->visibility() == IntentInfo::Public ? Intent::Public
+ : Intent::Private,
+ ii->parameterMatch(), ii->names(),
+ ii->descriptions(),
+ QUrl::fromLocalFile(m_pi->baseDir().absoluteFilePath(ii->icon())),
+ ii->categories());
+ }
+ }
+ } catch (const Exception &e) {
+ m_lastLoadFailure = e.errorString();
}
}
- QCOMPARE(m_pkgs.size(), 2);
-}
+ ~TestPackageLoader()
+ {
+ delete m_p;
+ qDeleteAll(m_i);
+ qDeleteAll(m_a);
+ delete m_pi;
+ }
-void tst_ApplicationInfo::cleanupTestCase()
+ PackageInfo *info() const { return m_pi; }
+ Package *package() const { return m_p; }
+ QVector<Intent *> intents() const { return m_i; }
+ QDir dataDir() const { return m_dataDir; }
+ QString lastLoadFailure() const { return m_lastLoadFailure; }
+
+private:
+ QDir m_dataDir;
+ QString m_lastLoadFailure;
+ PackageInfo *m_pi = nullptr;
+ Package *m_p = nullptr;
+ QVector<Application *> m_a;
+ QVector<Intent *> m_i;
+};
+
+QT_END_NAMESPACE_AM
+
+static QUrl qmlIcon(PackageInfo *pi, const QString &iconFile)
{
- qDeleteAll(m_pkgs);
+ return QUrl::fromLocalFile(pi->baseDir().absoluteFilePath(iconFile));
}
-void tst_ApplicationInfo::application_data()
+static QVariantMap qmlStringMap(const QMap<QString, QString> &sm)
{
- QTest::addColumn<QString>("id");
-
- QTest::newRow("normal") << "com.pelagicore.test";
- QTest::newRow("json") << "com.pelagicore.json-legacy";
+ QVariantMap vm;
+ for (auto it = sm.cbegin(); it != sm.cend(); ++it)
+ vm.insert(it.key(), it.value());
+ return vm;
}
-void tst_ApplicationInfo::application()
+
+void tst_ApplicationInfo::full()
{
- QFETCH(QString, id);
+ TestPackageLoader pl("full");
+ QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure()));
+
+ QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id()));
+ QCOMPARE(pl.info()->id(), qL1S("full"));
+ QCOMPARE(pl.info()->icon(), qL1S("full.png"));
+ QCOMPARE(pl.info()->version(), qL1S("v1"));
+ QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } };
+ QCOMPARE(pl.info()->names(), names);
+ QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } };
+ QCOMPARE(pl.info()->descriptions(), descs);
+ QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") };
+ QCOMPARE(pl.info()->categories(), cats);
+ QCOMPARE(pl.info()->applications().size(), 2);
+ QCOMPARE(pl.info()->intents().size(), 2);
+
+ const ApplicationInfo *ai = pl.info()->applications().constFirst();
+
+ QCOMPARE(ai->id(), qSL("full.app.1"));
+ QCOMPARE(ai->icon(), qSL("app1.png"));
+ QMap<QString, QString> app1names { { qL1S("en"), qL1S("app1.name.en") }, { qL1S("de"), qL1S("app1.name.de") } };
+ QCOMPARE(ai->names(), app1names);
+ QMap<QString, QString> app1descs { { qL1S("en"), qL1S("app1.desc.en") }, { qL1S("de"), qL1S("app1.desc.de") } };
+ QCOMPARE(ai->descriptions(), app1descs);
+ QStringList app1cats { qL1S("app1.cat.1"), qL1S("app1.cat.2") };
+ QCOMPARE(ai->categories(), app1cats);
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml"));
+ QCOMPARE(ai->runtimeName(), qSL("qml"));
+ QCOMPARE(ai->runtimeParameters().size(), 5);
+ QCOMPARE(ai->supportsApplicationInterface(), true);
+ QCOMPARE(ai->capabilities(), QStringList { qSL("app1.cap") });
+ QVariantMap app1ogl { { qSL("desktopProfile"), qSL("core") }, { qSL("esMajorVersion"), 3 }, { qSL("esMinorVersion"), 2 }};
+ QCOMPARE(ai->openGLConfiguration(), app1ogl);
+ QVariantMap app1prop { { qSL("custom.app1.key"), 42 } };
+ QCOMPARE(ai->applicationProperties(), app1prop);
+ QVariantMap app1dlt { { qSL("id"), qSL("app1.dlt.id") }, { qSL("description"), qSL("app1.dlt.desc") } };
+ QCOMPARE(ai->dltConfiguration(), app1dlt);
+
+ ai = pl.info()->applications().constLast();
+
+ QCOMPARE(ai->id(), qSL("full.app.2"));
+ QCOMPARE(ai->icon(), qSL("app2.png"));
+ QMap<QString, QString> app2names { { qL1S("en"), qL1S("app2.name.en") }, { qL1S("de"), qL1S("app2.name.de") } };
+ QCOMPARE(ai->names(), app2names);
+ QMap<QString, QString> app2descs { { qL1S("en"), qL1S("app2.desc.en") }, { qL1S("de"), qL1S("app2.desc.de") } };
+ QCOMPARE(ai->descriptions(), app2descs);
+ QStringList app2cats { qL1S("app2.cat.1"), qL1S("app2.cat.2") };
+ QCOMPARE(ai->categories(), app2cats);
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe"));
+ QCOMPARE(ai->runtimeName(), qSL("native"));
+ QCOMPARE(ai->runtimeParameters().size(), 2);
+
+ IntentInfo *ii = pl.info()->intents().constFirst();
+
+ QCOMPARE(ii->id(), qSL("full.int.1"));
+ QCOMPARE(ii->icon(), qSL("int1.png"));
+ QMap<QString, QString> int1names { { qL1S("en"), qL1S("int1.name.en") }, { qL1S("de"), qL1S("int1.name.de") } };
+ QCOMPARE(ii->names(), int1names);
+ QMap<QString, QString> int1descs { { qL1S("en"), qL1S("int1.desc.en") }, { qL1S("de"), qL1S("int1.desc.de") } };
+ QCOMPARE(ii->descriptions(), int1descs);
+ QStringList int1cats { qL1S("int1.cat.1"), qL1S("int1.cat.2") };
+ QCOMPARE(ii->categories(), int1cats);
+ QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constFirst()->id());
+ QCOMPARE(ii->visibility(), IntentInfo::Private);
+ QStringList req1caps { qSL("int1.cap.1"), qSL("int1.cap.2") };
+ QCOMPARE(ii->requiredCapabilities(), req1caps);
+ QVariantMap param1match { { qSL("mimeType"), qSL("^image/.*\\.png$") } };
+ QCOMPARE(ii->parameterMatch(), param1match);
+
+ ii = pl.info()->intents().constLast();
+
+ QCOMPARE(ii->id(), qSL("full.int.2"));
+ QCOMPARE(ii->icon(), qSL("int2.png"));
+ QMap<QString, QString> int2names { { qL1S("en"), qL1S("int2.name.en") }, { qL1S("de"), qL1S("int2.name.de") } };
+ QCOMPARE(ii->names(), int2names);
+ QMap<QString, QString> int2descs { { qL1S("en"), qL1S("int2.desc.en") }, { qL1S("de"), qL1S("int2.desc.de") } };
+ QCOMPARE(ii->descriptions(), int2descs);
+ QStringList int2cats { qL1S("int2.cat.1"), qL1S("int2.cat.2") };
+ QCOMPARE(ii->categories(), int2cats);
+ QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constLast()->id());
+ QCOMPARE(ii->visibility(), IntentInfo::Public);
+ QStringList req2caps { qSL("int2.cap.1"), qSL("int2.cap.2") };
+ QCOMPARE(ii->requiredCapabilities(), req2caps);
+ QVariantMap param2match { { qSL("test"), qSL("foo") } };
+ QCOMPARE(ii->parameterMatch(), param2match);
+
+ // now the QML interface
+
+ Package *p = pl.package();
+
+ QVERIFY(p);
+ QCOMPARE(p->id(), pl.info()->id());
+ QCOMPARE(p->icon(), qmlIcon(pl.info(), pl.info()->icon()));
+ QCOMPARE(p->version(), pl.info()->version());
+ QVERIFY(p->names().values().contains(p->name()));
+ QCOMPARE(p->names(), qmlStringMap(pl.info()->names()));
+ QVERIFY(p->descriptions().values().contains(p->description()));
+ QCOMPARE(p->descriptions(), qmlStringMap(pl.info()->descriptions()));
+ QCOMPARE(p->categories(), pl.info()->categories());
+ QCOMPARE(p->applications().size(), pl.info()->applications().size());
+ QCOMPARE(pl.intents().size(), pl.info()->intents().size());
+
+ Application *a = qobject_cast<Application *>(p->applications().last());
+
+ QVERIFY(a);
+ QCOMPARE(a->id(), ai->id());
+ QCOMPARE(a->icon(), qmlIcon(pl.info(), ai->icon()));
+ QVERIFY(a->names().values().contains(a->name()));
+ QCOMPARE(a->names(), qmlStringMap(ai->names()));
+ QVERIFY(a->descriptions().values().contains(a->description()));
+ QCOMPARE(a->descriptions(), qmlStringMap(ai->descriptions()));
+ QCOMPARE(a->categories(), ai->categories());
+ QCOMPARE(a->supportedMimeTypes(), ai->supportedMimeTypes());
+ QCOMPARE(a->capabilities(), ai->capabilities());
+ QCOMPARE(a->runtimeName(), ai->runtimeName());
+ QCOMPARE(a->runtimeParameters(), ai->runtimeParameters());
+
+ Intent *i = pl.intents().last();
+
+ QVERIFY(i);
+ QCOMPARE(i->intentId(), ii->id());
+ QCOMPARE(i->icon(), qmlIcon(pl.info(), ii->icon()));
+ QVERIFY(i->names().values().contains(i->name()));
+ QCOMPARE(i->names(), qmlStringMap(ii->names()));
+ QVERIFY(i->descriptions().values().contains(i->description()));
+ QCOMPARE(i->descriptions(), qmlStringMap(ii->descriptions()));
+ QCOMPARE(i->categories(), ii->categories());
+ QCOMPARE(int(i->visibility()), int(ii->visibility()));
+ QCOMPARE(i->requiredCapabilities(), ii->requiredCapabilities());
+ QCOMPARE(i->parameterMatch(), ii->parameterMatch());
+}
- QString name = QString::fromLatin1(AM_TESTDATA_DIR "manifests/%1/info.yaml").arg(id);
+void tst_ApplicationInfo::minimal()
+{
+ TestPackageLoader pl("minimal");
+ QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure()));
+
+ QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id()));
+ QCOMPARE(pl.info()->id(), qL1S("minimal"));
+ QCOMPARE(pl.info()->icon(), QString { });
+ QCOMPARE(pl.info()->version(), QString { });
+ QMap<QString, QString> emptyMap;
+ QCOMPARE(pl.info()->names(), emptyMap);
+ QCOMPARE(pl.info()->descriptions(), emptyMap);
+ QCOMPARE(pl.info()->categories(), QStringList { });
+ QCOMPARE(pl.info()->applications().size(), 1);
+ QCOMPARE(pl.info()->intents().size(), 0);
+
+ const ApplicationInfo *ai = pl.info()->applications().constFirst();
+
+ QCOMPARE(ai->id(), qSL("minimal.app"));
+ QCOMPARE(ai->icon(), pl.info()->icon());
+ QCOMPARE(ai->names(), pl.info()->names());
+ QCOMPARE(ai->descriptions(), pl.info()->descriptions());
+ QCOMPARE(ai->categories(), pl.info()->categories());
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("minimal.qml"));
+ QCOMPARE(ai->runtimeName(), qSL("qml"));
+ QCOMPARE(ai->runtimeParameters().size(), 0);
+}
- YamlPackageScanner scanner;
- PackageInfo *pkg;
- try {
- pkg = scanner.scan(name);
- QVERIFY(pkg);
- } catch (const std::exception &e) {
- QFAIL(e.what());
- }
+void tst_ApplicationInfo::inherit()
+{
+ TestPackageLoader pl("inherit");
+ QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure()));
+
+ QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id()));
+ QCOMPARE(pl.info()->id(), qL1S("inherit"));
+ QCOMPARE(pl.info()->icon(), qL1S("pkg.png"));
+ QCOMPARE(pl.info()->version(), QString { });
+ QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } };
+ QCOMPARE(pl.info()->names(), names);
+ QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } };
+ QCOMPARE(pl.info()->descriptions(), descs);
+ QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") };
+ QCOMPARE(pl.info()->categories(), cats);
+ QCOMPARE(pl.info()->applications().size(), 2);
+ QCOMPARE(pl.info()->intents().size(), 2);
+
+ const ApplicationInfo *ai = pl.info()->applications().constFirst();
+
+ QCOMPARE(ai->id(), qSL("inherit.app.1"));
+ QCOMPARE(ai->icon(), pl.info()->icon());
+ QCOMPARE(ai->names(), pl.info()->names());
+ QCOMPARE(ai->descriptions(), pl.info()->descriptions());
+ QCOMPARE(ai->categories(), pl.info()->categories());
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml"));
+ QCOMPARE(ai->runtimeName(), qSL("qml"));
+ QCOMPARE(ai->runtimeParameters().size(), 0);
+
+ ai = pl.info()->applications().constLast();
+
+ QCOMPARE(ai->id(), qSL("inherit.app.2"));
+ QCOMPARE(ai->icon(), pl.info()->icon());
+ QCOMPARE(ai->names(), pl.info()->names());
+ QCOMPARE(ai->descriptions(), pl.info()->descriptions());
+ QCOMPARE(ai->categories(), pl.info()->categories());
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe"));
+ QCOMPARE(ai->runtimeName(), qSL("native"));
+ QCOMPARE(ai->runtimeParameters().size(), 0);
+
+ IntentInfo *ii = pl.info()->intents().constFirst();
+
+ QCOMPARE(ii->id(), qSL("inherit.int.1"));
+ QCOMPARE(ii->icon(), pl.info()->icon());
+ QCOMPARE(ii->names(), pl.info()->names());
+ QCOMPARE(ii->descriptions(), pl.info()->descriptions());
+ QCOMPARE(ii->categories(), pl.info()->categories());
+ QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constFirst()->id());
+
+ ii = pl.info()->intents().constLast();
+
+ QCOMPARE(ii->id(), qSL("inherit.int.2"));
+ QCOMPARE(ii->icon(), pl.info()->icon());
+ QCOMPARE(ii->names(), pl.info()->names());
+ QCOMPARE(ii->descriptions(), pl.info()->descriptions());
+ QCOMPARE(ii->categories(), pl.info()->categories());
+ QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constLast()->id());
+
+ // now the QML interface
+
+ Package *p = pl.package();
+
+ QVERIFY(p);
+ QVERIFY(!p->name().isEmpty() && (p->name() != p->id()));
+ QCOMPARE(p->names(), qmlStringMap(pl.info()->names()));
+ QVERIFY(!p->description().isEmpty());
+ QCOMPARE(p->descriptions(), qmlStringMap(pl.info()->descriptions()));
+ QCOMPARE(p->categories(), pl.info()->categories());
+
+ Application *a = qobject_cast<Application *>(p->applications().first());
+
+ QVERIFY(a);
+ QCOMPARE(a->icon(), p->icon());
+ QCOMPARE(a->name(), p->name());
+ QCOMPARE(a->description(), p->description());
+ QCOMPARE(a->names(), p->names());
+ QCOMPARE(a->descriptions(), p->descriptions());
+
+ Intent *i = pl.intents().first();
+
+ QVERIFY(i);
+ QCOMPARE(i->icon(), p->icon());
+ QCOMPARE(i->name(), p->name());
+ QCOMPARE(i->description(), p->description());
+ QCOMPARE(i->names(), p->names());
+ QCOMPARE(i->descriptions(), p->descriptions());
+}
- QCOMPARE(pkg->id(), id);
- QCOMPARE(QFileInfo(pkg->icon()).fileName(), qSL("icon.png"));
- QCOMPARE(pkg->names().size(), 2);
- QCOMPARE(pkg->names().value(qSL("en")), qSL("english"));
- QCOMPARE(pkg->names().value(qSL("de")), qSL("deutsch"));
- QCOMPARE(pkg->name(qSL("en")), qSL("english"));
- QCOMPARE(pkg->isBuiltIn(), false);
- QCOMPARE(pkg->categories().size(), 2);
- QVERIFY(pkg->categories().startsWith(qSL("bar")));
- QVERIFY(pkg->categories().endsWith(qSL("foo")));
-
- ApplicationInfo *app = pkg->applications().size() == 1 ? pkg->applications().constFirst() : nullptr;
- QVERIFY(app);
- QCOMPARE(QFileInfo(app->codeFilePath()).fileName(), qSL("Test.qml"));
- QCOMPARE(app->runtimeName(), qSL("qml"));
- QCOMPARE(app->runtimeParameters().size(), 1);
- QCOMPARE(app->runtimeParameters().value(qSL("loadDummyData")).toBool(), true);
- QCOMPARE(app->capabilities().size(), 2);
- QVERIFY(app->capabilities().startsWith(qSL("cameraAccess")));
- QVERIFY(app->capabilities().endsWith(qSL("locationAccess")));
-
- // legacy
- QCOMPARE(app->supportedMimeTypes().size(), 2);
- QVERIFY(app->supportedMimeTypes().startsWith(qSL("text/plain")));
- QVERIFY(app->supportedMimeTypes().endsWith(qSL("x-scheme-handler/mailto")));
-
- delete pkg;
+void tst_ApplicationInfo::legacy()
+{
+ TestPackageLoader pl("legacy");
+ QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure()));
+
+ QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id()));
+ QCOMPARE(pl.info()->id(), qL1S("legacy"));
+ QCOMPARE(pl.info()->icon(), qL1S("icon.png"));
+ QCOMPARE(pl.info()->version(), qL1S("v1"));
+ QMap<QString, QString> names { { qL1S("en"), qL1S("legacy.en") }, { qL1S("de"), qL1S("legacy.de") } };
+ QCOMPARE(pl.info()->names(), names);
+ QStringList cats { qL1S("bar"), qL1S("foo") };
+ QVERIFY(pl.info()->descriptions().isEmpty());
+ QCOMPARE(pl.info()->categories(), cats);
+ QCOMPARE(pl.info()->applications().size(), 1);
+ QCOMPARE(pl.info()->intents().size(), 0);
+
+ const ApplicationInfo *ai = pl.info()->applications().constFirst();
+
+ QCOMPARE(ai->id(), pl.info()->id());
+ QCOMPARE(ai->icon(), pl.info()->icon());
+ QCOMPARE(ai->names(), pl.info()->names());
+ QVERIFY(ai->descriptions().isEmpty());
+ QCOMPARE(ai->categories(), pl.info()->categories());
+ QStringList mimes { qL1S("text/plain"), qL1S("x-scheme-handler/mailto") };
+ QCOMPARE(ai->supportedMimeTypes(), mimes);
+ QStringList caps { qL1S("cameraAccess"), qL1S("locationAccess") };
+ QCOMPARE(ai->capabilities(), caps);
+ QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("legacy.qml"));
+ QCOMPARE(ai->runtimeName(), qSL("qml"));
+ QCOMPARE(ai->runtimeParameters().size(), 1);
+ QCOMPARE(ai->runtimeParameters().value(qSL("loadDummyData")).toBool(), true);
}
void tst_ApplicationInfo::validApplicationId_data()
@@ -184,36 +456,6 @@ void tst_ApplicationInfo::validApplicationId()
QVERIFY2(valid == result, qPrintable(errorString));
}
-void tst_ApplicationInfo::validIcon_data()
-{
- QTest::addColumn<QString>("icon");
- QTest::addColumn<bool>("isValid");
-
- // valid
- QTest::newRow("'icon.png' is valid") << "icon.png" << true;
- QTest::newRow("'foo.bar' is valid") << "foo.bar" << true;
- QTest::newRow("'foo' is valid") << "foo" << true;
-
- // invalid
- QTest::newRow("empty is invalid") << "" << false;
- QTest::newRow("'foo/icon.png' is invalid") << "foo/icon.png" << false;
- QTest::newRow("'../icon.png' is invalid") << "../icon.png" << false;
- QTest::newRow("'icon.png/' is invalid") << "icon.png/" << false;
- QTest::newRow("'/foo' is invalid") << "/foo" << false;
-}
-
-void tst_ApplicationInfo::validIcon()
-{
- QFETCH(QString, icon);
- QFETCH(bool, isValid);
-
- QString errorString;
- bool result = PackageInfo::isValidIcon(icon, &errorString);
-
- QCOMPARE(result, isValid);
-}
-
QTEST_APPLESS_MAIN(tst_ApplicationInfo)
#include "tst_applicationinfo.moc"
-
diff --git a/tests/auto/main/tst_main.cpp b/tests/auto/main/tst_main.cpp
index df52b32d..73f6b24d 100644
--- a/tests/auto/main/tst_main.cpp
+++ b/tests/auto/main/tst_main.cpp
@@ -216,10 +216,10 @@ void tst_Main::installAndRemoveUpdateForBuiltIn()
QCOMPARE(intents->count(), 2);
auto app1 = appMan->application(0);
- QCOMPARE(app1->name(qSL("en")), qSL("Hello Red"));
+ QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red"));
QCOMPARE(app1->id(), qSL("red1"));
auto app2 = appMan->application(1);
- QCOMPARE(app2->name(qSL("en")), qSL("Hello Red"));
+ QCOMPARE(app2->names().value(qSL("en")), qSL("Hello Red"));
QCOMPARE(app2->id(), qSL("red2"));
auto intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1"));
@@ -248,7 +248,7 @@ void tst_Main::installAndRemoveUpdateForBuiltIn()
app1 = appMan->application(0);
// but with different contents
- QCOMPARE(app1->name(qSL("en")), qSL("Hello Updated Red"));
+ QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Updated Red"));
intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1"));
QVERIFY(!intent1);
@@ -260,7 +260,7 @@ void tst_Main::installAndRemoveUpdateForBuiltIn()
QCOMPARE(intents->count(), 2);
app1 = appMan->application(0);
- QCOMPARE(app1->name(qSL("en")), qSL("Hello Red"));
+ QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red"));
intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1"));
QVERIFY(intent1);
QCOMPARE(intent1->intentId(), qSL("red.intent1"));
@@ -288,7 +288,7 @@ void tst_Main::updateForBuiltInAlreadyInstalled()
QCOMPARE(appMan->count(), 1);
auto app = appMan->application(0);
- QCOMPARE(app->name(qSL("en")), qSL("Hello Updated Red"));
+ QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red"));
}
/*
@@ -309,7 +309,7 @@ void tst_Main::loadDatabaseWithUpdatedBuiltInApp()
QCOMPARE(appMan->count(), 1);
auto app = appMan->application(0);
- QCOMPARE(app->name(qSL("en")), qSL("Hello Updated Red"));
+ QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red"));
}
void tst_Main::mainQmlFile_data()
diff --git a/tests/auto/packager-tool/tst_packager-tool.cpp b/tests/auto/packager-tool/tst_packager-tool.cpp
index 8dd5ae1a..1071c178 100644
--- a/tests/auto/packager-tool/tst_packager-tool.cpp
+++ b/tests/auto/packager-tool/tst_packager-tool.cpp
@@ -280,7 +280,6 @@ void tst_PackagerTool::brokenMetadata_data()
QTest::addColumn<QVariant>("yamlValue");
QTest::addColumn<QString>("errorString");
- QTest::newRow("missing-name") << "name" << QVariant() << "~.*Required fields are missing: name.*";
QTest::newRow("missing-runtime") << "runtime" << QVariant() << "~.*Required fields are missing: runtime";
QTest::newRow("missing-identifier") << "id" << QVariant() << "~.*Required fields are missing: id";
QTest::newRow("missing-code") << "code" << QVariant() << "~.*Required fields are missing: code";
diff --git a/tests/data/manifests/com.pelagicore.json-legacy/info.yaml b/tests/data/manifests/com.pelagicore.json-legacy/info.yaml
deleted file mode 100644
index 75002d1f..00000000
--- a/tests/data/manifests/com.pelagicore.json-legacy/info.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-formatVersion: 1
-formatType: am-application
----
-{
- "id": "com.pelagicore.json-legacy",
- "icon": "icon.png",
- "code": "Test.qml",
- "runtime": "qml",
- "runtimeParameters": {
- "loadDummyData": true
- },
- "name": { "en": "english", "de": "deutsch" },
-
- "mimeTypes": [ "x-scheme-handler/mailto", "text/plain" ],
-
- "capabilities": [ "cameraAccess", "locationAccess" ],
-
- "categories": [ "foo", "bar" ]
-}