diff options
Diffstat (limited to 'tests/auto/corelib')
13 files changed, 182 insertions, 84 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 42dca7fc66..2b029203e9 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -3255,11 +3255,14 @@ void tst_QFile::objectConstructors() void tst_QFile::caseSensitivity() { -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) +#if defined(Q_OS_WIN) const bool caseSensitive = false; +#elif defined(Q_OS_MAC) + const bool caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); #else const bool caseSensitive = true; #endif + QByteArray testData("a little test"); QString filename("File.txt"); { diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index bcc971bf4b..af2578ac37 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -916,16 +916,6 @@ void tst_QFileInfo::compare_data() QTest::addColumn<QString>("file2"); QTest::addColumn<bool>("same"); -#if defined(Q_OS_MAC) - // Since 10.6 we use realpath() in qfsfileengine, and it properly handles - // file system case sensitivity. However here in the autotest we don't - // check if the file system is case sensitive, so to make it pass in the - // default OS X installation we assume we are running on a case insensitive - // file system if on 10.6 and on a case sensitive file system if on 10.5 - bool caseSensitiveOnMac = true; - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) - caseSensitiveOnMac = false; -#endif QString caseChangedSource = m_sourceFile; caseChangedSource.replace("info", "Info"); @@ -947,7 +937,7 @@ void tst_QFileInfo::compare_data() #if defined(Q_OS_WIN) << true; #elif defined(Q_OS_MAC) - << !caseSensitiveOnMac; + << !pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); #else << false; #endif @@ -955,6 +945,11 @@ void tst_QFileInfo::compare_data() void tst_QFileInfo::compare() { +#if defined(Q_OS_MAC) + if (qstrcmp(QTest::currentDataTag(), "casesense1") == 0) + QSKIP("Qt thinks all UNIX filesystems are case sensitive, see QTBUG-28246"); +#endif + QFETCH(QString, file1); QFETCH(QString, file2); QFETCH(bool, same); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 2756fcce50..4105a43735 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -468,7 +468,12 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); - QCOMPARE(fileChangedSpy.count(), 0); + int fileChangedSpyCount = fileChangedSpy.count(); +#ifdef Q_OS_WIN64 + if (fileChangedSpyCount != 0) + QEXPECT_FAIL("", "See QTBUG-30943", Continue); +#endif + QCOMPARE(fileChangedSpyCount, 0); #ifdef Q_OS_WINCE QEXPECT_FAIL("poller", "Directory does not get updated on file removal(See #137910)", Abort); #endif diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index f2759dfd6e..7a3f6837f8 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -154,6 +154,7 @@ private slots: void invalidProgramString(); void onlyOneStartedSignal(); void finishProcessBeforeReadingDone(); + void waitForStartedWithoutStart(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2214,6 +2215,12 @@ void tst_QProcess::finishProcessBeforeReadingDone() QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number")); } +void tst_QProcess::waitForStartedWithoutStart() +{ + QProcess process; + QVERIFY(!process.waitForStarted(5000)); +} + #endif //QT_NO_PROCESS QTEST_MAIN(tst_QProcess) diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index c2909cf7c5..aec8d1b241 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -513,12 +513,20 @@ void tst_QSettings::ctor() QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp"); if (format == QSettings::NativeFormat) { #if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +# ifdef Q_OS_MACX + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) + QEXPECT_FAIL("native", "See QTBUG-32655", Continue); +# endif // Q_OS_MACX QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); #endif } else { #if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +# ifdef Q_OS_MACX + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) + QEXPECT_FAIL("", "See QTBUG-32655", Continue); +# endif // Q_OS_MACX QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); @@ -3162,6 +3170,10 @@ void tst_QSettings::rainersSyncBugOnMac() { QSettings s3(format, QSettings::UserScope, "software.org", "KillerAPP"); +#ifdef Q_OS_MACX + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) + QEXPECT_FAIL("native", "See QTBUG-32655", Continue); +#endif QCOMPARE(s3.value("key1", 30).toInt(), 25); } } diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro index 2f681c3330..3f726692ff 100644 --- a/tests/auto/corelib/itemmodels/itemmodels.pro +++ b/tests/auto/corelib/itemmodels/itemmodels.pro @@ -1,11 +1,11 @@ TEMPLATE=subdirs SUBDIRS = qabstractitemmodel \ - qstringlistmodel - -qtHaveModule(widgets): SUBDIRS += \ qabstractproxymodel \ qidentityproxymodel \ - qitemmodel \ qitemselectionmodel \ + qstringlistmodel \ + +qtHaveModule(widgets): SUBDIRS += \ + qitemmodel \ qsortfilterproxymodel \ diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro b/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro index 9241676076..1b6279ba1b 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro @@ -1,6 +1,6 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qitemselectionmodel -QT += widgets testlib +QT += testlib SOURCES += tst_qitemselectionmodel.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 8fac2c19eb..9788b78771 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -42,7 +42,6 @@ #include <QtTest/QtTest> #include <QtGui/QtGui> -#include <QtWidgets/QtWidgets> class tst_QItemSelectionModel : public QObject { @@ -1526,22 +1525,21 @@ public: void tst_QItemSelectionModel::resetModel() { MyStandardItemModel model(20, 20); - QTreeView view; - view.setModel(&model); + QItemSelectionModel *selectionModel = new QItemSelectionModel(&model); - QSignalSpy spy(view.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); QVERIFY(spy.isValid()); - view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); + selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); QCOMPARE(spy.count(), 1); model.reset(); - QVERIFY(view.selectionModel()->selection().isEmpty()); - QVERIFY(view.selectionModel()->hasSelection() == false); + QVERIFY(selectionModel->selection().isEmpty()); + QVERIFY(selectionModel->hasSelection() == false); - view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); + selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); QCOMPARE(spy.count(), 2); QCOMPARE(spy.at(1).count(), 2); @@ -1905,22 +1903,20 @@ void tst_QItemSelectionModel::selectedColumns() void tst_QItemSelectionModel::setCurrentIndex() { // Build up a simple tree - QStandardItemModel *treemodel = new QStandardItemModel(0, 1); + QScopedPointer<QStandardItemModel> treemodel(new QStandardItemModel(0, 1)); treemodel->insertRow(0, new QStandardItem(1)); treemodel->insertRow(1, new QStandardItem(2)); - QTreeView treeView; - treeView.setModel(treemodel); - QItemSelectionModel *selectionModel = treeView.selectionModel(); - selectionModel->setCurrentIndex( + QItemSelectionModel selectionModel(treemodel.data()); + selectionModel.setCurrentIndex( treemodel->index(0, 0, treemodel->index(0, 0)), QItemSelectionModel::SelectCurrent); - QSignalSpy currentSpy(selectionModel, + QSignalSpy currentSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex))); - QSignalSpy rowSpy(selectionModel, + QSignalSpy rowSpy(&selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex))); - QSignalSpy columnSpy(selectionModel, + QSignalSpy columnSpy(&selectionModel, SIGNAL(currentColumnChanged(QModelIndex,QModelIndex))); QVERIFY(currentSpy.isValid()); @@ -1928,7 +1924,7 @@ void tst_QItemSelectionModel::setCurrentIndex() QVERIFY(columnSpy.isValid()); // Select the same row and column indexes, but with a different parent - selectionModel->setCurrentIndex( + selectionModel.setCurrentIndex( treemodel->index(0, 0, treemodel->index(1, 0)), QItemSelectionModel::SelectCurrent); @@ -1937,15 +1933,13 @@ void tst_QItemSelectionModel::setCurrentIndex() QCOMPARE(columnSpy.count(), 1); // Select another row in the same parent - selectionModel->setCurrentIndex( + selectionModel.setCurrentIndex( treemodel->index(1, 0, treemodel->index(1, 0)), QItemSelectionModel::SelectCurrent); QCOMPARE(currentSpy.count(), 2); QCOMPARE(rowSpy.count(), 2); QCOMPARE(columnSpy.count(), 1); - - delete treemodel; } void tst_QItemSelectionModel::splitOnInsert() @@ -1960,29 +1954,27 @@ void tst_QItemSelectionModel::splitOnInsert() void tst_QItemSelectionModel::rowIntersectsSelection1() { - QTableWidget table; - table.setColumnCount(1); - table.setRowCount(1); - table.setItem(0, 0, new QTableWidgetItem("foo")); - QAbstractItemModel *model = table.model(); - QItemSelectionModel *selectionModel = table.selectionModel(); - QModelIndex index = model->index(0, 0, QModelIndex()); - - selectionModel->select(index, QItemSelectionModel::Select); - QVERIFY(selectionModel->rowIntersectsSelection(0, QModelIndex())); - QVERIFY(selectionModel->columnIntersectsSelection(0, QModelIndex())); - - selectionModel->select(index, QItemSelectionModel::Deselect); - QVERIFY(!selectionModel->rowIntersectsSelection(0, QModelIndex())); - QVERIFY(!selectionModel->columnIntersectsSelection(0, QModelIndex())); - - selectionModel->select(index, QItemSelectionModel::Toggle); - QVERIFY(selectionModel->rowIntersectsSelection(0, QModelIndex())); - QVERIFY(selectionModel->columnIntersectsSelection(0, QModelIndex())); - - selectionModel->select(index, QItemSelectionModel::Toggle); - QVERIFY(!selectionModel->rowIntersectsSelection(0, QModelIndex())); - QVERIFY(!selectionModel->columnIntersectsSelection(0, QModelIndex())); + QStandardItemModel model; + model.setItem(0, 0, new QStandardItem("foo")); + QItemSelectionModel selectionModel(&model); + + QModelIndex index = model.index(0, 0, QModelIndex()); + + selectionModel.select(index, QItemSelectionModel::Select); + QVERIFY(selectionModel.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(selectionModel.columnIntersectsSelection(0, QModelIndex())); + + selectionModel.select(index, QItemSelectionModel::Deselect); + QVERIFY(!selectionModel.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(!selectionModel.columnIntersectsSelection(0, QModelIndex())); + + selectionModel.select(index, QItemSelectionModel::Toggle); + QVERIFY(selectionModel.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(selectionModel.columnIntersectsSelection(0, QModelIndex())); + + selectionModel.select(index, QItemSelectionModel::Toggle); + QVERIFY(!selectionModel.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(!selectionModel.columnIntersectsSelection(0, QModelIndex())); } void tst_QItemSelectionModel::rowIntersectsSelection2() @@ -2057,16 +2049,21 @@ void tst_QItemSelectionModel::rowIntersectsSelection3() void tst_QItemSelectionModel::unselectable() { - QTreeWidget w; - for (int i = 0; i < 10; ++i) - w.setItemSelected(new QTreeWidgetItem(&w), true); - QCOMPARE(w.topLevelItemCount(), 10); - QCOMPARE(w.selectionModel()->selectedIndexes().count(), 10); - QCOMPARE(w.selectionModel()->selectedRows().count(), 10); + QStandardItemModel model; + QStandardItem *parentItem = model.invisibleRootItem(); + + for (int i = 0; i < 10; ++i) { + QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + parentItem->appendRow(item); + } + QItemSelectionModel selectionModel(&model); + selectionModel.select(QItemSelection(model.index(0, 0), model.index(9, 0)), QItemSelectionModel::Select); + QCOMPARE(selectionModel.selectedIndexes().count(), 10); + QCOMPARE(selectionModel.selectedRows().count(), 10); for (int j = 0; j < 10; ++j) - w.topLevelItem(j)->setFlags(0); - QCOMPARE(w.selectionModel()->selectedIndexes().count(), 0); - QCOMPARE(w.selectionModel()->selectedRows().count(), 0); + model.item(j)->setFlags(0); + QCOMPARE(selectionModel.selectedIndexes().count(), 0); + QCOMPARE(selectionModel.selectedRows().count(), 0); } void tst_QItemSelectionModel::selectedIndexes() diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 78cb4277b2..9111c59408 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1065,6 +1065,8 @@ void tst_QtJson::fromVariantMap() void tst_QtJson::toVariantMap() { + QCOMPARE(QMetaType::Type(QJsonValue(QJsonObject()).toVariant().type()), QMetaType::QVariantMap); // QTBUG-32524 + QJsonObject object; QVariantMap map = object.toVariantMap(); QVERIFY(map.isEmpty()); @@ -1094,6 +1096,8 @@ void tst_QtJson::toVariantMap() void tst_QtJson::toVariantList() { + QCOMPARE(QMetaType::Type(QJsonValue(QJsonArray()).toVariant().type()), QMetaType::QVariantList); // QTBUG-32524 + QJsonArray array; QVariantList list = array.toVariantList(); QVERIFY(list.isEmpty()); diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro index c510052298..e5bcc31e6a 100644 --- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro +++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro @@ -2,7 +2,9 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qeventloop QT = core network testlib core-private -SOURCES = tst_qeventloop.cpp +SOURCES = $$PWD/tst_qeventloop.cpp win32:!wince*:LIBS += -luser32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +contains(QT_CONFIG, glib): DEFINES += HAVE_GLIB diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 73f8365ce5..c6d04e64db 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -46,6 +46,12 @@ #include <qcoreevent.h> #include <qeventloop.h> #include <private/qeventloop_p.h> +#if defined(Q_OS_UNIX) + #include <private/qeventdispatcher_unix_p.h> + #if defined(HAVE_GLIB) + #include <private/qeventdispatcher_glib_p.h> + #endif +#endif #include <qmutex.h> #include <qthread.h> #include <qtimer.h> @@ -159,6 +165,10 @@ public slots: } }; +#ifdef QT_GUI_LIB + #define tst_QEventLoop tst_QGuiEventLoop +#endif + class tst_QEventLoop : public QObject { Q_OBJECT @@ -491,11 +501,19 @@ void tst_QEventLoop::processEventsExcludeTimers() QCOMPARE(timerReceiver.gotTimerEvent, timerId); timerReceiver.gotTimerEvent = -1; - // normal process events will send timers + // but not if we exclude timers eventLoop.processEvents(QEventLoop::X11ExcludeTimers); -#if !defined(Q_OS_UNIX) - QEXPECT_FAIL("", "X11ExcludeTimers only works on UN*X", Continue); + + QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher(); +#if defined(Q_OS_UNIX) + if (!qobject_cast<QEventDispatcherUNIX *>(eventDispatcher) + #if defined(HAVE_GLIB) + && !qobject_cast<QEventDispatcherGlib *>(eventDispatcher) + #endif + ) #endif + QEXPECT_FAIL("", "X11ExcludeTimers only supported in the UNIX/Glib dispatchers", Continue); + QCOMPARE(timerReceiver.gotTimerEvent, -1); timerReceiver.gotTimerEvent = -1; @@ -580,7 +598,7 @@ class JobObject : public QObject public: explicit JobObject(QEventLoop *loop, QObject *parent = 0) - : QObject(parent), loop(loop), locker(loop) + : QObject(parent), locker(loop) { } @@ -606,7 +624,6 @@ signals: void done(); private: - QEventLoop *loop; QEventLoopLocker locker; }; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 9bf28430b0..8d1ea3b510 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5727,27 +5727,44 @@ void tst_QObject::connectFunctorOverloads() #endif } +class GetSenderObject : public QObject +{ + Q_OBJECT +public: + QObject *accessSender() { return sender(); } + +public Q_SLOTS: + void triggerSignal() { Q_EMIT aSignal(); } + +Q_SIGNALS: + void aSignal(); +}; + static int countedStructObjectsCount = 0; struct CountedStruct { - CountedStruct() { ++countedStructObjectsCount; } - CountedStruct(const CountedStruct &) { ++countedStructObjectsCount; } + CountedStruct() : sender(Q_NULLPTR) { ++countedStructObjectsCount; } + CountedStruct(GetSenderObject *sender) : sender(sender) { ++countedStructObjectsCount; } + CountedStruct(const CountedStruct &o) : sender(o.sender) { ++countedStructObjectsCount; } CountedStruct &operator=(const CountedStruct &) { return *this; } - ~CountedStruct() { --countedStructObjectsCount; } - void operator()() const {} + // accessSender here allows us to check if there's a deadlock + ~CountedStruct() { --countedStructObjectsCount; if (sender != Q_NULLPTR) (void)sender->accessSender(); } + void operator()() const { } + + GetSenderObject *sender; }; void tst_QObject::disconnectDoesNotLeakFunctor() { QCOMPARE(countedStructObjectsCount, 0); { + GetSenderObject obj; QMetaObject::Connection c; { - CountedStruct s; + CountedStruct s(&obj); QCOMPARE(countedStructObjectsCount, 1); - QTimer timer; - c = connect(&timer, &QTimer::timeout, s); + c = connect(&obj, &GetSenderObject::aSignal, s); QVERIFY(c); QCOMPARE(countedStructObjectsCount, 2); QVERIFY(QObject::disconnect(c)); @@ -5798,6 +5815,33 @@ void tst_QObject::disconnectDoesNotLeakFunctor() } QCOMPARE(countedStructObjectsCount, 0); { + QTimer *timer = new QTimer; + QEventLoop e; + + connect(timer, &QTimer::timeout, CountedStruct()); + QCOMPARE(countedStructObjectsCount, 1); // only one instance, in Qt internals + timer->deleteLater(); + connect(timer, &QObject::destroyed, &e, &QEventLoop::quit, Qt::QueuedConnection); + e.exec(); + QCOMPARE(countedStructObjectsCount, 0); // functor being destroyed + } + QCOMPARE(countedStructObjectsCount, 0); + { + GetSenderObject obj; + + connect(&obj, &GetSenderObject::aSignal, CountedStruct(&obj)); + QCOMPARE(countedStructObjectsCount, 1); + } + QCOMPARE(countedStructObjectsCount, 0); + { + GetSenderObject obj; + + connect(&obj, &GetSenderObject::aSignal, CountedStruct(&obj)); + QCOMPARE(countedStructObjectsCount, 1); + QObject::disconnect(&obj, &GetSenderObject::aSignal, 0, 0); + } + QCOMPARE(countedStructObjectsCount, 0); + { #if defined(Q_COMPILER_LAMBDA) CountedStruct s; QCOMPARE(countedStructObjectsCount, 1); 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(), |