summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-08-03 11:41:25 +1000
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-04 14:15:38 +1000
commitf2218e751c226b031d9ac1785279c5117e2d22f7 (patch)
treea9c759553dbf393fa7de721bef63de439b44ed4b /tests
parent0df9658696e7505fecce2b4497c3156311304fda (diff)
Limit the pixmap cache in space as well as in time.
QTBUG-12590 (cherry picked from commit 1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a)
Diffstat (limited to 'tests')
-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 0000000000..bc6cc9e6ca
--- /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 0c7780ce97..16d206345e 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"