From 5892cf6b29c62cc632e94b22624a0bbbe6c21c54 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 25 Jul 2018 17:31:31 +0200 Subject: Shutdown resources at the end of the test to keep them from blocking the test from exiting. --- tests/teststore.cpp | 8 ++++++++ tests/teststore.h | 1 + views/accounts/tests/tst_accountsview.qml | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/tests/teststore.cpp b/tests/teststore.cpp index 71b19499..c69588ef 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp @@ -243,6 +243,14 @@ void TestStore::setup(const QVariantMap &map) Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished(); } +void TestStore::shutdownResources() +{ + const auto resources = Sink::Store::read({}); + for (const auto &resource : resources) { + Sink::ResourceControl::shutdown(resource.identifier()).exec().waitForFinished(); + } +} + QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter) { using namespace Sink::ApplicationDomain; diff --git a/tests/teststore.h b/tests/teststore.h index 1a6a2563..4d5359a7 100644 --- a/tests/teststore.h +++ b/tests/teststore.h @@ -27,6 +27,7 @@ class TestStore : public QObject { Q_OBJECT public: Q_INVOKABLE void setup(const QVariantMap &); + Q_INVOKABLE void shutdownResources(); Q_INVOKABLE QVariant load(const QByteArray &type, const QVariantMap &); Q_INVOKABLE QVariantList loadList(const QByteArray &type, const QVariantMap &); Q_INVOKABLE QVariantMap read(const QVariant &); diff --git a/views/accounts/tests/tst_accountsview.qml b/views/accounts/tests/tst_accountsview.qml index c3b919c0..8d7bc29d 100644 --- a/views/accounts/tests/tst_accountsview.qml +++ b/views/accounts/tests/tst_accountsview.qml @@ -29,6 +29,10 @@ TestCase { name: "AccountsView" when: windowShown + function cleanup() { + TestStore.shutdownResources(); + } + function visitChildren(item) { console.warn(item) for (var i = 0; i < item.children.length; i++) { -- cgit v1.2.3