From 4f1ebf666e36020c501e6d3b20d70320b45ab2ec Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 26 Mar 2020 11:09:24 +0200 Subject: QMimeType::suffixForFileName shouldn't lowercase the file suffix It was returning a lowercased suffix because it was extracting it from the pattern (*.txt) rather than from the filename ("README.TXT"). This broke expectations on the application side, since this method is documented to return a suffix from the given filename. Ref: https://bugs.kde.org/show_bug.cgi?id=402388 Change-Id: I7dae13db31280249d3f592fa9592c4067804e22d Reviewed-by: Thiago Macieira --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto/corelib/mimetypes') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 3c6da506e2..c214c75d52 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -667,6 +667,9 @@ void tst_QMimeDatabase::knownSuffix() QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.bz2")), QString::fromLatin1("bz2")); QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.bar.bz2")), QString::fromLatin1("bz2")); QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.tar.bz2")), QString::fromLatin1("tar.bz2")); + QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.TAR")), QString::fromLatin1("TAR")); // preserve case + QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.flatpakrepo")), QString::fromLatin1("flatpakrepo")); + QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.anim2")), QString()); // the glob is anim[0-9], no way to extract the extension without expensive regexp capturing } void tst_QMimeDatabase::symlinkToFifo() // QTBUG-48529 @@ -784,6 +787,9 @@ void tst_QMimeDatabase::findByFileName() // Test QFileInfo overload const QMimeType mimeForFileInfo = database.mimeTypeForFile(QFileInfo(filePath), QMimeDatabase::MatchExtension); QCOMPARE(mimeForFileInfo.name(), resultMimeTypeName); + + const QString suffix = database.suffixForFileName(filePath); + QVERIFY2(filePath.endsWith(suffix), qPrintable(filePath + " does not end with " + suffix)); } void tst_QMimeDatabase::findByData_data() -- cgit v1.2.3