From db390d46c3a983f0270fb40be7f59297e9a77d64 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 16:48:17 -0800 Subject: Move the auto test of QPixmap::grabWidget() from QPixmap to QWidget Change-Id: Id565fa1eb8fe13c62a93a5afa39a5701ce7b20ea QPixmap::grabWidget is deprecated, which calls QWidget::grab() at present. Reviewed-by: Gunnar Sletta Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 43 ---------------------------- 1 file changed, 43 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 563baef486..c7652e445f 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -111,7 +110,6 @@ private slots: void setGetMask(); void cacheKey(); void drawBitmap(); - void grabWidget(); void grabWindow(); void isNull(); void task_246446(); @@ -718,47 +716,6 @@ void tst_QPixmap::drawBitmap() QVERIFY(lenientCompare(pixmap, expected)); } -void tst_QPixmap::grabWidget() -{ - for (int opaque = 0; opaque < 2; ++opaque) { - QWidget widget; - QImage image(128, 128, opaque ? QImage::Format_RGB32 : QImage::Format_ARGB32_Premultiplied); - for (int row = 0; row < image.height(); ++row) { - QRgb *line = reinterpret_cast(image.scanLine(row)); - for (int col = 0; col < image.width(); ++col) - line[col] = qRgba(rand() & 255, row, col, opaque ? 255 : 127); - } - - QPalette pal = widget.palette(); - pal.setBrush(QPalette::Window, QBrush(image)); - widget.setPalette(pal); - widget.resize(128, 128); - - QPixmap expected(64, 64); - if (!opaque) - expected.fill(Qt::transparent); - - QPainter p(&expected); - p.translate(-64, -64); - p.drawTiledPixmap(0, 0, 128, 128, pal.brush(QPalette::Window).texture(), 0, 0); - p.end(); - - QPixmap actual = QPixmap::grabWidget(&widget, QRect(64, 64, 64, 64)); - QVERIFY(lenientCompare(actual, expected)); - - actual = QPixmap::grabWidget(&widget, 64, 64); - QVERIFY(lenientCompare(actual, expected)); - - // Make sure a widget that is not yet shown is grabbed correctly. - QTreeWidget widget2; - actual = QPixmap::grabWidget(&widget2); - widget2.show(); - expected = QPixmap::grabWidget(&widget2); - - QVERIFY(lenientCompare(actual, expected)); - } -} - void tst_QPixmap::grabWindow() { // ### fixme: Check platforms -- cgit v1.2.3