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>bb10
parent
57fb8b11cd
commit
db2054fb2f
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue