diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-04-26 14:01:08 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-04-26 14:01:08 (GMT) |
commit | 903d4dc2196df2775255c24c707bfeb571992bb7 (patch) | |
tree | 95946adb85ed6365f0a443065ba720641170634f | |
parent | b4b4e3311f06ef79e307f90eb216b05ed2990358 (diff) | |
download | Qt-903d4dc2196df2775255c24c707bfeb571992bb7.zip Qt-903d4dc2196df2775255c24c707bfeb571992bb7.tar.gz Qt-903d4dc2196df2775255c24c707bfeb571992bb7.tar.bz2 |
Added autotest for threaded text rendering.
Task-number: QTBUG-18516
Reviewed-by: TRUSTME
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index c21514b..33e4c49 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -72,6 +72,7 @@ #include <qgraphicsscene.h> #include <qgraphicsproxywidget.h> #include <qlayout.h> +#include <qfontdatabase.h> #if defined(Q_OS_SYMBIAN) # define SRCDIR "." @@ -264,6 +265,8 @@ private slots: void QTBUG17053_zeroDashPattern(); + void drawTextOutsideGuiThread(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4706,6 +4709,44 @@ void tst_QPainter::QTBUG17053_zeroDashPattern() QCOMPARE(image, original); } +class TextDrawerThread : public QThread +{ +public: + void run(); + QImage rendering; +}; + +void TextDrawerThread::run() +{ + rendering = QImage(100, 100, QImage::Format_ARGB32_Premultiplied); + rendering.fill(0); + QPainter p(&rendering); + p.fillRect(10, 10, 100, 100, Qt::blue); + p.setPen(Qt::green); + p.drawText(20, 20, "some text"); + p.end(); +} + +void tst_QPainter::drawTextOutsideGuiThread() +{ + if (!QFontDatabase::supportsThreadedFontRendering()) + QSKIP("No threaded font rendering", SkipAll); + + QImage referenceRendering(100, 100, QImage::Format_ARGB32_Premultiplied); + referenceRendering.fill(0); + QPainter p(&referenceRendering); + p.fillRect(10, 10, 100, 100, Qt::blue); + p.setPen(Qt::green); + p.drawText(20, 20, "some text"); + p.end(); + + TextDrawerThread t; + t.start(); + t.wait(); + + QCOMPARE(referenceRendering, t.rendering); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |