From 3ad00c4e56eb9fe6ea7386f8ca1db6e15c26ac11 Mon Sep 17 00:00:00 2001 From: Wolfgang Bauer Date: Tue, 25 Apr 2017 23:37:11 +0200 Subject: Fix relativePath calculation in KDesktopFile::locateLocal() The "dir" and "path" variables were obviously swapped here by mistake. This resulted in the relativePath always being empty, and made the function return "~/.local/share/" (or "~/.config/") instead of the correct path. BUG: 345100 FIXED-IN: 5.34.0 Differential Revision: https://phabricator.kde.org/D5502 --- autotests/kdesktopfiletest.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'autotests/kdesktopfiletest.cpp') diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index 393a6a03..a0461964 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -255,3 +255,34 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction() QVERIFY(!desktopFile.tryExec()); } } + +void KDesktopFileTest::testLocateLocal_data() +{ + QString systemConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation).last(); + QString writableConfigLocation = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); + QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last(); + QString writableDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + + QTest::addColumn("path"); + QTest::addColumn("result"); + + QTest::newRow("configLocation, system-wide") << systemConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; + QTest::newRow("autostart, system-wide") << systemConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; + QTest::newRow("dataLocation, system-wide") << systemDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; + QTest::newRow("applications, system-wide") << systemDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; + QTest::newRow("desktop-directories, system-wide") << systemDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; + QTest::newRow("configLocation, writable") << writableConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; + QTest::newRow("autostart, writable") << writableConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; + QTest::newRow("dataLocation, writable") << writableDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; + QTest::newRow("applications, writable") << writableDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; + QTest::newRow("desktop-directories, writable") << writableDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; + QTest::newRow("unknown location") << "/test.desktop" << writableDataLocation + "/test.desktop"; +} + +void KDesktopFileTest::testLocateLocal() +{ + QFETCH(QString, path); + QFETCH(QString, result); + + QCOMPARE(KDesktopFile::locateLocal(path), result); +} -- cgit v1.2.1