2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2019-08-02 10:57:12 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-08-02 10:57:12 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2019-08-02 10:57:12 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Tests.h"
|
|
|
|
|
2019-08-20 10:15:35 +02:00
|
|
|
#ifdef HAVE_XML
|
|
|
|
#include "ItemAppData.h"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_APPSTREAM
|
|
|
|
#include "ItemAppStream.h"
|
|
|
|
#endif
|
2019-08-06 14:33:57 +02:00
|
|
|
#include "PackageModel.h"
|
|
|
|
|
2019-08-06 14:41:40 +02:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
2019-08-02 10:57:12 +02:00
|
|
|
#include <QtTest/QtTest>
|
|
|
|
|
2019-08-06 15:19:20 +02:00
|
|
|
QTEST_MAIN( PackageChooserTests )
|
2019-08-02 10:57:12 +02:00
|
|
|
|
|
|
|
PackageChooserTests::PackageChooserTests() {}
|
|
|
|
|
|
|
|
PackageChooserTests::~PackageChooserTests() {}
|
|
|
|
|
|
|
|
void
|
|
|
|
PackageChooserTests::initTestCase()
|
|
|
|
{
|
2019-08-06 14:41:40 +02:00
|
|
|
Logger::setupLogLevel( Logger::LOGDEBUG );
|
2019-08-02 10:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PackageChooserTests::testBogus()
|
|
|
|
{
|
|
|
|
QVERIFY( true );
|
|
|
|
}
|
2019-08-06 14:33:57 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
PackageChooserTests::testAppData()
|
|
|
|
{
|
2019-08-07 12:54:03 +02:00
|
|
|
// Path from the build-dir and from the running-the-test varies,
|
|
|
|
// for in-source build, for build/, and for tests-in-build/,
|
|
|
|
// so look in multiple places.
|
|
|
|
QString appdataName( "io.calamares.calamares.appdata.xml" );
|
|
|
|
for ( const auto& prefix : QStringList { "", "../", "../../../", "../../../../" } )
|
2019-08-07 12:02:03 +02:00
|
|
|
{
|
2019-08-07 12:54:03 +02:00
|
|
|
if ( QFile::exists( prefix + appdataName ) )
|
|
|
|
{
|
|
|
|
appdataName = prefix + appdataName;
|
|
|
|
break;
|
|
|
|
}
|
2019-08-07 12:02:03 +02:00
|
|
|
}
|
2019-08-06 14:33:57 +02:00
|
|
|
QVERIFY( QFile::exists( appdataName ) );
|
|
|
|
|
2019-08-06 22:47:37 +02:00
|
|
|
QVariantMap m;
|
|
|
|
m.insert( "appdata", appdataName );
|
2019-08-07 12:54:03 +02:00
|
|
|
|
2019-08-06 14:33:57 +02:00
|
|
|
#ifdef HAVE_XML
|
2019-08-20 10:15:35 +02:00
|
|
|
PackageItem p1 = fromAppData( m );
|
2019-08-06 22:51:14 +02:00
|
|
|
QVERIFY( p1.isValid() );
|
2020-02-21 18:24:39 +01:00
|
|
|
QCOMPARE( p1.id, QStringLiteral( "io.calamares.calamares.desktop" ) );
|
|
|
|
QCOMPARE( p1.name.get(), QStringLiteral( "Calamares" ) );
|
2019-08-06 15:45:14 +02:00
|
|
|
// The <description> entry has precedence
|
2020-02-21 18:24:39 +01:00
|
|
|
QCOMPARE( p1.description.get(), QStringLiteral( "Calamares is an installer program for Linux distributions." ) );
|
2019-08-06 15:45:14 +02:00
|
|
|
// .. but en_GB doesn't have an entry in description, so uses <summary>
|
2020-02-21 18:24:39 +01:00
|
|
|
QCOMPARE( p1.description.get( QLocale( "en_GB" ) ), QStringLiteral( "Calamares Linux Installer" ) );
|
2020-08-22 01:19:58 +02:00
|
|
|
QCOMPARE( p1.description.get( QLocale( "nl" ) ),
|
|
|
|
QStringLiteral( "Calamares is een installatieprogramma voor Linux distributies." ) );
|
2019-08-06 22:51:14 +02:00
|
|
|
QVERIFY( p1.screenshot.isNull() );
|
2019-08-07 12:54:03 +02:00
|
|
|
|
2019-08-06 22:47:37 +02:00
|
|
|
m.insert( "id", "calamares" );
|
|
|
|
m.insert( "screenshot", ":/images/calamares.png" );
|
2019-08-20 10:15:35 +02:00
|
|
|
PackageItem p2 = fromAppData( m );
|
2019-08-06 22:51:14 +02:00
|
|
|
QVERIFY( p2.isValid() );
|
2020-02-21 18:24:39 +01:00
|
|
|
QCOMPARE( p2.id, QStringLiteral( "calamares" ) );
|
2020-08-22 01:19:58 +02:00
|
|
|
QCOMPARE( p2.description.get( QLocale( "nl" ) ),
|
|
|
|
QStringLiteral( "Calamares is een installatieprogramma voor Linux distributies." ) );
|
2019-08-06 22:51:14 +02:00
|
|
|
QVERIFY( !p2.screenshot.isNull() );
|
2019-08-06 14:33:57 +02:00
|
|
|
#endif
|
|
|
|
}
|