OpenCoverage

qfilesystemwatcher.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfilesystemwatcher.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)-
21{-
22-
23-
24-
25-
26-
27 return
executed 355 times by 10 tests: return QInotifyFileSystemWatcherEngine::create(parent);
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
QInotifyFileSystemWatcherEngine::create(parent);
executed 355 times by 10 tests: return QInotifyFileSystemWatcherEngine::create(parent);
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
28}-
29-
30QFileSystemWatcherPrivate::QFileSystemWatcherPrivate()-
31 : native(0), poller(0)-
32{-
33}
executed 355 times by 10 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
34-
35void QFileSystemWatcherPrivate::init()-
36{-
37 QFileSystemWatcher * const q = q_func();-
38 native = createNativeEngine(q);-
39 if (native
nativeDescription
TRUEevaluated 355 times by 10 tests
Evaluated by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
FALSEnever evaluated
) {
0-355
40 QObject::connect(native,-
41 qFlagLocation("2""fileChanged(QString,bool)" "\0" __FILE__ ":" "98"),-
42 q,-
43 qFlagLocation("1""_q_fileChanged(QString,bool)" "\0" __FILE__ ":" "100"));-
44 QObject::connect(native,-
45 qFlagLocation("2""directoryChanged(QString,bool)" "\0" __FILE__ ":" "102"),-
46 q,-
47 qFlagLocation("1""_q_directoryChanged(QString,bool)" "\0" __FILE__ ":" "104"));-
48 }
executed 355 times by 10 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
49}
executed 355 times by 10 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
50-
51void QFileSystemWatcherPrivate::initPollerEngine()-
52{-
53 if(poller
pollerDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
)
4-5
54 return;
executed 5 times by 1 test: return;
Executed by:
  • tst_QFileSystemWatcher
5
55-
56 QFileSystemWatcher * const q = q_func();-
57 poller = new QPollingFileSystemWatcherEngine(q);-
58 QObject::connect(poller,-
59 qFlagLocation("2""fileChanged(QString,bool)" "\0" __FILE__ ":" "116"),-
60 q,-
61 qFlagLocation("1""_q_fileChanged(QString,bool)" "\0" __FILE__ ":" "118"));-
62 QObject::connect(poller,-
63 qFlagLocation("2""directoryChanged(QString,bool)" "\0" __FILE__ ":" "120"),-
64 q,-
65 qFlagLocation("1""_q_directoryChanged(QString,bool)" "\0" __FILE__ ":" "122"));-
66}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
67-
68void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)-
69{-
70 QFileSystemWatcher * const q = q_func();-
71 if (!files.contains(path)
!files.contains(path)Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
) {
0-28
72-
73 return;
never executed: return;
0
74 }-
75 if (removed
removedDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
)
12-16
76 files.removeAll(path);
executed 16 times by 1 test: files.removeAll(path);
Executed by:
  • tst_QFileSystemWatcher
16
77 q->fileChanged(path, QFileSystemWatcher::QPrivateSignal());-
78}
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
28
79-
80void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)-
81{-
82 QFileSystemWatcher * const q = q_func();-
83 if (!directories.contains(path)
!directories.contains(path)Description
TRUEnever evaluated
FALSEevaluated 64 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
) {
0-64
84-
85 return;
never executed: return;
0
86 }-
87 if (removed
removedDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 58 times by 4 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
)
6-58
88 directories.removeAll(path);
executed 6 times by 1 test: directories.removeAll(path);
Executed by:
  • tst_QFileSystemWatcher
6
89 q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal());-
90}
executed 64 times by 4 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
64
91QFileSystemWatcher::QFileSystemWatcher(QObject *parent)-
92 : QObject(*new QFileSystemWatcherPrivate, parent)-
93{-
94 d_func()->init();-
95}
executed 355 times by 10 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_QSidebar
  • tst_languageChange
355
96-
97-
98-
99-
100-
101QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent)-
102 : QObject(*new QFileSystemWatcherPrivate, parent)-
103{-
104 d_func()->init();-
105 addPaths(paths);-
106}
never executed: end of block
0
107-
108-
109-
110-
111QFileSystemWatcher::~QFileSystemWatcher()-
112{ }-
113bool QFileSystemWatcher::addPath(const QString &path)-
114{-
115 if (path.isEmpty()
path.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 482 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
) {
1-482
116 QMessageLogger(__FILE__, 255, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPath: path is empty");-
117 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QFileSystemWatcher
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QFileSystemWatcher
1
118 }-
119-
120 QStringList paths = addPaths(QStringList(path));-
121 return
executed 482 times by 8 tests: return paths.isEmpty();
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
paths.isEmpty();
executed 482 times by 8 tests: return paths.isEmpty();
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
482
122}-
123QStringList QFileSystemWatcher::addPaths(const QStringList &paths)-
124{-
125 QFileSystemWatcherPrivate * const d = d_func();-
126-
127 QStringList p = paths;-
128 QMutableListIterator<QString> it(p);-
129-
130 while (it.hasNext()
it.hasNext()Description
TRUEevaluated 488 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 487 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
) {
487-488
131 const QString &path = it.next();-
132 if (path.isEmpty()
path.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 487 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
)
1-487
133 it.remove();
executed 1 time by 1 test: it.remove();
Executed by:
  • tst_QFileSystemWatcher
1
134 }
executed 488 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
488
135-
136 if (p.isEmpty()
p.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 485 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
) {
2-485
137 QMessageLogger(__FILE__, 300, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPaths: list is empty");-
138 return
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
QStringList();
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
2
139 }-
140-
141 QFileSystemWatcherEngine *engine = 0;-
142-
143 const QString on = objectName();-
144-
145 if (!on.startsWith(QLatin1String("_qt_autotest_force_engine_"))
!on.startsWith...rce_engine_"))Description
TRUEevaluated 458 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
) {
27-458
146-
147 if(d->native
d->nativeDescription
TRUEevaluated 458 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEnever evaluated
) {
0-458
148 engine = d->native;-
149 }
executed 458 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
else {
458
150 d_func()->initPollerEngine();-
151 engine = d->poller;-
152 }
never executed: end of block
0
153-
154 } else {-
155-
156 const QStringRef forceName = on.midRef(26);-
157 if(forceName == QLatin1String("poller")
forceName == Q...ring("poller")Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
) {
9-18
158 QMessageLogger(__FILE__, 321, __PRETTY_FUNCTION__).debug("QFileSystemWatcher: skipping native engine, using only polling engine");-
159 d_func()->initPollerEngine();-
160 engine = d->poller;-
161 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
else if(forceName == QLatin1String("native")
forceName == Q...ring("native")Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
) {
0-18
162 QMessageLogger(__FILE__, 325, __PRETTY_FUNCTION__).debug("QFileSystemWatcher: skipping polling engine, using only native engine");-
163 engine = d->native;-
164 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
18
165 }
executed 27 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
27
166-
167 if(engine
engineDescription
TRUEevaluated 485 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEnever evaluated
)
0-485
168 p = engine->addPaths(p, &d->files, &d->directories);
executed 485 times by 8 tests: p = engine->addPaths(p, &d->files, &d->directories);
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
485
169-
170 return
executed 485 times by 8 tests: return p;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
p;
executed 485 times by 8 tests: return p;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
485
171}-
172bool QFileSystemWatcher::removePath(const QString &path)-
173{-
174 if (path.isEmpty()
path.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 105 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
) {
1-105
175 QMessageLogger(__FILE__, 349, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePath: path is empty");-
176 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QFileSystemWatcher
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QFileSystemWatcher
1
177 }-
178-
179 QStringList paths = removePaths(QStringList(path));-
180 return
executed 105 times by 5 tests: return paths.isEmpty();
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
paths.isEmpty();
executed 105 times by 5 tests: return paths.isEmpty();
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
105
181}-
182QStringList QFileSystemWatcher::removePaths(const QStringList &paths)-
183{-
184 QFileSystemWatcherPrivate * const d = d_func();-
185-
186 QStringList p = paths;-
187 QMutableListIterator<QString> it(p);-
188-
189 while (it.hasNext()
it.hasNext()Description
TRUEevaluated 108 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEevaluated 108 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
) {
108
190 const QString &path = it.next();-
191 if (path.isEmpty()
path.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
)
1-107
192 it.remove();
executed 1 time by 1 test: it.remove();
Executed by:
  • tst_QFileSystemWatcher
1
193 }
executed 108 times by 5 tests: end of block
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
108
194-
195 if (p.isEmpty()
p.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 106 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
) {
2-106
196 QMessageLogger(__FILE__, 382, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePaths: list is empty");-
197 return
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
QStringList();
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
2
198 }-
199-
200 if (d->native
d->nativeDescription
TRUEevaluated 106 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
FALSEnever evaluated
)
0-106
201 p = d->native->removePaths(p, &d->files, &d->directories);
executed 106 times by 5 tests: p = d->native->removePaths(p, &d->files, &d->directories);
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106
202 if (d->poller
d->pollerDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 101 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
)
5-101
203 p = d->poller->removePaths(p, &d->files, &d->directories);
executed 5 times by 1 test: p = d->poller->removePaths(p, &d->files, &d->directories);
Executed by:
  • tst_QFileSystemWatcher
5
204-
205 return
executed 106 times by 5 tests: return p;
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
p;
executed 106 times by 5 tests: return p;
Executed by:
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_languageChange
106
206}-
207QStringList QFileSystemWatcher::directories() const-
208{-
209 const QFileSystemWatcherPrivate * const d = d_func();-
210 return
executed 478 times by 8 tests: return d->directories;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
d->directories;
executed 478 times by 8 tests: return d->directories;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
478
211}-
212-
213QStringList QFileSystemWatcher::files() const-
214{-
215 const QFileSystemWatcherPrivate * const d = d_func();-
216 return
executed 4 times by 1 test: return d->files;
Executed by:
  • tst_QFileSystemWatcher
d->files;
executed 4 times by 1 test: return d->files;
Executed by:
  • tst_QFileSystemWatcher
4
217}-
218-
219-
220-
Switch to Source codePreprocessed file

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