File indexing completed on 2024-04-28 15:22:14

0001 /*
0002     SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau <kossebau@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "appimageextractortest.h"
0008 
0009 // Qt
0010 #include <QTest>
0011 
0012 #include "simpleextractionresult.h"
0013 #include "indexerextractortestsconfig.h"
0014 #include "extractors/appimageextractor.h"
0015 
0016 using namespace KFileMetaData;
0017 
0018 QString AppImageExtractorTest::testFilePath(const QString& fileName) const
0019 {
0020     return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) + QLatin1Char('/') + fileName;
0021 }
0022 
0023 /*
0024 The test.AppImage got created by:
0025 
0026 wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
0027 chmod +x linuxdeploy-x86_64.AppImage
0028 ./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage --executable=/usr/bin/echo --desktop-file=appimagetest.desktop --icon-file=/usr/share/icons/oxygen/base/16x16/apps/kde.png
0029 mkdir AppDir/usr/share/metainfo/
0030 cp org.kde.kfilemetadata.appimagetest.appdata.xml AppDir/usr/share/metainfo/
0031 ./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage
0032 mv Test_Desktop_Name-x86_64.AppImage test.AppImage
0033 
0034 To edit the appdata.xml & desktop file, run ./test.AppImage --appimage-extract to get the files.
0035 Use linuxdeploy to create the appimage then again.
0036 */
0037 
0038 void AppImageExtractorTest::test()
0039 {
0040     AppImageExtractor plugin{this};
0041 
0042     SimpleExtractionResult result(testFilePath(QStringLiteral("test.AppImage")), QStringLiteral("application/vnd.appimage"));
0043     plugin.extract(&result);
0044 
0045     QCOMPARE(result.types().size(), 0);
0046 
0047     QCOMPARE(result.properties().value(Property::Author), QVariant(QStringLiteral("Konqi")));
0048     QCOMPARE(result.properties().value(Property::Title), QVariant(QStringLiteral("Test Desktop Name")));
0049     QCOMPARE(result.properties().value(Property::Comment), QVariant(QStringLiteral("Test Desktop Comment")));
0050     QCOMPARE(result.properties().value(Property::Description), QVariant(QStringLiteral("Test description line 1.\nTest description line 2.")));
0051     QCOMPARE(result.properties().value(Property::License), QVariant(QStringLiteral("GPL-2.0")));
0052 
0053 }
0054 
0055 QTEST_GUILESS_MAIN(AppImageExtractorTest)
0056 
0057 #include "moc_appimageextractortest.cpp"