diff --git a/autotests/unit/file/CMakeLists.txt b/autotests/unit/file/CMakeLists.txt --- a/autotests/unit/file/CMakeLists.txt +++ b/autotests/unit/file/CMakeLists.txt @@ -41,3 +41,12 @@ LINK_LIBRARIES Qt5::Test Qt5::DBus KF5::Baloo baloofilecommon ) +# +# Result Test +# +set(resultTest_SRC resulttest.cpp ../../../src/file/extractor/result.cpp) +ecm_add_test(${resultTest_SRC} + TEST_NAME "resulttest" + LINK_LIBRARIES Qt5::Test Qt5::DBus KF5::Baloo baloofilecommon +) + diff --git a/autotests/unit/file/resulttest.cpp b/autotests/unit/file/resulttest.cpp new file mode 100644 --- /dev/null +++ b/autotests/unit/file/resulttest.cpp @@ -0,0 +1,55 @@ +/* + * + * Copyright (C) 2018 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "document.h" +#include "extractor/result.h" + +#include + +#include + +using namespace Baloo; + +class ResultTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testStringMerging() + { + Document doc; + + Result result(QStringLiteral("test"),QStringLiteral("audo/mpeg3"),KFileMetaData::ExtractionResult::ExtractEverything); + result.setDocument(doc); + + result.add(KFileMetaData::Property::Artist, QVariant(QStringLiteral("artist1"))); + result.add(KFileMetaData::Property::Artist, QVariant(QStringLiteral("artist2"))); + + result.finish(); + auto properties = result.map(); + auto artist = properties.find(QString::number(KFileMetaData::Property::Artist)); + QCOMPARE(artist->type(), QVariant::List); + QCOMPARE(artist->toStringList().join(", "), QStringLiteral("artist1, artist2")); + } +}; + +QTEST_MAIN(ResultTest) + +#include "resulttest.moc"