Added autotest for threaded text rendering.
Task-number: QTBUG-18516 Reviewed-by: TRUSTME (cherry picked from commit 903d4dc2196df2775255c24c707bfeb571992bb7)
This commit is contained in:
parent
4d38a48a70
commit
c9cf5b45e3
@ -72,6 +72,7 @@
|
||||
#include <qgraphicsscene.h>
|
||||
#include <qgraphicsproxywidget.h>
|
||||
#include <qlayout.h>
|
||||
#include <qfontdatabase.h>
|
||||
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
# define SRCDIR "."
|
||||
@ -266,6 +267,8 @@ private slots:
|
||||
|
||||
void QTBUG17053_zeroDashPattern();
|
||||
|
||||
void drawTextOutsideGuiThread();
|
||||
|
||||
private:
|
||||
void fillData();
|
||||
void setPenColor(QPainter& p);
|
||||
@ -4739,6 +4742,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"
|
||||
|
Loading…
Reference in New Issue
Block a user