diff options
author | David Faure <david.faure@kdab.com> | 2013-07-28 20:03:57 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-03 14:44:12 +0200 |
commit | 672fcbe9c6586e909513c91f5b36ad9a83a0ef1c (patch) | |
tree | 94f9a721ecb15a4bc59793b8a7953cfa1114bf10 /tests | |
parent | be8974633c4f812227db256dae6fa249f60c61d1 (diff) |
QMimeDatabase: Fix handling of duplicate mimetype definitions (2/2).
7721c3d27c6a fixed the case where two similar definitions are in the same
directory. This commit fixes the case where two similar definitions are
in different directories, both in the search path (GenericDataLocation).
If the file extension gives us the same mimetype twice, there's no conflict,
i.e. no reason to fallback to determination from contents.
Change-Id: I72c56004b6d5e88964159e53ec160ce8b06c2264
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index a90bfadd73..07d3c5c7b8 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -876,7 +876,10 @@ void tst_QMimeDatabase::installNewLocalMimeType() QDir().mkpath(destDir); const QString destFile = destDir + QLatin1String(yastFileName); QFile::remove(destFile); + const QString destQmlFile = destDir + QLatin1String(qmlAgainFileName); + QFile::remove(destQmlFile); QVERIFY(QFile::copy(m_yastMimeTypes, destFile)); + QVERIFY(QFile::copy(m_qmlAgainFileName, destQmlFile)); if (!runUpdateMimeDatabase(mimeDir)) { const QString skipWarning = QStringLiteral("shared-mime-info not found, skipping mime.cache test (") + QDir::toNativeSeparators(mimeDir) + QLatin1Char(')'); @@ -888,8 +891,17 @@ void tst_QMimeDatabase::installNewLocalMimeType() QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); checkHasMimeType("text/x-suse-ymp"); - // Now test removing it again (note, this leaves a mostly-empty mime.cache file) + // Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs"). + const QString qmlTestFile = QFINDTESTDATA("test.qml"); + QVERIFY2(!qmlTestFile.isEmpty(), + qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). + arg("test.qml", QDir::currentPath()))); + QCOMPARE(db.mimeTypeForFile(qmlTestFile).name(), + QString::fromLatin1("text/x-qml")); + + // Now test removing the local mimetypes again (note, this leaves a mostly-empty mime.cache file) QFile::remove(destFile); + QFile::remove(destQmlFile); if (!waitAndRunUpdateMimeDatabase(mimeDir)) QSKIP("shared-mime-info not found, skipping mime.cache test"); QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), |