diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-02-01 11:36:17 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-02-02 15:10:27 +0000 |
commit | db2054fb2f5d538b21feaec83d83ca5b687f2867 (patch) | |
tree | a9205bfd6ff1a6c7f25014a1d795432e7a39416d /tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | |
parent | 57fb8b11cd04848cebe434dcb76947db94b142ff (diff) |
Fix tst_QFontMetrics::elidedMultiLengthF with some fonts
The QFontMetricsF version of the test should not truncate the
returned values, as the results may then be wrong.
Change-Id: I17f97f846bb723709e695e8866e437d6888d275b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp')
-rw-r--r-- | tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 6192e3cd8d..8667caa1ef 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -202,36 +202,36 @@ void tst_QFontMetrics::bypassShaping() QCOMPARE(textWidth, charsWidth); } -template<class FontMetrics> void elidedMultiLength_helper() +template<class FontMetrics, typename PrimitiveType> void elidedMultiLength_helper() { QString text1 = QLatin1String("Long Text 1\x9cShorter\x9csmall"); QString text1_long = "Long Text 1"; QString text1_short = "Shorter"; QString text1_small = "small"; FontMetrics fm = FontMetrics(QFont()); - int width_long = fm.size(0, text1_long).width(); + PrimitiveType width_long = fm.size(0, text1_long).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long + 1), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long - 1), text1_short); - int width_short = fm.size(0, text1_short).width(); + PrimitiveType width_short = fm.size(0, text1_short).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short + 1), text1_short); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small); // Not even wide enough for "small" - should use ellipsis QChar ellipsisChar(0x2026); QString text1_el = QString::fromLatin1("s") + ellipsisChar; - int width_small = fm.width(text1_el); + PrimitiveType width_small = fm.width(text1_el); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); } void tst_QFontMetrics::elidedMultiLength() { - elidedMultiLength_helper<QFontMetrics>(); + elidedMultiLength_helper<QFontMetrics, int>(); } void tst_QFontMetrics::elidedMultiLengthF() { - elidedMultiLength_helper<QFontMetricsF>(); + elidedMultiLength_helper<QFontMetricsF, qreal>(); } void tst_QFontMetrics::inFontUcs4() |