Added autotest for threaded text rendering.

Task-number: QTBUG-18516
Reviewed-by: TRUSTME
(cherry picked from commit 903d4dc2196df2775255c24c707bfeb571992bb7)
This commit is contained in:
Laszlo Agocs 2011-04-26 16:01:08 +02:00 committed by Olivier Goffart
parent 4d38a48a70
commit c9cf5b45e3

View File

@ -72,6 +72,7 @@
#include <qgraphicsscene.h> #include <qgraphicsscene.h>
#include <qgraphicsproxywidget.h> #include <qgraphicsproxywidget.h>
#include <qlayout.h> #include <qlayout.h>
#include <qfontdatabase.h>
#if defined(Q_OS_SYMBIAN) #if defined(Q_OS_SYMBIAN)
# define SRCDIR "." # define SRCDIR "."
@ -266,6 +267,8 @@ private slots:
void QTBUG17053_zeroDashPattern(); void QTBUG17053_zeroDashPattern();
void drawTextOutsideGuiThread();
private: private:
void fillData(); void fillData();
void setPenColor(QPainter& p); void setPenColor(QPainter& p);
@ -4739,6 +4742,44 @@ void tst_QPainter::QTBUG17053_zeroDashPattern()
QCOMPARE(image, original); 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) QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc" #include "tst_qpainter.moc"