diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-08-03 01:41:25 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-08-03 01:41:25 (GMT) |
commit | 1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a (patch) | |
tree | f02f980de13e8b282fb0f58f6da421b29044552f /tests/auto/declarative/qdeclarativepixmapcache | |
parent | 30e55019f3ddf9d0df82df68c6324c96904fdc3a (diff) | |
download | Qt-1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a.zip Qt-1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a.tar.gz Qt-1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a.tar.bz2 |
Limit the pixmap cache in space as well as in time.
QTBUG-12590
Diffstat (limited to 'tests/auto/declarative/qdeclarativepixmapcache')
-rw-r--r-- | tests/auto/declarative/qdeclarativepixmapcache/data/massive.png | bin | 0 -> 31834 bytes | |||
-rw-r--r-- | tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp | 40 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png b/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png Binary files differnew file mode 100644 index 0000000..bc6cc9e --- /dev/null +++ b/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index 0c7780c..16d2063 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -70,6 +70,7 @@ private slots: void single_data(); void parallel(); void parallel_data(); + void massive(); private: QDeclarativeEngine engine; @@ -276,6 +277,45 @@ void tst_qdeclarativepixmapcache::parallel() qDeleteAll(pixmaps); } +void tst_qdeclarativepixmapcache::massive() +{ + QUrl url = thisfile.resolved(QUrl("data/massive.png")); + + // Confirm that massive images remain in the cache while they are + // in use by the application. + { + qint64 cachekey = 0; + QDeclarativePixmap p(0, url); + QVERIFY(p.isReady()); + QVERIFY(p.pixmap().size() == QSize(10000, 1000)); + cachekey = p.pixmap().cacheKey(); + + QDeclarativePixmap p2(0, url); + QVERIFY(p2.isReady()); + QVERIFY(p2.pixmap().size() == QSize(10000, 1000)); + + QVERIFY(p2.pixmap().cacheKey() == cachekey); + } + + // Confirm that massive images are removed from the cache when + // they become unused + { + qint64 cachekey = 0; + { + QDeclarativePixmap p(0, url); + QVERIFY(p.isReady()); + QVERIFY(p.pixmap().size() == QSize(10000, 1000)); + cachekey = p.pixmap().cacheKey(); + } + + QDeclarativePixmap p2(0, url); + QVERIFY(p2.isReady()); + QVERIFY(p2.pixmap().size() == QSize(10000, 1000)); + + QVERIFY(p2.pixmap().cacheKey() != cachekey); + } +} + QTEST_MAIN(tst_qdeclarativepixmapcache) #include "tst_qdeclarativepixmapcache.moc" |