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/qstatictext | |
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/qstatictext')
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 111 |
1 files changed, 0 insertions, 111 deletions
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 |