diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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" |