summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-19 15:22:51 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-20 06:17:42 +0100
commit85a77cd5c8f4a9a2e71676ff7b600ba891983115 (patch)
tree42757b4bcd9b8f9702e11fbf70e8ad573d49d1b2
parent1749fef3c5c1dda98c6ea32e0ac17202892fc9fe (diff)
Retire QTest::pixmapsAreEqual().
QTest::pixmapsAreEqual() was left in the Qt4 API for compatibility with some old tests written for Qt3. QCOMPARE() is the preferred way to compare QPixmaps and provides superior diagnostic output when a comparison fails. This commit removes QTest::pixmapsAreEqual() from the testlib API and replaces the last few remaining calls with QCOMPARE. Change-Id: I051c0e7d3bda072855fcd262d82e8e540619233b Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--dist/changes-5.0.03
-rw-r--r--src/testlib/qtest_gui.h15
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp14
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp10
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp4
5 files changed, 20 insertions, 26 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index fe159c4ad9..159ef73341 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -57,6 +57,9 @@ information about a particular change.
internal testlib function that was exposed in the public API due to its use
in a public macro. Any calls to this function should be replaced by a call
to qsnprintf(), which comes from the <QtCore/QByteArray> header.
+ * The QTest::pixmapsAreEqual() function has been removed from the API.
+ Comparison of QPixmap objects should be done using QCOMPARE, which provides
+ more informative output in the event of a failure.
* The QSKIP macro no longer has the "mode" parameter, which caused problems
for calculating test metrics, as the SkipAll mode hid information about
what test data was skipped. Calling QSKIP in a test function now behaves
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 89f63e25c6..99b7700e3b 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -94,21 +94,6 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
}
-/* compatibility */
-
-inline static bool pixmapsAreEqual(const QPixmap *actual, const QPixmap *expected)
-{
- if (!actual && !expected)
- return true;
- if (!actual || !expected)
- return false;
- if (actual->isNull() && expected->isNull())
- return true;
- if (actual->isNull() || expected->isNull() || actual->size() != expected->size())
- return false;
- return actual->toImage() == expected->toImage();
-}
-
#ifdef Q_WS_X11
extern void qt_x11_wait_for_window_manager(QWidget *w);
#endif
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index 3d3f5b4a97..9e7e93255d 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -1100,11 +1100,17 @@ void tst_QDataStream::readQCursor(QDataStream *s)
QVERIFY(d5.shape() == test.shape()); //## lacks operator==
QVERIFY(d5.hotSpot() == test.hotSpot());
QVERIFY((d5.bitmap() != 0 && test.bitmap() != 0) || (d5.bitmap() == 0 && test.bitmap() == 0));
- if (d5.bitmap() != 0)
- QVERIFY(pixmapsAreEqual(d5.bitmap(), test.bitmap()));
+ if (d5.bitmap() != 0) {
+ QPixmap actual = *(d5.bitmap());
+ QPixmap expected = *(test.bitmap());
+ QCOMPARE(actual, expected);
+ }
QVERIFY((d5.mask() != 0 && test.mask() != 0) || (d5.mask() == 0 && test.mask() == 0));
- if (d5.mask() != 0)
- QVERIFY(pixmapsAreEqual(d5.mask(), test.mask()));
+ if (d5.mask() != 0) {
+ QPixmap actual = *(d5.mask());
+ QPixmap expected = *(test.mask());
+ QCOMPARE(actual, expected);
+ }
#endif
}
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index c15d1e6976..8d575c90c0 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -329,7 +329,7 @@ void tst_QPixmap::convertFromImage()
pix = QPixmap::fromImage(img2);
QPixmap res = QPixmap::fromImage(img2);
- QVERIFY( pixmapsAreEqual(&pix, &res) );
+ QCOMPARE(pix, res);
}
void tst_QPixmap::scroll_data()
@@ -1149,7 +1149,7 @@ void tst_QPixmap::copy()
trans.fill(Qt::transparent);
QPixmap transCopy = trans.copy();
- QVERIFY(pixmapsAreEqual(&trans, &transCopy));
+ QCOMPARE(trans, transCopy);
}
void tst_QPixmap::depthOfNullObjects()
@@ -1317,7 +1317,7 @@ void tst_QPixmap::loadFromDataImage()
QPixmap directLoadingPixmap;
directLoadingPixmap.loadFromData(rawData);
- QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
+ QCOMPARE(pixmapWithCopy, directLoadingPixmap);
}
void tst_QPixmap::fromImageReader_data()
@@ -1348,7 +1348,7 @@ void tst_QPixmap::fromImageReader()
QPixmap directLoadingPixmap = QPixmap::fromImageReader(&imageReader);
- QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
+ QCOMPARE(pixmapWithCopy, directLoadingPixmap);
}
void tst_QPixmap::fromImageReaderAnimatedGif_data()
@@ -1376,7 +1376,7 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
QPixmap refPixmap = QPixmap::fromImage(refImage);
QPixmap directLoadingPixmap = QPixmap::fromImageReader(&pixmapReader);
- QVERIFY(pixmapsAreEqual(&refPixmap, &directLoadingPixmap));
+ QCOMPARE(refPixmap, directLoadingPixmap);
}
}
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index 5dede997ae..d5849f1c2c 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -273,7 +273,7 @@ void tst_QStyle::drawItemPixmap()
QPixmap p(QString(SRCDIR) + "/task_25863.png", "PNG");
QPixmap actualPix = QPixmap::grabWidget(testWidget);
- QVERIFY(pixmapsAreEqual(&actualPix,&p));
+ QCOMPARE(actualPix, p);
testWidget->hide();
}
@@ -458,7 +458,7 @@ void comparePixmap(const QString &filename, const QPixmap &pixmap)
QImage oldFile = readImage(filename);
QPixmap oldPixmap = QPixmap::fromImage(oldFile);
if (!oldFile.isNull())
- QVERIFY(pixmapsAreEqual(&pixmap, &oldPixmap));
+ QCOMPARE(pixmap, oldPixmap);
else
writeImage(filename, pixmap.toImage());
}