diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
commit | db8f05e257019694f5e8076845626008f2adc3dd (patch) | |
tree | 05d3959403cf15ac5f702091439e028af01f343b /tests/auto/qpixmap | |
parent | 8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff) | |
parent | 796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff) | |
download | Qt-db8f05e257019694f5e8076845626008f2adc3dd.zip Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2 |
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo.
Conflicts:
configure.exe
mkspecs/features/qttest_p4.prf
qmake/generators/makefile.cpp
src/corelib/io/qdir.cpp
src/corelib/io/qprocess.h
src/corelib/kernel/qcoreevent.h
src/corelib/kernel/qobject.cpp
src/corelib/kernel/qsharedmemory_unix.cpp
src/corelib/thread/qthread_p.h
src/corelib/tools/qvector.h
src/gui/dialogs/qdialog.cpp
src/gui/dialogs/qfiledialog.cpp
src/gui/dialogs/qfiledialog_p.h
src/gui/dialogs/qmessagebox.cpp
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsview.cpp
src/gui/image/qpixmapcache.cpp
src/gui/kernel/qapplication.cpp
src/gui/kernel/qapplication_p.h
src/gui/kernel/qwidget.cpp
src/gui/kernel/qwidget_p.h
src/gui/painting/qdrawhelper.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/text/qfontengine_qpf.cpp
src/gui/widgets/qmenubar.cpp
src/network/socket/qlocalserver.cpp
src/testlib/qtestcase.cpp
src/testlib/testlib.pro
tests/auto/qimagereader/tst_qimagereader.cpp
tests/auto/qitemdelegate/tst_qitemdelegate.cpp
tests/auto/qnetworkreply/tst_qnetworkreply.cpp
tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'tests/auto/qpixmap')
28 files changed, 197 insertions, 30 deletions
diff --git a/tests/auto/qpixmap/images/designer.png b/tests/auto/qpixmap/images/designer.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/designer.png diff --git a/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..a4a1924 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..1506af5 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..8500ab1 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..2145c61 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..728ee79 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..e9d5850 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_null.png b/tests/auto/qpixmap/images/dx_0_dy_0_null.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_0_null.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..7c09b17 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..70a6340 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_0_dy_1_null.png b/tests/auto/qpixmap/images/dx_0_dy_1_null.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_0_dy_1_null.png diff --git a/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..85abada --- /dev/null +++ b/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..3e03450 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png Binary files differnew file mode 100644 index 0000000..315fbe0 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png diff --git a/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..d91dc71 --- /dev/null +++ b/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png b/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png diff --git a/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png diff --git a/tests/auto/qpixmap/images/dx_1_dy_0_null.png b/tests/auto/qpixmap/images/dx_1_dy_0_null.png Binary files differnew file mode 100644 index 0000000..bca471d --- /dev/null +++ b/tests/auto/qpixmap/images/dx_1_dy_0_null.png diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index c992f6e..68d7141 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -19,3 +19,4 @@ wince*: { win32:LIBS += -lgdi32 -luser32 } +RESOURCES += qpixmap.qrc diff --git a/tests/auto/qpixmap/qpixmap.qrc b/tests/auto/qpixmap/qpixmap.qrc new file mode 100644 index 0000000..99fde61 --- /dev/null +++ b/tests/auto/qpixmap/qpixmap.qrc @@ -0,0 +1,29 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/designer.png</file> + <file>images/dx_0_dy_0_50_50_100_100.png</file> + <file>images/dx_0_dy_0_null.png</file> + <file>images/dx_0_dy_0_x_y_w_h.png</file> + <file>images/dx_0_dy_-10_50_50_100_100.png</file> + <file>images/dx_0_dy_10_50_50_100_100.png</file> + <file>images/dx_0_dy_-10_x_y_w_h.png</file> + <file>images/dx_0_dy_10_x_y_w_h.png</file> + <file>images/dx_0_dy_-128_x_y_w_h.png</file> + <file>images/dx_0_dy_128_x_y_w_h.png</file> + <file>images/dx_0_dy_1_null.png</file> + <file>images/dx_-10_dy_0_50_50_100_100.png</file> + <file>images/dx_10_dy_0_50_50_100_100.png</file> + <file>images/dx_-10_dy_0_x_y_w_h.png</file> + <file>images/dx_10_dy_0_x_y_w_h.png</file> + <file>images/dx_-10_dy_-10_50_50_100_100.png</file> + <file>images/dx_10_dy_10_50_50_100_100.png</file> + <file>images/dx_-10_dy_-10_x_y_w_h.png</file> + <file>images/dx_10_dy_10_x_y_w_h.png</file> + <file>images/dx_-128_dy_0_x_y_w_h.png</file> + <file>images/dx_128_dy_0_x_y_w_h.png</file> + <file>images/dx_128_dy_128_64_64_128_128.png</file> + <file>images/dx_-128_dy_-128_x_y_w_h.png</file> + <file>images/dx_128_dy_128_x_y_w_h.png</file> + <file>images/dx_1_dy_0_null.png</file> +</qresource> +</RCC> diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 9f73e34..404b478 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -48,6 +48,8 @@ #include <qdesktopwidget.h> #include <qpaintengine.h> +#include <private/qpixmapdata_p.h> + #include <QSet> #ifdef Q_WS_WIN @@ -98,6 +100,9 @@ private slots: void testMetrics(); + void scroll_data(); + void scroll(); + void fill_data(); void fill(); void fill_transparent(); @@ -152,6 +157,38 @@ private slots: void fromData(); }; +static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) +{ + QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32); + QImage actualImage = actual.toImage().convertToFormat(QImage::Format_RGB32); + + if (expectedImage.size() != actualImage.size()) + return false; + + int size = actual.width() * actual.height(); + + QRgb *a = (QRgb *)actualImage.bits(); + QRgb *e = (QRgb *)expectedImage.bits(); + for (int i = 0; i < size; ++i) { + QColor ca(a[i]); + QColor ce(e[i]); + + bool result = true; + + if (qAbs(ca.red() - ce.red()) > 2) + result = false; + if (qAbs(ca.green() - ce.green()) > 2) + result = false; + if (qAbs(ca.blue() - ce.blue()) > 2) + result = false; + + if (!result) + return false; + } + + return true; +} + Q_DECLARE_METATYPE(QImage) Q_DECLARE_METATYPE(QPixmap) Q_DECLARE_METATYPE(QMatrix) @@ -214,7 +251,7 @@ void tst_QPixmap::setAlphaChannel() pixmap.setAlphaChannel(alphaChannel); #ifdef Q_WS_X11 - if (!pixmap.x11PictureHandle()) + if (pixmap.pixmapData()->classId() == QPixmapData::X11Class && !pixmap.x11PictureHandle()) QSKIP("Requires XRender support", SkipAll); #endif @@ -273,7 +310,7 @@ void tst_QPixmap::fromImage() const QPixmap pixmap = QPixmap::fromImage(image); #ifdef Q_WS_X11 - if (!pixmap.x11PictureHandle()) + if (pixmap.pixmapData()->classId() == QPixmapData::X11Class && !pixmap.x11PictureHandle()) QSKIP("Requires XRender support", SkipAll); #endif const QImage result = pixmap.toImage(); @@ -320,6 +357,99 @@ void tst_QPixmap::convertFromImage() QVERIFY( pixmapsAreEqual(&pix, &res) ); } +void tst_QPixmap::scroll_data() +{ + QTest::addColumn<QImage>("input"); + QTest::addColumn<int>("dx"); + QTest::addColumn<int>("dy"); + QTest::addColumn<QRect>("rect"); + QTest::addColumn<QRegion>("exposed"); + QTest::addColumn<bool>("newPix"); + + QImage input(":/images/designer.png"); + + // Noop tests + QTest::newRow("null") << QImage() << 0 << 0 << QRect() << QRegion() << false; + QTest::newRow("dx_0_dy_0_null") << input << 0 << 0 << QRect() << QRegion() << false; + QTest::newRow("dx_1_dy_0_null") << input << 1 << 0 << QRect() << QRegion() << false; + QTest::newRow("dx_0_dy_1_null") << input << 0 << 1 << QRect() << QRegion() << false; + QTest::newRow("dx_0_dy_0_x_y_w_h") << input << 0 << 0 << input.rect() << QRegion() << false; + + QRegion r; + // Scroll whole pixmap + r = QRegion(); r += QRect(0, 0, 128, 10); + QTest::newRow("dx_0_dy_10_x_y_w_h") << input << 0 << 10 << input.rect() << r << true; + r = QRegion(); r += QRect(0, 0, 10, 128); + QTest::newRow("dx_10_dy_0_x_y_w_h") << input << 10 << 0 << input.rect() << r << true; + r = QRegion(); r += QRect(0, 0, 128, 10); r += QRect(0, 10, 10, 118); + QTest::newRow("dx_10_dy_10_x_y_w_h") << input << 10 << 10 << input.rect() << r << true; + r = QRegion(); r += QRect(118, 0, 10, 128); + QTest::newRow("dx_-10_dy_0_x_y_w_h") << input << -10 << 0 << input.rect() << r << true; + r = QRegion(); r += QRect(0, 118, 128, 10); + QTest::newRow("dx_0_dy_-10_x_y_w_h") << input << 0 << -10 << input.rect() << r << true; + r = QRegion(); r += QRect(118, 0, 10, 118); r += QRect(0, 118, 128, 10); + QTest::newRow("dx_-10_dy_-10_x_y_w_h") << input << -10 << -10 << input.rect() << r << true; + + // Scroll part of pixmap + QTest::newRow("dx_0_dy_0_50_50_100_100") << input << 0 << 0 << QRect(50, 50, 100, 100) << QRegion() << false; + r = QRegion(); r += QRect(50, 50, 10, 78); + QTest::newRow("dx_10_dy_0_50_50_100_100") << input << 10 << 0 << QRect(50, 50, 100, 100) << r << true; + r = QRegion(); r += QRect(50, 50, 78, 10); + QTest::newRow("dx_0_dy_10_50_50_100_100") << input << 0 << 10 << QRect(50, 50, 100, 100) << r << true; + r = QRegion(); r += QRect(50, 50, 78, 10); r += QRect(50, 60, 10, 68); + QTest::newRow("dx_10_dy_10_50_50_100_100") << input << 10 << 10 << QRect(50, 50, 100, 100) << r << true; + r = QRegion(); r += QRect(118, 50, 10, 78); + QTest::newRow("dx_-10_dy_0_50_50_100_100") << input << -10 << 0 << QRect(50, 50, 100, 100) << r << true; + r = QRegion(); r += QRect(50, 118, 78, 10); + QTest::newRow("dx_0_dy_-10_50_50_100_100") << input << 0 << -10 << QRect(50, 50, 100, 100) << r << true; + r = QRegion(); r += QRect(118, 50, 10, 68); r += QRect(50, 118, 78, 10); + QTest::newRow("dx_-10_dy_-10_50_50_100_100") << input << -10 << -10 << QRect(50, 50, 100, 100) << r << true; + + // Scroll away the whole pixmap + r = input.rect(); + QTest::newRow("dx_128_dy_0_x_y_w_h") << input << 128 << 0 << input.rect() << r << false; + QTest::newRow("dx_0_dy_128_x_y_w_h") << input << 0 << 128 << input.rect() << r << false; + QTest::newRow("dx_128_dy_128_x_y_w_h") << input << 128 << 128 << input.rect() << r << false; + QTest::newRow("dx_-128_dy_0_x_y_w_h") << input << -128 << 0 << input.rect() << r << false; + QTest::newRow("dx_0_dy_-128_x_y_w_h") << input << 0 << -128 << input.rect() << r << false; + QTest::newRow("dx_-128_dy_-128_x_y_w_h") << input << -128 << -128 << input.rect() << r << false; + + // Scroll away part of the pixmap + r = QRegion(); r += QRect(64, 64, 64, 64); + QTest::newRow("dx_128_dy_128_64_64_128_128") << input << 128 << 128 << QRect(64, 64, 128, 128) << r << false; +} + +void tst_QPixmap::scroll() +{ + QFETCH(QImage, input); + QFETCH(int, dx); + QFETCH(int, dy); + QFETCH(QRect, rect); + QFETCH(QRegion, exposed); + QFETCH(bool, newPix); + + QPixmap pixmap = QPixmap::fromImage(input); + QRegion exp; + qint64 oldKey = pixmap.cacheKey(); + pixmap.scroll(dx, dy, rect, &exp); + if (!newPix) + QCOMPARE(pixmap.cacheKey(), oldKey); + else + QVERIFY(pixmap.cacheKey() != oldKey); + +#if 0 + // Remember to add to resources. + QString fileName = QString("images/%1.png").arg(QTest::currentDataTag()); + pixmap.toImage().save(fileName); +#else + QString fileName = QString(":/images/%1.png").arg(QTest::currentDataTag()); +#endif + QPixmap output(fileName); + QVERIFY(input.isNull() == output.isNull()); + QVERIFY(lenientCompare(pixmap, output)); + QCOMPARE(exp, exposed); +} + void tst_QPixmap::fill_data() { QTest::addColumn<uint>("pixel"); @@ -385,7 +515,7 @@ void tst_QPixmap::fill() pm = QPixmap(400, 400); #if defined(Q_WS_X11) - if (!bitmap && !pm.x11PictureHandle()) + if (!bitmap && pm.pixmapData()->classId() == QPixmapData::X11Class && !pm.x11PictureHandle()) QSKIP("Requires XRender support", SkipSingle); #endif @@ -397,7 +527,7 @@ void tst_QPixmap::fill() QImage image = pm.toImage(); if (bitmap && syscolor) { int pixelindex = (pixel == Qt::color0) ? 0 : 1; - QVERIFY(image.pixelIndex(0,0) == pixelindex); + QCOMPARE(image.pixelIndex(0,0), pixelindex); } QImage::Format format = compareColor.alpha() != 255 ? QImage::Format_ARGB32 @@ -415,7 +545,7 @@ void tst_QPixmap::fill_transparent() { QPixmap pixmap(10, 10); #ifdef Q_WS_X11 - if (!pixmap.x11PictureHandle()) + if (pixmap.pixmapData()->classId() == QPixmapData::X11Class && !pixmap.x11PictureHandle()) QSKIP("Requires XRender support", SkipAll); #endif pixmap.fill(Qt::transparent); @@ -535,7 +665,7 @@ void tst_QPixmap::testMetrics() QCOMPARE(pixmap.width(), 100); QCOMPARE(pixmap.height(), 100); - QCOMPARE(pixmap.depth(), QPixmap::defaultDepth()); + QVERIFY(pixmap.depth() >= QPixmap::defaultDepth()); QBitmap bitmap(100, 100); @@ -597,7 +727,11 @@ void tst_QPixmap::drawBitmap() painter2.setPen(Qt::red); painter2.drawPixmap(0,0,10,10, bitmap); painter2.end(); - QCOMPARE(pixmap.toImage().pixel(5,5), QColor(Qt::red).rgb()); + + QPixmap expected(10, 10); + expected.fill(Qt::red); + + QVERIFY(lenientCompare(pixmap, expected)); } void tst_QPixmap::grabWidget() @@ -610,8 +744,7 @@ void tst_QPixmap::grabWidget() expected.fill(Qt::green); QPixmap actual = QPixmap::grabWidget(&widget, QRect(64, 64, 64, 64)); - - QCOMPARE(actual, expected); + QVERIFY(lenientCompare(actual, expected)); } void tst_QPixmap::grabWindow() @@ -642,7 +775,7 @@ void tst_QPixmap::grabWindow() QPixmap grabWindowPixmap = QPixmap::grabWindow(child.winId()); QPixmap grabWidgetPixmap = QPixmap::grabWidget(&child); - QCOMPARE(grabWindowPixmap, grabWidgetPixmap); + lenientCompare(grabWindowPixmap, grabWidgetPixmap); } void tst_QPixmap::isNull() @@ -978,10 +1111,10 @@ void tst_QPixmap::copy() } QPixmap dest = src.copy(10, 10, 10, 10); - QImage result = dest.toImage().convertToFormat(QImage::Format_RGB32); - QImage expected(10, 10, QImage::Format_RGB32); - expected.fill(0xff0000ff); - QCOMPARE(result, expected); + + QPixmap expected(10, 10); + expected.fill(Qt::blue); + QVERIFY(lenientCompare(dest, expected)); } #ifdef QT3_SUPPORT @@ -1049,27 +1182,33 @@ void tst_QPixmap::transformed() } QPixmap p2(10, 20); - p2.fill(Qt::red); { QPainter p(&p2); - p.drawRect(0, 0, p2.width() - 1, p2.height() - 1); + p.rotate(90); + p.drawPixmap(0, -p1.height(), p1); + } + + QPixmap p3(20, 10); + { + QPainter p(&p3); + p.rotate(180); + p.drawPixmap(-p1.width(), -p1.height(), p1); + } + + QPixmap p4(10, 20); + { + QPainter p(&p4); + p.rotate(270); + p.drawPixmap(-p1.width(), 0, p1); } QPixmap p1_90 = p1.transformed(QTransform().rotate(90)); QPixmap p1_180 = p1.transformed(QTransform().rotate(180)); QPixmap p1_270 = p1.transformed(QTransform().rotate(270)); - QCOMPARE(p1_90.size(), p2.size()); - QCOMPARE(p1_90.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied), - p2.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied)); - - QCOMPARE(p1_180.size(), p1.size()); - QCOMPARE(p1_180.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied), - p1.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied)); - - QCOMPARE(p1_270.size(), p2.size()); - QCOMPARE(p1_270.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied), - p2.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied)); + QVERIFY(lenientCompare(p1_90, p2)); + QVERIFY(lenientCompare(p1_180, p3)); + QVERIFY(lenientCompare(p1_270, p4)); } void tst_QPixmap::transformed2() @@ -1097,9 +1236,7 @@ void tst_QPixmap::transformed2() p.drawRect(3, 6, 3, 3); p.end(); - QCOMPARE(actual.size(), expected.size()); - QCOMPARE(actual.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied), - expected.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied)); + QVERIFY(lenientCompare(actual, expected)); } void tst_QPixmap::fromImage_crash() |