[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kfilemetadata] /: increase test coverage of taglibwriter
From: Alexander Stippich <null () kde ! org>
Date: 2018-09-28 20:36:03
Message-ID: E1g5zUZ-0007m1-Fn () code ! kde ! org
[Download RAW message or body]
Git commit ae3c3829342113127e54177d60baf76e6c242d5f by Alexander Stippich.
Committed on 28/09/2018 at 20:35.
Pushed by astippich into branch 'master'.
increase test coverage of taglibwriter
Summary: increase the test coverage by testing more mimetypes, and use some unicode characters
Test Plan: taglibwriter test pass
Reviewers: mgallien, bruns
Reviewed By: bruns
Subscribers: svuorela, kde-frameworks-devel, #baloo
Tags: #frameworks, #baloo
Differential Revision: https://phabricator.kde.org/D15704
M +44 -13 autotests/taglibwritertest.cpp
M +2 -3 autotests/taglibwritertest.h
M +7 -2 src/writers/taglibwriter.cpp
https://commits.kde.org/kfilemetadata/ae3c3829342113127e54177d60baf76e6c242d5f
diff --git a/autotests/taglibwritertest.cpp b/autotests/taglibwritertest.cpp
index 75be80b..e192bde 100644
--- a/autotests/taglibwritertest.cpp
+++ b/autotests/taglibwritertest.cpp
@@ -11,8 +11,6 @@
#include <QDir>
#include <QFile>
-#define TEST_FILENAME "writertest.opus"
-
using namespace KFileMetaData;
static QString t2q(const TagLib::String& t)
@@ -25,18 +23,18 @@ QString TagLibWriterTest::testFilePath(const QString& fileName) const
return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) + QDir::separator() + fileName;
}
-void TagLibWriterTest::initTestCase()
+void TagLibWriterTest::testCommonData()
{
- QFile testFile(testFilePath("test.opus"));
- QFile writerTestFile(testFilePath(TEST_FILENAME));
- QFile::copy(testFilePath("test.opus"), testFilePath(TEST_FILENAME));
-}
+ QFETCH(QString, fileType);
+ QFETCH(QString, mimeType);
-void TagLibWriterTest::test()
-{
+ QString temporaryFileName = QStringLiteral("writertest.") + fileType;
+
+ QFile::copy(testFilePath("test." + fileType), testFilePath(temporaryFileName));
TagLibWriter writerPlugin{this};
+ QCOMPARE(writerPlugin.writeMimetypes().contains(mimeType),true);
- WriteData data(testFilePath(TEST_FILENAME), "audio/opus");
+ WriteData data(testFilePath(temporaryFileName), mimeType);
data.add(Property::Title, "Title1");
data.add(Property::Artist, "Artist1");
data.add(Property::Album, "Album1");
@@ -46,7 +44,7 @@ void TagLibWriterTest::test()
data.add(Property::Comment, "Comment1");
writerPlugin.write(data);
- TagLib::FileRef file(testFilePath(TEST_FILENAME).toUtf8().constData(), true);
+ TagLib::FileRef file(testFilePath(temporaryFileName).toUtf8().constData(), true);
TagLib::Tag* tags = file.tag();
QString extractedTitle = t2q(tags->title());
@@ -64,11 +62,44 @@ void TagLibWriterTest::test()
QCOMPARE(extractedYear, 1999u);
QCOMPARE(extractedGenre, QStringLiteral("Genre1"));
QCOMPARE(extractedComment, QStringLiteral("Comment1"));
+
+ QFile::remove(testFilePath(temporaryFileName));
}
-void TagLibWriterTest::cleanupTestCase()
+void TagLibWriterTest::testCommonData_data()
{
- QFile::remove(testFilePath(TEST_FILENAME));
+ QTest::addColumn<QString>("fileType");
+ QTest::addColumn<QString>("mimeType");
+
+ QTest::addRow("flac")
+ << QStringLiteral("flac")
+ << QStringLiteral("audio/flac")
+ ;
+
+ QTest::addRow("m4a")
+ << QStringLiteral("m4a")
+ << QStringLiteral("audio/mp4")
+ ;
+
+ QTest::addRow("mp3")
+ << QStringLiteral("mp3")
+ << QStringLiteral("audio/mpeg3")
+ ;
+
+ QTest::addRow("mpc")
+ << QStringLiteral("mpc")
+ << QStringLiteral("audio/x-musepack")
+ ;
+
+ QTest::addRow("ogg")
+ << QStringLiteral("ogg")
+ << QStringLiteral("audio/ogg")
+ ;
+
+ QTest::addRow("opus")
+ << QStringLiteral("opus")
+ << QStringLiteral("audio/opus")
+ ;
}
QTEST_GUILESS_MAIN(TagLibWriterTest)
diff --git a/autotests/taglibwritertest.h b/autotests/taglibwritertest.h
index 2e3c180..951ef3d 100644
--- a/autotests/taglibwritertest.h
+++ b/autotests/taglibwritertest.h
@@ -10,9 +10,8 @@ private:
QString testFilePath(const QString& fileName) const;
private Q_SLOTS:
- void initTestCase();
- void test();
- void cleanupTestCase();
+ void testCommonData();
+ void testCommonData_data();
};
#endif // TAGLIBWRITERTEST_H
diff --git a/src/writers/taglibwriter.cpp b/src/writers/taglibwriter.cpp
index 4cf7503..f811ea6 100644
--- a/src/writers/taglibwriter.cpp
+++ b/src/writers/taglibwriter.cpp
@@ -20,11 +20,16 @@ TagLib::String q2t(const QString& q)
QStringList TagLibWriter::writeMimetypes() const
{
QStringList types = {
+ QStringLiteral("audio/flac"),
+ QStringLiteral("audio/mp4"),
QStringLiteral("audio/mpeg"),
QStringLiteral("audio/mpeg3"),
- QStringLiteral("audio/x-mpeg"),
+ QStringLiteral("audio/ogg"),
QStringLiteral("audio/opus"),
- QStringLiteral("audio/x-opus+ogg")
+ QStringLiteral("audio/x-mpeg"),
+ QStringLiteral("audio/x-musepack"),
+ QStringLiteral("audio/x-opus+ogg"),
+ QStringLiteral("audio/x-vorbis+ogg"),
};
return types;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic