From af38078ecd26bf5967256c77cf4f6ca0e4499e08 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Tue, 23 Feb 2021 10:51:28 +0100 Subject: [PATCH] libtaskmanager: Fix autotest The test depends on the applications being installed and the path being correctly set. To make it more robust the path is set inside of the test and the files the test used are shipped with it. --- .../data/applications/org.kde.dolphin.desktop | 15 +++++++++++++++ .../applications/org.kde.konversation.desktop | 15 +++++++++++++++ .../autotests/launchertasksmodeltest.cpp | 12 +++++++----- 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 libtaskmanager/autotests/data/applications/org.kde.dolphin.desktop create mode 100644 libtaskmanager/autotests/data/applications/org.kde.konversation.desktop diff --git a/libtaskmanager/autotests/data/applications/org.kde.dolphin.desktop b/libtaskmanager/autotests/data/applications/org.kde.dolphin.desktop new file mode 100644 index 000000000..bfe7943ce --- /dev/null +++ b/libtaskmanager/autotests/data/applications/org.kde.dolphin.desktop @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: none +# SPDX-License-Identifier: CC0-1.0 +[Desktop Entry] +Name=Dolphin +Exec=dolphin %u +Icon=system-file-manager +Type=Application +X-DocPath=dolphin/index.html +Categories=Qt;KDE;System;FileTools;FileManager; +GenericName=File Manager +Terminal=false +MimeType=inode/directory; +InitialPreference=10 +X-DBUS-ServiceName=org.kde.dolphin +StartupWMClass=dolphin diff --git a/libtaskmanager/autotests/data/applications/org.kde.konversation.desktop b/libtaskmanager/autotests/data/applications/org.kde.konversation.desktop new file mode 100644 index 000000000..1f5925014 --- /dev/null +++ b/libtaskmanager/autotests/data/applications/org.kde.konversation.desktop @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: none +# SPDX-License-Identifier: CC0-1.0 +[Desktop Entry] +Type=Application +Exec=konversation -qwindowtitle %c %u +Icon=konversation +X-DocPath=konversation/index.html +MimeType=x-scheme-handler/irc;x-scheme-handler/ircs; +GenericName=IRC Client +Terminal=false +Name=Konversation +Categories=Qt;KDE;Network;IRCClient; +X-DBUS-StartupType=Unique +X-DBUS-ServiceName=org.kde.konversation +StartupNotify=true diff --git a/libtaskmanager/autotests/launchertasksmodeltest.cpp b/libtaskmanager/autotests/launchertasksmodeltest.cpp index 1d9e031f9..59d0bbff0 100644 --- a/libtaskmanager/autotests/launchertasksmodeltest.cpp +++ b/libtaskmanager/autotests/launchertasksmodeltest.cpp @@ -1,5 +1,6 @@ /******************************************************************** Copyright 2016 Eike Hein +Copyright 2021 Alexander Lohnau This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -49,8 +50,10 @@ private: void LauncherTasksModelTest::initTestCase() { qApp->setProperty("org.kde.KActivities.core.disableAutostart", true); - m_urlStrings << QLatin1String("file:///usr/share/applications/org.kde.systemmonitor.desktop"); - m_urlStrings << QLatin1String("file:///usr/share/applications/org.kde.konversation.desktop"); + m_urlStrings = QStringList{QUrl::fromLocalFile(QFINDTESTDATA("data/applications/org.kde.dolphin.desktop")).toString(), + QUrl::fromLocalFile(QFINDTESTDATA("data/applications/org.kde.konversation.desktop")).toString()}; + // We don't want the globally installed apps to interfere and want the test to use our data files + qputenv("XDG_DATA_DIRS", QFINDTESTDATA("data").toLocal8Bit()); } void LauncherTasksModelTest::shouldRoundTripLauncherUrlList() @@ -113,9 +116,8 @@ void LauncherTasksModelTest::shouldRejectDuplicates() { LauncherTasksModel m; - QStringList urlStrings; - urlStrings << QLatin1String("file:///usr/share/applications/org.kde.dolphin.desktop"); - urlStrings << QLatin1String("file:///usr/share/applications/org.kde.dolphin.desktop"); + const QStringList urlStrings = {QUrl::fromLocalFile(QFINDTESTDATA("data/applications/org.kde.dolphin.desktop")).toString(), + QUrl::fromLocalFile(QFINDTESTDATA("data/applications/org.kde.dolphin.desktop")).toString()}; QSignalSpy launcherListChangedSpy(&m, &LauncherTasksModel::launcherListChanged); QVERIFY(launcherListChangedSpy.isValid());