summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qpixmapcache/tst_qpixmapcache.cpp')
-rw-r--r--tests/auto/qpixmapcache/tst_qpixmapcache.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
index 9f7192d..b36cf98 100644
--- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
@@ -72,6 +72,7 @@ private slots:
void clear();
void pixmapKey();
void noLeak();
+ void strictCacheLimit();
};
static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key)
@@ -517,5 +518,29 @@ void tst_QPixmapCache::noLeak()
QCOMPARE(oldSize, newSize);
}
+
+void tst_QPixmapCache::strictCacheLimit()
+{
+ const int limit = 1024; // 1024 KB
+
+ QPixmapCache::clear();
+ QPixmapCache::setCacheLimit(limit);
+
+ // insert 200 64x64 pixmaps
+ // 3200 KB for 32-bit depths
+ // 1600 KB for 16-bit depths
+ // not counting the duplicate entries
+ for (int i = 0; i < 200; ++i) {
+ QPixmap pixmap(64, 64);
+ pixmap.fill(Qt::transparent);
+
+ QString id = QString::number(i);
+ QPixmapCache::insert(id + "-a", pixmap);
+ QPixmapCache::insert(id + "-b", pixmap);
+ }
+
+ QVERIFY(QPixmapCache::totalUsed() <= limit);
+}
+
QTEST_MAIN(tst_QPixmapCache)
#include "tst_qpixmapcache.moc"