mirror of https://github.com/qt/qtbase.git
tst_QStyle::drawItemPixmap(): Check on the image color
Verify that all pixels of the grabbed image are green instead of comparing an image loaded from file. The test then also passes when High DPI scaling is active in which case a twice as big pixmap with DPR=2 is obtained when grabbing the widget. Change-Id: Ie5244a39a68ea0defd2590cf30f251d660d0869b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
ea4fae0df6
commit
a9dfdbd06a
Binary file not shown.
Before Width: | Height: | Size: 910 B |
|
@ -15,6 +15,5 @@
|
|||
<file>images/vista/radiobutton.png</file>
|
||||
<file>images/vista/slider.png</file>
|
||||
<file>images/vista/spinbox.png</file>
|
||||
<file>task_25863.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
#include <qscrollarea.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// Make a widget frameless to prevent size constraints of title bars
|
||||
// from interfering (Windows).
|
||||
static inline void setFrameless(QWidget *w)
|
||||
|
@ -208,13 +210,12 @@ void tst_QStyle::drawItemPixmap()
|
|||
testWidget->resize(300, 300);
|
||||
testWidget->showNormal();
|
||||
|
||||
const QString imageFileName = QFINDTESTDATA("task_25863.png");
|
||||
QVERIFY(!imageFileName.isEmpty());
|
||||
|
||||
QPixmap p(imageFileName, "PNG");
|
||||
const QPixmap actualPix = testWidget->grab();
|
||||
|
||||
QCOMPARE(actualPix, p);
|
||||
QImage image = testWidget->grab().toImage();
|
||||
const QRgb green = QColor(Qt::green).rgb();
|
||||
QVERIFY(image.reinterpretAsFormat(QImage::Format_RGB32));
|
||||
const QRgb *bits = reinterpret_cast<const QRgb *>(image.constBits());
|
||||
const QRgb *end = bits + image.byteCount() / sizeof(QRgb);
|
||||
QVERIFY(std::all_of(bits, end, [green] (QRgb r) { return r == green; }));
|
||||
testWidget->hide();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue