diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-28 17:40:21 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-01 15:28:04 +0000 |
commit | 143f22babb43d50dd5ee99f73f04016c84d6171a (patch) | |
tree | cbb7f02861d503aa3f85cc68450f7fa43746c439 /tests/auto/qml/qqmlpropertycache | |
parent | 897eb7f1290428dcc257e999b099d0ef14349e35 (diff) |
Add a checksum to QQmlPropertyCache
By running an md5 hash over the meta-object data and string tables this will
allow us to detect changes to meta-objects and invalidate QML disk caches.
Change-Id: I15b92de4cdf0cb525281b86e1c7b8ba0b11347a0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache')
-rw-r--r-- | tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index acc68befb5..2916d8455c 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -31,6 +31,7 @@ #include <QtQml/qqmlengine.h> #include <private/qv8engine_p.h> #include <private/qmetaobjectbuilder_p.h> +#include <QCryptographicHash> #include "../../shared/util.h" class tst_qqmlpropertycache : public QObject @@ -48,6 +49,7 @@ private slots: void signalHandlersDerived(); void metaObjectSize_data(); void metaObjectSize(); + void metaObjectChecksum(); private: QQmlEngine engine; @@ -361,4 +363,40 @@ void tst_qqmlpropertycache::metaObjectSize() QCOMPARE(stringDataSize, expectedStringCount); } +void tst_qqmlpropertycache::metaObjectChecksum() +{ + QMetaObjectBuilder builder; + builder.setClassName("Test"); + builder.addClassInfo("foo", "bar"); + + QCryptographicHash hash(QCryptographicHash::Md5); + + QScopedPointer<QMetaObject, QScopedPointerPodDeleter> mo(builder.toMetaObject()); + QVERIFY(!mo.isNull()); + + QVERIFY(QQmlPropertyCache::addToHash(hash, *mo.data())); + QByteArray initialHash = hash.result(); + QVERIFY(!initialHash.isEmpty()); + hash.reset(); + + { + QVERIFY(QQmlPropertyCache::addToHash(hash, *mo.data())); + QByteArray nextHash = hash.result(); + QVERIFY(!nextHash.isEmpty()); + hash.reset(); + QCOMPARE(initialHash, nextHash); + } + + builder.addProperty("testProperty", "int", -1); + + mo.reset(builder.toMetaObject()); + { + QVERIFY(QQmlPropertyCache::addToHash(hash, *mo.data())); + QByteArray nextHash = hash.result(); + QVERIFY(!nextHash.isEmpty()); + hash.reset(); + QVERIFY(initialHash != nextHash); + } +} + QTEST_MAIN(tst_qqmlpropertycache) |