Changeset View
Changeset View
Standalone View
Standalone View
autotests/ffmpegextractortest.cpp
Show All 15 Lines | |||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | * | 17 | * | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "ffmpegextractortest.h" | 20 | #include "ffmpegextractortest.h" | ||
21 | #include "simpleextractionresult.h" | 21 | #include "simpleextractionresult.h" | ||
22 | #include "indexerextractortestsconfig.h" | 22 | #include "indexerextractortestsconfig.h" | ||
23 | #include "extractors/ffmpegextractor.h" | 23 | #include "extractors/ffmpegextractor.h" | ||
24 | #include "mimeutils.h" | ||||
24 | 25 | | |||
25 | #include <QTest> | 26 | #include <QTest> | ||
26 | 27 | | |||
bruns: remove comment | |||||
27 | using namespace KFileMetaData; | 28 | using namespace KFileMetaData; | ||
28 | 29 | | |||
29 | namespace { | 30 | namespace { | ||
30 | 31 | | |||
31 | QString testFilePath(const QString& baseName, const QString& extension) | 32 | QString testFilePath(const QString& baseName, const QString& extension) | ||
32 | { | 33 | { | ||
33 | return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) | 34 | return QLatin1String(INDEXER_TESTS_SAMPLE_FILES_PATH) | ||
34 | + QLatin1Char('/') + baseName + QLatin1Char('.') + extension; | 35 | + QLatin1Char('/') + baseName + QLatin1Char('.') + extension; | ||
35 | } | 36 | } | ||
36 | 37 | | |||
37 | } // namespace | 38 | } // namespace | ||
38 | 39 | | |||
39 | void ffmpegExtractorTest::testVideoProperties_data() | 40 | void ffmpegExtractorTest::testVideoProperties_data() | ||
40 | { | 41 | { | ||
41 | QTest::addColumn<QString>("fileType"); | 42 | QTest::addColumn<QString>("fileType"); | ||
42 | QTest::addColumn<QString>("mimeType"); | | |||
43 | 43 | | |||
44 | QTest::addRow("WebM") | 44 | QTest::addRow("WebM") | ||
45 | << QStringLiteral("webm") | 45 | << QStringLiteral("webm"); | ||
46 | << QStringLiteral("video/webm"); | | |||
47 | 46 | | |||
48 | QTest::addRow("Matroska Video") | 47 | QTest::addRow("Matroska Video") | ||
49 | << QStringLiteral("mkv") | 48 | << QStringLiteral("mkv"); | ||
50 | << QStringLiteral("video/x-matroska"); | | |||
51 | 49 | | |||
52 | QTest::addRow("Vorbis Video") | 50 | QTest::addRow("Vorbis Video") | ||
53 | << QStringLiteral("ogv") | 51 | << QStringLiteral("ogv"); | ||
54 | << QStringLiteral("video/ogg"); | | |||
55 | 52 | | |||
56 | QTest::addRow("MPEG Transport") | 53 | QTest::addRow("MPEG Transport") | ||
57 | << QStringLiteral("ts") | 54 | << QStringLiteral("ts"); | ||
58 | << QStringLiteral("video/mp2t"); | | |||
59 | } | 55 | } | ||
60 | 56 | | |||
61 | // only for testing of intrinsic video properties | 57 | // only for testing of intrinsic video properties | ||
62 | void ffmpegExtractorTest::testVideoProperties() | 58 | void ffmpegExtractorTest::testVideoProperties() | ||
63 | { | 59 | { | ||
64 | QFETCH(QString, fileType); | 60 | QFETCH(QString, fileType); | ||
65 | QFETCH(QString, mimeType); | 61 | | ||
62 | QString fileName = testFilePath(QStringLiteral("test"), fileType); | ||||
63 | QString mimeType = MimeUtils::strictMimeType(fileName, mimeDb).name(); | ||||
66 | 64 | | |||
67 | FFmpegExtractor plugin{this}; | 65 | FFmpegExtractor plugin{this}; | ||
68 | 66 | | |||
69 | SimpleExtractionResult result(testFilePath(QLatin1String("test"), fileType), mimeType); | 67 | QVERIFY(plugin.mimetypes().contains(plugin.getSupportedMimeType(mimeType))); | ||
68 | | ||||
69 | SimpleExtractionResult result(fileName, mimeType); | ||||
70 | plugin.extract(&result); | 70 | plugin.extract(&result); | ||
71 | 71 | | |||
72 | QCOMPARE(result.types().size(), 1); | 72 | QCOMPARE(result.types().size(), 1); | ||
73 | QCOMPARE(result.types().constFirst(), Type::Video); | 73 | QCOMPARE(result.types().constFirst(), Type::Video); | ||
74 | 74 | | |||
75 | QCOMPARE(result.properties().value(Property::Width).toInt(), 1280); | 75 | QCOMPARE(result.properties().value(Property::Width).toInt(), 1280); | ||
76 | QCOMPARE(result.properties().value(Property::Height).toInt(), 720); | 76 | QCOMPARE(result.properties().value(Property::Height).toInt(), 720); | ||
77 | QCOMPARE(result.properties().value(Property::FrameRate).toDouble(), 24.0/1.001); | 77 | QCOMPARE(result.properties().value(Property::FrameRate).toDouble(), 24.0/1.001); | ||
78 | QCOMPARE(result.properties().value(Property::AspectRatio).toDouble(), 16.0/9); | 78 | QCOMPARE(result.properties().value(Property::AspectRatio).toDouble(), 16.0/9); | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | void ffmpegExtractorTest::testMetaData_data() | 81 | void ffmpegExtractorTest::testMetaData_data() | ||
82 | { | 82 | { | ||
83 | QTest::addColumn<QString>("fileType"); | 83 | QTest::addColumn<QString>("fileType"); | ||
84 | QTest::addColumn<QString>("mimeType"); | | |||
85 | 84 | | |||
86 | QTest::addRow("WebM") | 85 | QTest::addRow("WebM") | ||
87 | << QStringLiteral("webm") | 86 | << QStringLiteral("webm"); | ||
88 | << QStringLiteral("video/webm"); | | |||
89 | 87 | | |||
90 | QTest::addRow("Matroska Video") | 88 | QTest::addRow("Matroska Video") | ||
91 | << QStringLiteral("mkv") | 89 | << QStringLiteral("mkv"); | ||
92 | << QStringLiteral("video/x-matroska"); | | |||
93 | 90 | | |||
94 | QTest::addRow("Vorbis Video") | 91 | QTest::addRow("Vorbis Video") | ||
95 | << QStringLiteral("ogv") | 92 | << QStringLiteral("ogv"); | ||
96 | << QStringLiteral("video/ogg"); | | |||
97 | } | 93 | } | ||
98 | 94 | | |||
99 | void ffmpegExtractorTest::testMetaData() | 95 | void ffmpegExtractorTest::testMetaData() | ||
100 | { | 96 | { | ||
101 | QFETCH(QString, fileType); | 97 | QFETCH(QString, fileType); | ||
102 | QFETCH(QString, mimeType); | 98 | | ||
99 | QString fileName = testFilePath(QStringLiteral("test"), fileType); | ||||
100 | QString mimeType = MimeUtils::strictMimeType(fileName, mimeDb).name(); | ||||
103 | 101 | | |||
104 | FFmpegExtractor plugin{this}; | 102 | FFmpegExtractor plugin{this}; | ||
105 | 103 | | |||
106 | SimpleExtractionResult result(testFilePath(QLatin1String("test"), fileType), mimeType); | 104 | SimpleExtractionResult result(fileName, mimeType); | ||
107 | plugin.extract(&result); | 105 | plugin.extract(&result); | ||
108 | 106 | | |||
109 | QEXPECT_FAIL("Vorbis Video", "Not yet supported", Abort); | 107 | QEXPECT_FAIL("Vorbis Video", "Not yet supported", Abort); | ||
110 | QCOMPARE(result.properties().value(Property::Title).toString(), QStringLiteral("Title")); | 108 | QCOMPARE(result.properties().value(Property::Title).toString(), QStringLiteral("Title")); | ||
111 | QCOMPARE(result.properties().value(Property::Copyright).toString(), QStringLiteral("Copyright")); | 109 | QCOMPARE(result.properties().value(Property::Copyright).toString(), QStringLiteral("Copyright")); | ||
112 | QCOMPARE(result.properties().value(Property::Author).toString(), QStringLiteral("Author")); | 110 | QCOMPARE(result.properties().value(Property::Author).toString(), QStringLiteral("Author")); | ||
113 | QCOMPARE(result.properties().value(Property::ReleaseYear).toInt(), 2019); | 111 | QCOMPARE(result.properties().value(Property::ReleaseYear).toInt(), 2019); | ||
114 | } | 112 | } | ||
115 | QTEST_GUILESS_MAIN(ffmpegExtractorTest) | 113 | QTEST_GUILESS_MAIN(ffmpegExtractorTest) |
remove comment