OpenCoverage

qmimedatabase.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12namespace { namespace Q_QGS_staticQMimeDatabase { typedef QMimeDatabasePrivate Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEevaluated 25 times by 25 tests
Evaluated by:
  • tst_languagechange - unknown status
  • tst_qaccessibility - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcombobox - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdebug - unknown status
  • tst_qfiledialog - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileiconprovider - unknown status
  • tst_qfilesystemmodel - unknown status
  • tst_qfontcombobox - unknown status
  • tst_qgraphicsproxywidget - unknown status
  • tst_qgraphicswidget - unknown status
  • tst_qguiapplication - unknown status
  • tst_qguivariant - unknown status
  • tst_qicon - unknown status
  • tst_qmimedatabase-cache - unknown status
  • tst_qmimedatabase-xml - unknown status
  • tst_qmimetype - unknown status
  • tst_qprinter - unknown status
  • tst_qsidebar - unknown status
  • tst_qstyle - unknown status
  • tst_qsystemtrayicon - unknown status
  • tst_qtoolbutton - unknown status
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
executed 25 times by 25 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_languagechange - unknown status
  • tst_qaccessibility - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcombobox - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdebug - unknown status
  • tst_qfiledialog - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileiconprovider - unknown status
  • tst_qfilesystemmodel - unknown status
  • tst_qfontcombobox - unknown status
  • tst_qgraphicsproxywidget - unknown status
  • tst_qgraphicswidget - unknown status
  • tst_qguiapplication - unknown status
  • tst_qguivariant - unknown status
  • tst_qicon - unknown status
  • tst_qmimedatabase-cache - unknown status
  • tst_qmimedatabase-xml - unknown status
  • tst_qmimetype - unknown status
  • tst_qprinter - unknown status
  • tst_qsidebar - unknown status
  • tst_qstyle - unknown status
  • tst_qsystemtrayicon - unknown status
  • tst_qtoolbutton - unknown status
}
executed 25 times by 25 tests: end of block
Executed by:
  • tst_languagechange - unknown status
  • tst_qaccessibility - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcombobox - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdebug - unknown status
  • tst_qfiledialog - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileiconprovider - unknown status
  • tst_qfilesystemmodel - unknown status
  • tst_qfontcombobox - unknown status
  • tst_qgraphicsproxywidget - unknown status
  • tst_qgraphicswidget - unknown status
  • tst_qguiapplication - unknown status
  • tst_qguivariant - unknown status
  • tst_qicon - unknown status
  • tst_qmimedatabase-cache - unknown status
  • tst_qmimedatabase-xml - unknown status
  • tst_qmimetype - unknown status
  • tst_qprinter - unknown status
  • tst_qsidebar - unknown status
  • tst_qstyle - unknown status
  • tst_qsystemtrayicon - unknown status
  • tst_qtoolbutton - unknown status
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
executed 5209 times by 24 tests: return &holder.value;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
&holder.value;
executed 5209 times by 24 tests: return &holder.value;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
} } } static QGlobalStatic<QMimeDatabasePrivate, Q_QGS_staticQMimeDatabase::innerFunction, Q_QGS_staticQMimeDatabase::guard> staticQMimeDatabase;
0-5209
13-
14QMimeDatabasePrivate *QMimeDatabasePrivate::instance()-
15{-
16 return
executed 2635 times by 23 tests: return staticQMimeDatabase();
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
staticQMimeDatabase();
executed 2635 times by 23 tests: return staticQMimeDatabase();
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
2635
17}-
18-
19QMimeDatabasePrivate::QMimeDatabasePrivate()-
20 : m_provider(0), m_defaultMimeType(QLatin1String("application/octet-stream"))-
21{-
22}
executed 25 times by 24 tests: end of block
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
25
23-
24QMimeDatabasePrivate::~QMimeDatabasePrivate()-
25{-
26 delete m_provider;-
27 m_provider = 0;-
28}
executed 25 times by 25 tests: end of block
Executed by:
  • tst_languagechange - unknown status
  • tst_qaccessibility - unknown status
  • tst_qcalendarwidget - unknown status
  • tst_qcombobox - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatetimeedit - unknown status
  • tst_qdebug - unknown status
  • tst_qfiledialog - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileiconprovider - unknown status
  • tst_qfilesystemmodel - unknown status
  • tst_qfontcombobox - unknown status
  • tst_qgraphicsproxywidget - unknown status
  • tst_qgraphicswidget - unknown status
  • tst_qguiapplication - unknown status
  • tst_qguivariant - unknown status
  • tst_qicon - unknown status
  • tst_qmimedatabase-cache - unknown status
  • tst_qmimedatabase-xml - unknown status
  • tst_qmimetype - unknown status
  • tst_qprinter - unknown status
  • tst_qsidebar - unknown status
  • tst_qstyle - unknown status
  • tst_qsystemtrayicon - unknown status
  • tst_qtoolbutton - unknown status
25
29-
30QMimeProviderBase *QMimeDatabasePrivate::provider()-
31{-
32 if (!m_provider
!m_providerDescription
TRUEevaluated 25 times by 24 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
FALSEevaluated 18819 times by 24 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
) {
25-18819
33 QMimeProviderBase *binaryProvider = new QMimeBinaryProvider(this);-
34 if (binaryProvider->isValid()
binaryProvider->isValid()Description
TRUEevaluated 23 times by 23 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qmimetype
) {
2-23
35 m_provider = binaryProvider;-
36 }
executed 23 times by 23 tests: end of block
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
else {
23
37 delete binaryProvider;-
38 m_provider = new QMimeXMLProvider(this);-
39 }
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
2
40 }-
41 return
executed 18844 times by 24 tests: return m_provider;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
m_provider;
executed 18844 times by 24 tests: return m_provider;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
  • tst_qmimetype
18844
42}-
43-
44void QMimeDatabasePrivate::setProvider(QMimeProviderBase *theProvider)-
45{-
46 delete m_provider;-
47 m_provider = theProvider;-
48}
never executed: end of block
0
49-
50-
51-
52-
53-
54QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias)-
55{-
56 return
executed 6732 times by 23 tests: return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));
executed 6732 times by 23 tests: return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
6732
57}-
58-
59QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName, QString *foundSuffix)-
60{-
61 if (fileName.endsWith(QLatin1Char('/'))
fileName.endsW...tin1Char('/'))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 2621 times by 22 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
)
4-2621
62 return
executed 4 times by 1 test: return QStringList() << QLatin1String("inode/directory");
Executed by:
  • tst_QMimeDatabase
QStringList() << QLatin1String("inode/directory");
executed 4 times by 1 test: return QStringList() << QLatin1String("inode/directory");
Executed by:
  • tst_QMimeDatabase
4
63-
64 QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix);-
65 matchingMimeTypes.sort();-
66 return
executed 2621 times by 22 tests: return matchingMimeTypes;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
matchingMimeTypes;
executed 2621 times by 22 tests: return matchingMimeTypes;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2621
67}-
68-
69static inline bool isTextFile(const QByteArray &data)-
70{-
71-
72 static const char bigEndianBOM[] = "\xFE\xFF";-
73 static const char littleEndianBOM[] = "\xFF\xFE";-
74 if (data.startsWith(bigEndianBOM)
data.startsWith(bigEndianBOM)Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
|| data.startsWith(littleEndianBOM)
data.startsWit...ttleEndianBOM)Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-18
75 return
never executed: return true;
true;
never executed: return true;
0
76-
77-
78 const char *p = data.constData();-
79 const char *e = p + qMin(32, data.size());-
80 for ( ; p < e
p < eDescription
TRUEevaluated 138 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++p) {
12-138
81 if ((
(unsigned char)(*p) < 32Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 132 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
unsigned char)(*p) < 32
(unsigned char)(*p) < 32Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 132 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
&& *
*p != 9Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
p != 9
*p != 9Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& *
*p !=10Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
p !=10
*p !=10Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& *
*p != 13Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
p != 13
*p != 13Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-132
82 return
executed 6 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 6 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
6
83 }
executed 132 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
132
84-
85 return
executed 12 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 12 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
12
86}-
87-
88QMimeType QMimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr)-
89{-
90 if (data.isEmpty()
data.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-64
91 *accuracyPtr = 100;-
92 return
never executed: return mimeTypeForName(QLatin1String("application/x-zerosize"));
mimeTypeForName(QLatin1String("application/x-zerosize"));
never executed: return mimeTypeForName(QLatin1String("application/x-zerosize"));
0
93 }-
94-
95 *accuracyPtr = 0;-
96 QMimeType candidate = provider()->findByMagic(data, accuracyPtr);-
97-
98 if (candidate.isValid()
candidate.isValid()Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
18-46
99 return
executed 46 times by 1 test: return candidate;
Executed by:
  • tst_QMimeDatabase
candidate;
executed 46 times by 1 test: return candidate;
Executed by:
  • tst_QMimeDatabase
46
100-
101 if (isTextFile(data)
isTextFile(data)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
6-12
102 *accuracyPtr = 5;-
103 return
executed 12 times by 1 test: return mimeTypeForName(QLatin1String("text/plain"));
Executed by:
  • tst_QMimeDatabase
mimeTypeForName(QLatin1String("text/plain"));
executed 12 times by 1 test: return mimeTypeForName(QLatin1String("text/plain"));
Executed by:
  • tst_QMimeDatabase
12
104 }-
105-
106 return
executed 6 times by 1 test: return mimeTypeForName(defaultMimeType());
Executed by:
  • tst_QMimeDatabase
mimeTypeForName(defaultMimeType());
executed 6 times by 1 test: return mimeTypeForName(defaultMimeType());
Executed by:
  • tst_QMimeDatabase
6
107}-
108-
109QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *accuracyPtr)-
110{-
111-
112-
113-
114-
115-
116 *accuracyPtr = 0;-
117-
118-
119 QStringList candidatesByName = mimeTypeForFileName(fileName);-
120 if (candidatesByName.count() == 1
candidatesByName.count() == 1Description
TRUEevaluated 2453 times by 21 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
FALSEevaluated 34 times by 3 tests
Evaluated by:
  • tst_QGraphicsWidget
  • tst_QIcon
  • tst_QMimeDatabase
) {
34-2453
121 *accuracyPtr = 100;-
122 const QMimeType mime = mimeTypeForName(candidatesByName.at(0));-
123 if (mime.isValid()
mime.isValid()Description
TRUEevaluated 2453 times by 21 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
FALSEnever evaluated
)
0-2453
124 return
executed 2453 times by 21 tests: return mime;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
mime;
executed 2453 times by 21 tests: return mime;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2453
125 candidatesByName.clear();-
126 }
never executed: end of block
0
127-
128-
129-
130 if (device->isOpen()
device->isOpen()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 8 times by 3 tests
Evaluated by:
  • tst_QGraphicsWidget
  • tst_QIcon
  • tst_QMimeDatabase
) {
8-26
131-
132-
133-
134 const QByteArray data = device->peek(16384);-
135-
136 int magicAccuracy = 0;-
137 QMimeType candidateByData(findByData(data, &magicAccuracy));-
138-
139-
140 if (candidateByData.isValid()
candidateByData.isValid()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& magicAccuracy > 0
magicAccuracy > 0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-26
141-
142-
143 const QString sniffedMime = candidateByData.name();-
144 for (const QString &m : qAsConst(candidatesByName)) {-
145 if (inherits(m, sniffedMime)
inherits(m, sniffedMime)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
146-
147 *accuracyPtr = 100;-
148 return
never executed: return mimeTypeForName(m);
mimeTypeForName(m);
never executed: return mimeTypeForName(m);
0
149 }-
150 }
never executed: end of block
0
151 *accuracyPtr = magicAccuracy;-
152 return
executed 26 times by 1 test: return candidateByData;
Executed by:
  • tst_QMimeDatabase
candidateByData;
executed 26 times by 1 test: return candidateByData;
Executed by:
  • tst_QMimeDatabase
26
153 }-
154 }
never executed: end of block
0
155-
156 if (candidatesByName.count() > 1
candidatesByName.count() > 1Description
TRUEnever evaluated
FALSEevaluated 8 times by 3 tests
Evaluated by:
  • tst_QGraphicsWidget
  • tst_QIcon
  • tst_QMimeDatabase
) {
0-8
157 *accuracyPtr = 20;-
158 const QMimeType mime = mimeTypeForName(candidatesByName.at(0));-
159 if (mime.isValid()
mime.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
160 return
never executed: return mime;
mime;
never executed: return mime;
0
161 }
never executed: end of block
0
162-
163 return
executed 8 times by 3 tests: return mimeTypeForName(defaultMimeType());
Executed by:
  • tst_QGraphicsWidget
  • tst_QIcon
  • tst_QMimeDatabase
mimeTypeForName(defaultMimeType());
executed 8 times by 3 tests: return mimeTypeForName(defaultMimeType());
Executed by:
  • tst_QGraphicsWidget
  • tst_QIcon
  • tst_QMimeDatabase
8
164}-
165-
166QList<QMimeType> QMimeDatabasePrivate::allMimeTypes()-
167{-
168 return
executed 10 times by 1 test: return provider()->allMimeTypes();
Executed by:
  • tst_QMimeDatabase
provider()->allMimeTypes();
executed 10 times by 1 test: return provider()->allMimeTypes();
Executed by:
  • tst_QMimeDatabase
10
169}-
170-
171bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent)-
172{-
173 const QString resolvedParent = provider()->resolveAlias(parent);-
174-
175 std::stack<QString, QStringList> toCheck;-
176 toCheck.push(mime);-
177 while (!toCheck.empty()
!toCheck.empty()Description
TRUEevaluated 116 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
4-116
178 if (toCheck.top() == resolvedParent
toCheck.top() ...resolvedParentDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
48-68
179 return
executed 48 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 48 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
48
180 const auto parents = provider()->parents(toCheck.top());-
181 toCheck.pop();-
182 for (const QString &par : parents)-
183 toCheck.push(par);
executed 68 times by 1 test: toCheck.push(par);
Executed by:
  • tst_QMimeDatabase
68
184 }
executed 68 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
68
185 return
executed 4 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
4
186}-
187QMimeDatabase::QMimeDatabase() :-
188 d(staticQMimeDatabase())-
189{-
190}
executed 2574 times by 23 tests: end of block
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2574
191-
192-
193-
194-
195-
196QMimeDatabase::~QMimeDatabase()-
197{-
198 d = 0;-
199}
executed 2574 times by 23 tests: end of block
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2574
200-
201-
202-
203-
204-
205QMimeType QMimeDatabase::mimeTypeForName(const QString &nameOrAlias) const-
206{-
207 QMutexLocker locker(&d->mutex);-
208-
209 return
executed 4121 times by 2 tests: return d->mimeTypeForName(nameOrAlias);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
d->mimeTypeForName(nameOrAlias);
executed 4121 times by 2 tests: return d->mimeTypeForName(nameOrAlias);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4121
210}-
211QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const-
212{-
213 QMutexLocker locker(&d->mutex);-
214-
215 if (fileInfo.isDir()
fileInfo.isDir()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 2465 times by 22 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
)
4-2465
216 return
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/directory"));
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForName(QLatin1String("inode/directory"));
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/directory"));
Executed by:
  • tst_QMimeDatabase
4
217-
218 QFile file(fileInfo.absoluteFilePath());-
219-
220-
221-
222-
223 const QByteArray nativeFilePath = QFile::encodeName(file.fileName());-
224 struct stat64 statBuffer;-
225 if (::
::stat64(nativ...atBuffer) == 0Description
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
FALSEevaluated 2425 times by 22 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
stat64(nativeFilePath.constData(), &statBuffer) == 0
::stat64(nativ...atBuffer) == 0Description
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
FALSEevaluated 2425 times by 22 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
) {
40-2425
226 if (((((
((((statBuffer... == (0020000))Description
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
statBuffer.st_mode)) & 0170000) == (0020000))
((((statBuffer... == (0020000))Description
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
)
0-40
227 return
never executed: return d->mimeTypeForName(QLatin1String("inode/chardevice"));
d->mimeTypeForName(QLatin1String("inode/chardevice"));
never executed: return d->mimeTypeForName(QLatin1String("inode/chardevice"));
0
228 if (((((
((((statBuffer... == (0060000))Description
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
statBuffer.st_mode)) & 0170000) == (0060000))
((((statBuffer... == (0060000))Description
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
)
0-40
229 return
never executed: return d->mimeTypeForName(QLatin1String("inode/blockdevice"));
d->mimeTypeForName(QLatin1String("inode/blockdevice"));
never executed: return d->mimeTypeForName(QLatin1String("inode/blockdevice"));
0
230 if (((((
((((statBuffer... == (0010000))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 36 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
statBuffer.st_mode)) & 0170000) == (0010000))
((((statBuffer... == (0010000))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 36 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
)
4-36
231 return
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/fifo"));
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForName(QLatin1String("inode/fifo"));
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/fifo"));
Executed by:
  • tst_QMimeDatabase
4
232 if (((((
((((statBuffer... == (0140000))Description
TRUEnever evaluated
FALSEevaluated 36 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
statBuffer.st_mode)) & 0170000) == (0140000))
((((statBuffer... == (0140000))Description
TRUEnever evaluated
FALSEevaluated 36 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
)
0-36
233 return
never executed: return d->mimeTypeForName(QLatin1String("inode/socket"));
d->mimeTypeForName(QLatin1String("inode/socket"));
never executed: return d->mimeTypeForName(QLatin1String("inode/socket"));
0
234 }
executed 36 times by 3 tests: end of block
Executed by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QSystemTrayIcon
36
235-
236-
237 int priority = 0;-
238 switch (mode) {-
239 case
executed 2457 times by 22 tests: case MatchDefault:
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
MatchDefault:
executed 2457 times by 22 tests: case MatchDefault:
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2457
240 file.open(QIODevice::ReadOnly);-
241 return
executed 2457 times by 22 tests: return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
executed 2457 times by 22 tests: return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSidebar
  • tst_QStyle
  • tst_QSystemTrayIcon
  • tst_QToolButton
  • tst_languageChange
2457
242 case
never executed: case MatchExtension:
MatchExtension:
never executed: case MatchExtension:
0
243 locker.unlock();-
244 return
never executed: return mimeTypeForFile(fileInfo.absoluteFilePath(), mode);
mimeTypeForFile(fileInfo.absoluteFilePath(), mode);
never executed: return mimeTypeForFile(fileInfo.absoluteFilePath(), mode);
0
245 case
executed 4 times by 1 test: case MatchContent:
Executed by:
  • tst_QMimeDatabase
MatchContent:
executed 4 times by 1 test: case MatchContent:
Executed by:
  • tst_QMimeDatabase
4
246 if (file.open(QIODevice::ReadOnly)
file.open(QIODevice::ReadOnly)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-4
247 locker.unlock();-
248 return
executed 4 times by 1 test: return mimeTypeForData(&file);
Executed by:
  • tst_QMimeDatabase
mimeTypeForData(&file);
executed 4 times by 1 test: return mimeTypeForData(&file);
Executed by:
  • tst_QMimeDatabase
4
249 } else {-
250 return
never executed: return d->mimeTypeForName(d->defaultMimeType());
d->mimeTypeForName(d->defaultMimeType());
never executed: return d->mimeTypeForName(d->defaultMimeType());
0
251 }-
252 default
never executed: default:
:
never executed: default:
0
253 ((!(false)) ? qt_assert("false",__FILE__,395) : qt_noop());-
254 }
never executed: end of block
0
255 return
never executed: return d->mimeTypeForName(d->defaultMimeType());
d->mimeTypeForName(d->defaultMimeType());
never executed: return d->mimeTypeForName(d->defaultMimeType());
0
256}-
257-
258-
259-
260-
261-
262-
263QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode) const-
264{-
265 if (mode == MatchExtension
mode == MatchExtensionDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
40-68
266 QMutexLocker locker(&d->mutex);-
267 const QStringList matches = d->mimeTypeForFileName(fileName);-
268 const int matchCount = matches.count();-
269 if (matchCount == 0
matchCount == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
16-52
270 return
executed 16 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForName(d->defaultMimeType());
executed 16 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
16
271 } else if (matchCount == 1
matchCount == 1Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-52
272 return
executed 52 times by 1 test: return d->mimeTypeForName(matches.first());
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForName(matches.first());
executed 52 times by 1 test: return d->mimeTypeForName(matches.first());
Executed by:
  • tst_QMimeDatabase
52
273 } else {-
274-
275 return
never executed: return d->mimeTypeForName(matches.first());
d->mimeTypeForName(matches.first());
never executed: return d->mimeTypeForName(matches.first());
0
276 }-
277 } else {-
278-
279 QFileInfo fileInfo(fileName);-
280 return
executed 40 times by 1 test: return mimeTypeForFile(fileInfo, mode);
Executed by:
  • tst_QMimeDatabase
mimeTypeForFile(fileInfo, mode);
executed 40 times by 1 test: return mimeTypeForFile(fileInfo, mode);
Executed by:
  • tst_QMimeDatabase
40
281 }-
282}-
283QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) const-
284{-
285 QMutexLocker locker(&d->mutex);-
286-
287 const QStringList matches = d->mimeTypeForFileName(fileName);-
288 QList<QMimeType> mimes;-
289 mimes.reserve(matches.count());-
290 for (const QString &mime : matches)-
291 mimes.append(d->mimeTypeForName(mime));
executed 52 times by 1 test: mimes.append(d->mimeTypeForName(mime));
Executed by:
  • tst_QMimeDatabase
52
292 return
executed 54 times by 1 test: return mimes;
Executed by:
  • tst_QMimeDatabase
mimes;
executed 54 times by 1 test: return mimes;
Executed by:
  • tst_QMimeDatabase
54
293}-
294-
295-
296-
297-
298-
299-
300QString QMimeDatabase::suffixForFileName(const QString &fileName) const-
301{-
302 QMutexLocker locker(&d->mutex);-
303 QString foundSuffix;-
304 d->mimeTypeForFileName(fileName, &foundSuffix);-
305 return
executed 16 times by 1 test: return foundSuffix;
Executed by:
  • tst_QMimeDatabase
foundSuffix;
executed 16 times by 1 test: return foundSuffix;
Executed by:
  • tst_QMimeDatabase
16
306}-
307QMimeType QMimeDatabase::mimeTypeForData(const QByteArray &data) const-
308{-
309 QMutexLocker locker(&d->mutex);-
310-
311 int accuracy = 0;-
312 return
executed 10 times by 1 test: return d->findByData(data, &accuracy);
Executed by:
  • tst_QMimeDatabase
d->findByData(data, &accuracy);
executed 10 times by 1 test: return d->findByData(data, &accuracy);
Executed by:
  • tst_QMimeDatabase
10
313}-
314QMimeType QMimeDatabase::mimeTypeForData(QIODevice *device) const-
315{-
316 QMutexLocker locker(&d->mutex);-
317-
318 int accuracy = 0;-
319 const bool openedByUs = !device->isOpen()
!device->isOpen()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
&& device->open(QIODevice::ReadOnly)
device->open(Q...ice::ReadOnly)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
;
4-18
320 if (device->isOpen()
device->isOpen()Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
4-28
321-
322-
323 const QByteArray data = device->peek(16384);-
324 const QMimeType result = d->findByData(data, &accuracy);-
325 if (openedByUs
openedByUsDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
14
326 device->close();
executed 14 times by 1 test: device->close();
Executed by:
  • tst_QMimeDatabase
14
327 return
executed 28 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 28 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
28
328 }-
329 return
executed 4 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForName(d->defaultMimeType());
executed 4 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
4
330}-
331QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const-
332{-
333 if (url.isLocalFile()
url.isLocalFile()Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-10
334 return
never executed: return mimeTypeForFile(url.toLocalFile());
mimeTypeForFile(url.toLocalFile());
never executed: return mimeTypeForFile(url.toLocalFile());
0
335-
336 const QString scheme = url.scheme();-
337 if (scheme.startsWith(QLatin1String("http"))
scheme.startsW...tring("http"))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
|| scheme == QLatin1String("mailto")
scheme == QLat...ring("mailto")Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
2-8
338 return
executed 6 times by 1 test: return mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
mimeTypeForName(d->defaultMimeType());
executed 6 times by 1 test: return mimeTypeForName(d->defaultMimeType());
Executed by:
  • tst_QMimeDatabase
6
339-
340 return
executed 4 times by 1 test: return mimeTypeForFile(url.path());
Executed by:
  • tst_QMimeDatabase
mimeTypeForFile(url.path());
executed 4 times by 1 test: return mimeTypeForFile(url.path());
Executed by:
  • tst_QMimeDatabase
4
341}-
342QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const-
343{-
344 int accuracy = 0;-
345 const bool openedByUs = !device->isOpen()
!device->isOpen()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
&& device->open(QIODevice::ReadOnly)
device->open(Q...ice::ReadOnly)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
;
0-10
346 const QMimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy);-
347 if (openedByUs
openedByUsDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
10
348 device->close();
executed 10 times by 1 test: device->close();
Executed by:
  • tst_QMimeDatabase
10
349 return
executed 20 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 20 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
20
350}-
351QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const-
352{-
353 QBuffer buffer(const_cast<QByteArray *>(&data));-
354 buffer.open(QIODevice::ReadOnly);-
355 int accuracy = 0;-
356 return
executed 10 times by 1 test: return d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);
Executed by:
  • tst_QMimeDatabase
d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);
executed 10 times by 1 test: return d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);
Executed by:
  • tst_QMimeDatabase
10
357}-
358QList<QMimeType> QMimeDatabase::allMimeTypes() const-
359{-
360 QMutexLocker locker(&d->mutex);-
361-
362 return
executed 10 times by 1 test: return d->allMimeTypes();
Executed by:
  • tst_QMimeDatabase
d->allMimeTypes();
executed 10 times by 1 test: return d->allMimeTypes();
Executed by:
  • tst_QMimeDatabase
10
363}-
364-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9