summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-11-12 13:48:04 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-11-12 14:10:36 (GMT)
commit951cceac68b4a6cf38da83b69dcde2c8109342a2 (patch)
treef422c1a36f83a24937145abda08396b4d32ff03c /tests/auto/qpixmap
parentb60ed9f084e45314787b84b686231ae68e0d39ba (diff)
downloadQt-951cceac68b4a6cf38da83b69dcde2c8109342a2.zip
Qt-951cceac68b4a6cf38da83b69dcde2c8109342a2.tar.gz
Qt-951cceac68b4a6cf38da83b69dcde2c8109342a2.tar.bz2
Fixed QPixmap::grabWidget() on widgets that have not yet been shown.
Fixed bug where QPixmap::grabWidget() would return a pixmap of a different size that the widget if the widget had not yet been shown or resized. Updated the qpixmap autotest. Task-number: QTBUG-4149 Reviewed-by: Trond
Diffstat (limited to 'tests/auto/qpixmap')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index d7f042e..fcb59f9 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -47,6 +47,7 @@
#include <qmatrix.h>
#include <qdesktopwidget.h>
#include <qpaintengine.h>
+#include <qtreewidget.h>
#include <private/qpixmapdata_p.h>
@@ -791,14 +792,32 @@ void tst_QPixmap::drawBitmap()
void tst_QPixmap::grabWidget()
{
QWidget widget;
- widget.setPalette(Qt::green);
- widget.resize(128, 128);
+ QImage image(128, 128, QImage::Format_ARGB32_Premultiplied);
+ for (int row = 0; row < image.height(); ++row) {
+ QRgb *line = reinterpret_cast<QRgb *>(image.scanLine(row));
+ for (int col = 0; col < image.width(); ++col)
+ line[col] = qRgb(rand() & 255, row, col);
+ }
- QPixmap expected(64, 64);
- expected.fill(Qt::green);
+ QPalette pal = widget.palette();
+ pal.setBrush(QPalette::Window, QBrush(image));
+ widget.setPalette(pal);
+ widget.resize(128, 128);
+ QPixmap expected = QPixmap::fromImage(QImage(image.scanLine(64) + 64 * 4, 64, 64, image.bytesPerLine(), image.format()));
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()