summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap/tst_qpixmap.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-04-28 12:07:47 (GMT)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-04-28 12:10:55 (GMT)
commita690e560b38385ebb9cd83288e8660d2a4ca2fde (patch)
tree356af75ffd13e110a117950721c8448e708baed1 /tests/auto/qpixmap/tst_qpixmap.cpp
parent0d70b0a9faecf042fdb20e0056bdaaec289b851c (diff)
downloadQt-a690e560b38385ebb9cd83288e8660d2a4ca2fde.zip
Qt-a690e560b38385ebb9cd83288e8660d2a4ca2fde.tar.gz
Qt-a690e560b38385ebb9cd83288e8660d2a4ca2fde.tar.bz2
Made the autotest for drawing pixmaps with painter open more fail safe.
The autotest relies on QPixmap::grabWindow() which causes random CI failures because it may capture bogus content if some other window comes to foreground, focus is changed, etc. To overcome these false positives the pixmap content comparison is now only done when the captured content is one of the three possible images. If it is anything else, we cannot verify so the case is skipped. Task-number: QT-4002 Reviewed-by: TRUSTME
Diffstat (limited to 'tests/auto/qpixmap/tst_qpixmap.cpp')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index d103cb7..0b2f527 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -1904,27 +1904,42 @@ private:
void tst_QPixmap::drawPixmapWhilePainterOpen()
{
- int size = 100;
+ const int delay = 1000;
+ const int size = 100;
+ const QColor colors[] = { Qt::red, Qt::blue, Qt::green };
+
QPixmap pix(size, size);
- pix.fill(Qt::red);
+ pix.fill(colors[0]);
PixmapWidget w(pix);
w.show();
QTest::qWaitForWindowShown(&w);
- QTest::qWait(1000);
+ QTest::qWait(delay);
QPainter p(&pix);
- p.fillRect(0, 0, size, size, Qt::blue);
+ p.fillRect(0, 0, size, size, colors[1]);
w.update();
- QTest::qWait(1000);
+ QTest::qWait(delay);
- p.fillRect(0, 0, size, size, Qt::green);
+ p.fillRect(0, 0, size, size, colors[2]);
w.update();
- QTest::qWait(1000);
+ QTest::qWait(delay);
QPixmap actual = QPixmap::grabWindow(w.effectiveWinId(), 0, 0, size, size);
- QVERIFY(lenientCompare(actual, pix));
+ // If we captured some bogus content with grabWindow(), the comparison makes no sense
+ // because it cannot prove the feature is broken.
+ QPixmap guard(size, size);
+ bool matchesColors = false;
+ for (size_t i = 0; i < sizeof(colors) / sizeof(const QColor); ++i) {
+ guard.fill(colors[i]);
+ matchesColors |= lenientCompare(actual, guard);
+ }
+ if (!matchesColors) {
+ QSKIP("Skipping verification due to grabWindow() issue", SkipSingle);
+ } else {
+ QVERIFY(lenientCompare(actual, pix));
+ }
}
QTEST_MAIN(tst_QPixmap)