summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2020-12-31 21:28:51 +0100
committerThiago Macieira <thiago.macieira@intel.com>2021-01-05 18:31:54 +0000
commit0cbbba2aa5b472241d45b4be6959a792062fbc30 (patch)
treee6e3b3352a4cd38b6d4cbe67d30328104815b71b /tests/auto/corelib
parente688b99995b8c624dbcea296c99fb89262d29e15 (diff)
Update shared-mime-info to the 2.1 release, adjust implementation
The spec hasn't changed, but I made the same mistake in xdgmime (the reference implementation) and in Qt: when multiple globs match, and the result from magic sniffing is unrelated to any of those globs, then I used the magic result, but that's wrong, globs have priority and one of them should be picked up. This is now fixed in xdgmime (https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/3) and in the expected results in shared-mime-info (https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/99) which this commit is also tested against. This change also optimizes QMimeBinaryProvider::addFileNameMatches to have the same logic as xdgmime for glob matching: literals > extensions > other globs As soon as one category matches, we can stop there. This makes no difference in the overall results, in practice. The user bug report (against the Qt implementation, actually) is https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/138 as well as https://bugs.kde.org/show_bug.cgi?id=411718 Pick-to: 6.0 5.15 Change-Id: Ia0a34080427daff43c732609443ee6df8f41447c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 6ee2539b1a..4abf13e3e6 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -73,15 +73,15 @@ static inline QString testSuiteWarning()
QString result;
QTextStream str(&result);
- str << "\nCannot find the shared-mime-info test suite\nstarting from: "
+ str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
<< QDir::toNativeSeparators(QDir::currentPath()) << "\n"
"cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
- "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/Release-1-10/shared-mime-info-Release-1-10.zip\n"
- "unzip shared-mime-info-Release-1-10.zip\n";
+ "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
+ "unzip shared-mime-info-2.1.zip\n";
#ifdef Q_OS_WIN
- str << "mkdir testfiles\nxcopy /s shared-mime-info-Release-1-10 s-m-i\n";
+ str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
#else
- str << "ln -s shared-mime-info-Release-1-10 s-m-i\n";
+ str << "ln -s shared-mime-info-2.1 s-m-i\n";
#endif
return result;
}
@@ -157,7 +157,7 @@ void tst_QMimeDatabase::initTestCase()
QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
#endif
- m_testSuite = QFINDTESTDATA("s-m-i/tests");
+ m_testSuite = QFINDTESTDATA("../s-m-i/tests/mime-detection");
if (m_testSuite.isEmpty())
qWarning("%s", qPrintable(testSuiteWarning()));
@@ -614,7 +614,7 @@ void tst_QMimeDatabase::allMimeTypes()
QVERIFY(!lst.isEmpty());
// Hardcoding this is the only way to check both providers find the same number of mimetypes.
- QCOMPARE(lst.count(), 779);
+ QCOMPARE(lst.count(), 811);
foreach (const QMimeType &mime, lst) {
const QString name = mime.name();
@@ -634,10 +634,9 @@ void tst_QMimeDatabase::suffixes_data()
QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
- QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
- //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
- QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
- //}
+ // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
+ QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
+ QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";