[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kfilemetadata] autotests: Add TagLibExtractor tests
From: Juan Palacios <jpalaciosdev () gmail ! com>
Date: 2015-01-31 19:47:09
Message-ID: E1YHe0b-00012a-De () scm ! kde ! org
[Download RAW message or body]
Git commit 4baf21cfdfbe2a63001ca42145e7e42d603f8915 by Juan Palacios.
Committed on 31/01/2015 at 20:47.
Pushed by jpalacios into branch 'master'.
Add TagLibExtractor tests
REVIEW: 122329
M +13 -0 autotests/CMakeLists.txt
A +- -- autotests/samplefiles/test.opus
A +60 -0 autotests/taglibextractortest.cpp [License: LGPL (v2.1+)]
A +37 -0 autotests/taglibextractortest.h [License: LGPL (v2.1+)]
http://commits.kde.org/kfilemetadata/4baf21cfdfbe2a63001ca42145e7e42d603f89=
15
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 6a98863..6cdc9e7 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -82,3 +82,16 @@ if(EXIV2_FOUND)
LINK_LIBRARIES Qt5::Test KF5::FileMetaData ${EXIV2_LIBRARIES}
)
endif()
+
+#
+# TagLib
+#
+if(TAGLIB_FOUND)
+ include_directories(${TAGLIB_INCLUDES})
+
+ kde_enable_exceptions()
+ ecm_add_test(taglibextractortest.cpp ../src/extractors/taglibextractor=
.cpp
+ TEST_NAME "taglibextractortest"
+ LINK_LIBRARIES Qt5::Test KF5::FileMetaData ${TAGLIB_LIBRARIES}
+ )
+endif()
diff --git a/autotests/samplefiles/test.opus b/autotests/samplefiles/test.o=
pus
new file mode 100644
index 0000000..cf72976
Binary files /dev/null and b/autotests/samplefiles/test.opus differ
diff --git a/autotests/taglibextractortest.cpp b/autotests/taglibextractort=
est.cpp
new file mode 100644
index 0000000..d46e49e
--- /dev/null
+++ b/autotests/taglibextractortest.cpp
@@ -0,0 +1,60 @@
+/*
+ * TagLibExtractor tests.
+ *
+ * Copyright (C) 2015 Juan Palacios <jpalaciosdev@gmail.com>
+ *
+ * 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-13=
01 USA
+ *
+ */
+
+#include "taglibextractortest.h"
+#include "simpleextractionresult.h"
+#include "indexerextractortestsconfig.h"
+#include "extractors/taglibextractor.h"
+
+#include <QDebug>
+#include <QTest>
+#include <QDir>
+
+using namespace KFileMetaData;
+
+QString TagLibExtractorTest::testFilePath(const QString& fileName) const
+{
+ return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) + QDir::separato=
r() + fileName;
+}
+
+void TagLibExtractorTest::test()
+{
+ QScopedPointer<ExtractorPlugin> plugin(new TagLibExtractor(this));
+
+ SimpleExtractionResult result(testFilePath("test.opus"), "audio/opus");
+ plugin->extract(&result);
+
+ QCOMPARE(result.types().size(), 1);
+ QCOMPARE(result.types().first(), Type::Audio);
+
+ QCOMPARE(result.properties().value(Property::Title), QVariant(QStringL=
iteral("Title")));
+ QCOMPARE(result.properties().value(Property::Artist), QVariant(QString=
Literal("Artist")));
+ QCOMPARE(result.properties().value(Property::Album), QVariant(QStringL=
iteral("Test")));
+ QCOMPARE(result.properties().value(Property::AlbumArtist), QVariant(QS=
tringLiteral("Album Artist")));
+ QCOMPARE(result.properties().value(Property::Genre), QVariant(QStringL=
iteral("Genre")));
+ QCOMPARE(result.properties().value(Property::Comment), QVariant(QStrin=
gLiteral("Comment")));
+ QCOMPARE(result.properties().value(Property::Composer), QVariant(QStri=
ngLiteral("Composer")));
+ QCOMPARE(result.properties().value(Property::TrackNumber).toInt(), 1);
+ QCOMPARE(result.properties().value(Property::ReleaseYear).toInt(), 201=
5);
+ QCOMPARE(result.properties().value(Property::Channels).toInt(), 1);
+}
+
+QTEST_MAIN(TagLibExtractorTest)
diff --git a/autotests/taglibextractortest.h b/autotests/taglibextractortes=
t.h
new file mode 100644
index 0000000..bb1efe0
--- /dev/null
+++ b/autotests/taglibextractortest.h
@@ -0,0 +1,37 @@
+/*
+ * TagLibExtractor tests.
+ *
+ * Copyright (C) 2015 Juan Palacios <jpalaciosdev@gmail.com>
+ *
+ * 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-13=
01 USA
+ *
+ */
+
+#ifndef TAGLIBEXTRACTORTEST_H
+#define TAGLIBEXTRACTORTEST_H
+
+#include <QObject>
+
+class TagLibExtractorTest : public QObject
+{
+ Q_OBJECT
+private:
+ QString testFilePath(const QString& fileName) const;
+
+private Q_SLOTS:
+ void test();
+};
+
+#endif // TAGLIBEXTRACTORTEST_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic