OpenCoverage

qnetworkdiskcache.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkdiskcache.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QNetworkDiskCache::QNetworkDiskCache(QObject *parent)-
4 : QAbstractNetworkCache(*new QNetworkDiskCachePrivate, parent)-
5{-
6}
executed 66 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
66
7-
8-
9-
10-
11QNetworkDiskCache::~QNetworkDiskCache()-
12{-
13 QNetworkDiskCachePrivate * const d = d_func();-
14 qDeleteAll(d->inserting);-
15}
executed 66 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
66
16-
17-
18-
19-
20QString QNetworkDiskCache::cacheDirectory() const-
21{-
22 const QNetworkDiskCachePrivate * const d = d_func();-
23 return
executed 226 times by 3 tests: return d->cacheDirectory;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
d->cacheDirectory;
executed 226 times by 3 tests: return d->cacheDirectory;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
226
24}-
25void QNetworkDiskCache::setCacheDirectory(const QString &cacheDir)-
26{-
27-
28-
29-
30 QNetworkDiskCachePrivate * const d = d_func();-
31 if (cacheDir.isEmpty()
cacheDir.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 65 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
2-65
32 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QNetworkDiskCache
2
33 d->cacheDirectory = cacheDir;-
34 QDir dir(d->cacheDirectory);-
35 d->cacheDirectory = dir.absolutePath();-
36 if (!d->cacheDirectory.endsWith(QLatin1Char('/'))
!d->cacheDirec...tin1Char('/'))Description
TRUEevaluated 65 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
)
0-65
37 d->cacheDirectory += QLatin1Char('/');
executed 65 times by 3 tests: d->cacheDirectory += QLatin1Char('/');
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
65
38-
39 d->dataDirectory = d->cacheDirectory + QLatin1String("data") + QString::number(8) + QLatin1Char('/');-
40 d->prepareLayout();-
41}
executed 65 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
65
42-
43-
44-
45-
46qint64 QNetworkDiskCache::cacheSize() const-
47{-
48-
49-
50-
51 const QNetworkDiskCachePrivate * const d = d_func();-
52 if (d->cacheDirectory.isEmpty()
d->cacheDirectory.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
)
1-4
53 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
1
54 if (d->currentCacheSize < 0
d->currentCacheSize < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
) {
1-3
55 QNetworkDiskCache *that = const_cast<QNetworkDiskCache*>(this);-
56 that->d_func()->currentCacheSize = that->expire();-
57 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
1
58 return
executed 4 times by 1 test: return d->currentCacheSize;
Executed by:
  • tst_QNetworkDiskCache
d->currentCacheSize;
executed 4 times by 1 test: return d->currentCacheSize;
Executed by:
  • tst_QNetworkDiskCache
4
59}-
60-
61-
62-
63-
64QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)-
65{-
66-
67-
68-
69 QNetworkDiskCachePrivate * const d = d_func();-
70 if (!metaData.isValid()
!metaData.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
|| !metaData.url().isValid()
!metaData.url().isValid()Description
TRUEnever evaluated
FALSEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
|| !metaData.saveToDisk()
!metaData.saveToDisk()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QAbstractNetworkCache
FALSEevaluated 88 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
0-95
71 return
executed 8 times by 2 tests: return 0;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
0;
executed 8 times by 2 tests: return 0;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
8
72-
73 if (d->cacheDirectory.isEmpty()
d->cacheDirectory.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
1-87
74 QMessageLogger(__FILE__, 188, __PRETTY_FUNCTION__).warning("QNetworkDiskCache::prepare() The cache directory is not set");-
75 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
1
76 }-
77-
78 const auto headers = metaData.rawHeaders();-
79 for (const auto &header : headers) {-
80 if (header.first.toLower() == "content-length"
header.first.t...ontent-length"Description
TRUEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 236 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
13-236
81 const qint64 size = header.second.toLongLong();-
82 if (size > (maximumCacheSize() * 3)/4
size > (maximu...eSize() * 3)/4Description
TRUEnever evaluated
FALSEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
)
0-13
83 return
never executed: return 0;
0;
never executed: return 0;
0
84 break;
executed 13 times by 2 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
13
85 }-
86 }
executed 236 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
236
87 QScopedPointer<QCacheItem> cacheItem(new QCacheItem);-
88 cacheItem->metaData = metaData;-
89-
90 QIODevice *device = 0;-
91 if (cacheItem->canCompress()
cacheItem->canCompress()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QAbstractNetworkCache
FALSEevaluated 75 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
12-75
92 cacheItem->data.open(QBuffer::ReadWrite);-
93 device = &(cacheItem->data);-
94 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QAbstractNetworkCache
else {
12
95 QString templateName = d->tmpCacheFileName();-
96 if (true) {-
97 cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);-
98 }
executed 75 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
else {
dead code: { cacheItem->file = 0; }
-
99 cacheItem->file = 0;
dead code: { cacheItem->file = 0; }
-
100 }
dead code: { cacheItem->file = 0; }
-
101 if (!cacheItem->file
!cacheItem->fileDescription
TRUEnever evaluated
FALSEevaluated 75 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
|| !cacheItem->file->open()
!cacheItem->file->open()Description
TRUEnever evaluated
FALSEevaluated 75 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
0-75
102 QMessageLogger(__FILE__, 216, __PRETTY_FUNCTION__).warning("QNetworkDiskCache::prepare() unable to open temporary file");-
103 cacheItem.reset();-
104 return
never executed: return 0;
0;
never executed: return 0;
0
105 }-
106 cacheItem->writeHeader(cacheItem->file);-
107 device = cacheItem->file;-
108 }
executed 75 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
75
109 d->inserting[device] = cacheItem.take();-
110 return
executed 87 times by 3 tests: return device;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
device;
executed 87 times by 3 tests: return device;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
87
111}-
112-
113-
114-
115-
116void QNetworkDiskCache::insert(QIODevice *device)-
117{-
118-
119-
120-
121 QNetworkDiskCachePrivate * const d = d_func();-
122 const auto it = d->inserting.constFind(device);-
123 if (__builtin_expect(!!(it == d->inserting.cend()), false)
__builtin_expe...end()), false)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 84 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
1-84
124 QMessageLogger(__FILE__, 238, __PRETTY_FUNCTION__).warning() << "QNetworkDiskCache::insert() called on a device we don't know about" << device;-
125 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkDiskCache
1
126 }-
127-
128 d->storeItem(it.value());-
129 delete it.value();-
130 d->inserting.erase(it);-
131}
executed 84 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
84
132-
133-
134-
135-
136-
137-
138void QNetworkDiskCachePrivate::prepareLayout()-
139{-
140 QDir helper;-
141 helper.mkpath(cacheDirectory + QLatin1String("prepared/"));-
142-
143-
144 helper.mkpath(dataDirectory);-
145 for (uint i = 0; i < 16
i < 16Description
TRUEevaluated 1040 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 65 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
; i++) {
65-1040
146 QString str = QString::number(i, 16);-
147 QString subdir = dataDirectory + str;-
148 helper.mkdir(subdir);-
149 }
executed 1040 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
1040
150}
executed 65 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
65
151-
152-
153void QNetworkDiskCachePrivate::storeItem(QCacheItem *cacheItem)-
154{-
155 QNetworkDiskCache * const q = q_func();-
156 ((!(cacheItem->metaData.saveToDisk())) ? qt_assert("cacheItem->metaData.saveToDisk()",__FILE__,270) : qt_noop());-
157-
158 QString fileName = cacheFileName(cacheItem->metaData.url());-
159 ((!(!fileName.isEmpty())) ? qt_assert("!fileName.isEmpty()",__FILE__,273) : qt_noop());-
160-
161 if (QFile::exists(fileName)
QFile::exists(fileName)Description
TRUEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 65 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
19-65
162 if (!QFile::remove(fileName)
!QFile::remove(fileName)Description
TRUEnever evaluated
FALSEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
0-19
163 QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning() << "QNetworkDiskCache: couldn't remove the cache file " << fileName;-
164 return;
never executed: return;
0
165 }-
166 }
executed 19 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
19
167-
168 if (currentCacheSize > 0
currentCacheSize > 0Description
TRUEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 55 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
29-55
169 currentCacheSize += 1024 + cacheItem->size();
executed 29 times by 2 tests: currentCacheSize += 1024 + cacheItem->size();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
29
170 currentCacheSize = q->expire();-
171 if (!cacheItem->file
!cacheItem->fileDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QAbstractNetworkCache
FALSEevaluated 72 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
12-72
172 QString templateName = tmpCacheFileName();-
173 cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);-
174 if (cacheItem->file->open()
cacheItem->file->open()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QAbstractNetworkCache
FALSEnever evaluated
) {
0-12
175 cacheItem->writeHeader(cacheItem->file);-
176 cacheItem->writeCompressedData(cacheItem->file);-
177 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QAbstractNetworkCache
12
178 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QAbstractNetworkCache
12
179-
180 if (cacheItem->file
cacheItem->fileDescription
TRUEevaluated 84 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
0-84
181 && cacheItem->file->isOpen()
cacheItem->file->isOpen()Description
TRUEevaluated 84 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
0-84
182 && cacheItem->file->error() == QFile::NoError
cacheItem->fil...QFile::NoErrorDescription
TRUEevaluated 84 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-84
183 cacheItem->file->setAutoRemove(false);-
184-
185 if (cacheItem->file->rename(fileName)
cacheItem->fil...name(fileName)Description
TRUEevaluated 84 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
)
0-84
186 currentCacheSize += cacheItem->file->size();
executed 84 times by 3 tests: currentCacheSize += cacheItem->file->size();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
84
187 else-
188 cacheItem->file->setAutoRemove(true);
never executed: cacheItem->file->setAutoRemove(true);
0
189 }-
190 if (cacheItem->metaData.url() == lastItem.metaData.url()
cacheItem->met...metaData.url()Description
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 73 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
11-73
191 lastItem.reset();
executed 11 times by 2 tests: lastItem.reset();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
11
192}
executed 84 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
84
193-
194-
195-
196-
197bool QNetworkDiskCache::remove(const QUrl &url)-
198{-
199-
200-
201-
202 QNetworkDiskCachePrivate * const d = d_func();-
203-
204-
205 for (auto it = d->inserting.cbegin(), end = d->inserting.cend(); it != end
it != endDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 14 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
; ++it) {
2-14
206 QCacheItem *item = it.value();-
207 if (item
itemDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEnever evaluated
&& item->metaData.url() == url
item->metaData.url() == urlDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
) {
0-2
208 delete item;-
209 d->inserting.erase(it);-
210 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkDiskCache
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkDiskCache
1
211 }-
212 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
1
213-
214 if (d->lastItem.metaData.url() == url
d->lastItem.me...a.url() == urlDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
)
3-11
215 d->lastItem.reset();
executed 3 times by 2 tests: d->lastItem.reset();
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
3
216 return
executed 14 times by 3 tests: return d->removeFile(d->cacheFileName(url));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
d->removeFile(d->cacheFileName(url));
executed 14 times by 3 tests: return d->removeFile(d->cacheFileName(url));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
14
217}-
218-
219-
220-
221-
222bool QNetworkDiskCachePrivate::removeFile(const QString &file)-
223{-
224-
225-
226-
227 if (file.isEmpty()
file.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-15
228 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
1
229 QFileInfo info(file);-
230 QString fileName = info.fileName();-
231 if (!fileName.endsWith(QLatin1String(".d"))
!fileName.ends...1String(".d"))Description
TRUEnever evaluated
FALSEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
0-15
232 return
never executed: return false;
false;
never executed: return false;
0
233 qint64 size = info.size();-
234 if (QFile::remove(file)
QFile::remove(file)Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
6-9
235 currentCacheSize -= size;-
236 return
executed 6 times by 2 tests: return true;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
true;
executed 6 times by 2 tests: return true;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
6
237 }-
238 return
executed 9 times by 2 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
false;
executed 9 times by 2 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
9
239}-
240-
241-
242-
243-
244QNetworkCacheMetaData QNetworkDiskCache::metaData(const QUrl &url)-
245{-
246-
247-
248-
249 QNetworkDiskCachePrivate * const d = d_func();-
250 if (d->lastItem.metaData.url() == url
d->lastItem.me...a.url() == urlDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
6-87
251 return
executed 6 times by 2 tests: return d->lastItem.metaData;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
d->lastItem.metaData;
executed 6 times by 2 tests: return d->lastItem.metaData;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
6
252 return
executed 87 times by 3 tests: return fileMetaData(d->cacheFileName(url));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
fileMetaData(d->cacheFileName(url));
executed 87 times by 3 tests: return fileMetaData(d->cacheFileName(url));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
87
253}-
254-
255-
256-
257-
258-
259-
260QNetworkCacheMetaData QNetworkDiskCache::fileMetaData(const QString &fileName) const-
261{-
262-
263-
264-
265 const QNetworkDiskCachePrivate * const d = d_func();-
266 QFile file(fileName);-
267 if (!file.open(QFile::ReadOnly)
!file.open(QFile::ReadOnly)Description
TRUEevaluated 50 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 48 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
48-50
268 return
executed 50 times by 3 tests: return QNetworkCacheMetaData();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
QNetworkCacheMetaData();
executed 50 times by 3 tests: return QNetworkCacheMetaData();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
50
269 if (!d->lastItem.read(&file, false)
!d->lastItem.r...(&file, false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 46 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
2-46
270 file.close();-
271 QNetworkDiskCachePrivate *that = const_cast<QNetworkDiskCachePrivate*>(d);-
272 that->removeFile(fileName);-
273 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
2
274 return
executed 48 times by 3 tests: return d->lastItem.metaData;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
d->lastItem.metaData;
executed 48 times by 3 tests: return d->lastItem.metaData;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
48
275}-
276-
277-
278-
279-
280QIODevice *QNetworkDiskCache::data(const QUrl &url)-
281{-
282-
283-
284-
285 QNetworkDiskCachePrivate * const d = d_func();-
286 QScopedPointer<QBuffer> buffer;-
287 if (!url.isValid()
!url.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 41 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-41
288 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
1
289 if (d->lastItem.metaData.url() == url
d->lastItem.me...a.url() == urlDescription
TRUEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
&& d->lastItem.data.isOpen()
d->lastItem.data.isOpen()Description
TRUEnever evaluated
FALSEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
0-27
290 buffer.reset(new QBuffer);-
291 buffer->setData(d->lastItem.data.data());-
292 }
never executed: end of block
else {
0
293 QScopedPointer<QFile> file(new QFile(d->cacheFileName(url)));-
294 if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered)
!file->open(QF...e::Unbuffered)Description
TRUEnever evaluated
FALSEevaluated 41 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
0-41
295 return
never executed: return 0;
0;
never executed: return 0;
0
296-
297 if (!d->lastItem.read(file.data(), true)
!d->lastItem.r....data(), true)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
1-40
298 file->close();-
299 remove(url);-
300 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
1
301 }-
302 if (d->lastItem.data.isOpen()
d->lastItem.data.isOpen()Description
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
11-29
303-
304 buffer.reset(new QBuffer);-
305 buffer->setData(d->lastItem.data.data());-
306 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
else {
11
307 buffer.reset(new QBuffer);-
308-
309 qint64 size = file->size() - file->pos();-
310 const uchar *p = 0;-
311-
312 p = file->map(file->pos(), size);-
313-
314 if (p
pDescription
TRUEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-29
315 buffer->setData((const char *)p, size);-
316 file.take()->setParent(buffer.data());-
317 }
executed 29 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
else {
29
318 buffer->setData(file->readAll());-
319 }
never executed: end of block
0
320 }-
321 }-
322 buffer->open(QBuffer::ReadOnly);-
323 return
executed 40 times by 3 tests: return buffer.take();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
buffer.take();
executed 40 times by 3 tests: return buffer.take();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
40
324}-
325-
326-
327-
328-
329void QNetworkDiskCache::updateMetaData(const QNetworkCacheMetaData &metaData)-
330{-
331-
332-
333-
334 QUrl url = metaData.url();-
335 QIODevice *oldDevice = data(url);-
336 if (!oldDevice
!oldDeviceDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
1-6
337-
338-
339-
340 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkDiskCache
1
341 }-
342-
343 QIODevice *newDevice = prepare(metaData);-
344 if (!newDevice
!newDeviceDescription
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
0-6
345-
346-
347-
348 return;
never executed: return;
0
349 }-
350 char data[1024];-
351 while (!oldDevice->atEnd()
!oldDevice->atEnd()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
6
352 qint64 s = oldDevice->read(data, 1024);-
353 newDevice->write(data, s);-
354 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
6
355 delete oldDevice;-
356 insert(newDevice);-
357}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
6
358-
359-
360-
361-
362-
363-
364qint64 QNetworkDiskCache::maximumCacheSize() const-
365{-
366 const QNetworkDiskCachePrivate * const d = d_func();-
367 return
executed 208 times by 3 tests: return d->maximumCacheSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
d->maximumCacheSize;
executed 208 times by 3 tests: return d->maximumCacheSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
208
368}-
369void QNetworkDiskCache::setMaximumCacheSize(qint64 size)-
370{-
371 QNetworkDiskCachePrivate * const d = d_func();-
372 bool expireCache = (size < d->maximumCacheSize);-
373 d->maximumCacheSize = size;-
374 if (expireCache
expireCacheDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEnever evaluated
)
0-1
375 d->currentCacheSize = expire();
executed 1 time by 1 test: d->currentCacheSize = expire();
Executed by:
  • tst_QNetworkDiskCache
1
376}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
1
377qint64 QNetworkDiskCache::expire()-
378{-
379 QNetworkDiskCachePrivate * const d = d_func();-
380 if (d->currentCacheSize >= 0
d->currentCacheSize >= 0Description
TRUEevaluated 98 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 65 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
&& d->currentCacheSize < maximumCacheSize()
d->currentCach...mumCacheSize()Description
TRUEevaluated 66 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
)
32-98
381 return
executed 66 times by 3 tests: return d->currentCacheSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
d->currentCacheSize;
executed 66 times by 3 tests: return d->currentCacheSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
66
382-
383 if (cacheDirectory().isEmpty()
cacheDirectory().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 96 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
1-96
384 QMessageLogger(__FILE__, 525, __PRETTY_FUNCTION__).warning("QNetworkDiskCache::expire() The cache directory is not set");-
385 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QNetworkDiskCache
1
386 }-
387-
388-
389 d->lastItem.reset();-
390-
391 QDir::Filters filters = QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot;-
392 QDirIterator it(cacheDirectory(), filters, QDirIterator::Subdirectories);-
393-
394 QMultiMap<QDateTime, QString> cacheItems;-
395 qint64 totalSize = 0;-
396 while (it.hasNext()
it.hasNext()Description
TRUEevaluated 1827 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 96 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
96-1827
397 QString path = it.next();-
398 QFileInfo info = it.fileInfo();-
399 QString fileName = info.fileName();-
400 if (fileName.endsWith(QLatin1String(".d"))
fileName.endsW...1String(".d"))Description
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 1729 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
98-1729
401 cacheItems.insert(info.created(), path);-
402 totalSize += info.size();-
403 }
executed 98 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
98
404 }
executed 1827 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
1827
405-
406 int removedFiles = 0;-
407 qint64 goal = (maximumCacheSize() * 9) / 10;-
408 QMultiMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin();-
409 while (i != cacheItems.constEnd()
i != cacheItems.constEnd()Description
TRUEevaluated 53 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 66 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
) {
53-66
410 if (totalSize < goal
totalSize < goalDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
)
23-30
411 break;
executed 30 times by 2 tests: break;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
30
412 QString name = i.value();-
413 QFile file(name);-
414-
415 if (name.contains(QLatin1String("prepared/"))
name.contains(...("prepared/"))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
) {
1-22
416 for (QCacheItem *item : qAsConst(d->inserting)) {-
417 if (item
itemDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEnever evaluated
&& item->file
item->fileDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEnever evaluated
&& item->file->fileName() == name
item->file->fileName() == nameDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEnever evaluated
) {
0-1
418 delete item->file;-
419 item->file = 0;-
420 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkDiskCache
1
421 }-
422 }
never executed: end of block
0
423 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
1
424-
425 qint64 size = file.size();-
426 file.remove();-
427 totalSize -= size;-
428 ++removedFiles;-
429 ++i;-
430 }
executed 23 times by 1 test: end of block
Executed by:
  • tst_QNetworkDiskCache
23
431-
432-
433-
434-
435-
436-
437-
438 return
executed 96 times by 3 tests: return totalSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
totalSize;
executed 96 times by 3 tests: return totalSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
96
439}-
440-
441-
442-
443-
444void QNetworkDiskCache::clear()-
445{-
446-
447-
448-
449 QNetworkDiskCachePrivate * const d = d_func();-
450 qint64 size = d->maximumCacheSize;-
451 d->maximumCacheSize = 0;-
452 d->currentCacheSize = expire();-
453 d->maximumCacheSize = size;-
454}
executed 65 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
65
455-
456-
457-
458-
459QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)-
460{-
461 QUrl cleanUrl = url;-
462 cleanUrl.setPassword(QString());-
463 cleanUrl.setFragment(QString());-
464-
465 QCryptographicHash hash(QCryptographicHash::Sha1);-
466 hash.addData(cleanUrl.toEncoded());-
467-
468 QByteArray id = QByteArray::number(*(qlonglong*)hash.result().data(), 36).left(8);-
469-
470 uint code = (uint)id.at(id.length()-1) % 16;-
471 QString pathFragment = QString::number(code, 16) + QLatin1Char('/')-
472 + QLatin1String(id) + QLatin1String(".d");-
473-
474 return
executed 310 times by 3 tests: return pathFragment;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
pathFragment;
executed 310 times by 3 tests: return pathFragment;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
310
475}-
476-
477QString QNetworkDiskCachePrivate::tmpCacheFileName() const-
478{-
479-
480 return
executed 87 times by 3 tests: return cacheDirectory + QLatin1String("prepared/") + QLatin1String("XXXXXX") + QLatin1String(".d");
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
cacheDirectory + QLatin1String("prepared/") + QLatin1String("XXXXXX") + QLatin1String(".d");
executed 87 times by 3 tests: return cacheDirectory + QLatin1String("prepared/") + QLatin1String("XXXXXX") + QLatin1String(".d");
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
87
481}-
482-
483-
484-
485-
486QString QNetworkDiskCachePrivate::cacheFileName(const QUrl &url) const-
487{-
488 if (!url.isValid()
!url.isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 225 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-225
489 return
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QNetworkDiskCache
QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QNetworkDiskCache
1
490-
491 QString fullpath = dataDirectory + uniqueFileName(url);-
492 return
executed 225 times by 3 tests: return fullpath;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
fullpath;
executed 225 times by 3 tests: return fullpath;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
225
493}-
494-
495-
496-
497-
498bool QCacheItem::canCompress() const-
499{-
500 bool sizeOk = false;-
501 bool typeOk = false;-
502 const auto headers = metaData.rawHeaders();-
503 for (const auto &header : headers) {-
504 if (header.first.toLower() == "content-length"
header.first.t...ontent-length"Description
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 496 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
26-496
505 qint64 size = header.second.toLongLong();-
506 if (size > (1024 * 1024 * 3)
size > (1024 * 1024 * 3)Description
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
)
0-26
507 return
never executed: return false;
false;
never executed: return false;
0
508 else-
509 sizeOk = true;
executed 26 times by 2 tests: sizeOk = true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
26
510 }-
511-
512 if (header.first.toLower() == "content-type"
header.first.t..."content-type"Description
TRUEevaluated 140 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 382 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
140-382
513 QByteArray type = header.second;-
514 if (type.startsWith("text/")
type.startsWith("text/")Description
TRUEevaluated 140 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
0-140
515 || (type.startsWith("application/")
type.startsWit...application/")Description
TRUEnever evaluated
FALSEnever evaluated
0
516 && (type.endsWith("javascript")
type.endsWith("javascript")Description
TRUEnever evaluated
FALSEnever evaluated
|| type.endsWith("ecmascript")
type.endsWith("ecmascript")Description
TRUEnever evaluated
FALSEnever evaluated
)))
0
517 typeOk = true;
executed 140 times by 3 tests: typeOk = true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
140
518 else-
519 return
never executed: return false;
false;
never executed: return false;
0
520 }-
521 if (sizeOk
sizeOkDescription
TRUEevaluated 50 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 472 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
&& typeOk
typeOkDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QAbstractNetworkCache
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
)
24-472
522 return
executed 24 times by 1 test: return true;
Executed by:
  • tst_QAbstractNetworkCache
true;
executed 24 times by 1 test: return true;
Executed by:
  • tst_QAbstractNetworkCache
24
523 }
executed 498 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
498
524 return
executed 150 times by 3 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
false;
executed 150 times by 3 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
150
525}-
526-
527enum-
528{-
529 CacheMagic = 0xe8,-
530 CurrentCacheVersion = 8-
531};-
532-
533void QCacheItem::writeHeader(QFile *device) const-
534{-
535 QDataStream out(device);-
536-
537 out << qint32(CacheMagic);-
538 out << qint32(CurrentCacheVersion);-
539 out << static_cast<qint32>(out.version());-
540 out << metaData;-
541 bool compressed = canCompress();-
542 out << compressed;-
543}
executed 87 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
87
544-
545void QCacheItem::writeCompressedData(QFile *device) const-
546{-
547 QDataStream out(device);-
548-
549 out << qCompress(data.data());-
550}
executed 12 times by 1 test: end of block
Executed by:
  • tst_QAbstractNetworkCache
12
551-
552-
553-
554-
555-
556bool QCacheItem::read(QFile *device, bool readData)-
557{-
558 reset();-
559-
560 QDataStream in(device);-
561-
562 qint32 marker;-
563 qint32 v;-
564 in >> marker;-
565 in >> v;-
566 if (marker != CacheMagic
marker != CacheMagicDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 88 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-88
567 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkDiskCache
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkDiskCache
1
568-
569-
570 if (v != CurrentCacheVersion
v != CurrentCacheVersionDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 86 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
2-86
571 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
2
572-
573 qint32 streamVersion;-
574 in >> streamVersion;-
575-
576 if (streamVersion > in.version()
streamVersion > in.version()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkDiskCache
FALSEevaluated 85 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-85
577 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QNetworkDiskCache
1
578 in.setVersion(streamVersion);-
579-
580 bool compressed;-
581 QByteArray dataBA;-
582 in >> metaData;-
583 in >> compressed;-
584 if (readData
readDataDescription
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
&& compressed
compressedDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
FALSEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
11-45
585 in >> dataBA;-
586 data.setData(qUncompress(dataBA));-
587 data.open(QBuffer::ReadOnly);-
588 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
11
589-
590-
591 QString expectedFilename = QNetworkDiskCachePrivate::uniqueFileName(metaData.url());-
592 if (!device->fileName().endsWith(expectedFilename)
!device->fileN...ectedFilename)Description
TRUEnever evaluated
FALSEevaluated 85 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
0-85
593 return
never executed: return false;
false;
never executed: return false;
0
594-
595 return
executed 85 times by 3 tests: return metaData.isValid();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
metaData.isValid();
executed 85 times by 3 tests: return metaData.isValid();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
85
596}-
597-
598-
Switch to Source codePreprocessed file

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