diff options
author | Boris Dušek <me@dusek.me> | 2015-02-08 09:11:49 +0100 |
---|---|---|
committer | Boris Dušek <me@dusek.me> | 2015-03-05 15:04:52 +0000 |
commit | 1cdb1170018303e56db71a6c9e31e9410317effb (patch) | |
tree | 1b02a0cbce8063158b4cbcebfe8ad2816fb6d1d7 /tests/auto/other/qaccessibility/tst_qaccessibility.cpp | |
parent | b1c43b072fd750b8cc52ae82cd6907e3c9c01dac (diff) |
Fix accessibility character rect tests
textEditTest in qaccessibility test was using QTextEdit::setCurrentFont
on second pass, but that did not change the font used for text in any way.
I don't know what was the purpose. So I changed it into something that
made sense to me and actually tests text with a different font on second pass.
Also fixed characterRect function in tests to use correct font/format.
Change-Id: I3663e02abda381be1401e298c15b51cd0fb75939
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Diffstat (limited to 'tests/auto/other/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index c15ec44bb8..8061b1ccb9 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1716,7 +1716,10 @@ static QRect characterRect(const QTextEdit &edit, int offset) QPointF layoutPosition = layout->position(); int relativeOffset = offset - block.position(); QTextLine line = layout->lineForTextPosition(relativeOffset); - QFontMetrics fm(edit.currentFont()); + QTextBlock::iterator it = block.begin(); + while (!it.fragment().contains(offset)) + ++it; + QFontMetrics fm(it.fragment().charFormat().font()); QChar ch = edit.document()->characterAt(offset); int w = fm.width(ch); int h = fm.height(); @@ -1759,7 +1762,7 @@ void tst_QAccessibility::textEditTest() QFont font("Helvetica"); font.setPointSizeF(12.5); font.setWordSpacing(1.1); - edit.setCurrentFont(font); + edit.document()->setDefaultFont(font); } edit.show(); @@ -1781,7 +1784,7 @@ void tst_QAccessibility::textEditTest() QCOMPARE(startOffset, 13); QCOMPARE(endOffset, 31); QCOMPARE(textIface->characterCount(), 48); - QFontMetrics fm(edit.currentFont()); + QFontMetrics fm(edit.document()->defaultFont()); QCOMPARE(textIface->characterRect(0).size(), QSize(fm.width("h"), fm.height())); QCOMPARE(textIface->characterRect(5).size(), QSize(fm.width(" "), fm.height())); QCOMPARE(textIface->characterRect(6).size(), QSize(fm.width("w"), fm.height())); |