2019-08-02 10:57:12 +02:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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" ) );
|
|
|
|
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" ) );
|
|
|
|
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
|
|
|
|
}
|