summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-07-10 17:04:42 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-07-13 10:43:15 +0200
commit2f33e030b8c80b4665cc2c120df7833469c05145 (patch)
treec82580c8ef761ddd5e22f695dc5934753429436d /tests/auto/gui/image
parente89b2f72c7147e46dcf606c3dcc507e2ae2841ce (diff)
Remove usages of deprecated APIs of qtbase/gui
- Replaced the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Modified the tests to make them build when deprecated APIs disabled: * Made the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, added tests for the replacement. Change-Id: Ic38245015377fc0c8127eb5458c184ffd4b450f1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/gui/image')
-rw-r--r--tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
index 158530428d..3158883ef5 100644
--- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
@@ -104,18 +104,28 @@ void tst_QPixmapCache::cacheLimit()
void tst_QPixmapCache::setCacheLimit()
{
+ QPixmap res;
QPixmap *p1 = new QPixmap(2, 3);
QPixmapCache::insert("P1", *p1);
+#if QT_DEPRECATED_SINCE(5, 13)
QVERIFY(QPixmapCache::find("P1") != 0);
+#endif
+ QVERIFY(QPixmapCache::find("P1", &res));
delete p1;
QPixmapCache::setCacheLimit(0);
+#if QT_DEPRECATED_SINCE(5, 13)
QVERIFY(!QPixmapCache::find("P1"));
+#endif
+ QVERIFY(!QPixmapCache::find("P1", &res));
p1 = new QPixmap(2, 3);
QPixmapCache::setCacheLimit(1000);
QPixmapCache::insert("P1", *p1);
+#if QT_DEPRECATED_SINCE(5, 13)
QVERIFY(QPixmapCache::find("P1") != 0);
+#endif
+ QVERIFY(QPixmapCache::find("P1", &res));
delete p1;
@@ -200,6 +210,7 @@ void tst_QPixmapCache::find()
QVERIFY(QPixmapCache::insert("P1", p1));
QPixmap p2;
+#if QT_DEPRECATED_SINCE(5, 13)
QVERIFY(QPixmapCache::find("P1", p2));
QCOMPARE(p2.width(), 10);
QCOMPARE(p2.height(), 10);
@@ -209,6 +220,12 @@ void tst_QPixmapCache::find()
QPixmap *p3 = QPixmapCache::find("P1");
QVERIFY(p3);
QCOMPARE(p1, *p3);
+#endif
+
+ QVERIFY(QPixmapCache::find("P1", &p2));
+ QCOMPARE(p2.width(), 10);
+ QCOMPARE(p2.height(), 10);
+ QCOMPARE(p1, p2);
//The int part of the API
QPixmapCache::Key key = QPixmapCache::insert(p1);
@@ -261,6 +278,7 @@ void tst_QPixmapCache::insert()
}
int num = 0;
+#if QT_DEPRECATED_SINCE(5, 13)
for (int k = 0; k < numberOfKeys; ++k) {
if (QPixmapCache::find(QString::number(k)))
++num;
@@ -268,6 +286,16 @@ void tst_QPixmapCache::insert()
if (QPixmapCache::find("0"))
++num;
+ num = 0;
+#endif
+ QPixmap res;
+ for (int k = 0; k < numberOfKeys; ++k) {
+ if (QPixmapCache::find(QString::number(k), &res))
+ ++num;
+ }
+
+ if (QPixmapCache::find("0", &res))
+ ++num;
QVERIFY(num <= estimatedNum);
QPixmap p3;
@@ -340,17 +368,17 @@ void tst_QPixmapCache::remove()
p1.fill(Qt::yellow);
QPixmap p2;
- QVERIFY(QPixmapCache::find("red", p2));
+ QVERIFY(QPixmapCache::find("red", &p2));
QVERIFY(p1.toImage() != p2.toImage());
QVERIFY(p1.toImage() == p1.toImage()); // sanity check
QPixmapCache::remove("red");
- QVERIFY(!QPixmapCache::find("red"));
+ QVERIFY(!QPixmapCache::find("red", &p2));
QPixmapCache::remove("red");
- QVERIFY(!QPixmapCache::find("red"));
+ QVERIFY(!QPixmapCache::find("red", &p2));
QPixmapCache::remove("green");
- QVERIFY(!QPixmapCache::find("green"));
+ QVERIFY(!QPixmapCache::find("green", &p2));
//The int part of the API
QPixmapCache::clear();
@@ -392,7 +420,7 @@ void tst_QPixmapCache::remove()
key = QPixmapCache::insert(p1);
QPixmapCache::remove(key);
QVERIFY(QPixmapCache::find(key, &p1) == 0);
- QVERIFY(QPixmapCache::find("red") != 0);
+ QVERIFY(QPixmapCache::find("red", &p1) != 0);
}
void tst_QPixmapCache::clear()
@@ -408,14 +436,14 @@ void tst_QPixmapCache::clear()
const int numberOfKeys = estimatedNum + 1000;
for (int i = 0; i < numberOfKeys; ++i)
- QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0);
+ QVERIFY(!QPixmapCache::find("x" + QString::number(i), &p1));
for (int j = 0; j < numberOfKeys; ++j)
QPixmapCache::insert(QString::number(j), p1);
int num = 0;
for (int k = 0; k < numberOfKeys; ++k) {
- if (QPixmapCache::find(QString::number(k), p1))
+ if (QPixmapCache::find(QString::number(k), &p1))
++num;
}
QVERIFY(num > 0);
@@ -423,7 +451,7 @@ void tst_QPixmapCache::clear()
QPixmapCache::clear();
for (int k = 0; k < numberOfKeys; ++k)
- QVERIFY(!QPixmapCache::find(QString::number(k)));
+ QVERIFY(!QPixmapCache::find(QString::number(k), &p1));
//The int part of the API
QPixmap p2(10, 10);