summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-05-02 12:20:42 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-02 12:20:42 (GMT)
commit8abaeb826c5fdb5bb872b27b3f411e63d63a12ff (patch)
treeca002b2327fbd8dd60220198c78173740a550550 /tests/auto/qpixmap
parentab29e9f1ab52901a5ed98055cf203817d2248dd2 (diff)
parent43503e38d91c0e8375c2d5993de201419ba854ec (diff)
downloadQt-8abaeb826c5fdb5bb872b27b3f411e63d63a12ff.zip
Qt-8abaeb826c5fdb5bb872b27b3f411e63d63a12ff.tar.gz
Qt-8abaeb826c5fdb5bb872b27b3f411e63d63a12ff.tar.bz2
Merge remote-tracking branch 'origin/4.7' into qt-4.8-from-4.7
Conflicts: src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtGuiu.def
Diffstat (limited to 'tests/auto/qpixmap')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 4ba51de..98f7839 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -196,6 +196,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)
@@ -1897,5 +1899,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"