summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-08-03 01:41:25 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-08-03 01:41:25 (GMT)
commit1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a (patch)
treef02f980de13e8b282fb0f58f6da421b29044552f /tests/auto
parent30e55019f3ddf9d0df82df68c6324c96904fdc3a (diff)
downloadQt-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')
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/massive.pngbin0 -> 31834 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp40
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
new file mode 100644
index 0000000..bc6cc9e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png
Binary files differ
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"