diff --git a/autotests/extractortest.cpp b/autotests/extractortest.cpp --- a/autotests/extractortest.cpp +++ b/autotests/extractortest.cpp @@ -34,7 +34,7 @@ { QString fileUrl = QFINDTESTDATA("samplefiles/test.mp3"); - QString exe = QStandardPaths::findExecutable(QLatin1String("baloo_filemetadata_temp_extractor")); + QString exe = QFINDTESTDATA("../src/baloo_filemetadata_temp_extractor"); QStringList args; args << fileUrl; diff --git a/autotests/filemetadatawidgettest.cpp b/autotests/filemetadatawidgettest.cpp --- a/autotests/filemetadatawidgettest.cpp +++ b/autotests/filemetadatawidgettest.cpp @@ -1,20 +1,20 @@ /* * This file is part of the KDE Baloo Project * Copyright 2018 Michael Heidelbach - * + * * This program 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 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. - * + * * This program 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 this program. If not, see . */ @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -47,14 +48,20 @@ void FileMetadataWidgetTest::initTestCase() { qRegisterMetaType("KFileItemList"); - + QStandardPaths::setTestModeEnabled(true); + // Use our temp extractor + const QString np = QFINDTESTDATA("../src"); + const QString op = qgetenv("PATH"); + qputenv("PATH", qPrintable(QStringLiteral("%1%2%3").arg(np).arg(QDir::listSeparator()).arg(op))); + const auto extractorPath = QDir(QStringLiteral("%1/baloo_filemetadata_temp_extractor").arg(QFINDTESTDATA("../src"))).absolutePath(); + QCOMPARE(QStandardPaths::findExecutable(QStringLiteral("baloo_filemetadata_temp_extractor")), extractorPath); KConfig balooConfig("baloofilerc", KConfig::NoGlobals); KConfigGroup balooSettings = balooConfig.group("General"); // If we use .writePathEntry here, the test will fail. balooSettings.writeEntry(QStringLiteral("folders"), QString()); - + // Ensure show configuration KConfig config("baloofileinformationrc", KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); @@ -68,7 +75,7 @@ if (exe.isEmpty()) { return; } - + const QStringList args = {QStringLiteral("--name=user.baloo.rating"), QStringLiteral("--value=5") , QFINDTESTDATA("samplefiles/testtagged.mp3"), @@ -117,19 +124,19 @@ void FileMetadataWidgetTest::shouldSignalOnceFile() { QSignalSpy spy(m_widget, &Baloo::FileMetaDataWidget::metaDataRequestFinished); - m_widget->setItems(KFileItemList() + m_widget->setItems(KFileItemList() << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) ); QVERIFY(spy.wait()); QCOMPARE(spy.count(), 1); QCOMPARE(m_widget->items().count(), 1); - + } void FileMetadataWidgetTest::shouldSignalOnceFiles() { QSignalSpy spy(m_widget, &Baloo::FileMetaDataWidget::metaDataRequestFinished); - m_widget->setItems(KFileItemList() + m_widget->setItems(KFileItemList() << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/test.mp3")) << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) @@ -142,18 +149,18 @@ void FileMetadataWidgetTest::shouldShowProperties() { QSignalSpy spy(m_widget, &Baloo::FileMetaDataWidget::metaDataRequestFinished); - m_widget->setItems(KFileItemList() + m_widget->setItems(KFileItemList() << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) ); - + QVERIFY(spy.wait()); QCOMPARE(spy.count(), 1); - + // simple property QLabel* valueWidget = m_widget->findChild("kfileitem#type"); QVERIFY2(valueWidget, "Type data missing"); QCOMPARE(valueWidget->text(), QLatin1String("MP3 audio")); - + if (m_mayTestRating) { // editable property KRatingWidget* ratingWidget = m_widget->findChild("rating"); @@ -166,27 +173,27 @@ valueWidget = m_widget->findChild("albumArtist"); QVERIFY2(valueWidget, "albumArtist data was not found"); QCOMPARE(valueWidget->text(), QLatin1String("Bill Laswell")); - + } void FileMetadataWidgetTest::shouldShowCommonProperties() { QSignalSpy spy(m_widget, &Baloo::FileMetaDataWidget::metaDataRequestFinished); - m_widget->setItems(KFileItemList() + m_widget->setItems(KFileItemList() << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) ); QVERIFY(spy.wait()); QCOMPARE(spy.count(), 1); - + // simple property QLabel* valueWidget = m_widget->findChild("kfileitem#type"); QVERIFY(!valueWidget); - + valueWidget = m_widget->findChild("kfileitem#totalSize"); // circumvent i18n formatting QCOMPARE(valueWidget->text().left(3), QLatin1String("153")); - + // editable property if (m_mayTestRating) { KRatingWidget* ratingWidget = m_widget->findChild("rating");