Commit 28aa00b6 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

Fix detection of .kexi file types after recent change of mime database on...

Fix detection of .kexi file types after recent change of mime database on Linux for SQLite type (2018-06-17)

Details: Add application/vnd.sqlite3 and application/x-vnd.kde.kexi to be sure everything is catch while detecting .kexi file types.
The change is apparently needed after this commit:

https://cgit.freedesktop.org/xdg/shared-mime-info/commit/freedesktop.org.xml.in?id=36a88b01f6ae90da35a2f6a072db159c84cea768

From https://cgit.freedesktop.org/xdg/shared-mime-info/tree/freedesktop.org.xml.in:
it's apparent that .kexi mime type still inherits from application/x-sqlite3 which is now only an alias:


<mime-type type="application/x-kexiproject-sqlite3">
    <_comment>Kexi database file-based project</_comment>
    <sub-class-of type="application/x-sqlite3"/>
    <glob pattern="*.kexi"/>
    <alias type="application/x-vnd.kde.kexi"/>

Also update the driver's autotest.

BUG:396999
FIXED-IN:3.2.0

Big thanks to therapon@netzero.com for extensive testing!

CCMAIL:therapon@netzero.com
CCMAIL:ville.skytta@iki.fi
CCMAIL:hadess@hadess.net
CCMAIL:teuf@gnome.org
parent 32639dc8
......@@ -95,6 +95,21 @@ KDBTESTUTILS_EXPORT bool qCompare(const QString &val1, const KDbEscapedString &v
toString(val1), toString(qPrintable(val2.toString())),
actual, expected, file, line);
}
static char *toString(const QStringList &list)
{
return toString(qPrintable(QStringLiteral("QStringList(%1)").arg(list.join(", "))));
}
KDBTESTUTILS_EXPORT bool qCompare(const QStringList &val1, const QStringList &val2,
const char *actual, const char *expected, const char *file,
int line)
{
return val1 == val2 ? compare_helper(true, "COMPARE()", toString(val1), toString(val2), actual,
expected, file, line)
: compare_helper(false, "Compared values are not the same", toString(val1),
toString(val2), actual, expected, file, line);
}
}
class KDbTestUtils::Private {
......@@ -197,7 +212,8 @@ void KDbTestUtils::testDriverManagerInternal()
testDriverManagerInternal(false);
}
void KDbTestUtils::testDriver(const QString &driverId, bool fileBased, const QStringList &mimeTypes)
void KDbTestUtils::testDriver(const QString &driverId, bool fileBased, const QStringList &mimeTypes,
const QStringList &possiblyInvalidMimeTypes)
{
// find the metadata
const KDbDriverMetaData* driverMetaData;
......@@ -214,8 +230,14 @@ void KDbTestUtils::testDriver(const QString &driverId, bool fileBased, const QSt
QVERIFY(!KDb::defaultFileBasedDriverMimeType().isEmpty());
QMimeDatabase mimeDb;
foreach(const QString &mimeName, expectedMimeTypes) {
QVERIFY2(mimeDb.mimeTypeForName(mimeName).isValid(),
qPrintable(QString("%1 MIME type not found in the MIME database").arg(mimeName)));
if (!mimeDb.mimeTypeForName(mimeName).isValid()) {
const QString msg = QStringLiteral("%1 MIME type not found in the MIME database").arg(mimeName);
if (possiblyInvalidMimeTypes.contains(mimeName)) {
qInfo() << qPrintable(msg);
} else {
QVERIFY2(mimeDb.mimeTypeForName(mimeName).isValid(), qPrintable(msg));
}
}
}
// find driver for the metadata
KDB_VERIFY(manager.resultable(), driver = manager.driver(driverId), "Driver not found");
......@@ -223,12 +245,12 @@ void KDbTestUtils::testDriver(const QString &driverId, bool fileBased, const QSt
void KDbTestUtils::testSqliteDriverInternal()
{
QStringList mimeTypes;
mimeTypes << "application/x-kexiproject-sqlite3" << "application/x-sqlite3";
testDriver("org.kde.kdb.sqlite",
true, // file-based
mimeTypes);
QVERIFY2(mimeTypes.contains(KDb::defaultFileBasedDriverMimeType()), "SQLite's MIME types should include the default file based one");
const QStringList mimeTypes { "application/x-kexiproject-sqlite3", "application/x-sqlite3",
"application/x-vnd.kde.kexi", "application/vnd.sqlite3" };
const QStringList possiblyInvalidMimeTypes { "application/vnd.sqlite3" };
testDriver("org.kde.kdb.sqlite", true /* file-based */, mimeTypes, possiblyInvalidMimeTypes);
QVERIFY2(mimeTypes.contains(KDb::defaultFileBasedDriverMimeType()),
"SQLite's MIME types should include the default file based one");
}
void KDbTestUtils::testConnectInternal(const KDbConnectionData &cdata,
......
......@@ -75,6 +75,10 @@ KDBTESTUTILS_EXPORT bool qCompare(const KDbEscapedString &val1, const QString &v
KDBTESTUTILS_EXPORT bool qCompare(const QString &val1, const KDbEscapedString &val2,
const char *actual, const char *expected, const char *file,
int line);
KDBTESTUTILS_EXPORT bool qCompare(const QStringList &val1, const QStringList &val2,
const char *actual, const char *expected, const char *file,
int line);
}
//! Calls @a call and verifies status of @a resultable
......@@ -191,7 +195,8 @@ public:
protected:
void testDisconnectPrivate();
void testDriver(const QString &driverId, bool fileBased, const QStringList &mimeTypes);
void testDriver(const QString &driverId, bool fileBased, const QStringList &mimeTypes,
const QStringList &possiblyInvalidMimeTypes);
void testDriverManagerInternal(bool forceEmpty);
private:
......
......@@ -64,7 +64,9 @@
"License": "LGPL",
"MimeTypes": [
"application/x-kexiproject-sqlite3",
"application/x-sqlite3"
"application/x-sqlite3",
"application/x-vnd.kde.kexi",
"application/vnd.sqlite3"
],
"Name": "SQLite",
"Name[ast]": "SQLite",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment