diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-28 12:27:27 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-28 12:27:27 (GMT) |
commit | c5cd6161a8b9e03eea58314806a67f7390ed0d6a (patch) | |
tree | 356af75ffd13e110a117950721c8448e708baed1 /tests/auto/qpixmap/tst_qpixmap.cpp | |
parent | ce4996b624678f37b13fbb7db810cccd8970a889 (diff) | |
parent | a690e560b38385ebb9cd83288e8660d2a4ca2fde (diff) | |
download | Qt-c5cd6161a8b9e03eea58314806a67f7390ed0d6a.zip Qt-c5cd6161a8b9e03eea58314806a67f7390ed0d6a.tar.gz Qt-c5cd6161a8b9e03eea58314806a67f7390ed0d6a.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public:
Made the autotest for drawing pixmaps with painter open more fail safe.
Upload VGImage data when drawing pixmaps that are being painted into.
Make translucent windows working properly with OpenVG.
Diffstat (limited to 'tests/auto/qpixmap/tst_qpixmap.cpp')
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 0b5c30b..0b2f527 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -194,6 +194,8 @@ private slots: #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) void vgImageReadBack(); #endif + + void drawPixmapWhilePainterOpen(); }; static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) @@ -1881,5 +1883,64 @@ void tst_QPixmap::vgImageReadBack() } #endif // Symbian & OpenVG +class PixmapWidget : public QWidget +{ +public: + PixmapWidget(QPixmap &pixmap) : QWidget(0), m_pixmap(pixmap) + { + resize(pixmap.width(), pixmap.height()); + } + +protected: + void paintEvent(QPaintEvent *) + { + QPainter p(this); + p.drawPixmap(0, 0, m_pixmap); + } + +private: + QPixmap &m_pixmap; +}; + +void tst_QPixmap::drawPixmapWhilePainterOpen() +{ + const int delay = 1000; + const int size = 100; + const QColor colors[] = { Qt::red, Qt::blue, Qt::green }; + + QPixmap pix(size, size); + pix.fill(colors[0]); + + PixmapWidget w(pix); + w.show(); + QTest::qWaitForWindowShown(&w); + QTest::qWait(delay); + + QPainter p(&pix); + p.fillRect(0, 0, size, size, colors[1]); + w.update(); + QTest::qWait(delay); + + p.fillRect(0, 0, size, size, colors[2]); + w.update(); + QTest::qWait(delay); + + QPixmap actual = QPixmap::grabWindow(w.effectiveWinId(), 0, 0, size, size); + + // 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) #include "tst_qpixmap.moc" |