summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorBoris Dušek <me@dusek.me>2015-03-17 23:02:23 +0100
committerBoris Dušek <me@dusek.me>2015-03-25 09:47:52 +0000
commit551f39bac501db95d2c1f0c66060eef716b4a653 (patch)
tree0660b1fed45e0ec20025a6cc5eb83f55e4d8fd69 /tests/auto/other
parent898ca6ff769c10c76c40cecb8f9cc82bacb3241f (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: I843c5b29f8048196ec3405b6717655e77b567dbb Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp9
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()));