summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/mimetypes
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2020-03-26 11:09:24 +0200
committerDavid Faure <david.faure@kdab.com>2020-06-01 13:36:05 +0200
commit4f1ebf666e36020c501e6d3b20d70320b45ab2ec (patch)
tree2993a066475042a3bc4abf2026dde4ac85d99e55 /tests/auto/corelib/mimetypes
parentb0294bb1c74ae3f5aabb873435788200da988908 (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/mimetypes')
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp6
1 files changed, 6 insertions, 0 deletions
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()