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>bb10
parent
1749fef3c5
commit
85a77cd5c8
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue