Changeset View
Changeset View
Standalone View
Standalone View
autotests/appimageextractortest.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This library is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public | ||||
15 | * License along with this library; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
17 | * | ||||
18 | */ | ||||
19 | | ||||
20 | #include "appimageextractortest.h" | ||||
21 | | ||||
22 | // Qt | ||||
23 | #include <QTest> | ||||
24 | #include <QDebug> | ||||
25 | | ||||
26 | #include "simpleextractionresult.h" | ||||
27 | #include "indexerextractortestsconfig.h" | ||||
28 | #include "extractors/appimageextractor.h" | ||||
29 | | ||||
30 | using namespace KFileMetaData; | ||||
31 | | ||||
32 | QString AppImageExtractorTest::testFilePath(const QString& fileName) const | ||||
33 | { | ||||
34 | return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) + QLatin1Char('/') + fileName; | ||||
35 | } | ||||
36 | | ||||
37 | /* | ||||
38 | The test.AppImage got created by: | ||||
39 | | ||||
40 | wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage | ||||
41 | chmod +x linuxdeploy-x86_64.AppImage | ||||
42 | ./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 | ||||
43 | mkdir AppDir/usr/share/metainfo/ | ||||
44 | cp org.kde.kfilemetadata.appimagetest.appdata.xml AppDir/usr/share/metainfo/ | ||||
45 | ./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage | ||||
46 | mv Test_Desktop_Name-x86_64.AppImage test.AppImage | ||||
47 | | ||||
48 | To edit the appdata.xml & desktop file, run ./test.AppImage --appimage-extract to get the files. | ||||
49 | Use linuxdeploy to create the appimage then again. | ||||
50 | */ | ||||
51 | | ||||
52 | void AppImageExtractorTest::test() | ||||
53 | { | ||||
54 | AppImageExtractor plugin{this}; | ||||
55 | | ||||
56 | SimpleExtractionResult result(testFilePath(QStringLiteral("test.AppImage")), QStringLiteral("application/vnd.appimage")); | ||||
57 | plugin.extract(&result); | ||||
58 | | ||||
59 | QCOMPARE(result.types().size(), 0); | ||||
60 | | ||||
61 | QCOMPARE(result.properties().value(Property::Author), QVariant(QStringLiteral("Konqi"))); | ||||
62 | QCOMPARE(result.properties().value(Property::Title), QVariant(QStringLiteral("Test Desktop Name"))); | ||||
63 | QCOMPARE(result.properties().value(Property::Comment), QVariant(QStringLiteral("Test Desktop Comment"))); | ||||
64 | QCOMPARE(result.properties().value(Property::Description), QVariant(QStringLiteral("Test description line 1.\nTest description line 2."))); | ||||
65 | QCOMPARE(result.properties().value(Property::License), QVariant(QStringLiteral("GPL-2.0"))); | ||||
66 | | ||||
67 | } | ||||
68 | | ||||
69 | QTEST_GUILESS_MAIN(AppImageExtractorTest) |