summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2019-08-08 18:42:58 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2019-08-08 18:42:58 +0200
commit646af9393fcd55ebb9691180009a791611237d5b (patch)
treefaae1dae5ccf800c15571d7df819a55de6fed9a3
parent30927653517edf96214c9a76d44775564ec8307d (diff)
parent457ba7b13a8fa21803ea52ec39aaddd7eee5e44a (diff)
Merge remote-tracking branch 'gerrit/5.12' into 5.13
-rw-r--r--src/manager-lib/qmlinprocessruntime.cpp2
-rw-r--r--src/tools/testrunner/testrunner.cpp12
-rw-r--r--src/tools/testrunner/testrunner_p.h4
-rw-r--r--tests/qml/lifecycle/am-config.yaml17
-rw-r--r--tests/qml/lifecycle/apps/tld.test.lifecycle/app.qml50
-rw-r--r--tests/qml/lifecycle/apps/tld.test.lifecycle/icon.pngbin0 -> 1486 bytes
-rw-r--r--tests/qml/lifecycle/apps/tld.test.lifecycle/info.yaml9
-rw-r--r--tests/qml/lifecycle/lifecycle.pro5
-rw-r--r--tests/qml/lifecycle/tst_lifecycle.qml144
-rw-r--r--tests/qml/qml.pro3
10 files changed, 245 insertions, 1 deletions
diff --git a/src/manager-lib/qmlinprocessruntime.cpp b/src/manager-lib/qmlinprocessruntime.cpp
index e45c555b..788e22d2 100644
--- a/src/manager-lib/qmlinprocessruntime.cpp
+++ b/src/manager-lib/qmlinprocessruntime.cpp
@@ -216,6 +216,8 @@ void QmlInProcessRuntime::finish(int exitCode, Am::ExitStatus status)
qCDebug(LogSystem) << "QmlInProcessRuntime (id:" << (m_app ? m_app->id() : qSL("(none)"))
<< ") exited with code:" << exitCode << "status:" << status;
emit finished(exitCode, status);
+ if (m_app)
+ m_app->setCurrentRuntime(nullptr);
setState(Am::NotRunning);
#if !defined(AM_HEADLESS)
if (m_surfaces.isEmpty())
diff --git a/src/tools/testrunner/testrunner.cpp b/src/tools/testrunner/testrunner.cpp
index 9d4c4e9f..33f03a69 100644
--- a/src/tools/testrunner/testrunner.cpp
+++ b/src/tools/testrunner/testrunner.cpp
@@ -116,6 +116,18 @@ void AmTest::ignoreMessage(MsgType type, const QRegExp &expression)
#endif
}
+int AmTest::observeObjectDestroyed(QObject *obj)
+{
+ static int idx = 0;
+ int index = idx++;
+
+ connect(obj, &QObject::destroyed, [this, index] () {
+ emit objectDestroyed(index);
+ });
+
+ return index;
+}
+
QTestRootObject::QTestRootObject(QObject *parent)
: QObject(parent)
diff --git a/src/tools/testrunner/testrunner_p.h b/src/tools/testrunner/testrunner_p.h
index 4dfbedfd..614e66c6 100644
--- a/src/tools/testrunner/testrunner_p.h
+++ b/src/tools/testrunner/testrunner_p.h
@@ -105,6 +105,10 @@ public:
Q_INVOKABLE void ignoreMessage(MsgType type, const char* msg);
Q_INVOKABLE void ignoreMessage(MsgType type, const QRegExp &expression);
+ Q_INVOKABLE int observeObjectDestroyed(QObject *obj);
+
+Q_SIGNALS:
+ void objectDestroyed(int index);
};
QT_END_NAMESPACE_AM
diff --git a/tests/qml/lifecycle/am-config.yaml b/tests/qml/lifecycle/am-config.yaml
new file mode 100644
index 00000000..b9c17b5e
--- /dev/null
+++ b/tests/qml/lifecycle/am-config.yaml
@@ -0,0 +1,17 @@
+formatVersion: 1
+formatType: am-configuration
+---
+applications:
+ builtinAppsManifestDir: "${CONFIG_PWD}/apps"
+ installedAppsManifestDir: "/tmp/am-crash-test/manifests"
+ appImageMountDir: "/tmp/am-crash-test/image-mounts"
+ database: "/tmp/am-crash-test/apps.db"
+
+installationLocations:
+- id: "internal-0"
+ installationPath: "/tmp/am/apps"
+ documentPath: "/tmp/am/docs"
+ mountPoint: "/tmp"
+
+flags:
+ noUiWatchdog: yes
diff --git a/tests/qml/lifecycle/apps/tld.test.lifecycle/app.qml b/tests/qml/lifecycle/apps/tld.test.lifecycle/app.qml
new file mode 100644
index 00000000..a994adf4
--- /dev/null
+++ b/tests/qml/lifecycle/apps/tld.test.lifecycle/app.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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 QtApplicationManager.Application 2.0
+
+ApplicationManagerWindow {
+ Image {
+ anchors.centerIn: parent
+ source: ApplicationInterface.icon
+ }
+}
diff --git a/tests/qml/lifecycle/apps/tld.test.lifecycle/icon.png b/tests/qml/lifecycle/apps/tld.test.lifecycle/icon.png
new file mode 100644
index 00000000..c1397153
--- /dev/null
+++ b/tests/qml/lifecycle/apps/tld.test.lifecycle/icon.png
Binary files differ
diff --git a/tests/qml/lifecycle/apps/tld.test.lifecycle/info.yaml b/tests/qml/lifecycle/apps/tld.test.lifecycle/info.yaml
new file mode 100644
index 00000000..198cbe51
--- /dev/null
+++ b/tests/qml/lifecycle/apps/tld.test.lifecycle/info.yaml
@@ -0,0 +1,9 @@
+formatVersion: 1
+formatType: am-application
+---
+id: 'tld.test.lifecycle'
+name:
+ en: 'Lifecycle Tests'
+icon: 'icon.png'
+code: 'app.qml'
+runtime: 'qml'
diff --git a/tests/qml/lifecycle/lifecycle.pro b/tests/qml/lifecycle/lifecycle.pro
new file mode 100644
index 00000000..98ab9709
--- /dev/null
+++ b/tests/qml/lifecycle/lifecycle.pro
@@ -0,0 +1,5 @@
+AM_CONFIG = am-config.yaml
+TEST_FILES = tst_lifecycle.qml
+TEST_APPS = tld.test.lifecycle
+
+load(am-qml-testcase)
diff --git a/tests/qml/lifecycle/tst_lifecycle.qml b/tests/qml/lifecycle/tst_lifecycle.qml
new file mode 100644
index 00000000..641ab7e1
--- /dev/null
+++ b/tests/qml/lifecycle/tst_lifecycle.qml
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** 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 QtTest 1.0
+import QtApplicationManager 2.0
+import QtApplicationManager.SystemUI 2.0
+
+TestCase {
+ id: testCase
+ when: windowShown
+ name: "LifeCycleTest"
+ visible: true
+
+ property var app: ApplicationManager.application("tld.test.lifecycle");
+
+
+ WindowItem {
+ id: chrome
+ anchors.fill: parent
+ }
+
+ Connections {
+ target: WindowManager
+ onWindowAdded: chrome.window = window;
+ }
+
+ Connections {
+ target: chrome.window
+ onContentStateChanged: {
+ if (chrome.window.contentState === WindowObject.NoSurface)
+ chrome.window = null;
+ }
+ }
+
+
+ SignalSpy {
+        id: runStateChangedSpy
+        target: ApplicationManager
+        signalName: "applicationRunStateChanged"
+    }
+
+ SignalSpy {
+        id: objectDestroyedSpy
+        target: AmTest
+        signalName: "objectDestroyed"
+    }
+
+ Timer {
+ id: stopTimer
+ interval: 1
+ onTriggered: app.stop();
+ }
+
+
+ function cleanup() {
+ objectDestroyedSpy.clear();
+ var index = AmTest.observeObjectDestroyed(app.runtime);
+ app.stop();
+ while (app.runState !== ApplicationObject.NotRunning)
+ runStateChangedSpy.wait();
+ objectDestroyedSpy.wait();
+ compare(objectDestroyedSpy.signalArguments[0][0], index);
+ }
+
+
+ // Start followed by quick stop/start in single-porcess mode caused an abort in the past
+ function test_fast_stop_start() {
+ app.start();
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.StartingUp);
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.Running);
+
+ objectDestroyedSpy.clear();
+ var index = AmTest.observeObjectDestroyed(app.runtime);
+
+ app.stop();
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.ShuttingDown);
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.NotRunning);
+
+ app.start();
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.StartingUp);
+ runStateChangedSpy.wait();
+ compare(app.runState, ApplicationObject.Running);
+
+ objectDestroyedSpy.wait();
+ compare(objectDestroyedSpy.signalArguments[0][0], index);
+ }
+
+ // Quick start/stop followd by start in single-process mode caused an abort in the past
+ function test_fast_start_stop() {
+ app.start();
+ stopTimer.start();
+
+ while (app.runState !== ApplicationObject.NotRunning)
+ runStateChangedSpy.wait();
+
+ app.start();
+ while (app.runState !== ApplicationObject.Running)
+ runStateChangedSpy.wait();
+ }
+}
diff --git a/tests/qml/qml.pro b/tests/qml/qml.pro
index 8a0cd59f..d6a064f6 100644
--- a/tests/qml/qml.pro
+++ b/tests/qml/qml.pro
@@ -14,4 +14,5 @@ SUBDIRS = \
intents \
crash/apps/tld.test.crash/terminator2 \
crash \
- configs
+ configs \
+ lifecycle