summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-04-25 08:20:24 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-05-06 14:32:55 -0700
commit62e0080a6a504e394bf55077e351e28c271a04fa (patch)
tree87edc9eed035d8d7bd6e23dc359d5d269a88d610 /tests/auto
parentecb0878cbc3bc677d0f440950d2d1e304bcea495 (diff)
tst_QResourceEngine: use both ways of registering dynamic resources
So we test both the mmap()ed and non-mmap()ed versions. Will be important in the next commit. Change-Id: I6979d02a7395405cbf23fffd17c98f0e207477e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index cf0e258412..f0dab35f81 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -45,6 +45,7 @@ private slots:
private:
const QString m_runtimeResourceRcc;
+ QByteArray m_runtimeResourceData;
};
@@ -73,15 +74,27 @@ void tst_QResourceEngine::initTestCase()
#endif
QVERIFY(!m_runtimeResourceRcc.isEmpty());
+
+ QFile resourceFile(m_runtimeResourceRcc);
+ QVERIFY2(resourceFile.open(QIODevice::ReadOnly), qPrintable(resourceFile.errorString()));
+
+ // register once with the file name, which will attempt to use mmap()
+ // (uses QDynamicFileResourceRoot)
QVERIFY(QResource::registerResource(m_runtimeResourceRcc));
- QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/"));
+
+ // and register a second time with a gifted memory block
+ // (uses QDynamicBufferResourceRoot)
+ m_runtimeResourceData = resourceFile.readAll();
+ auto resourcePtr = reinterpret_cast<const uchar *>(m_runtimeResourceData.constData());
+ QVERIFY(QResource::registerResource(resourcePtr, "/secondary_root/"));
}
void tst_QResourceEngine::cleanupTestCase()
{
// make sure we don't leak memory
QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc));
- QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc, "/secondary_root/"));
+ auto resourcePtr = reinterpret_cast<const uchar *>(m_runtimeResourceData.constData());
+ QVERIFY(QResource::unregisterResource(resourcePtr, "/secondary_root/"));
}
void tst_QResourceEngine::compressedResource_data()