Changeset View
Changeset View
Standalone View
Standalone View
autotests/xmlextractortest.cpp
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "xmlextractortest.h" | 21 | #include "xmlextractortest.h" | ||
22 | 22 | | |||
23 | #include <QtTest> | 23 | #include <QtTest> | ||
24 | #include <QMimeDatabase> | ||||
24 | 25 | | |||
25 | #include "simpleextractionresult.h" | 26 | #include "simpleextractionresult.h" | ||
26 | #include "indexerextractortestsconfig.h" | 27 | #include "indexerextractortestsconfig.h" | ||
27 | #include "extractors/xmlextractor.h" | 28 | #include "extractors/xmlextractor.h" | ||
29 | #include "mimeutils.h" | ||||
28 | 30 | | |||
29 | using namespace KFileMetaData; | 31 | using namespace KFileMetaData; | ||
30 | 32 | | |||
31 | XmlExtractorTests::XmlExtractorTests(QObject* parent) : | 33 | XmlExtractorTests::XmlExtractorTests(QObject* parent) : | ||
32 | QObject(parent) | 34 | QObject(parent) | ||
33 | { | 35 | { | ||
34 | } | 36 | } | ||
35 | 37 | | |||
Show All 37 Lines | 74 | QBENCHMARK { | |||
73 | plugin.extract(&result); | 75 | plugin.extract(&result); | ||
74 | } | 76 | } | ||
75 | } | 77 | } | ||
76 | 78 | | |||
77 | void XmlExtractorTests::testXmlExtractor() | 79 | void XmlExtractorTests::testXmlExtractor() | ||
78 | { | 80 | { | ||
79 | XmlExtractor plugin{this}; | 81 | XmlExtractor plugin{this}; | ||
80 | 82 | | |||
81 | SimpleExtractionResult result(testFilePath(QStringLiteral("test_with_metadata.svg")), | 83 | QString fileName = testFilePath(QStringLiteral("test_with_metadata.svg")); | ||
82 | QStringLiteral("image/svg"), | 84 | QMimeDatabase mimeDb; | ||
85 | QString mimeType = MimeUtils::strictMimeType(fileName, mimeDb).name(); | ||||
86 | QVERIFY(plugin.mimetypes().contains(mimeType)); | ||||
87 | | ||||
88 | SimpleExtractionResult result(fileName, mimeType, | ||||
83 | ExtractionResult::ExtractEverything); | 89 | ExtractionResult::ExtractEverything); | ||
84 | plugin.extract(&result); | 90 | plugin.extract(&result); | ||
85 | 91 | | |||
86 | QString content = QStringLiteral("Some text\n"); | 92 | QString content = QStringLiteral("Some text\n"); | ||
87 | 93 | | |||
88 | QCOMPARE(result.types().size(), 1); | 94 | QCOMPARE(result.types().size(), 1); | ||
89 | QCOMPARE(result.types().at(0), Type::Image); | 95 | QCOMPARE(result.types().at(0), Type::Image); | ||
90 | 96 | | |||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |