[packagechooser] Fix tests when run from in-source build
This commit is contained in:
parent
e2cb2690bd
commit
8636689cea
@ -45,21 +45,23 @@ PackageChooserTests::testBogus()
|
|||||||
void
|
void
|
||||||
PackageChooserTests::testAppData()
|
PackageChooserTests::testAppData()
|
||||||
{
|
{
|
||||||
// Path from the build-dir
|
// Path from the build-dir and from the running-the-test varies,
|
||||||
QString appdataName( "../io.calamares.calamares.appdata.xml" );
|
// for in-source build, for build/, and for tests-in-build/,
|
||||||
if ( !QFile::exists( appdataName ) )
|
// so look in multiple places.
|
||||||
|
QString appdataName( "io.calamares.calamares.appdata.xml" );
|
||||||
|
for ( const auto& prefix : QStringList { "", "../", "../../../", "../../../../" } )
|
||||||
{
|
{
|
||||||
// Running the tests by hand from the build-dir uses the
|
if ( QFile::exists( prefix + appdataName ) )
|
||||||
// path above, but ctest, used by "make test", runs them in
|
{
|
||||||
// the module build dir (e.g. build/src/modules/packagechooser)
|
appdataName = prefix + appdataName;
|
||||||
// so we need to adjust the path some.
|
break;
|
||||||
appdataName.prepend( "../../../" );
|
}
|
||||||
}
|
}
|
||||||
QVERIFY( QFile::exists( appdataName ) );
|
QVERIFY( QFile::exists( appdataName ) );
|
||||||
|
|
||||||
QVariantMap m;
|
QVariantMap m;
|
||||||
m.insert( "appdata", appdataName );
|
m.insert( "appdata", appdataName );
|
||||||
|
|
||||||
PackageItem p1 = PackageItem::fromAppData( m );
|
PackageItem p1 = PackageItem::fromAppData( m );
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
QVERIFY( p1.isValid() );
|
QVERIFY( p1.isValid() );
|
||||||
@ -71,10 +73,10 @@ PackageChooserTests::testAppData()
|
|||||||
QCOMPARE( p1.description.get( QLocale( "en_GB" ) ), "Calamares Linux Installer" );
|
QCOMPARE( p1.description.get( QLocale( "en_GB" ) ), "Calamares Linux Installer" );
|
||||||
QCOMPARE( p1.description.get( QLocale( "nl" ) ), "Calamares is een installatieprogramma voor Linux distributies." );
|
QCOMPARE( p1.description.get( QLocale( "nl" ) ), "Calamares is een installatieprogramma voor Linux distributies." );
|
||||||
QVERIFY( p1.screenshot.isNull() );
|
QVERIFY( p1.screenshot.isNull() );
|
||||||
|
|
||||||
m.insert( "id", "calamares" );
|
m.insert( "id", "calamares" );
|
||||||
m.insert( "screenshot", ":/images/calamares.png" );
|
m.insert( "screenshot", ":/images/calamares.png" );
|
||||||
PackageItem p2= PackageItem::fromAppData( m );
|
PackageItem p2 = PackageItem::fromAppData( m );
|
||||||
QVERIFY( p2.isValid() );
|
QVERIFY( p2.isValid() );
|
||||||
QCOMPARE( p2.id, "calamares" );
|
QCOMPARE( p2.id, "calamares" );
|
||||||
QCOMPARE( p2.description.get( QLocale( "nl" ) ), "Calamares is een installatieprogramma voor Linux distributies." );
|
QCOMPARE( p2.description.get( QLocale( "nl" ) ), "Calamares is een installatieprogramma voor Linux distributies." );
|
||||||
|
Loading…
Reference in New Issue
Block a user