diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-06-05 08:07:14 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-06-08 06:45:49 +0200 |
commit | 3279c8e7d72c5eee379fa8e4a2789acfe40445c0 (patch) | |
tree | 7d944b86759be03bd9334675d735e4fd45497852 /tests/auto/gui/text | |
parent | 69795835f3a578f60b16f09943feee6326087342 (diff) |
Move some flaky text tests into Lancelot
There are some slight differences between normal drawText()
and QGlyphRuns/QStaticText for decoration widths in certain
fonts. We decided to accept this and tried working around it
in the test by using ForceIntegerMetrics (since the difference
is < 0.5 pixel). This enum has been deprecated, so we move
the tests into Lancelot instead, since the idea here is to
test for regressions, not to compare the two painter commands.
Note that there is something off about decorations with
drawGlyphRuns() and drawStaticText() which is exposed
(not caused) by this, perhaps related to using a matrix
for positioning, since that was untested before.
This also takes the liberty of moving the emoji test string
from text.qps, since this was not in the statictext.qps yet.
Change-Id: Ib2d697095cbd11829cdd50b3c0268c85e9607c78
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r-- | tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | 132 | ||||
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 111 |
2 files changed, 0 insertions, 243 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 344fa2c981..cc04d86389 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -56,9 +56,6 @@ private slots: void drawNonExistentGlyphs(); void drawMultiScriptText1(); void drawMultiScriptText2(); - void drawStruckOutText(); - void drawOverlinedText(); - void drawUnderlinedText(); void drawRightToLeft(); void detach(); void setRawData(); @@ -511,135 +508,6 @@ void tst_QGlyphRun::detach() QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3); } -void tst_QGlyphRun::drawStruckOutText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setStrikeOut(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - QTextLayout layout(s); - layout.setFont(font); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphRun glyphs = layout.glyphRuns().size() > 0 - ? layout.glyphRuns().at(0) - : QGlyphRun(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphRun(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawStruckOutText_textLayoutDraw.png"); - drawGlyphs.save("drawStruckOutText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphRun::drawOverlinedText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setOverline(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - QTextLayout layout(s); - layout.setFont(font); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphRun glyphs = layout.glyphRuns().size() > 0 - ? layout.glyphRuns().at(0) - : QGlyphRun(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphRun(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawOverlineText_textLayoutDraw.png"); - drawGlyphs.save("drawOverlineText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphRun::drawUnderlinedText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setUnderline(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - QTextLayout layout(s); - layout.setFont(font); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphRun glyphs = layout.glyphRuns().size() > 0 - ? layout.glyphRuns().at(0) - : QGlyphRun(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphRun(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawUnderlineText_textLayoutDraw.png"); - drawGlyphs.save("drawUnderlineText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - void tst_QGlyphRun::drawRightToLeft() { QString s; diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index b091edb64d..645ff39cbe 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -87,10 +87,6 @@ private slots: void setPenRichText(); void richTextOverridesPen(); - void drawStruckOutText(); - void drawOverlinedText(); - void drawUnderlinedText(); - void unprintableCharacter_qtbug12614(); #ifdef QT_BUILD_INTERNAL @@ -774,113 +770,6 @@ void tst_QStaticText::richTextOverridesPen() errorMessage.constData()); } -void tst_QStaticText::drawStruckOutText() -{ - QPixmap imageDrawText(1000, 1000); - QPixmap imageDrawStaticText(1000, 1000); - - imageDrawText.fill(Qt::white); - imageDrawStaticText.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setStrikeOut(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - { - QPainter p(&imageDrawText); - p.setFont(font); - p.drawText(QPointF(50, 50), s); - } - - { - QPainter p(&imageDrawStaticText); - QStaticText text = QStaticText(s); - p.setFont(font); - p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text); - } - -#if defined(DEBUG_SAVE_IMAGE) - imageDrawText.save("drawStruckOutText_imageDrawText.png"); - imageDrawStaticText.save("drawStruckOutText_imageDrawStaticText.png"); -#endif - - QVERIFY(imageDrawText.toImage() != m_whiteSquare); - QCOMPARE(imageDrawText, imageDrawStaticText); -} - -void tst_QStaticText::drawOverlinedText() -{ - QPixmap imageDrawText(1000, 1000); - QPixmap imageDrawStaticText(1000, 1000); - - imageDrawText.fill(Qt::white); - imageDrawStaticText.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setOverline(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - { - QPainter p(&imageDrawText); - p.setFont(font); - p.drawText(QPointF(50, 50), s); - } - - { - QPainter p(&imageDrawStaticText); - QStaticText text = QStaticText(s); - p.setFont(font); - p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text); - } - -#if defined(DEBUG_SAVE_IMAGE) - imageDrawText.save("drawOverlinedText_imageDrawText.png"); - imageDrawStaticText.save("drawOverlinedText_imageDrawStaticText.png"); -#endif - - QVERIFY(imageDrawText.toImage() != m_whiteSquare); - QCOMPARE(imageDrawText, imageDrawStaticText); -} - -void tst_QStaticText::drawUnderlinedText() -{ - QPixmap imageDrawText(1000, 1000); - QPixmap imageDrawStaticText(1000, 1000); - - imageDrawText.fill(Qt::white); - imageDrawStaticText.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setUnderline(true); - font.setStyleStrategy(QFont::ForceIntegerMetrics); - - { - QPainter p(&imageDrawText); - p.setFont(font); - p.drawText(QPointF(50, 50), s); - } - - { - QPainter p(&imageDrawStaticText); - QStaticText text = QStaticText(s); - p.setFont(font); - p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text); - } - -#if defined(DEBUG_SAVE_IMAGE) - imageDrawText.save("drawUnderlinedText_imageDrawText.png"); - imageDrawStaticText.save("drawUnderlinedText_imageDrawStaticText.png"); -#endif - - QCOMPARE(imageDrawText, imageDrawStaticText); -} - void tst_QStaticText::unprintableCharacter_qtbug12614() { QString s(QChar(0x200B)); // U+200B, ZERO WIDTH SPACE |