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

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