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.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
index b487d74..9775d36 100644
--- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
@@ -244,16 +244,23 @@ void tst_QPixmapCache::insert()
QPixmap p2(10, 10);
p2.fill(Qt::yellow);
+ // Calcuate estimated num of items what fits to cache
+ int estimatedNum = (1024 * QPixmapCache::cacheLimit())
+ / ((p1.width() * p1.height() * p1.depth()) / 8);
+
+ // Mare sure we will put enough items to reach the cache limit
+ const int numberOfKeys = estimatedNum + 1000;
+
// make sure it doesn't explode
- for (int i = 0; i < 20000; ++i)
+ for (int i = 0; i < numberOfKeys; ++i)
QPixmapCache::insert("0", p1);
// ditto
- for (int j = 0; j < 40000; ++j)
+ for (int j = 0; j < numberOfKeys; ++j)
QPixmapCache::insert(QString::number(j), p1);
int num = 0;
- for (int k = 0; k < 40000; ++k) {
+ for (int k = 0; k < numberOfKeys; ++k) {
if (QPixmapCache::find(QString::number(k)))
++num;
}
@@ -261,9 +268,6 @@ void tst_QPixmapCache::insert()
if (QPixmapCache::find("0"))
++num;
- int estimatedNum = (1024 * QPixmapCache::cacheLimit())
- / ((p1.width() * p1.height() * p1.depth()) / 8);
-
QVERIFY(num <= estimatedNum);
QPixmap p3;
QPixmapCache::insert("null", p3);
@@ -281,11 +285,11 @@ void tst_QPixmapCache::insert()
//The int part of the API
// make sure it doesn't explode
QList<QPixmapCache::Key> keys;
- for (int i = 0; i < 40000; ++i)
+ for (int i = 0; i < numberOfKeys; ++i)
keys.append(QPixmapCache::insert(p1));
num = 0;
- for (int k = 0; k < 40000; ++k) {
+ for (int k = 0; k < numberOfKeys; ++k) {
if (QPixmapCache::find(keys.at(k), &p2))
++num;
}
@@ -393,7 +397,12 @@ void tst_QPixmapCache::clear()
QPixmap p1(10, 10);
p1.fill(Qt::red);
- const int numberOfKeys = 40000;
+ // Calcuate estimated num of items what fits to cache
+ int estimatedNum = (1024 * QPixmapCache::cacheLimit())
+ / ((p1.width() * p1.height() * p1.depth()) / 8);
+
+ // Mare sure we will put enough items to reach the cache limit
+ const int numberOfKeys = estimatedNum + 1000;
for (int i = 0; i < numberOfKeys; ++i)
QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0);